Commit Graph

279 Commits

Author SHA1 Message Date
Rémi Verschelde dc41f2504b
Merge pull request #88417 from dsnopek/gdextension-compatibility-maximum
Allow GDExtensions to set a `compatibility_maximum`
2024-02-19 00:08:14 +01:00
David Snopek 99fd6ca98c Unbind GDExtension methods that can't reasonably be used 2024-02-16 16:31:09 -06:00
David Snopek 2afa3557b4 Allow GDExtensions to set a compatibility_maximum 2024-02-16 16:02:55 -06:00
Muller-Castro a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
Rémi Verschelde fd43a7f3be
Merge pull request #88188 from dsnopek/gdextension-api-double-compatibility-hashes
Fix `gdextension_compat_hashes.cpp` for double precision builds
2024-02-12 23:29:41 +01:00
Rémi Verschelde 306dd5be3f
Merge pull request #87758 from dsnopek/gdextension-register-virtual-method
Allow GDExtensions to register virtual methods and call them on scripts
2024-02-12 23:29:37 +01:00
David Snopek be11002e41 Allow GDExtensions to register virtual methods and call them on scripts 2024-02-12 13:29:18 -06:00
David Snopek 445e3018f5 Fix `gdextension_compat_hashes.cpp` for double precision builds 2024-02-10 19:05:33 -06:00
Mikhail Tishin dc4c6cfb9b Add null check for gdextension deinitialization 2024-02-04 18:38:59 +03:00
Riteo f468e59efd GDExtension: add an interface for loading extra documentation
Adds two new GDExtension interface methods:
 - `editor_help_load_xml_from_utf8_chars`
 - `editor_help_load_xml_from_utf8_chars_and_len`

Both of these methods parse the XML passed into an extra documentation
container which, when needed, is merged into the main doc container.

Co-Authored-By: Rémi Verschelde <rverschelde@gmail.com>
2024-01-26 13:53:33 +01:00
Muller-Castro 96a95cb974 Add const lvalue ref to container parameters 2024-01-05 14:49:57 -03:00
Daylily-Zeleen fe6b073811 Distinguishs between dynamic library not found and can't be opened. 2024-01-01 20:01:57 +08:00
Ricardo Buring 82afe58aca Fix operator documentation in GDExtension API dump with docs
The type of the right operand is now taken into account.
2023-12-12 18:55:31 +01:00
David Snopek 5cf6d08dda Check that GDExtensionCompatHashes are valid when generating extension_api.json 2023-11-16 06:40:06 -06:00
Rémi Verschelde dfe2df989d
Merge pull request #84493 from bruvzg/gde_ios_static_fix
[iOS, GDExtension] Fix loading and exporting static libraries and xcframeworks.
2023-11-10 10:44:56 +01:00
bruvzg d4d5d68eda
[iOS, GDExtension] Fix loading and exporting static libraries and xcframeworks. 2023-11-09 20:04:40 +02:00
David Snopek 09fcc3a1ad Change `GDExtension`'s `library_path` back to an absolute path 2023-11-09 11:24:57 -06:00
David Snopek f86054e3a0 GDExtension: Save and compare modification times separately for reload 2023-11-02 08:29:22 -05:00
Rémi Verschelde f7c43a8a19
Merge pull request #83800 from dsnopek/gdextension-callable-custom-object-id
GDExtension: Use `ObjectID` when creating custom callable
2023-10-25 10:29:58 +02:00
David Snopek b0a33cac7c GDExtension: Use ObjectID when creating custom callable 2023-10-23 09:05:17 -05:00
Mario Liebisch f2bcd7d61f
GDExtension: Fixed error on loading extensions
Previously, before loading an extension, the editor just tried to
retrieve the extension by path to test if it's been loaded already.

While this is handled gracefully, it ignored an error thrown inside
`GDExtensionManager::get_extension()`, that would essentially still
report a not yet loaded extension to the engine's log:

```
ERROR: Condition "!E" is true. Returning: Ref<GDExtension>()
   at: GDExtensionManager::get_extension (core\extension\gdextension_manager.cpp:165)
```

