Commit graph

137 commits

Author SHA1 Message Date
Rémi Verschelde
70dcfdab1f
Merge pull request #76446 from reduz/add-gdextension-api-compatibility
Add a backwards-compatibility system for GDExtension
2023-05-15 13:43:46 +02:00
Juan Linietsky
d8078d3f4c Add a backwards-compatibility system for GDExtension method
This adds a way to ensure that methods that were modified in the Godot API will continue working in older builds of GDExtension even if the new signature is different.

```C++
// New version (changed)
ClassDB::bind_method(D_METHOD("add_sphere","radius","position"),&MyShapes::add_sphere);
// Compatibility version (still available to extensions).
ClassDB::bind_compatibility_method(D_METHOD("add_sphere","radius"),&MyShapes::_compat_add_sphere);
```

**Q**: If I add an extra argument and provide a default value (hence can still be called the same), do I still have to provide the compatibility version?
**A**: Yes, you must still provide a compatibility method. Most language bindings use the raw method pointer to do the call and process the default parameters in the binding language, hence if the actual method signature changes it will no longer work.

**Q**: If I removed a method, can I still bind a compatibility version even though the main method no longer exists?
**A**: Yes, for methods that were removed or renamed, compatibility versions can still be provided.

**Q**: Would it be possible to automate checking that methods were removed by mistake?
**A**: Yes, as part of a future PR, the idea is to add a a command line option to Godot that can be run like : `$ godot --test-api-compatibility older_api_dump.json`, which will also be integrated to the CI runs.
2023-05-15 12:05:40 +02:00
Emmanuel Leblond
7501ebb91a
Make *_operator_index in gdnative_interface not logging an error if called with an out-of-bound index 2023-05-13 20:01:55 +02:00
Juan Linietsky
1c93606e47 Add ValidatedCall to MethodBind
* This should optimize GDScript function calling _enormously_.
* It also should simplify the GDScript VM considerably.

NOTE: GDExtension calling performance has most likely been affected until going via ptrcall is fixed.
2023-04-30 20:01:26 +02:00
Yuri Sizov
ee2cc347c6 Add support for icons in GDExtension classes
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2023-03-31 21:39:02 +02:00
Haoyu Qiu
49400e0c1c Fix crash when dumping extension API in a non-writable directory 2023-03-08 15:05:44 +08:00
Jan Haller
45e6abde1d GDExtension: array_set_typed() accepts enum instead of uint32_t 2023-02-08 23:24:56 +01:00
Haoyu Qiu
d8d5cb1198 Use GDExtensionBool in GDExtension interface 2023-02-08 14:57:07 +08:00
Mikael Hermansson
99dba702f5
Expose _err_print_error with message parameter to GDExtension 2023-02-07 14:02:18 +01:00
Haoyu Qiu
f4ffa87a35 Remove unnecessary stdio.h from gdextension interface 2023-02-06 16:11:50 +08:00
Dmitrii Maganov
5909f9f075 GDScript: Fix issues with typed arrays 2023-01-31 11:54:41 +02:00
bruvzg
5aa87ccc03
Move Array:set_typed to internal GDExtension structure and unexposed it. 2023-01-30 14:23:31 +02:00
Raul Santos
cac7a784d6
Add GodotTypeInfo::Metadata to MethodInfo 2023-01-26 15:51:34 +01:00
Jan Haller
b8c4ae28b7 Fix use of bool in extension header 2023-01-19 22:21:19 +01:00
bruvzg
db7d8c2d87
[GDExtension] Expose some low level functions and String operators. 2023-01-19 12:50:49 +02:00
Emmanuel Leblond
38d9e8b366
Add missing is_bitfield field for global enum in extension_api_dump 2023-01-14 16:08:41 +01:00
Juan Linietsky
2b815df3c1 Use BitField<> in core type masks
* All core types masks are now correctly marked as bitfields.
* The enum hacks in MouseButtonMask and many other types are gone. This ensures that binders to other languages non C++ can actually implement type safe bitmasks.
* Most bitmask operations replaced by functions in BitField<>
* Key is still a problem because its enum and mask at the same time. While it kind of works in C++, this most likely can't be implemented safely in other languages and will have to be changed at some point. Mostly left as-is.
* Documentation and API dump updated to reflect bitfields in core types.
2023-01-08 22:17:40 +01:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Rémi Verschelde
418ec03a40
Merge pull request #65990 from touilleMan/gdextension-expose-builtins-members-real-types
Expose in builtins' members internal type & size (on top of offset) in extension_api.json
2022-12-19 16:26:05 +01:00
Emmanuel Leblond
2c2fd0820a
Expose in builtins' members internal type & size (on top of offset) in extension_api.json 2022-12-15 12:43:42 +01:00
Jan Haller
ebb3306da3 Extension header: amend const correctness of p_args parameters
A while ago, argument arrays were passed as const GDNativeTypePtr* (void* const*)
This was changed to GDNativeConstTypePtr* (void const**), adding const on the value but removing it on the pointer level.
This commit changes argument types to const GDExtensionConstTypePtr* (void const* const*).

