Commit Graph

173 Commits (53b546e1df6c732a6a59ddf0ded5eb4249664eb8)

Author SHA1 Message Date
Daylily-Zeleen 2d1f852baf Implement register unexposed class. 2023-09-04 00:59:10 +08:00
Markus Sauermann c2d99fd519 Fix `Object::notification` order
For the notification-order to work correctly, it is necessary to
allow the `p_reversed` argument to be used within cpp.
This PR changes the necessary bindings.
2023-08-30 00:07:28 +02:00
David Snopek 3cd3f24150 Ensure that PtrToArg specializations for native structs are used 2023-08-15 17:54:11 -05:00
David Snopek 6f913563d8 Add static methods to `ClassDB` for the methods bound to the `ClassDB` singleton 2023-07-31 16:04:27 -05:00
David Snopek 1d49bef096
Merge pull request #1184 from Zylann/fix_get_property_list_calling_parent
Don't call parent _get_property_list when a class doesn't define it (for internal binding).
2023-07-26 15:31:15 -05:00
Marc Gilleron baf0b9e0f7 Don't call parent _get_property_list when a class doesn't define it.
Godot is already supposed to call _get_property_list of parent classes,
so this binding function must really only return procedural properties of
the class it belongs to, and not parent or child classes.
2023-07-26 20:12:25 +01:00
Mikael Hermansson 7d8cb7c155 Add support for indexed properties 2023-07-26 00:31:53 +02:00
Kehom 20be441026 Unregister custom classes in reverse registration order 2023-06-19 11:04:11 -03:00
Andy Maloney db2394dbe7 Identifiers containing double underscore are reserved according to the C++ standard
Rename __* to _gde_*

https://timsong-cpp.github.io/cppwp/n3337/global.names

https://en.cppreference.com/w/cpp/language/identifiers

Identifiers appearing as a token or preprocessing token (i.e., not in user-defined-string-literal like operator ""id) (since C++11) of one of the following forms are reserved:
 - identifiers with a double underscore anywhere;
 - identifiers that begin with an underscore followed by an uppercase letter;
 - in the global namespace, identifiers that begin with an underscore.
2023-06-15 20:45:01 -04:00
David Snopek ad726015e7 Revert the changes from PR #1044 and #1045 and standardize on `Object **` encoding in ptrcall 2023-06-07 08:30:33 -05:00
David Snopek 431e30bc32 Ensure GDExtension class is the correct type for the Godot engine class 2023-05-16 15:18:48 -05:00
David Snopek a5c6ca5920 Update to load function pointers for GDExtension interface 2023-05-09 21:45:48 -05:00
Rémi Verschelde e9942db502
Merge pull request #1044 from zhehangd/fix_obj_ptr_crash
Fix crash using Object* as parameter
2023-04-01 11:36:17 +02:00
Zhehang Ding 093f0673f5 Fix PtrToArg<Object*> crash 2023-03-30 19:38:12 -07:00
bruvzg ba4b50118d
Fix incorrect memory allocation in release builds.
Co-authored-by: lightyears <lightyears1998@hotmail.com>
2023-02-21 15:32:26 +02:00
David Snopek 964c515d75 Revert "Fix Object::cast_to<T>() for custom classes"
This reverts commit 75af9003dc.
2023-02-16 06:58:32 -06:00
David Snopek 75af9003dc Fix Object::cast_to<T>() for custom classes 2023-02-11 17:16:59 -06:00
Rémi Verschelde fccceb8736
Merge pull request #1011 from mihe/error-macros
Update error macros to match core
2023-02-07 13:47:51 +01:00
Rémi Verschelde c1d4fb2b68
Merge pull request #1023 from mashumafi/fix-alloc-order
Move DefaultTypedAllocator after memdelete
2023-01-30 12:32:07 +01:00
Rémi Verschelde 2ef10f9754
Merge pull request #956 from DmitriySalnikov/enum_bitfield_cast
Fixed `VARIANT_ENUM/BITFIELD_CAST` to show the correct names
2023-01-30 12:07:15 +01:00
mashumafi a8be6aa8dd Move allocator to after memdelete 2023-01-29 23:29:31 -05:00
George Marques 64be8c1507
Use std type traits instead of intrinsics
This removes warnings and mimics what has been done in Godot itself.
2023-01-28 13:59:34 -03:00
Mikael Hermansson d174b47e51 Update error macros to match core 2023-01-22 14:24:57 +01:00
Rémi Verschelde 00b29630ba
Merge pull request #1003 from akien-mga/fix-sign-0
Change behavior of Math::sign to match Godot builtin
2023-01-20 23:02:13 +01:00
Дмитрий Сальников 6528c7177f Fixed variant casting for enum and bitfield 2023-01-20 21:10:03 +03:00
Andy Maloney e6b636cc51 Fix sign comparison warnings in method_bind.hpp
Part of #999
2023-01-19 08:26:02 -05:00
bruvzg abca497b72
Expose some low level functions and String operators. 2023-01-19 13:12:21 +02:00
Erik Abair d3f17c1dca
Change behavior of Math::sign to match Godot builtin
Fixes #551.
2023-01-19 09:47:13 +01:00
Дмитрий Сальников 0c6e26dabe Added property info for ptr and ref + ported the implementation of the `check` method 2023-01-13 15:56:51 +03:00
Rémi Verschelde 931f1a3f34
Sync license copyright with upstream GH-70885 2023-01-10 16:15:31 +01:00
Fabio Alessandrelli 9fd33b5cde Allow method binds to take Object subclasses as arguments
As done in upstream Godot via GH-57205.

