1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00
Commit Graph

880 Commits

Author SHA1 Message Date
George Marques
28d3214acd Expose type validator from Dictionary and allow testing without error
- Now you can get the ContainerTypeValidate from a Dictionary (both for
  keys and for values).
- ContainerTypeValidate exposes a validator function that does not show
  any error in case of failure. This allows testing values before trying
  to use them in Dictionary.
2025-07-24 13:35:48 -03:00
Rémi Verschelde
a0f9f5d90a Merge pull request #107770 from RandomShaper/fix_res_dupe_bindings
Enhance bindings of deep resource duplication
2025-06-21 11:14:19 +02:00
Pedro J. Estébanez
7dc37bdc9c Enhance bindings of deep resource duplication 2025-06-20 18:40:41 +02:00
Rémi Verschelde
6eb6e3e6e0 Merge pull request #107457 from akien-mga/improve-error-message-call-single-argument
Improve error messages for method calls expecting only 1 argument
2025-06-12 22:49:36 +02:00
Rémi Verschelde
ae484828bb Merge pull request #107408 from Ivorforce/node-path-string-explicit
Make conversions from `NodePath` to `String` explicit.
2025-06-12 22:49:03 +02:00
Rémi Verschelde
1a64b6b5b6 Merge pull request #106913 from Ivorforce/string-resize-uninitialized
Rename `String::resize` to `resize_uninitialized`
2025-06-12 22:48:45 +02:00
OsakiTsukiko
805ad87340 Add PackedByteArray conversion to PackedVector2Array, PackedVector3Array, PackedVector4Array and PackedColorArray 2025-06-12 17:05:57 +02:00
Rémi Verschelde
d1083c9722 Improve error messages for method calls expecting only 1 argument 2025-06-12 17:02:59 +02:00
Rémi Verschelde
d9cd011e2f Merge pull request #107406 from Ivorforce/ip-to-string-explicit
Core: Remove implicit conversions from `IPAddress` to `String`, to avoid accidental conversions
2025-06-12 01:15:53 +02:00
Danil Alexeev
f864d0ce11 GDScript: Re-add ord() function 2025-06-11 21:01:13 +03:00
Lukas Tenbrink
b13a0e1834 Rename String::resize to resize_uninitialized, to better communicate to callers that new characters must be initialized. 2025-06-11 18:13:02 +02:00
Lukas Tenbrink
e2931a5c19 Make conversions from NodePath to String explicit. 2025-06-11 16:50:27 +02:00
Lukas Tenbrink
1498eb327f Make IPAddress to String conversion explicit. 2025-06-11 15:44:16 +02:00
Lukas Tenbrink
d2f9d31270 Make more types (Callable, Signal) conversion to String explicit. 2025-06-10 23:55:35 +02:00
Thaddeus Crews
86415f1732 Merge pull request #99150 from dalexeev/gds-fix-callable-call-errror-text
GDScript: Fix `Callable` call error text
2025-06-09 12:31:39 -05:00
Thaddeus Crews
7d5ecc2c6f Merge pull request #107295 from Ivorforce/explicit-math-to-string
Remove implicit conversions from math types to `String`, to avoid accidental conversions
2025-06-09 12:31:30 -05:00
Thaddeus Crews
01ef1c0eae Merge pull request #105231 from Ivorforce/ptr-to-arg-nomacro
Convert `PtrToArg` macros to regular C++ structs.
2025-06-09 12:31:25 -05:00
Lukas Tenbrink
ed836df150 Make conversions from math types to String explicit, to avoid accidental conversions. 2025-06-09 01:58:18 +02:00
Rémi Verschelde
f759f52d8f Merge pull request #106902 from lyuma/config_file_uids
Implement UID references in VariantParser
2025-06-09 00:44:32 +02:00
Lyuma
f948ab5366 Implement uid Resource references in VariantWriter
VariantWriter now writes the uid and the path into Resource() references.
This change will affect ConfigFile, used for .import or project settings.
2025-06-08 06:11:35 -07:00
Lukas Tenbrink
78ae5919af Convert PtrToArg macros to regular C++ structs. 2025-06-07 22:17:06 +02:00
Zi Ye
b957cf73ef Optimized and exposed Basis::scaled_local. 2025-06-05 13:06:46 -05:00
Rémi Verschelde
61639d9574 Merge pull request #106996 from Ivorforce/no-oa-hashmap
Core: Remove `OAHashMap`, in favour of `AHashMap`
2025-06-05 13:12:34 +02:00
aaronp64
6b2674fe18 Reuse and optimize sorting logic for List, SelfList, and HashMap
Added SortList class, and updated List, SelfList, and HashMap sort methods to use it.  Sorting is done with merge sort, with an initial check to optimize for already sorted lists, and sorted lists that were appended to.
2025-06-04 10:18:22 -04:00
Aaron Franke
5777a88b76 Support 64-bit sizes in Compression 2025-06-03 00:03:01 -07:00
Lukas Tenbrink
963c20565b Remove OAHashMap, in favour of AHashMap.
The two types had (mostly) the same decisions, but `AHashMap` is a faster implementation, and is more consistent with `HashMap`.
2025-05-31 15:50:10 +02:00
Thaddeus Crews
0f67c3e992 Merge pull request #104522 from Ivorforce/localvector-force-trivial-resize
Core: Add `resize_initialized` and `resize_uninitialized` to `Vector` and `LocalVector`
2025-05-27 09:39:27 -05:00
Thaddeus Crews
63dff62948 Merge pull request #100673 from RandomShaper/res_duplicate
Overhaul resource duplication
2025-05-27 09:39:25 -05:00
Lukas Tenbrink
4cb8a0c77e Add resize_initialized and resize_uninitialized to Vector. These functions serve as replacements for resize, to make sure the caller understands whether elements need to be initialized 'by hand' after the call. 2025-05-26 18:35:41 +02:00
Pedro J. Estébanez
6841b45552 Add tests for resource duplication 2025-05-26 17:05:04 +02:00
Pedro J. Estébanez
342266cfd9 Overhaul Variant::duplicate() for resources
This in the scope of a duplication triggered via any type in the `Variant` realm. that is, the following: `Variant` itself, `Array` and `Dictionary`. That includes invoking `duplicate()` from scripts.