This change actively checks whether the extension path is known and only
then proceeds to actually return the already loaded extension or loads
and returns the new one otherwise.
2023-10-21 17:00:18 +02:00
David Snopek b14f359c94 GDExtension: Fix `variant_iter_get()` actually calling `iter_next()` 2023-10-20 10:07:46 -05:00
Yuri Sizov 582ed157b5 Fix StringName leaks in GDExtension, core, and editor themes 2023-10-18 17:36:20 +02:00
Emmanuel Leblond fd33c7b32f
Merge pull request #83415 from touilleMan/fix-comment-gdextension_interface
Fix comment in `gdextension_interface.h`
2023-10-16 21:42:01 +02:00
Emmanuel Leblond 5aa9f1ce64
Fix comment in gdextension_interface.h 2023-10-16 21:40:45 +02:00
Rémi Verschelde eb9903b4ce
Merge pull request #83285 from dsnopek/gdextension-double-reload
GDExtension: Prevent issues with the editor trying to reload GDExtensions through its usual mechanism
2023-10-16 18:44:51 +02:00
Ricardo Buring c87b2a606e Add brief description in GDExtension API dump with docs
Also rename the "documentation" key to "description" for internal
consistency.
2023-10-14 12:06:37 +02:00
David Snopek 16a86b9604 GDExtension: Prevent issues with the editor trying to reload GDExtensions through its usual mechanism 2023-10-13 13:24:29 -05:00
Rémi Verschelde b40d90d333
Merge pull request #83107 from dsnopek/validated-method-vararg-message
GDExtension: Fix incorrect error message about vararg methods
2023-10-10 22:51:41 +02:00
David Snopek 87cb0bfa50 GDExtension: Fix incorrect error message about vararg methods 2023-10-10 08:46:25 -05:00
David Snopek 88b6fee547 GDExtension: Use correct return pointer for validated calls that return `Variant` 2023-10-10 08:31:08 -05:00
A Thousand Ships f18aa00e85 Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-10-08 17:23:33 +02:00
Rémi Verschelde a6a2d0d159
Merge pull request #82794 from dsnopek/gdextension-validated-call
GDExtension: Convert `validated_call()` to `ptrcall()` (rather than `call()`)
2023-10-06 16:50:57 +02:00
Rémi Verschelde 7c56631419
Merge pull request #82861 from mihe/gdext-entry-false
Fix extensions loading/initializing even when entry point fails
2023-10-05 22:50:35 +02:00
Mikael Hermansson 5c6353ae17 Fix extensions loading/initializing even when entry point fails 2023-10-05 18:24:58 +02:00
Yuri Sizov d427851013 Resolve relative icon paths for GDExtensions 2023-10-05 12:49:31 +02:00
Ced Naru 0a246e9b54 expose Object::free_instance_binding to GDExtension 2023-10-04 19:24:37 +02:00
David Snopek 55596eaac6 GDExtension: Convert `validated_call()` to `ptrcall()` (rather than `call()`) 2023-10-04 10:53:17 -05:00
Rémi Verschelde dbd4c79c38
Merge pull request #82682 from dsnopek/gdextension-dont-deprecate-script-category
GDExtension: Don't deprecate old method of getting script category
2023-10-03 17:26:41 +02:00
David Snopek cbf939e121 GDExtension: Don't deprecate old method of getting script category 2023-10-02 09:23:27 -05:00
kkolyan 43f92e4752 Fix inconsistent last_modified_time handling (prevent GDExtension reload spam on Windows 10) 2023-10-01 22:05:57 +04:00
Yuri Sizov 5f53ec9129 Merge pull request #78995 from Gallilus/master
Allow implementing `get_class_category` in GDExtension
2023-09-27 19:07:50 +02:00
David Cambré 531f56e830 add GDExtensionScriptInstanceGetClassCategory
Change GetClassCategory so it is handled in native directly
2023-09-27 17:45:48 +02:00
Rémi Verschelde 251fb83d53
Merge pull request #82331 from rburing/gdextension_dump_docs
Optionally include documentation in GDExtension API dump
2023-09-26 22:46:34 +02:00
Ricardo Buring 8ee04c5f87 Optionally include documentation in GDExtension API dump 2023-09-26 21:39:24 +02:00
David Snopek 2733a6f762 Implement reloading of GDExtensions 2023-09-25 22:10:17 -05:00
Rémi Verschelde d8c31155a8
Merge pull request #82191 from dsnopek/gdextension-redundant-hash-check
GDExtension: Remove redundant method bind hash check
2023-09-24 23:35:45 +02:00
Rémi Verschelde 40b48b13ee
Merge pull request #78580 from Bromeon/feature/gdextension-stringname-ctor
Add GDExtension function to construct StringName directly from char*
2023-09-24 23:30:04 +02:00
Jan Haller c770937db5 More precise documentation for GDExtension String constructors (bytes vs. character count) 2023-09-24 20:57:58 +02:00
Jan Haller ed3015e979 GDExtension: construct StringName directly from char*
So far, an indirection via String was necessary, causing at least 2 allocations and copies (String; String inside StringName).
Since StringNames often refer to string literals, this allows them to be directly constructed from C strings.

There are two formats: Latin-1 and UTF-8.

The Latin-1 constructor also provides the `p_is_static` flag: when the source has static storage duration, no copy/allocation will be needed.
However, the extension developer needs to uphold this lifetime guarantee.
2023-09-24 18:18:05 +02:00
David Snopek 0967fe6217 GDExtension: Remove redundant method bind hash check 2023-09-23 08:48:33 -05:00
Rémi Verschelde 6fc1d50db3
Merge pull request #81521 from dsnopek/method-bind-default-argument-hash-fix
Fix method hashes with default arguments
2023-09-22 22:03:30 +02:00
David Snopek 0d13727c97 Fix method hashes with default arguments 2023-09-21 12:39:04 -05:00
Jeff Ward 60851af4da Add functions for non-ptr style virtual calls in GDExtension
This adds two functions to `GDExtensionClassCreationInfo` that allow for developers to supply a generic virtual call function along with user data to be sent to that call.