Besides object pointers, the same change is applied to variant pointers.
2022-12-14 18:25:30 +01:00
Bastiaan Olij
7502e1dc0d Improve logic around using Ref<T> with GDExtension virtual functions 2022-12-13 10:54:29 +11:00
Gilles Roudière
be1c9d677d Rename all gdnative occurences 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:04:57 +01:00
Rémi Verschelde
83b426bca5
Merge pull request #67906 from groud/simpler_gdextension_config
Remove unnecessary checks when exporting gdextension binaries and allow using a prefix to auto-detect files
2022-12-06 11:01:09 +01:00
Emmanuel Leblond
61c900ac6f
Fix const qualifier for parameters in GDExtension api functions 2022-12-02 23:00:01 +01:00
Gilles Roudière
fa4143cdeb Allow specifying a prefix to automatically detect library files for gdextension exports 2022-12-01 18:20:40 +01:00
Rémi Verschelde
96796c1518
Merge pull request #64427 from touilleMan/gdextension-skip-undefined-field-in-properties
[GDExtension] Skip unset getter/setter/index fields in class property
2022-12-01 18:10:26 +01:00
Rémi Verschelde
fc2241d5d8
Merge pull request #64360 from touilleMan/gdextension-correct-rect2-members-offsets-declaration
[GDExtension] Correct Rect2 members offsets declaration in extension_api.json generator
2022-12-01 18:10:05 +01:00
Jan Haller
09f84102e3 Extension header: fix typos, documentation and member order 2022-11-16 00:51:48 +01:00
Emmanuel Leblond
a2e6e996b2
Skip unset getter/setter/index fields in class property when generating extension_api.json 2022-11-12 20:13:00 +01:00
Emmanuel Leblond
ce11ba2e30
Correct Rect2 members offsets declaration in extension_api.json generator 2022-11-12 20:12:04 +01:00
Emmanuel Leblond
39c039a363
Revert removal of GDNativeExtensionScriptInstanceInfo::get_property_type_func in GDExtension
This function pointer is needed to stay close to internal Godot's ScriptInstance class.
Besides, by removing this function pointer, we had to do property list create/free each time
we want to access type which is quadratic complexity :/
2022-11-12 04:18:21 +01:00
Emmanuel Leblond
1e8756c94b
Use StringName in the whole GDExtension API instead of const char * 2022-11-08 21:44:07 +01:00
Emmanuel Leblond
84262efd2a
Uses StringName in GDExtension perf critical instance creation & method/properties setter/getter 2022-11-08 21:44:07 +01:00
Rémi Verschelde
669888b9cf
GDExtension: Ensure newline at EOF 2022-11-07 14:32:43 +01:00
Rémi Verschelde
6946bc56ef
Merge pull request #67309 from groud/implement_gdnative_interface_h_dump
Implement a way to dump the gdnative_interface.h file from the executable
2022-10-31 11:54:38 +01:00
Ricardo Buring
1d5aa74ac3 GDExtension: add support for abstract and virtual classes 2022-10-16 09:02:49 +02:00
Rémi Verschelde
99bc4905cb Merge pull request #67138 from touilleMan/gdextension-typed-enum-in-struct
Use enum type in GDExtension info structs for better readability
2022-10-13 15:25:11 +02:00
Gilles Roudière
55010a2d9f Implement a way to dump the gdnative_interface.h file from the executable 2022-10-13 10:03:30 +02:00
Emmanuel Leblond
a9aedb0cf2 Fix extension_api.json Variant types incorrectly displayed as Nil 2022-10-10 13:54:33 +02:00
Emmanuel Leblond
aa76a905c7
Remove unused GDNativeExtensionClassObjectInstance type def from GDExtension 2022-10-10 01:15:07 +02:00
Emmanuel Leblond
1bd3597362
Use enum type in GDExtension info structs for better readability 2022-10-09 17:07:13 +02:00
bruvzg
ea1848ce0a
Use constexpr in the conditions with template parameters and sizeofs to suppress C4127 warnings. 2022-09-29 10:38:21 +03:00
bruvzg
8f5d56e04a
[GDExtension] Use function names with underscore for TextServer extension, add macros to generate wrappers for module functions. 2022-09-28 10:04:11 +03:00
Rémi Verschelde
006e345695
Merge pull request #65817 from bruvzg/typed_array 2022-09-23 10:24:46 +02:00
bruvzg
163257d51b
[GDExtension] Implement support for typed arrays. 2022-09-22 23:31:27 +03:00
Rémi Verschelde
d1a155e3cd Fix various -Wmaybe-uninitialized warnings from GCC 12.2.1
Not sure why I didn't get those before, it may be due to upstream
changes (12.2.1 is a moving target, it's basically 12.3-dev), or simply
rebuilding Godot from scratch with different options.
2022-09-22 11:29:48 +02:00
Rémi Verschelde
e9ad0fd190 Merge pull request #66181 from touilleMan/extension_api_dump-correct-keyed
Fix is_keyed param in extension_api.json
2022-09-21 11:06:20 +02:00
Emmanuel Leblond
2ee951cef5
Fix hash mismatch error print in gdextension's gdnative_classdb_get_method_bind 2022-09-21 00:41:48 +02:00
Emmanuel Leblond
b7c3bbc627
Fix is_keyed param in extension_api.json 2022-09-21 00:14:53 +02:00