Commit Graph

76 Commits (daf8ac1c330839304040fb0ed5e8ff5775980cc3)

Author SHA1 Message Date
Emmanuel Leblond a706a9ceb9
Remove now useless `_alloc_and_copy_cstr` 2022-11-08 21:44:31 +01:00
Emmanuel Leblond e24b6b0e51
Use StringName in the whole GDExtension API instead of const char * 2022-11-08 21:44:31 +01:00
Emmanuel Leblond 0e81f89dd3
Uses `StringName` in GDExtension perf critical instance creation & method/properties setter/getter 2022-11-08 21:44:30 +01:00
Emmanuel Leblond b21931c4a3
Type `GDNativePropertyInfo.type` field as `GDNativeVariantType` 2022-10-13 14:04:54 +02:00
Aaron Franke 592bd15c7a
Run scripts to format and make headers consistent 2022-10-09 01:47:07 -05:00
Marc Gilleron 5de2c059d1 Fix deriving a custom class with virtual methods 2022-09-21 19:31:30 +01:00
Rémi Verschelde 3276688c82
Merge pull request #844 from Zylann/fix_get_const
Fix issues with `_get` and `_get_property_list`
2022-09-16 08:48:00 +02:00
Marc Gilleron 6f3bdab090 Fix issues with `_get` and `_get_property_list`
`_get` was using `_set` internally, and should be `const`.
`_get_property_list` should be `const`.
2022-09-15 23:46:50 +01:00
bruvzg 36273baa7e
Change PropertyInfo members to String. 2022-09-14 08:41:09 +03:00
Fabio Alessandrelli bcf27d8af4 Ensure GDCLASS can be used outside the godot namespace.
The `GDCLASS` macro should not assume to be called inside the `godot`
namespace and should thus prefix function calls for that namespace with
`::godot::` to ensure proper namespace referencing.
2022-09-01 04:11:23 +02:00
bruvzg 270ad28931
Add support for `_notification`, `_set`, `_get`, `_get_property_list`, `_property_can_revert`, `_property_get_revert`, and `_to_string` methods. 2022-08-22 12:59:38 +03:00
Kevin Smith fd8173f109 Allow GDCLASS in own namespaces
The unqualified ClassDB friending was causing (at least for me on
VS2022) an implicit forward declaration of ClassDB in the namespace
of my class, instead of using the godot namespaced one. By qualifying
the namespace, this compiles for me.

Test-Information:
My project builds now.
2022-07-31 11:54:40 +01:00
Fabio Alessandrelli 78cbae910d Fix "_instance_bindings != nullptr" for Wrapped objects.
This is an attempt to make the lifecycle of wrapped objects clearer.
Godot keeps track of bindings' userdata for each object it creates.
This allows allocating the memory of the wrapper only once per object
even if that object is passed multiple times between binding code and
godot code.

The binding information is composed of multiple functions, this includes
a callback for when the userdata is to be allocated (called once) and
for when the userdata is to be deallocated (again, called once).

When allocating data with "memnew" we set the object bindings during the
postinitialize phase, but surely we shouldn't do that when allocating
the userdata as a result of bindings callback themselves.

Additionally, since we let Godot handle (and track) raw memory
allocation and de-allocation, we need to manually call the deconstructor
of the wrapper class during the free callback, to ensure that its
non-trivial members are correctly de-initialized.
2022-07-29 02:36:12 +02:00
Fabio Alessandrelli 8d4de1b537
Merge pull request #677 from lukas-toenne/fix_object_ptr_args
Fixed pointer indirection in the PtrToArg template for Object arguments.
2022-07-29 01:17:34 +02:00
Rémi Verschelde 1632322ce0 Update copyright year 2022-03-15 10:17:53 +01:00
Marc Gilleron 6fdcb18f6a Fix GDCLASS when inherited class is in another namespace 2022-02-20 19:33:00 +00:00
Lukas Tönne 836cc4d3dc Fix for pointer indirection in the Ref<T> template.
Patch by Nana Sakisaka (saki7).
2022-01-07 09:20:05 +01:00
Gilles Roudière adbbf1a3a1 Fix object_set_instance being wrongly called for built-in wrapped classes 2021-12-06 15:40:19 +01:00
Gilles Roudière 3fcb8a4d1e Make extension instances create the corresponding godot object in their constructor 2021-12-03 15:37:49 +01:00
Bastiaan Olij ef528d3a86 Rename interface to gdn_interface because it's a defined keyword under windows 2021-10-28 19:44:20 +11:00
Fabio Alessandrelli b90d0ac555 Add Ref<T> binding support.
Added PtrToArg and GetTypeInfo adapted from Godot.
2021-09-28 15:49:08 +02:00
Bastiaan Olij fad6329699 Implement Ref copy constructor 2021-09-27 23:08:12 +10:00
Fabio Alessandrelli b4632e317d Fix creation (and godot-side deletion) of extended objects.
Proper initialization for godot-cpp classes with memnew.

Extension classes (i.e. the `GDCLASS` macro) behave differently from
regular wrapped classes, and requires Godot to initialize them during
object construction.

This commit update the GDCLASS macro to not create/destroy the instance
during the bindings callback, but during the extension callbacks.

When setting the object instance, the bindings instance is set to the
pointer of the extension instance so that it can later be retrieved
normally via `object_get_instance_bindings`.
2021-09-27 23:08:11 +10:00
George Marques 38ee8bfcf7 Change constructor/destructor management of extension classes
This makes sure custom constructors are always called on extension
classes. However, note that constructors should not take any parameters,
since Godot doesn't support that. Parameters are ignore in memnew macro.

Use memnew(MyClass()) instead of memnew(MyClass) since it now needs a
value instead of a class name. This macro calls MyClass::_new() (define
in GDCLASS macro) which ultimately calls Godot to create the object,
ensuring that both the Godot and the extension instances are created.

Non Godot classes (that don't derive godot::Object) are constructed as
usual an can have parameters.

memdelete is also changed for the same reason, as it needs to destroy
the Godot object as well, and that automatically frees the bound
extension instance.
2021-09-27 23:08:11 +10:00
George Marques a0634cca3f Auto-bind virtual method overrides 2021-09-27 23:08:08 +10:00
George Marques e4ed48976a Replace bindgins to work with extensions 2021-09-27 23:08:08 +10:00