A `duplicate_deep(deep_subresources_mode)` method is added to `Variant`, `Array` and `Dictionary` (for compatibility reasons, simply adding an extra parameter was not possible). The default value for it is `RESOURCE_DEEP_DUPLICATE_NONE`, which is like calling `duplicate(true)`.

Remarks:
- The results of copying resources via those `Variant` types are exactly the same as if the copy were initiated from the `Resource` type at C++.
- In order to keep some separation between `Variant` and the higher-level animal which is `Resource`, `Variant` still contains the original code for that, so it's self-sufficient unless there's a `Resource` involved. Once the deep copy finds a `Resource` that has to be copied according to the duplication parameters, the algorithm invokes the `Resource` duplication machinery. When the stack is unwind back to a nesting level `Variant` can handle, `Variant` duplication logic keeps functioning.

While that is good from a responsibility separation standpoint, that would have a caveat: `Variant` would not be aware of the mapping between original and duplicate subresources and so wouldn't be able to keep preventing multiple duplicates.

To avoid that, this commit also introduces a wormwhole, a sharing mechanism by which `Variant` and `Resource` can collaborate in managing the lifetime of the original-to-duplicates map. The user-visible benefit is that the overduplicate prevention works as broadly as the whole `Variant` entity being copied, including all nesting levels, regardless how disconnected the data members containing resources may be across al the nesting levels. In other words, despite the aforementioned division of duties between `Variant` and `Resource` duplication logic, the duplicates map is shared among them. It's created when first finding a `Resource` and, however how deep the copy was working at that point, the map kept alive unitl the stack is unwind to the root user call, until the first step of the recursion.

