Better support for Arrays and PackedArrays from plain C API (GDExtension) #6119
Replies: 1 comment
-
I believe them main issue is that there isn't really any constructor of packed arrays that takes an array of values (except from a copy constructor and one that creates from a variant array). I'm not sure if it's possible to expose one that would work well with C and would be okay using the current type API (which is also used by scripting). Potentially there could be some special constructors available only for extensions which can use lower-level constructs. IMO it could be productive to have "C bindings", as a series of helper structs and functions, besides a code generator from the JSON (not unlike the C++ bindings) to make it easier work directly from C and potentially for other bindings relying C code. The API for GDExtension was not really made for using straight from C, but to rely on bindings and generators. I don't think adding many more things to Godot itself is a good solution. This is because the API should be as stable as possible and having more things is more surface to have to change something. Another reason is that any improvement would have to wait for a new Godot release. Even though we plan to have short release cycles after 4.0, it's not necessary to wait the release to improve the helper functions in the periphery. Not to mention that Godot core has huge friction to add stuff, while an external set of bindings would be much easier to change. |
Beta Was this translation helpful? Give feedback.
-
I am doing some work on the rust bindings for gdextension, and getting Arrays (and typed arrays) working seems to be kind of a hurdle.
It's entirely possible I just don't know what I'm doing yet, but it seems like there ought to be a way at the C level to just pass in an array of int32 values and a length, and construct a
PackedInt32Array
. (And of course same for all the other packed array types).Could we add a function for this, or is it already possible somehow?
(As far as I can tell, the Packed types rely on classes generated by a custom C++ template... which seems like a large burden for non-c++ users).
links:
Beta Was this translation helpful? Give feedback.
All reactions