├── boost ├── daslib ├── .gdignore ├── godot.das ├── godot_utils.das ├── godot_signals.das ├── godot_macros.das ├── godot_signals_gen.das └── godot_casts_gen.das ├── examples ├── demo │ ├── boost │ ├── Bar.das │ ├── unrelated_name.das │ ├── project.godot │ ├── main.tscn │ ├── icon.svg.import │ ├── Foo.das │ └── icon.svg ├── bunnymark │ ├── boost │ ├── Bunny.gd │ ├── bunny.png │ ├── Bunny.das │ ├── bunnymark_gd.tscn │ ├── bunnymark_das.tscn │ ├── project.godot │ ├── bunny.png.import │ ├── Bunnymark.gd │ └── Bunnymark.das └── flappy_bird │ ├── boost │ ├── .gitignore │ ├── .gitattributes │ ├── bird.tscn │ ├── Pipes.das │ ├── icon.svg │ ├── icon.svg.import │ ├── pipes.tscn │ ├── main.tscn │ ├── project.godot │ ├── Bird.das │ └── Main.das ├── .gitmodules ├── config.py ├── src ├── generate_bindings.h ├── init_daslang.h ├── godot_types_extra.cpp ├── godot_types_aliases.cpp ├── init_daslang.cpp ├── godot_types_aliases.h ├── godot_types_extra.h ├── godot_module.h ├── das_resource_io.h ├── godot_functions_extra.cpp ├── das_script_instance.cpp ├── das_script_instance.h ├── types_and_funcs.h ├── godot_types_gen.cpp ├── godot_functions_gen.cpp ├── das_resource_io.cpp ├── godot_types_macro.h ├── das_script.h ├── godot_functions_macro.h ├── das_script_language.h ├── godot_types_gen.h ├── godot_functions_wrapper.h ├── godot_utils.cpp ├── das_script_language.cpp ├── das_script.cpp ├── godot_all_includes.h └── generate_bindings.cpp ├── .gitignore ├── register_types.h ├── CMakeLists.txt ├── _vscode_files ├── tasks.json ├── c_cpp_properties.json ├── launch.json └── settings.json ├── SCsub ├── register_types.cpp ├── LICENSE ├── README.md ├── icons └── DasScript.svg └── logo.svg /boost/daslib: -------------------------------------------------------------------------------- 1 | ../daScript/daslib -------------------------------------------------------------------------------- /examples/demo/boost: -------------------------------------------------------------------------------- 1 | ../../boost -------------------------------------------------------------------------------- /examples/bunnymark/boost: -------------------------------------------------------------------------------- 1 | ../../boost -------------------------------------------------------------------------------- /examples/flappy_bird/boost: -------------------------------------------------------------------------------- 1 | ../../boost -------------------------------------------------------------------------------- /examples/flappy_bird/.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | .godot/ 3 | -------------------------------------------------------------------------------- /boost/.gdignore: -------------------------------------------------------------------------------- 1 | This file is needed so Godot does not import contents of this folder 2 | -------------------------------------------------------------------------------- /examples/bunnymark/Bunny.gd: -------------------------------------------------------------------------------- 1 | class_name Bunny 2 | extends Sprite2D 3 | 4 | var velocity: Vector2 5 | -------------------------------------------------------------------------------- /examples/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GaijinEntertainment/godot-das/HEAD/examples/bunnymark/bunny.png -------------------------------------------------------------------------------- /examples/flappy_bird/.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "daScript"] 2 | path = daScript 3 | url = git@github.com:GaijinEntertainment/daScript.git 4 | ignore = all -------------------------------------------------------------------------------- /examples/bunnymark/Bunny.das: -------------------------------------------------------------------------------- 1 | require boost/godot 2 | 3 | 4 | [godot_class(Sprite2D)] 5 | class Bunny 6 | velocity : Vector2 7 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | def is_enabled(): 2 | return True 3 | 4 | def can_build(env, platform): 5 | return True 6 | 7 | def configure(env): 8 | pass -------------------------------------------------------------------------------- /src/generate_bindings.h: -------------------------------------------------------------------------------- 1 | #ifndef GENERATE_CODE_H 2 | #define GENERATE_CODE_H 3 | 4 | void generate_godot_module_code(); 5 | 6 | #endif // GENERATE_CODE_H 7 | -------------------------------------------------------------------------------- /src/init_daslang.h: -------------------------------------------------------------------------------- 1 | #ifndef INIT_DASLANG_H 2 | #define INIT_DASLANG_H 3 | 4 | 5 | void initialize_daslang(); 6 | void deinitialize_daslang(); 7 | 8 | #endif //INIT_DASLANG_H 9 | -------------------------------------------------------------------------------- /examples/demo/Bar.das: -------------------------------------------------------------------------------- 1 | // files that are not used might be loaded anyway, and if so - in a separate thread 2 | // I've added this file to demonstarte that it now works! 3 | 4 | let ABRACADABRA = 413; 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | examples/**/.godot/ 3 | 4 | # build files 5 | *.o 6 | __pycache__ 7 | __cmake_temp 8 | *.a 9 | 10 | # vscode stuff 11 | .vscode 12 | 13 | # tmp headers 14 | *.inc -------------------------------------------------------------------------------- /boost/godot.das: -------------------------------------------------------------------------------- 1 | require godot_native public 2 | require godot_casts_gen public 3 | require godot_utils public 4 | require godot_macros public 5 | require godot_signals public 6 | require godot_signals_gen public 7 | -------------------------------------------------------------------------------- /src/godot_types_extra.cpp: -------------------------------------------------------------------------------- 1 | #include "godot_types_extra.h" 2 | #include "godot_module.h" 3 | 4 | 5 | void Module_Godot::bind_types_extra(das::ModuleLibrary & lib) { 6 | BIND_ENUM(ResourceLoader, CacheMode) 7 | 8 | BIND_NATIVE_BASE(Color) 9 | } -------------------------------------------------------------------------------- /boost/godot_utils.das: -------------------------------------------------------------------------------- 1 | require godot_native 2 | 3 | def iterate_children(node: Node?) 4 | return <- generator () <| 5 | let child_count = node |> get_child_count() 6 | for i in range(0, child_count) 7 | yield node |> get_child(i) 8 | return false 9 | -------------------------------------------------------------------------------- /examples/demo/unrelated_name.das: -------------------------------------------------------------------------------- 1 | require boost/godot 2 | require Foo 3 | 4 | [godot_class(Node2D)] 5 | class SignalReciever 6 | 7 | def _ready() 8 | var foo = native |> get_parent() as Foo 9 | foo.test |> connect(native) <| "signal_from_foo" 10 | 11 | def signal_from_foo() 12 | print("recieved signal from Foo!") 13 | 14 | -------------------------------------------------------------------------------- /register_types.h: -------------------------------------------------------------------------------- 1 | #ifndef DASLANG_REGISTER_TYPES_H 2 | #define DASLANG_REGISTER_TYPES_H 3 | 4 | #include "modules/register_module_types.h" 5 | 6 | void initialize_daslang_module(ModuleInitializationLevel p_level); 7 | void uninitialize_daslang_module(ModuleInitializationLevel p_level); 8 | 9 | #endif // DASLANG_REGISTER_TYPES_H 10 | -------------------------------------------------------------------------------- /src/godot_types_aliases.cpp: -------------------------------------------------------------------------------- 1 | #include "godot_types_aliases.h" 2 | #include "godot_module.h" 3 | 4 | 5 | void Module_Godot::bind_types_aliases(das::ModuleLibrary & lib) { 6 | addAlias(das::typeFactory::make(lib)); 7 | addAlias(das::typeFactory::make(lib)); 8 | addAlias(das::typeFactory<::RID>::make(lib)); 9 | } 10 | -------------------------------------------------------------------------------- /examples/demo/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=5 10 | 11 | [application] 12 | 13 | config/name="Demo" 14 | run/main_scene="res://main.tscn" 15 | config/features=PackedStringArray("4.2", "Forward Plus") 16 | config/icon="res://icon.svg" 17 | 18 | [filesystem] 19 | 20 | import/blender/enabled=false 21 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file is for convinient building of Daslang 2 | 3 | cmake_minimum_required(VERSION 3.27) 4 | project(godot-das) 5 | 6 | # remove for release 7 | set(CMAKE_BUILD_TYPE Debug) 8 | 9 | # don't build any binaries 10 | set(DAS_TESTS_DISABLED ON) 11 | set(DAS_PROFILE_DISABLED ON) 12 | set(DAS_TUTORIAL_DISABLED ON) 13 | set(DAS_TOOLS_DISABLED ON) 14 | set(DAS_AOT_EXAMPLES_DISABLED ON) 15 | set(DAS_GLFW_DISABLED ON) 16 | 17 | add_subdirectory(daScript) 18 | 19 | set_target_properties(libDaScript PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../lib") 20 | -------------------------------------------------------------------------------- /examples/bunnymark/bunnymark_gd.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://bvhw8nkdgodxl"] 2 | 3 | [ext_resource type="Script" path="res://Bunnymark.gd" id="1_kxwx1"] 4 | 5 | [node name="BunnymarkGD" type="Node2D"] 6 | script = ExtResource("1_kxwx1") 7 | 8 | [node name="FPS" type="Label" parent="."] 9 | z_index = 100 10 | offset_right = 40.0 11 | offset_bottom = 23.0 12 | theme_override_colors/font_outline_color = Color(0, 0, 0, 1) 13 | theme_override_constants/outline_size = 10 14 | theme_override_font_sizes/font_size = 32 15 | 16 | [node name="Bunnies" type="Node2D" parent="."] 17 | -------------------------------------------------------------------------------- /src/init_daslang.cpp: -------------------------------------------------------------------------------- 1 | #include "init_daslang.h" 2 | 3 | #include 4 | 5 | #include "core/config/project_settings.h" 6 | 7 | void initialize_daslang() { 8 | if (das::Module::require("$")) { 9 | return; 10 | } 11 | CharString boost_global_path = ProjectSettings::get_singleton()->globalize_path("res://boost").utf8(); 12 | das::setDasRoot(boost_global_path.get_data()); 13 | NEED_ALL_DEFAULT_MODULES; 14 | NEED_MODULE(Module_Godot); 15 | das::Module::Initialize(); 16 | } 17 | 18 | void deinitialize_daslang(){ 19 | das::Module::Shutdown(); 20 | } 21 | -------------------------------------------------------------------------------- /examples/bunnymark/bunnymark_das.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://d1lldyrxlk2a8"] 2 | 3 | [ext_resource type="Script" path="res://Bunnymark.das" id="1_wvtqn"] 4 | 5 | [node name="BunnymarkDAS" type="Node2D"] 6 | script = ExtResource("1_wvtqn") 7 | 8 | [node name="FPS" type="Label" parent="."] 9 | z_index = 100 10 | offset_right = 40.0 11 | offset_bottom = 23.0 12 | theme_override_colors/font_outline_color = Color(0, 0, 0, 1) 13 | theme_override_constants/outline_size = 10 14 | theme_override_font_sizes/font_size = 32 15 | text = "FPS = 138 16 | Bunnies = 0" 17 | 18 | [node name="Bunnies" type="Node2D" parent="."] 19 | -------------------------------------------------------------------------------- /_vscode_files/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "group": "build", 9 | "type": "shell", 10 | "command": "pyston-scons", 11 | }, 12 | { 13 | "label": "run", 14 | "group": "run", 15 | "type": "shell", 16 | "command": "{workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64 --path {workspaceFolder}/modules/daslang/demo", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /src/godot_types_aliases.h: -------------------------------------------------------------------------------- 1 | #ifndef GODOT_TYPES_ALIASES_H 2 | #define GODOT_TYPES_ALIASES_H 3 | 4 | #include "godot_types_macro.h" 5 | 6 | #include "core/math/vector2.h" 7 | 8 | MAKE_TYPE_FACTORY_ALIAS(Vector2, tFloat2); 9 | template <> struct das::cast : das::cast_fVec_half {}; 10 | 11 | #include "core/math/vector2i.h" 12 | 13 | MAKE_TYPE_FACTORY_ALIAS(Vector2i, tInt2); 14 | template <> struct das::cast : cast_iVec_half {}; 15 | 16 | #include "core/templates/rid.h" 17 | 18 | MAKE_TYPE_FACTORY_ALIAS(::RID, tUInt64); 19 | template <> struct das::cast<::RID> : das::cast {}; 20 | 21 | #endif // GODOT_TYPES_ALIASES_H 22 | -------------------------------------------------------------------------------- /_vscode_files/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}", 7 | "${workspaceFolder}/modules/daslang/daScript/include", 8 | "${workspaceFolder}/platform/linuxbsd", 9 | "${workspaceFolder}/modules/daslang/src" 10 | ], 11 | "defines": [ 12 | "DEBUG_ENABLED", 13 | "TOOLS_ENABLED", 14 | "DEV_ENABLED" 15 | ], 16 | "compilerPath": "/usr/bin/g++", 17 | "intelliSenseMode": "linux-gcc-x64", 18 | "cppStandard": "c++17" 19 | } 20 | ], 21 | "version": 4 22 | } -------------------------------------------------------------------------------- /examples/flappy_bird/bird.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=3 uid="uid://caxudicqjb7ri"] 2 | 3 | [ext_resource type="Texture2D" uid="uid://d2c3lsuihy6fe" path="res://icon.svg" id="1_b347b"] 4 | [ext_resource type="Script" path="res://Bird.das" id="1_nilun"] 5 | 6 | [sub_resource type="RectangleShape2D" id="RectangleShape2D_oqqhv"] 7 | size = Vector2(50, 50) 8 | 9 | [node name="Bird" type="Node2D"] 10 | script = ExtResource("1_nilun") 11 | 12 | [node name="Sprite" type="Sprite2D" parent="."] 13 | scale = Vector2(0.390625, 0.390625) 14 | texture = ExtResource("1_b347b") 15 | 16 | [node name="Collider" type="Area2D" parent="."] 17 | 18 | [node name="Shape" type="CollisionShape2D" parent="Collider"] 19 | shape = SubResource("RectangleShape2D_oqqhv") 20 | -------------------------------------------------------------------------------- /examples/flappy_bird/Pipes.das: -------------------------------------------------------------------------------- 1 | require boost/godot 2 | require Main 3 | 4 | 5 | [godot_class(Node2D)] 6 | class Pipes 7 | 8 | velocity = Vector2(-200, 0) 9 | game : Main? 10 | stopped : bool = false 11 | 12 | def _ready() 13 | game = native |> get_parent() |> get_parent() as Main 14 | 15 | def stop() 16 | stopped = true 17 | 18 | def _process(dt : float) 19 | if stopped 20 | return 21 | 22 | let prev_pos = native |> get_position() 23 | 24 | let translation = velocity * dt 25 | native |> translate(translation) 26 | 27 | let pos = native |> get_position() 28 | if prev_pos.x > game->get_bird_level() && pos.x < game->get_bird_level() 29 | game->add_point() 30 | 31 | if pos.x < - pipe_width * 0.5 32 | native |> queue_free() 33 | -------------------------------------------------------------------------------- /src/godot_types_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef GODOT_TYPES_EXTRA_H 2 | #define GODOT_TYPES_EXTRA_H 3 | 4 | // this file is for everything that I don't yet know how to generate 5 | 6 | #include "godot_types_macro.h" 7 | 8 | #include "core/math/color.h" 9 | 10 | MAKE_NATIVE_TYPE_FACTORY(Color) 11 | 12 | template <> struct das::cast : das::cast_fVec {}; 13 | 14 | #include "core/core_bind.h" 15 | 16 | DAS_BIND_ENUM_CAST(core_bind::ResourceLoader::CacheMode) 17 | DAS_BASE_BIND_ENUM_SAFE(core_bind::ResourceLoader::CacheMode, ResourceLoader`CacheMode, ResourceLoader_CacheMode, CACHE_MODE_IGNORE, CACHE_MODE_REUSE, CACHE_MODE_REPLACE) 18 | 19 | #include "core/variant/variant_utility.h" 20 | #include "core/config/engine.h" 21 | 22 | 23 | #endif // GODOT_TYPES_EXTRA_H -------------------------------------------------------------------------------- /examples/bunnymark/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=5 10 | 11 | [application] 12 | 13 | config/name="Bunnymark" 14 | run/main_scene="res://bunnymark_das.tscn" 15 | config/features=PackedStringArray("4.2", "Forward Plus") 16 | config/icon="res://bunny.png" 17 | 18 | [display] 19 | 20 | window/size/viewport_width=1024 21 | window/size/viewport_height=512 22 | window/size/resizable=false 23 | 24 | [filesystem] 25 | 26 | import/blender/enabled=false 27 | 28 | [rendering] 29 | 30 | environment/defaults/default_clear_color=Color(0.329412, 0.607843, 0.2, 1) 31 | -------------------------------------------------------------------------------- /examples/demo/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=3 uid="uid://d0qrnbd0js2v"] 2 | 3 | [ext_resource type="Script" path="res://Foo.das" id="1_sq7uu"] 4 | [ext_resource type="Texture2D" uid="uid://cgwhexj46bt6v" path="res://icon.svg" id="1_uetd5"] 5 | [ext_resource type="Script" path="res://unrelated_name.das" id="3_tlb08"] 6 | 7 | [node name="Main" type="Node2D"] 8 | 9 | [node name="Foo" type="Sprite2D" parent="."] 10 | position = Vector2(394, 255) 11 | texture = ExtResource("1_uetd5") 12 | script = ExtResource("1_sq7uu") 13 | 14 | [node name="Timer" type="Timer" parent="Foo"] 15 | autostart = true 16 | 17 | [node name="SignalReciever" type="Node2D" parent="Foo"] 18 | position = Vector2(-394, -255) 19 | script = ExtResource("3_tlb08") 20 | 21 | [node name="Center" type="Marker2D" parent="."] 22 | position = Vector2(600, 300) 23 | -------------------------------------------------------------------------------- /examples/bunnymark/bunny.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="CompressedTexture2D" 5 | uid="uid://bapr105lc8n4h" 6 | path="res://.godot/imported/bunny.png-e23606c57d59402d46f8f11b8e3b74b2.ctex" 7 | metadata={ 8 | "vram_texture": false 9 | } 10 | 11 | [deps] 12 | 13 | source_file="res://bunny.png" 14 | dest_files=["res://.godot/imported/bunny.png-e23606c57d59402d46f8f11b8e3b74b2.ctex"] 15 | 16 | [params] 17 | 18 | compress/mode=0 19 | compress/high_quality=false 20 | compress/lossy_quality=0.7 21 | compress/hdr_compression=1 22 | compress/normal_map=0 23 | compress/channel_pack=0 24 | mipmaps/generate=false 25 | mipmaps/limit=-1 26 | roughness/mode=0 27 | roughness/src_normal="" 28 | process/fix_alpha_border=true 29 | process/premult_alpha=false 30 | process/normal_map_invert_y=false 31 | process/hdr_as_srgb=false 32 | process/hdr_clamp_exposure=false 33 | process/size_limit=0 34 | detect_3d/compress_to=1 35 | -------------------------------------------------------------------------------- /src/godot_module.h: -------------------------------------------------------------------------------- 1 | #ifndef MODULE_GODOT_H 2 | #define MODULE_GODOT_H 3 | 4 | 5 | #include 6 | 7 | class Module_Godot : public das::Module { 8 | void bind_types_gen(das::ModuleLibrary & lib); 9 | void bind_types_aliases(das::ModuleLibrary & lib); 10 | void bind_types_extra(das::ModuleLibrary & lib); 11 | void bind_functions_gen(das::ModuleLibrary & lib); 12 | void bind_functions_extra(das::ModuleLibrary & lib); 13 | void bind_utils(das::ModuleLibrary & lib); 14 | public: 15 | Module_Godot() : Module("godot_native") { 16 | das::ModuleLibrary lib(this); 17 | options["tool"] = das::Type::tBool; 18 | 19 | bind_types_gen(lib); 20 | bind_types_aliases(lib); 21 | bind_types_extra(lib); 22 | 23 | bind_functions_gen(lib); 24 | bind_functions_extra(lib); 25 | 26 | bind_utils(lib); 27 | } 28 | }; 29 | 30 | #endif // MODULE_GODOT_H 31 | -------------------------------------------------------------------------------- /examples/flappy_bird/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/demo/icon.svg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="CompressedTexture2D" 5 | uid="uid://cgwhexj46bt6v" 6 | path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" 7 | metadata={ 8 | "vram_texture": false 9 | } 10 | 11 | [deps] 12 | 13 | source_file="res://icon.svg" 14 | dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] 15 | 16 | [params] 17 | 18 | compress/mode=0 19 | compress/high_quality=false 20 | compress/lossy_quality=0.7 21 | compress/hdr_compression=1 22 | compress/normal_map=0 23 | compress/channel_pack=0 24 | mipmaps/generate=false 25 | mipmaps/limit=-1 26 | roughness/mode=0 27 | roughness/src_normal="" 28 | process/fix_alpha_border=true 29 | process/premult_alpha=false 30 | process/normal_map_invert_y=false 31 | process/hdr_as_srgb=false 32 | process/hdr_clamp_exposure=false 33 | process/size_limit=0 34 | detect_3d/compress_to=1 35 | svg/scale=1.0 36 | editor/scale_with_editor_scale=false 37 | editor/convert_colors_with_editor_theme=false 38 | -------------------------------------------------------------------------------- /examples/flappy_bird/icon.svg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="CompressedTexture2D" 5 | uid="uid://d2c3lsuihy6fe" 6 | path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" 7 | metadata={ 8 | "vram_texture": false 9 | } 10 | 11 | [deps] 12 | 13 | source_file="res://icon.svg" 14 | dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] 15 | 16 | [params] 17 | 18 | compress/mode=0 19 | compress/high_quality=false 20 | compress/lossy_quality=0.7 21 | compress/hdr_compression=1 22 | compress/normal_map=0 23 | compress/channel_pack=0 24 | mipmaps/generate=false 25 | mipmaps/limit=-1 26 | roughness/mode=0 27 | roughness/src_normal="" 28 | process/fix_alpha_border=true 29 | process/premult_alpha=false 30 | process/normal_map_invert_y=false 31 | process/hdr_as_srgb=false 32 | process/hdr_clamp_exposure=false 33 | process/size_limit=0 34 | detect_3d/compress_to=1 35 | svg/scale=1.0 36 | editor/scale_with_editor_scale=false 37 | editor/convert_colors_with_editor_theme=false 38 | -------------------------------------------------------------------------------- /examples/flappy_bird/pipes.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=3 uid="uid://cfut6ggpxmwim"] 2 | 3 | [ext_resource type="Script" path="res://Pipes.das" id="1_svets"] 4 | 5 | [sub_resource type="RectangleShape2D" id="RectangleShape2D_oqgue"] 6 | size = Vector2(50, 400) 7 | 8 | [node name="Pipes" type="Node2D"] 9 | script = ExtResource("1_svets") 10 | 11 | [node name="Upper" type="Area2D" parent="."] 12 | 13 | [node name="Shape" type="CollisionShape2D" parent="Upper"] 14 | shape = SubResource("RectangleShape2D_oqgue") 15 | 16 | [node name="Sprite" type="Polygon2D" parent="Upper"] 17 | color = Color(0, 0.769531, 0.0841675, 1) 18 | polygon = PackedVector2Array(-25, -200, -25, 200, 25, 200, 25, -200) 19 | 20 | [node name="Lower" type="Area2D" parent="."] 21 | position = Vector2(0, 648) 22 | 23 | [node name="Shape" type="CollisionShape2D" parent="Lower"] 24 | shape = SubResource("RectangleShape2D_oqgue") 25 | 26 | [node name="Sprite" type="Polygon2D" parent="Lower"] 27 | color = Color(0, 0.769531, 0.0841675, 1) 28 | polygon = PackedVector2Array(-25, -200, -25, 200, 25, 200, 25, -200) 29 | -------------------------------------------------------------------------------- /boost/godot_signals.das: -------------------------------------------------------------------------------- 1 | require godot_native 2 | 3 | 4 | struct Signal 5 | name : string 6 | owner : Object? 7 | 8 | // backup method 9 | def get_signal(obj : Object?; name : string) 10 | return [[Signal name = name, owner = obj]] 11 | 12 | // Connect to native signal 13 | // timer |> get_timeout() |> connect(obj) <| "on_timeout" 14 | // Connect to user signal 15 | // sig |> connect(obj) <| "on_timeout" 16 | // Connect to any signal 17 | // obj |> get_signal("pls add mutual require??") |> connect(obj) <| "on_timeout" 18 | def connect(signal : Signal; peer : Object?; func_name : string) 19 | connect_signal_to_func_str(signal.owner, signal.name, peer, func_name) 20 | // TODO make in macro connect with bound self 21 | 22 | // Connect lambda to signal 23 | // timer |> get_timeout() |> connect() <| @ 24 | // print("Hello") 25 | def connect(signal : Signal; lmd : lambda) 26 | connect_signal_to_lambda(signal.owner, signal.name, lmd) 27 | 28 | // Emit custom signal 29 | // sig |> emit() 30 | // Emit native signal 31 | // timer |> get_timeout() |> emit() 32 | def emit(signal : Signal) 33 | emit_signal(signal.owner, signal.name) 34 | -------------------------------------------------------------------------------- /SCsub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | Import("env") 4 | Import("env_modules") 5 | 6 | env_daslang = env_modules.Clone() 7 | 8 | import subprocess 9 | import os 10 | 11 | DASLANG_PATH = "daScript" # if changing this, be sure to disable downloading submodule 12 | DASLANG_LIB_PATH = "lib/liblibDaScript.a" 13 | DASLANG_INCLUDE_PATH = f"{DASLANG_PATH}/include" 14 | 15 | 16 | src_list = [ 17 | "register_types.cpp", 18 | "src/godot_types_gen.cpp", 19 | "src/godot_types_aliases.cpp", 20 | "src/godot_types_extra.cpp", 21 | "src/godot_functions_gen.cpp", 22 | "src/godot_functions_extra.cpp", 23 | "src/godot_utils.cpp", 24 | "src/init_daslang.cpp", 25 | "src/das_script.cpp", 26 | "src/das_script_language.cpp", 27 | "src/das_script_instance.cpp", 28 | "src/das_resource_io.cpp", 29 | ] 30 | 31 | if "DEV_ENABLED" in env["CPPDEFINES"]: 32 | src_list.append("src/generate_bindings.cpp") 33 | 34 | env_daslang.Append(CCFLAGS=["-w"]) # TODO suspend only warnings in Daslang headers 35 | env_daslang.Append(CPPPATH=["src", DASLANG_INCLUDE_PATH]) 36 | env_daslang.add_source_files(env.modules_sources, src_list) 37 | 38 | 39 | daslang_lib = File(DASLANG_LIB_PATH) 40 | env.Append(LIBS=[daslang_lib]) 41 | -------------------------------------------------------------------------------- /src/das_resource_io.h: -------------------------------------------------------------------------------- 1 | #ifndef DAS_RESOURCE_FORMAT_H 2 | #define DAS_RESOURCE_FORMAT_H 3 | 4 | #include "core/io/resource_loader.h" 5 | 6 | 7 | class DasResourceFormatLoader : public ResourceFormatLoader { 8 | Ref _get_full_script(const String &p_path, Error &r_error); 9 | public: 10 | Ref load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE) override; 11 | void get_recognized_extensions(List *p_extensions) const override; 12 | bool handles_type(const String &p_type) const override; 13 | String get_resource_type(const String &p_path) const override; 14 | void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false) override; 15 | }; 16 | 17 | 18 | #include 19 | 20 | class DasResourceFormatSaver : public ResourceFormatSaver { 21 | public: 22 | Error save(const Ref &p_resource, const String &p_path, uint32_t p_flags = 0) override; 23 | void get_recognized_extensions(const Ref &p_resource, List *p_extensions) const override; 24 | bool recognize(const Ref &p_resource) const override; 25 | }; 26 | 27 | #endif // DAS_RESOURCE_FORMAT_H 28 | 29 | -------------------------------------------------------------------------------- /register_types.cpp: -------------------------------------------------------------------------------- 1 | #include "register_types.h" 2 | 3 | #include "das_script_language.h" 4 | #include "das_script.h" 5 | #include "das_resource_io.h" 6 | 7 | DasScriptLanguage *das_script_language = nullptr; 8 | Ref das_resource_loader; 9 | Ref das_resource_saver; 10 | 11 | 12 | void initialize_daslang_module(ModuleInitializationLevel p_level) { 13 | if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { 14 | GDREGISTER_CLASS(DasScript); 15 | 16 | das_script_language = memnew(DasScriptLanguage); 17 | ScriptServer::register_language(das_script_language); 18 | 19 | das_resource_loader.instantiate(); 20 | ResourceLoader::add_resource_format_loader(das_resource_loader); 21 | 22 | das_resource_saver.instantiate(); 23 | ResourceSaver::add_resource_format_saver(das_resource_saver); 24 | } 25 | } 26 | 27 | void uninitialize_daslang_module(ModuleInitializationLevel p_level) { 28 | if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { 29 | ScriptServer::unregister_language(das_script_language); 30 | 31 | if (das_script_language) { 32 | memdelete(das_script_language); 33 | } 34 | 35 | ResourceLoader::remove_resource_format_loader(das_resource_loader); 36 | das_resource_loader.unref(); 37 | 38 | ResourceSaver::remove_resource_format_saver(das_resource_saver); 39 | das_resource_saver.unref(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/godot_functions_extra.cpp: -------------------------------------------------------------------------------- 1 | #include "godot_module.h" 2 | 3 | #include "godot_types_gen.h" 4 | #include "godot_types_extra.h" 5 | 6 | #include "godot_functions_wrapper.h" 7 | 8 | #include "das_script_instance.h" 9 | #include "core/core_bind.h" 10 | 11 | // Here are functions that are 12 | // 1) not generated yet, but will be 13 | // 2) not in a large enough group to put in a separate file 14 | 15 | using CoreResourceLoader = core_bind::ResourceLoader; 16 | 17 | 18 | void Module_Godot::bind_functions_extra(das::ModuleLibrary & lib) { 19 | BIND_GODOT_SINGLETON_MEMBER_BUILTIN(CoreResourceLoader, load, "path", "type_hint", "no_cache") 20 | SET_DEFAULT_ARG(CoreResourceLoader, load, 1, "") 21 | SET_DEFAULT_ARG(CoreResourceLoader, load, 2, 1) 22 | 23 | // Color 24 | // TODO properly bind simnode ctor 25 | using _Color_named = DAS_CALL_GODOT_STATIC_MEMBER(*static_cast(&Color::named)); 26 | das::addExtern(*this, lib, "Color`named", das::SideEffects::modifyExternal, DAS_CALL_GODOT_STATIC_MEMBER_CPP(Color::named)); 27 | 28 | BIND_GODOT_SINGLETON_MEMBER(Engine, get_frames_per_second) 29 | BIND_GODOT_SINGLETON_MEMBER(Input, is_action_just_pressed, "action", "exact_match") 30 | SET_DEFAULT_ARG(Input, is_action_just_pressed, 1, false) 31 | 32 | BIND_GODOT_BUILTIN_FUNCTION(VariantUtilityFunctions, randf_range) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /_vscode_files/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | 4 | "configurations": [ 5 | 6 | // Consult https://docs.godotengine.org/en/stable/contributing/development/configuring_an_ide/visual_studio_code.html#debugging-the-project 7 | // for more info about debugging configurations 8 | { 9 | "name": "Debug demo", 10 | "type": "lldb", 11 | "request": "launch", 12 | // Change to your Godot binary path name if you are not on Linux 13 | "program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64", 14 | "args": [ "--editor", "--path", "${workspaceFolder}/modules/daslang/examples/flappy_bird"], 15 | "stopAtEntry": false, 16 | "cwd": "${workspaceFolder}", 17 | "environment": [], 18 | "externalConsole": false, 19 | // uncomment this if you want to spend time waiting for building every time 20 | //"preLaunchTask": "build" 21 | }, 22 | { 23 | "name": "Debug codegen", 24 | "type": "lldb", 25 | "request": "launch", 26 | "program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64", 27 | "args": [ "--", "--bind-das"], 28 | "stopAtEntry": false, 29 | "cwd": "${workspaceFolder}", 30 | "environment": [], 31 | "externalConsole": false, 32 | // uncomment this if you want to spend time waiting for building every time 33 | //"preLaunchTask": "build" 34 | }, 35 | ] 36 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019-2023, Gaijin Entertainment 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /examples/flappy_bird/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=4 format=3 uid="uid://b0ck5fwwdn3hh"] 2 | 3 | [ext_resource type="Script" path="res://Main.das" id="1_c4qn6"] 4 | [ext_resource type="PackedScene" uid="uid://caxudicqjb7ri" path="res://bird.tscn" id="1_pa2s4"] 5 | 6 | [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_4dj23"] 7 | 8 | [node name="Main" type="Node2D"] 9 | script = ExtResource("1_c4qn6") 10 | 11 | [node name="Bird" parent="." instance=ExtResource("1_pa2s4")] 12 | position = Vector2(577, 336) 13 | 14 | [node name="Ground" type="Area2D" parent="."] 15 | position = Vector2(574, 626) 16 | 17 | [node name="Shape" type="CollisionShape2D" parent="Ground"] 18 | shape = SubResource("WorldBoundaryShape2D_4dj23") 19 | 20 | [node name="Sprite" type="Polygon2D" parent="Ground"] 21 | polygon = PackedVector2Array(-600, 0, 600, 0, 600, 100, -600, 100) 22 | 23 | [node name="Pipes" type="Node2D" parent="."] 24 | 25 | [node name="HUD" type="CanvasLayer" parent="."] 26 | 27 | [node name="Points" type="Label" parent="HUD"] 28 | anchors_preset = -1 29 | anchor_left = 0.5 30 | anchor_top = 0.125 31 | anchor_right = 0.5 32 | anchor_bottom = 0.125 33 | grow_horizontal = 2 34 | theme_override_font_sizes/font_size = 64 35 | text = "0" 36 | horizontal_alignment = 1 37 | 38 | [node name="GameOver" type="Label" parent="HUD"] 39 | visible = false 40 | anchors_preset = 8 41 | anchor_left = 0.5 42 | anchor_top = 0.5 43 | anchor_right = 0.5 44 | anchor_bottom = 0.5 45 | grow_horizontal = 2 46 | grow_vertical = 2 47 | theme_override_font_sizes/font_size = 48 48 | text = "Game Over! 49 | Press any key to restart" 50 | horizontal_alignment = 1 51 | 52 | [node name="CanRestart" type="Timer" parent="."] 53 | wait_time = 0.25 54 | one_shot = true 55 | -------------------------------------------------------------------------------- /examples/flappy_bird/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=5 10 | 11 | [application] 12 | 13 | config/name="Flappy Bird" 14 | run/main_scene="res://main.tscn" 15 | config/features=PackedStringArray("4.2", "Forward Plus") 16 | config/icon="res://icon.svg" 17 | 18 | [display] 19 | 20 | window/size/resizable=false 21 | 22 | [input] 23 | 24 | jump={ 25 | "deadzone": 0.5, 26 | "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) 27 | , Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(161, 25),"global_position":Vector2(165, 66),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) 28 | , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null) 29 | , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null) 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/das_script_instance.cpp: -------------------------------------------------------------------------------- 1 | #include "das_script_instance.h" 2 | 3 | #include "das_script_language.h" 4 | 5 | 6 | DasScriptInstance::~DasScriptInstance() { 7 | script->free_instance(this); 8 | } 9 | 10 | void DasScriptInstance::set_script(Ref p_script) { 11 | script = p_script; 12 | } 13 | 14 | void DasScriptInstance::set_owner(Object *p_owner) { 15 | owner = p_owner; 16 | } 17 | 18 | void DasScriptInstance::set_class_ptr(char* p_class_ptr) { 19 | class_ptr = p_class_ptr; 20 | } 21 | 22 | char* DasScriptInstance::get_class_ptr() { 23 | return class_ptr; 24 | } 25 | 26 | void DasScriptInstance::get_method_list(List *p_list) const { 27 | script.ptr()->get_script_method_list(p_list); 28 | } 29 | 30 | bool DasScriptInstance::has_method(const StringName &p_method) const { 31 | // TODO take inheritance into account (see notes) 32 | return script.ptr()->has_method(p_method); 33 | } 34 | 35 | Variant DasScriptInstance::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { 36 | das::ContextPtr ctx = script->get_ctx(); 37 | int offset = script->get_func_offset(p_method); 38 | if (offset == INVALID_OFFSET) { 39 | r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; 40 | return Variant(); 41 | } 42 | auto func_ptr = reinterpret_cast(class_ptr + offset)->PTR; 43 | 44 | auto ret = DasScriptLanguage::call_function(func_ptr, ctx.get(), class_ptr, String(p_method).utf8().get_data(), p_args, p_argcount, r_error); 45 | return ret; 46 | } 47 | 48 | Ref