59 Commits

Author SHA1 Message Date
Klaim (Joël Lamotte)
d529fc5b69 removes warnings generated by GDCLASS usage
This change removes the warnings (unused parameters) coming from code injected by the GDCLASS macro.
Contrary to warnings coming from the normal source code which can be suppressed with most compiles by specifying the include directories of this library as external or system,
when the code is injected through a macro it is considered in the context of the user, which is the source code of user of the library.
That forces the users to modify their code to hide the warnings coming from the mandatory `GDCLASS` here.
That's why it's important to remove these warning from that specific macro and ideally any other macro that the user must use.

(cherry picked from commit 738859f49b)
2024-09-04 10:10:04 -05:00
Chris Cranford
9a4ba00b0e Make sure _get and _set dispatch up the class hierarchy
(cherry picked from commit c77d44f3f6)
2024-09-04 10:09:27 -05:00
David Snopek
7b93607779 Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent class
(cherry picked from commit 06373ce1cf)
2024-05-17 17:11:27 -05:00
Daylily-Zeleen
1ab42ec6c5 mark return value of get_class_static and get_parent_class_static as const
(cherry picked from commit 3db8549e19)
2024-05-17 16:58:32 -05:00
David Snopek
fff665e0f5 Give compile-time error if registering a class without its own _bind_methods() function
(cherry picked from commit ca46ef4d25)
2024-05-17 16:55:41 -05:00
Thaddeus Crews
9e48c45bfc Enforce template syntax typename over class
(cherry picked from commit 87f5fb0691)
2024-04-08 11:39:21 -05:00
David Snopek
f7a9d32f32 Fix _notification with parent and child classes
(cherry picked from commit 23c010900c)
2024-03-11 13:31:19 -05:00
Thaddeus Crews
805cdde0b7 GDCLASS synced by ending with "private:"
• Matches implementation used by modules and godot itself
• Apply same to GDEXTENSION_CLASS, setup with same diff-friendly spacers as GDCLASS

(cherry picked from commit 6eb5d450bd)
2023-11-13 13:00:24 -06:00
David Snopek
9d813310bb Add protections against registering classes that didn't use GDCLASS()
(cherry picked from commit a61cdc8860)
2023-10-23 10:11:04 -05:00
David Snopek
f7ffc4fe4d Automatically register only engine classes whose header has been included
(cherry picked from commit b507b3e591)
2023-10-22 14:46:26 -05:00
A Thousand Ships
205beacc5b Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable
(cherry picked from commit 1e5767693e)
2023-10-09 08:42:16 -05:00
David Snopek
bc82ae8b0b Add static methods to ClassDB for the methods bound to the ClassDB singleton
(cherry picked from commit 6f913563d8)
2023-09-19 21:30:03 -05:00
A Thousand Ships
014132d4c0 Ensure const correctness for wrappers
(cherry picked from commit f651df5e7a)
2023-09-19 21:21:20 -05: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
0d0d5a670b Merge pull request #1116 from saki7/Ref-allow-non-const-access
Change Ref<T> to allow non const access to ptr
2023-05-24 21:17:25 -05:00
Nana Sakisaka
48635729b9 Change Ref<T> to allow non const access to ptr 2023-05-17 19:24:09 +09: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
Zhehang Ding
517db6686a Fix PtrToArg<Ref<T>> crash 2023-02-15 22:36:29 -08:00
Rémi Verschelde
04731d2b78 Merge pull request #965 from WildRackoon/fix-GDCLASS-fwddeclaration
Fix GDCLASS needs explicit ClassDB fwd declaration
2023-01-19 13:55:14 +01:00
Andy Maloney
5dd2928790 "Wrapped" has virtual functions so it should have a virtual destructor.
Deleting an object through a pointer to a base class is undefined behaviour unless the destructor in the base class is virtual.
2023-01-19 05:57:17 -05: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
Rackoon
72d537fd95 Fix GDCLASS needs explicit ClassDB fwd declaration 2022-12-16 13:49:10 +01:00
Bastiaan Olij
992d85e6f8 Fix virtual GDExtension method Ref<T> conversion 2022-12-13 10:41:55 +11: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
fe86a94dcf Fix const qualifier for parameters in GDExtension api functions 2022-12-03 00:27:07 +01:00
Emmanuel Leblond
fa405a8337 Fix lifetime of StringName objects returned by Wrapped::_get_property_list 2022-11-29 18:23:56 +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
2745d341aa Fix broken namespace isolation in GDCLASS macro 2022-11-11 16:45:42 +01:00
Emmanuel Leblond
b6ba0dca13 StringName is working fine with demo \o/ 2022-11-08 21:44:33 +01:00
Emmanuel Leblond
3b82d5937b Correct GDNativeExtensionScriptInstanceToString 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
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