Commit Graph

58 Commits

Author SHA1 Message Date
506600a560 Rename GDExtensionCompatHashes to make it clear it's only for exceptional situations 2024-12-19 18:08:42 -06:00
ffd4de67d0 Add variant_get_ptr_internal_getter to gdextension_interface.h. The function returns functions to retrieve a pointer to a Variant's internal value. This enables GDExtensions to implement functionality similar to VariantGetInternalPtr, to access Variant internal values directly. 2024-11-26 02:19:03 +01:00
38f9769bc6 [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
af6d260c17 Don't include core/io/image.h in core/os/os.h
`core/os/os.h` doesn't use `core/io/image.h`. It just brings
transitive dependencies. Lots of dependencies because `core/os/os.h`
is transitively included in almost every file of godot

Also added `core/io/image.h` into files^1 where `Ref<Image>` and `core/os/os.h`
were used to prevent obscure errors involving `Ref<Image>`

^1 except those which include `core/io/image_loader.h` or `core/io/image.h` by
corresponding .h file with the same name

Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-10-18 19:04:19 +03:00
971e154588 GDExtension: Allow directly getting ObjectID from Variant 2024-09-17 11:58:55 -05:00
9853a69144 Implement typed dictionaries 2024-09-04 10:27:26 -05:00
49bcdf78a7 Core: Сheck r_error after calling callp() 2024-08-30 21:09:30 +03:00
3d575801ce Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
e651421905 [TextServer, GDExtension] Fix building text servers as GDExtension, expose new/changed low-level methods to GDExtension API. 2024-06-12 19:30:19 +03:00
f9b488508c Add PackedVector4Array Variant type
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2024-05-03 00:58:27 +02:00
0c19d0f5a0 Add extension support for argument count to ScriptInstance 2024-03-13 22:40:09 +01:00
59bcc2888c Add methods to get argument count of methods
Added to:
* `Callable`s
* `Object`s
* `ClassDB`
* `Script(Instance)`s
2024-03-10 11:02:43 +01:00
50ca190286 Merge pull request #89055 from dsnopek/gdextension-script-free-lists
GDExtension: Pass count when freeing method and property lists for script instances
2024-03-04 13:33:45 +01:00
0badf07657 GDExtension: Pass count when freeing method and property lists for script instances 2024-03-02 10:13:37 -06:00
3a08c646ee Pre-commit: Update to clang-format 17.0.6 and black 24.2.0 2024-02-28 14:25:35 +01:00
ea75307a11 Allow registering "runtime classes" 2024-02-20 09:20:58 -06:00
be11002e41 Allow GDExtensions to register virtual methods and call them on scripts 2024-02-12 13:29:18 -06:00
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
b0a33cac7c GDExtension: Use ObjectID when creating custom callable 2023-10-23 09:05:17 -05:00
b14f359c94 GDExtension: Fix variant_iter_get() actually calling iter_next() 2023-10-20 10:07:46 -05:00
0a246e9b54 expose Object::free_instance_binding to GDExtension 2023-10-04 19:24:37 +02:00
531f56e830 add GDExtensionScriptInstanceGetClassCategory
Change GetClassCategory so it is handled in native directly
2023-09-27 17:45:48 +02:00
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
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
c770937db5 More precise documentation for GDExtension String constructors (bytes vs. character count) 2023-09-24 20:57:58 +02:00
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
0967fe6217 GDExtension: Remove redundant method bind hash check 2023-09-23 08:48:33 -05:00
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
0d13727c97 Fix method hashes with default arguments 2023-09-21 12:39:04 -05:00
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
893f889d74 [Core] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-11 19:45:49 +02:00
3e7a6e058a Allow implementing ScriptInstance::validate_property() from GDExtension 2023-09-04 13:55:48 -05:00
83faf84ec9 GDExtension: Allocate GDExtensionScriptInstanceInfo2 for compatibility on the heap to prevent crash 2023-08-31 15:19:31 -05:00
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
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
4b5da7e0ac Expose PlaceHolderScriptInstance to GDExtension
Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-28 17:43:45 -04:00
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
e87900970c Allow resizing String's from GDExtension 2023-07-26 21:31:37 -05:00
ef9cb793d3 Remove GDExtension compatibility code for Godot 4.0 2023-06-07 13:01:42 -05:00
699b66b62d Merge pull request #77010 from dsnopek/gdextension-editor-plugins
Allow GDExtensions to add editor plugins
2023-05-26 11:00:32 +02:00
3007163210 Allow GDExtensions to add editor plugins 2023-05-25 09:14:29 -05:00
c6b0d4aae3 Add GDExtension function to get Object class name 2023-05-22 06:58:59 -05:00
9b9482d4bb Rework GDExtension interface from a struct to loading function pointers 2023-05-16 10:27:46 -05:00
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
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
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
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
45e6abde1d GDExtension: array_set_typed() accepts enum instead of uint32_t 2023-02-08 23:24:56 +01:00
d8d5cb1198 Use GDExtensionBool in GDExtension interface 2023-02-08 14:57:07 +08:00
99dba702f5 Expose _err_print_error with message parameter to GDExtension 2023-02-07 14:02:18 +01:00