Add a test that ensures it works also for "gdextended" objects.
2023-01-10 12:55:41 +01:00
Jan Haller fce753c05d Extension header: amend const correctness of `p_args` parameters 2022-12-14 15:47:42 +01:00
Rémi Verschelde bab247dcb6
Rename godot-headers to gdextension, move header to top folder
Changes the `<godot/gdextension_interface.h>` include to simply
`<gdextension_interface.h>`.

Refactor and better document the SCons and CMake logic around setting
the paths to the header and API JSON file.
2022-12-14 12:36:59 +01:00
Дмитрий Сальников b7eeddcf52 Use int64_t for BitField as in Godot itself 2022-12-13 13:36:16 +03:00
Gilles Roudière c02e644679 Rename GDNative to GDExtension
Non-exhaustive list of case-sensitive renames:

GDExtension -> GDNative
GDNATIVE -> GDEXTENSION
gdextension -> gdnative
ExtensionExtension -> Extension (for where there was GDNativeExtension)
EXTENSION_EXTENSION -> EXTENSION (for where there was GDNATIVE_EXTENSION)
gdnlib -> gdextension
gdn_interface -> gde_interface
gdni -> gde_interface
2022-12-12 11:06:38 +01:00
Emmanuel Leblond fe79449969
Fix cast on PtrToArg::convert 2022-12-05 03:30:50 +01:00
Emmanuel Leblond fe86a94dcf
Fix const qualifier for parameters in GDExtension api functions 2022-12-03 00:27:07 +01:00
Andy Maloney c7e34c2f9d Basic static analysis fixes
- remove extraneous semicolons
- use "nullptr" instead of "0"
- remove "break" after "return"
- use <cstdio> instead of <stdio.h>
2022-11-18 17:46:13 -05:00
Emmanuel Leblond b6ba0dca13
StringName is working fine with demo \o/ 2022-11-08 21:44:33 +01:00
Emmanuel Leblond d1963dc133
Correct __constant_get_bitfield_name with StringName 2022-11-08 21:44:32 +01:00
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
Fabio Alessandrelli a9c341656d Add missing bindings for GDNativePtr<void>. 2022-10-20 18:08:15 +02:00
Ricardo Buring 01960ffc9f Add support for virtual and abstract classes 2022-10-15 13:15:05 +02: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
Rémi Verschelde db8679443f Merge pull request #885 from aaronfranke/core-data-structs
Update core data structures to match the engine
2022-10-07 22:25:54 +02:00
Rémi Verschelde 0eba81ef79 Merge pull request #876 from Daylily-Zeleen/Daylily-Zeleen/master
Add detail infos for binding error message.
2022-10-07 22:25:49 +02:00
Aaron Franke 65eeb94f75
Update core data structures to match the engine 2022-10-07 11:27:41 -05:00
Mikael Hermansson 40d181d2f3 Bind enums in built-in types and expose bindings for global constants 2022-10-06 11:16:17 +02:00
Rémi Verschelde 50a534bf55 Merge pull request #880 from aaronfranke/struct
Use `struct` instead of `class` for core structures
2022-10-05 10:35:59 +02:00
Rémi Verschelde 91afc08de1 Merge pull request #855 from Zylann/fix_issue854_virtual_methods
Fix deriving a custom class with virtual methods
2022-10-05 10:35:54 +02:00
Aaron Franke 0455f72ede
Use struct instead of class for core structures 2022-10-05 01:46:15 -05:00
Rémi Verschelde d25cae9b61 Merge pull request #859 from aaronfranke/basis-transform-quat
Update Basis/Transform3D/Quaternion to match the engine
2022-10-04 16:39:46 +02:00
daylilyzeleen 3e91ec1729 Add detail infos for binding error message. 2022-09-30 15:16:43 +08:00
bruvzg c001d0e5c7
Implement support for typed arrays. 2022-09-23 09:02:00 +03:00
Marc Gilleron 5de2c059d1 Fix deriving a custom class with virtual methods 2022-09-21 19:31:30 +01:00
Aaron Franke e83d472c00
Update Basis/Transform3D/Quaternion to match the engine 2022-09-20 01:07:45 -05:00
Aaron Franke 7ba459ae7b
Add integer posmod and rename range_lerp to remap
https://github.com/godotengine/godot/pull/23310
https://github.com/godotengine/godot/pull/65361
2022-09-19 03:09:59 -05:00
Aaron Franke 9a2e8d907b
Add pingpong and fract methods to Math
https://github.com/godotengine/godot/pull/53819
2022-09-19 03:09:59 -05:00
Aaron Franke b11ff9d876
Replace stepify with snapped
https://github.com/godotengine/godot/pull/44586
2022-09-19 03:09:59 -05:00
Aaron Franke d20c4200db
Update cubic interpolation methods to match core
https://github.com/godotengine/godot/pull/64924
https://github.com/godotengine/godot/pull/63602
https://github.com/godotengine/godot/pull/62458
2022-09-19 03:09:38 -05:00
Aaron Franke 942cd466ed
Split is_equal_approx into float and double versions to match Godot
https://github.com/godotengine/godot/pull/48882
2022-09-19 02:47:27 -05:00
Marc Gilleron 99c004f689 Add `Object::cast_to` for `const Object*` 2022-09-18 22:23:49 +01:00
bruvzg 36273baa7e
Change PropertyInfo members to String. 2022-09-14 08:41:09 +03:00
Fabio Alessandrelli 43cdc2e037 Update hashfuncs, add some missing math funcs. 2022-09-11 13:11:52 +02: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
Yuri Sizov fa111d7078 Add support for `property_*_revert` methods 2022-08-18 16:43:01 +03: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
DNKpp 95574c1b11 fix: Object::cast_to checks provided object for nullptr 2022-07-26 00:41:57 +02:00
bruvzg 91c56a0ad1
Add bindings for Vector4, Vector4i, Projection built-in types. 2022-07-21 09:36:38 +03:00
Rémi Verschelde 8772a7faca
Merge pull request #686 from ondy-personal/patch-1 2022-07-18 15:48:17 +02:00
bruvzg 713b122b84
Add support for BitField hint, sync API files. 2022-07-11 15:00:17 +03:00
Alessandro Famà d894f48f25 Fix crash when using static methods without return value 2022-07-03 17:00:43 +02:00
Fabio Alessandrelli 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
bruvzg e3119e7d05
Sync containers with new HashMap/HashSet, sync API headers. 2022-06-06 12:18:07 +03:00
Teodor Potancok 5c32dc3948 Cast `Variant::Type` to `GDNativeVariantType` 2022-05-17 07:01:43 +02:00
bruvzg 031a83b0ea
[Method Bind] Add support for default argument values and static method binding. Sync headers. 2022-05-06 10:17:51 +03:00
bruvzg 057a771fda
Add support for variadic method binds with the typed return. Sync headers. 2022-03-30 15:11:28 +03:00
bruvzg 93de1b2b0b
Sync godot-headers and fix build after "Create GDExtension clases for PhysicsServer3D". 2022-03-16 20:33:06 +02:00
bruvzg 817efdd484
Fix build after "Discern between VIRTUAL and ABSTRACT class bindings". 2022-03-15 13:43:12 +02:00
Rémi Verschelde 1632322ce0 Update copyright year 2022-03-15 10:17:53 +01:00
bruvzg b1385953fe
Add `ObjectDB::get_instance` method to get wrapped `Object *` from `ObjectID`. 2022-03-08 10:17:33 +02:00
Melissa Geels d97dc518d3 Fixed crash on release builds due to missing argument type information 2022-03-02 14:44:23 +01:00
bruvzg e36180f377
Port a bunch of Godot container templates to GDExtension. 2022-02-18 21:07:53 +02:00
bruvzg 65dc3e89c7
Add ERR_ macros variants using `String` messages. 2022-02-17 10:18:04 +02:00
bruvzg a8cd21ac07
Fix "const" NativePtr binds. 2022-02-16 11:35:13 +02:00
ondy-personal 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
Lukas Tönne 5fa9b765dc Fixed pointer indirection in the PtrToArg template for Object arguments. 2022-01-02 17:10:32 +01:00
Bradley Clemetson 76c4adb7f8
Normalized additional macros to ensure that everything works without client code needing using 2021-12-18 15:16:14 -08:00
Bradley Clemetson 37938a1761
Fix namespace to be consistent with the previous ADD functions 2021-12-12 18:23:33 -08: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 94efe3d410 Fixing compiler warnings around implicit type casting loosing precision 2021-11-22 21:48:20 +11: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 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
Bastiaan Olij 0e3bc393d5 Fully register class on register_class call 2021-09-27 23:08:12 +10:00
Fabio Alessandrelli ea7324afe8 Fix encoding/decoding of null objects. 2021-09-27 23:08:12 +10:00
Fabio Alessandrelli 42dd64f22f Fix binding of function that takes Object * parameters. 2021-09-27 23:08:11 +10:00
Fabio Alessandrelli cc88df05e7 Fix PtrToArg encoding for `Object *`.
It didn't set the return value at all, changing the local value instead.
Now instead correctly sets it as a generic pointer type from `_owner`.
2021-09-27 23:08:11 +10:00