If `get_virutal_call_data_func` is not null, extensions call this function to get user data to pass to a supplied `call_virtual_with_data_func`. Both must be provided is one is provided.

If `get_virtual_call_data_func` is null, Godot falls back to the old `get_virtual_func` logic.

Fixes #63275

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-09-19 22:33:32 -04:00
Rémi Verschelde 8dfc3f1864
Merge pull request #79005 from maiself/gde-custom-callable
Allow CallableCustom objects to be created from GDExtensions (extended)
2023-09-19 09:02:49 +02:00
David Snopek 6554ccf86d GDExtension: Delete left-over DLL copy before making a new copy 2023-09-12 09:57:40 -05:00
A Thousand Ships 893f889d74 [Core] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-09-11 19:45:49 +02:00
Rémi Verschelde 43c7e8d3b5
Merge pull request #81515 from dsnopek/gdextension-validate-property-object
Allow implementing `Object::_validate_property()` from GDExtension
2023-09-11 15:40:05 +02:00
Rémi Verschelde 786dab42fd
Merge pull request #70329 from Daylily-Zeleen/daylily-zeleen/register_internal_class
Allow GDExtension to register unexposed classes.
2023-09-11 15:35:31 +02:00
David Snopek abef8e3874 Allow implementing `Object::_validate_property()` from GDExtension 2023-09-10 11:17:59 -05:00
Rémi Verschelde d1c94eef06
Merge pull request #81261 from dsnopek/gdextension-validate-property
Allow implementing `ScriptInstance::validate_property()` from GDExtension
2023-09-07 13:51:44 +02:00
David Snopek 3e7a6e058a Allow implementing `ScriptInstance::validate_property()` from GDExtension 2023-09-04 13:55:48 -05:00
Daylily-Zeleen 41ffe5461f Allow GDExtension to register unexposed class. 2023-09-04 10:18:20 +08:00
Fredia Huya-Kouadio 8cc7739197 Godot Android plugin re-architecture 2023-09-03 17:04:10 -07:00
Jan Haller 4e202bcec7 GDExtension: fix `bool` unknown in C 2023-09-02 21:04:49 +02:00
David Snopek 83faf84ec9 GDExtension: Allocate `GDExtensionScriptInstanceInfo2` for compatibility on the heap to prevent crash 2023-08-31 15:19:31 -05:00
Mai Lavelle e0ee985f64 Allow CallableCustom objects to be created from GDExtensions
Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-31 12:36:25 -04:00
Rémi Verschelde 8edc0b43b9
Merge pull request #78634 from Sauermann/fix-notification-order
Fix `Object::notification` order
2023-08-30 08:44:36 +02:00
Markus Sauermann c4705a590b Fix Object::notification order
Previously the `p_reversed` parameter didn't influence the order
in a correct way.
Also script overridden _notification functions were not called in
the correct order.

To fix this some `notification` functions had to add a `p_reversed`
parameter.

This made it necessary to adjust cpp-bindings.

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-30 00:15:55 +02:00
David Snopek 39a604c9ab Exclude unexposed classes from the extension_api.json 2023-08-29 08:45:58 -05:00
Mai Lavelle 4b5da7e0ac Expose PlaceHolderScriptInstance to GDExtension
Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-28 17:43:45 -04:00
David Snopek 908b8c0507 GDExtension: Remove DLL copy if it fails to load 2023-08-17 13:23:31 -05:00
Rémi Verschelde 1e3b1a7137
Merge pull request #80188 from vnen/gdextension-copy-dll
GDExtension: Copy DLL to a temp file before opening
2023-08-16 16:55:19 +02:00
Ninni Pipping 97ef4a0536 Fix version check for GDExtension 2023-08-15 10:10:04 +02:00
George Marques cff69b0612
GDExtension: Copy DLL to a temp file before opening
This is done only in the editor and only on Windows, to avoid a file
lock that prevents the original library being updated (e.g. by a
compiler).

When the game runs it will load the original DLL and pick up any
changes, only the editor will stay with the copy (until it is restarted
and create a new copy).

The copy is done in place by prepending a `~` to the original file name,
so dependencies that are loaded with a relative file path still work.
When the library is unloaded the copy file is deleted. The copy is also
marked as hidden to not show up in explorer.
2023-08-11 10:44:23 -03:00
Jeff Ward efc8fd6e2c Add get_script_instance to GDExtension
Adds a method to GDExtension to get the ScriptInstanceExtension for an object.
2023-08-07 23:09:24 -04:00
Yuri Sizov 6bfda7f5c5 Merge pull request #79156 from dsnopek/gdextension-string-resize
Allow resizing Strings from GDExtension
2023-07-27 15:22:32 +02:00
David Snopek e87900970c Allow resizing String's from GDExtension 2023-07-26 21:31:37 -05:00
Mikael Hermansson 2173821b38 Add support for indexed properties in GDExtension 2023-07-21 22:59:24 +02:00
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