Thanks to that common map of duplicates, this commit is able to fix the issue that `Resource::duplicate_for_local_scene()` used to ignore overridden duplicate logic.
2025-05-26 10:06:40 +02:00
Aaron Franke
15de1d6c35 Use Grisu2 algorithm in String::num_scientific to fix serializing 2025-05-22 09:13:16 -07:00
Thaddeus Crews
d237e31a89 Style: Remove redundant DEBUG_METHODS_ENABLED
• Replaced with functionally identical and far more ubiquitous `DEBUG_ENABLED`
2025-05-15 13:09:41 -05:00
Yufeng Ying
3bf400ffae Move bisect to Span and deduplicate code.
Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
2025-05-14 18:19:09 +08:00
Thaddeus Crews
243c8932d3 Merge pull request #82497 from Repiteo/typed-array-consolidation
Typed array equality operator update
2025-05-13 16:22:15 -05:00
Thaddeus Crews
a2b49d0800 Merge pull request #93883 from TV4Fun/variant_join
Consolidate and simplify string joining code in `VariantUtilityFunctions`
2025-05-13 16:22:13 -05:00
Thaddeus Crews
172794337c Merge pull request #99985 from allenwp/release-only-crash-99797
Print error message when index is out of range in `Variant::iter_get`
2025-05-13 16:22:11 -05:00
Thaddeus Crews
5b935881fc Typed array equality operator logic updated
• Instead of calling to `_ref`, the same effect is achieved by calling to the base class assignment operator
• No longer need to be expose `_ref`; set back to private & remove reference from gdextension_interface
2025-05-13 14:41:16 -05:00
Allen Pestaluky
5657ecc542 Print error message when index is out of range in Variant::iter_get of DEBUG_ENABLED builds.
Mitigates #99797
2025-05-13 13:57:16 -04:00
Rémi Verschelde
620206b0ae Merge pull request #106309 from aaronp64/string_chr_appends
Avoid single character `String` allocations when appending characters
2025-05-13 01:05:45 +02:00
Joel Croteau
981f1e9298 Rename VariantUtilityFunctions::join() to join_string() 2025-05-12 17:51:09 -05:00
Joel Croteau
8be7ad32e7 Consolidate and simplify string joining code in VariantUtilityFunctions
`variant_utility.cpp` has 8 different copies of the exact same loop to join
vararg strings together. This is bad coding process and makes the codebase
needlessly cluttered. Also, the loop itself has an i == 0 check that is
unnecessary since String is auto-initialized to be empty and String::operator+=
already checks if it is empty before appending. This is a non-functional change
that only reorganizes the code to be a bit more readable.
2025-05-12 17:47:14 -05:00
aaronp64
8fb3697916 Avoid single character String allocations when appending characters
Removed calls to String::chr() when appending characters to Strings in Expression, Resource, and VariantParser, to avoid creating temporary Strings for each character.  Also updated the Resource case to resize String up front, since size is known.
2025-05-12 17:35:42 -04:00
mashumafi
b73346ef19 Avoid copy-on-write when reading vectors 2025-05-12 16:08:05 +02:00
Thaddeus Crews
051712dfb8 Merge pull request #103264 from mhilbrunner/docs-path-join
Rename "file" param for str.path_join() to "path"
2025-05-07 12:48:29 -05:00
aaronp64
d176ba045f Array performance improvements to reduce copying/copy_on_write calls
- Avoid temporary copy of p_array in Array::append_array when types match
- Call ptrw() once before looping in methods that return new Arrays, to avoid copy_on_write call for each item (recursive_duplicate, slice, filter, map)
2025-05-06 13:19:50 -04:00
Thaddeus Crews
5fec9a9fdc Merge pull request #100057 from aaronp64/container_validate_obj_perf
Improve `ContainerTypeValidate` performance for object types
2025-05-06 08:38:03 -05:00
Danil Alexeev
2b30f23595 GDScript: Fix Callable call error text 2025-05-02 18:30:35 +03:00
Thaddeus Crews
01fc9aee6c Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00
Thaddeus Crews
347e51e077 Merge pull request #105922 from aaronp64/dictionary_has_all
Avoid extra copy/validation of keys in `Dictionary::has_all`
2025-04-29 16:05:14 -05:00