Commit graph

150 commits

Author SHA1 Message Date
Jan Haller
9ddd3c2af6 GDExtension @since attribute
All GDExtension function pointer types are versioned using a `@since` attribute, denoting the Godot minor version in
which they were introduced. This allows bindings to query if a feature is available for a target API version, or provide
a polyfill/fallback for it. It also serves as documentation for humans giving a feeling about recency of features.
2023-06-21 12:47:48 +02:00
Jan Haller
618507eb89 GDExtension: Uninitialized*Ptr for constructors/converters using placement new
These methods construct their destination in-place, but the parameters are not declared using the `Uninitialized*Ptr` pointer types.
2023-06-18 23:14:10 +02:00
David Snopek
ef9cb793d3 Remove GDExtension compatibility code for Godot 4.0 2023-06-07 13:01:42 -05:00
Yuri Sizov
a12327e277
Merge pull request #77445 from RedworkDE/gdextension-compat-update-validation
Update extension API validation
2023-05-27 17:23:26 +02:00
Rémi Verschelde
699b66b62d
Merge pull request #77010 from dsnopek/gdextension-editor-plugins
Allow GDExtensions to add editor plugins
2023-05-26 11:00:32 +02:00
David Snopek
3007163210 Allow GDExtensions to add editor plugins 2023-05-25 09:14:29 -05:00
RedworkDE
bbe04e1ec8 Update extension api validation
- Ensure that multiple changes to one method cannot hide each other in the CI.
- Check virtual methods for changes.
- Compare the detailed changes to a method.
- Compare enums.
- Fix comparing global enums.
- Use `vformat` to build error messages.
2023-05-24 18:51:33 +02:00
Rémi Verschelde
80bf8fd186
Merge pull request #73511 from dsnopek/gdextension-object-name
Add GDExtension function to get Object class name
2023-05-22 14:02:59 +02:00
David Snopek
c6b0d4aae3 Add GDExtension function to get Object class name 2023-05-22 06:58:59 -05:00
RedworkDE
402b3d146a Bind forgotten default value for GDExtension::open_library argument 2023-05-22 00:14:55 +02:00
RedworkDE
110bc5058d Compress embedded GDExtension interface 2023-05-16 22:16:45 +02:00
David Snopek
9b9482d4bb Rework GDExtension interface from a struct to loading function pointers 2023-05-16 10:27:46 -05:00
Emmanuel Leblond
e785dd9dd9
Improve user-friendliness of "return value as function param" pattern in GDExtension API
This commit introduce separate types (e.g. GDNativeStringPtr vs GDNativeUninitializedStringPtr)
depending on if the pointed data is already initialized (C++ style where constructor is alway
called when create a variable even if it is to be passed as return value) or not (C style).
On top of that, small changes has been made to `GDNativeInterface` so that it methods are
consistent on using uninitialized return value.
2023-05-15 17:14:57 +02:00
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