fuzzybinary / godot_dart Goto Github PK
View Code? Open in Web Editor NEWUsing Dart as a scripting language for Godot
License: MIT License
Using Dart as a scripting language for Godot
License: MIT License
Support default arguments for the generated API using named arguments in Dart.
This will diverge from Godot / GDScript which uses positional default arguments but I'm okay with that.
Pending godotengine/godot#63275 we need to get rid of the generated template metaprogramming that's used for virtual function calls. We're limited to a total of 512 distinct functions, which is likely not enough for larger project.
While it might be useful for Extensions to make a distinction between Godot String
and StringName
, GDScript doesn't, or at least converts between the string types transparently.
The generated API could should do the same, and GDString and StringName should really only be used by internal classes. Everything external should take Dart strings if possible.
The code currently generated for Indexers doesn't work. In Array
I hack replaced it with:
Variant operator [](int index) {
Variant ret = Variant();
final getter = gde.interface.ref.variant_get_indexed.asFunction<
void Function(Pointer<Void>, int, Pointer<Void>, Pointer<Uint8>,
Pointer<Uint8>)>(isLeaf: true);
using((arena) {
final valid = arena.allocate<Uint8>(sizeOf<Uint8>());
final oob = arena.allocate<Uint8>(sizeOf<Uint8>());
getter(nativePtr.cast(), index, ret.nativePtr.cast(), valid, oob);
if (oob.value != 0) {
throw RangeError.index(index, this);
}
});
return ret;
}
This should probably serve as the template for both indexed getters and setters for now, even though it doesn't take advantage of ptr calls. We can revisit ptr call support for these at a later date.
Vararg methods cannot be called with Ptr calls in Godot, and attempting to get them returns a null address for the function (which obviously crashes).
For Built In types, this means using variant_call
instead.
The generated code should take this into account (and while we're there, vararg funcitons should take a List<Variant>
as their paraemter list, defaulted to []
)
Linux build support needs support in https://github.com/fuzzybinary/dart_shared_libray (probably after fuzzybinary/dart_shared_libray#5 is implemented). Then we should look into replacing the Visual Studio project files with Godot standard scons scripts.
Vararg methods cannot be called with Ptr calls in Godot, and attempting to get them returns a null address for the function (which obviously crashes).
This should work okay for Engine classes which are already not using ptr calls, but the generated code have the funcitons take a List as their paraemter list, defaulted to [], and make sure this is passed as the arguments to the vararg function
Packed arrays can use Ptr calls to get variables more efficiently than converting to Variants. It will need some specific for certain types though.
Dart doesn't support "static inheritance," but we can fake it by assuming all Godot classes have a static member sTypeInfo
and use gde.dartBindings.getGodotTypeInfo(T)
to get it (see [src/dart/lib/godot_dart_extensions.dart] for an example).
This could simplify many functions that currently take both a generic paramet and a TypeInfo
argument (cast
being the main one)
godot-cpp
doesn't generate a lot of the builtin types, especially the math heavy ones, as going back and forth through the Godot calling system would be cumbersome. Instead, they re-implement them in C++
We should take a similar approach in Dart, only copying values out to opaque memory when needed. The classes that should get this treatment are:
This will also allow us to simplify their interfaces, including allowing default parameters for constructors instead of using named constructors for everything but the default.
The logic for Dictionary's keyed getters is likely wrong and needs to be fixed.
We should also support keyed getters on other types that support them (if there are any.)
From what I can tell, __engine_binding_reference_callback
is used to let the bindings know that an object is being referenced or dereferenced. It is supposed to return true
if the the object can die (meaning the binding is no longer holding onto references of it) and false otherwise.
For expediency, I have it return false
always which means certain Ref counted objects are leaking.
Mac build support needs support in https://github.com/fuzzybinary/dart_shared_libray (probably after fuzzybinary/dart_shared_libray#5 is implemented). Then we should look into replacing the Visual Studio project files with Godot standard scons scripts.
Something about recent changes broke the Simple
node in the example from showing up as a creatable node. Need to research why.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.