Commit Graph

55 Commits

Author SHA1 Message Date
Yevhen Babiichuk (DustDFG)
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
David Snopek
971e154588 GDExtension: Allow directly getting ObjectID from Variant 2024-09-17 11:58:55 -05:00
Thaddeus Crews
9853a69144
Implement typed dictionaries 2024-09-04 10:27:26 -05:00
Danil Alexeev
49bcdf78a7
Core: Сheck r_error after calling callp() 2024-08-30 21:09:30 +03:00
Daylily-Zeleen
3d575801ce Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
bruvzg
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
K. S. Ernest (iFire) Lee
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
A Thousand Ships
0c19d0f5a0
Add extension support for argument count to ScriptInstance 2024-03-13 22:40:09 +01:00
A Thousand Ships
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
Rémi Verschelde
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
David Snopek
0badf07657 GDExtension: Pass count when freeing method and property lists for script instances 2024-03-02 10:13:37 -06:00
Rémi Verschelde
3a08c646ee
Pre-commit: Update to clang-format 17.0.6 and black 24.2.0 2024-02-28 14:25:35 +01:00
David Snopek
ea75307a11 Allow registering "runtime classes" 2024-02-20 09:20:58 -06:00
David Snopek
be11002e41 Allow GDExtensions to register virtual methods and call them on scripts 2024-02-12 13:29:18 -06: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
David Snopek
b0a33cac7c GDExtension: Use ObjectID when creating custom callable 2023-10-23 09:05:17 -05:00
David Snopek
b14f359c94 GDExtension: Fix variant_iter_get() actually calling iter_next() 2023-10-20 10:07:46 -05:00
Ced Naru
0a246e9b54 expose Object::free_instance_binding to GDExtension 2023-10-04 19:24:37 +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
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
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
A Thousand Ships
893f889d74 [Core] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-11 19:45:49 +02:00
David Snopek
3e7a6e058a Allow implementing ScriptInstance::validate_property() from GDExtension 2023-09-04 13:55:48 -05: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
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
Mai Lavelle
4b5da7e0ac Expose PlaceHolderScriptInstance to GDExtension
Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-28 17:43:45 -04: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
David Snopek
e87900970c Allow resizing String's from GDExtension 2023-07-26 21:31:37 -05:00
David Snopek
ef9cb793d3 Remove GDExtension compatibility code for Godot 4.0 2023-06-07 13:01:42 -05: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
David Snopek
c6b0d4aae3 Add GDExtension function to get Object class name 2023-05-22 06:58:59 -05: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
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
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
Jan Haller
b8c4ae28b7 Fix use of bool in extension header 2023-01-19 22:21:19 +01:00