Commit Graph

88 Commits

Author SHA1 Message Date
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
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
fa111d7078 Add support for property_*_revert methods 2022-08-18 16:43:01 +03:00
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
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
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
95574c1b11 fix: Object::cast_to checks provided object for nullptr 2022-07-26 00:41:57 +02:00
91c56a0ad1 Add bindings for Vector4, Vector4i, Projection built-in types. 2022-07-21 09:36:38 +03:00
8772a7faca Merge pull request #686 from ondy-personal/patch-1 2022-07-18 15:48:17 +02:00
713b122b84 Add support for BitField hint, sync API files. 2022-07-11 15:00:17 +03:00
d894f48f25 Fix crash when using static methods without return value 2022-07-03 17:00:43 +02:00
5bbcd42378 Fix GDN_EXPORT define with mingw.
This commit changes the platform detection order to detect mingw
compiling for windows (which defines `__GNUC__`).

This commit also wraps the definition around a guard so it can be
overridden via a define at build-time.
2022-06-18 14:38:18 +02:00
e3119e7d05 Sync containers with new HashMap/HashSet, sync API headers. 2022-06-06 12:18:07 +03:00
5c32dc3948 Cast Variant::Type to GDNativeVariantType 2022-05-17 07:01:43 +02:00
031a83b0ea [Method Bind] Add support for default argument values and static method binding. Sync headers. 2022-05-06 10:17:51 +03:00
e06d5cd414 Add double precision build support. 2022-05-04 15:56:35 +03:00
8bf5a532de Change registered initializers / terminators to the single function with level argument. 2022-05-04 11:14:51 +03:00
24f5cd2d48 Color: Rename to_srgb/to_linear to include base color space
Counterpart to https://github.com/godotengine/godot/pull/60199.
Also syncs the extension API with that PR.
2022-04-13 12:50:21 +02:00
057a771fda Add support for variadic method binds with the typed return. Sync headers. 2022-03-30 15:11:28 +03:00
93de1b2b0b Sync godot-headers and fix build after "Create GDExtension clases for PhysicsServer3D". 2022-03-16 20:33:06 +02:00
817efdd484 Fix build after "Discern between VIRTUAL and ABSTRACT class bindings". 2022-03-15 13:43:12 +02:00
1632322ce0 Update copyright year 2022-03-15 10:17:53 +01:00
b1385953fe Add ObjectDB::get_instance method to get wrapped Object * from ObjectID. 2022-03-08 10:17:33 +02:00
d97dc518d3 Fixed crash on release builds due to missing argument type information 2022-03-02 14:44:23 +01:00
a94148ca4c Reorder native extension initialization steps 2022-02-28 15:44:54 +01:00
d154ffbe86 Merge pull request #708 from Zylann/fix_inheriting_class_with_namespace 2022-02-21 11:27:31 +01:00
76bad22978 Merge pull request #701 from bruvzg/port_templates 2022-02-21 11:25:40 +01:00
6fdcb18f6a Fix GDCLASS when inherited class is in another namespace 2022-02-20 19:33:00 +00:00
7e3321d1b2 Use forward declares for vector math types
Adds operators to convert from int vector types to float vector types
as done in the upstream engine implementations.
2022-02-20 12:04:08 +01:00
917b0c2ca3 Merge pull request #688 from zhehangd/master 2022-02-19 16:31:32 +01:00
e36180f377 Port a bunch of Godot container templates to GDExtension. 2022-02-18 21:07:53 +02:00
65dc3e89c7 Add ERR_ macros variants using String messages. 2022-02-17 10:18:04 +02:00
a8cd21ac07 Fix "const" NativePtr binds. 2022-02-16 11:35:13 +02:00
bf8fc4c53d Add ptr() / ptrw() to the arrays, add missing String methods, add missing CharString method implementations. 2022-02-14 23:17:21 +02:00
df0e28fe43 Add missing Vector2::operator Vector2i() 2022-02-07 01:23:18 -08:00
3d237fc7d7 Fixed crash when called methods return nullptr.
The returned value "ret" may be nullptr in which case the code would crash because "object_get_instance_binding" can't be called on nullptr input.

This should be very easy to reproduce, I encountered it pretty much any time I called a method that returned Ref<Something>. E.g.:

Ref<GeometryInstance3D> instance;
instance.instantiate();
instance.get_mesh();    // Crash because no mesh was set for the instance and the returned value was nullptr.
2022-01-31 17:12:45 -08:00
836cc4d3dc Fix for pointer indirection in the Ref<T> template.
Patch by Nana Sakisaka (saki7).
2022-01-07 09:20:05 +01:00
cfd3fa97d1 Merge pull request #668 from groud/fix_extension_instance_set 2022-01-06 17:44:29 +01:00
5fa9b765dc Fixed pointer indirection in the PtrToArg template for Object arguments. 2022-01-02 17:10:32 +01:00
76c4adb7f8 Normalized additional macros to ensure that everything works without client code needing using 2021-12-18 15:16:14 -08:00
37938a1761 Fix namespace to be consistent with the previous ADD functions 2021-12-12 18:23:33 -08:00
adbbf1a3a1 Fix object_set_instance being wrongly called for built-in wrapped classes 2021-12-06 15:40:19 +01:00
3fcb8a4d1e Make extension instances create the corresponding godot object in their constructor 2021-12-03 15:37:49 +01:00
94efe3d410 Fixing compiler warnings around implicit type casting loosing precision 2021-11-22 21:48:20 +11:00
957f86c3e3 Add Array:make macro 2021-11-02 00:20:19 +11:00
ef528d3a86 Rename interface to gdn_interface because it's a defined keyword under windows 2021-10-28 19:44:20 +11:00
6a720e5c7c Merge pull request #631 from Faless/ext/ref_casting_2 2021-09-28 16:14:45 +02:00
b90d0ac555 Add Ref<T> binding support.
Added PtrToArg and GetTypeInfo adapted from Godot.
2021-09-28 15:49:08 +02:00
80fdb9146f Add pointers support for virtual methods.
As introduced in godot for virtual methods.
Custom structs are not yet supported.
2021-09-27 16:13:24 +02:00
0e3bc393d5 Fully register class on register_class call 2021-09-27 23:08:12 +10:00