Commit graph

172 commits

Author SHA1 Message Date
Pedro J. Estébanez
7dc37bdc9c Enhance bindings of deep resource duplication 2025-06-20 18:40:41 +02:00
kobewi
13f642d959
Replace XML codeblock spaces with tabs 2025-06-06 14:35:38 +02:00
Thaddeus Crews
e41af67e29
Merge pull request #107020 from Aioshiro/typo-array-slice
Fix extra parenthesis in `Array.slice` description
2025-06-02 18:51:22 -05:00
Thaddeus Crews
d7d6bc77ed
Merge pull request #106369 from Calinou/doc-array-get
Improve documentation for `Array.get()` and `Packed*Array.get()` methods
2025-06-02 18:51:20 -05:00
Aioshiro
8fc060b8b3 Fix extra parenthesis in Array.slice description 2025-06-01 17:05:30 +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
Hugo Locurcio
59a75babf8
Improve documentation for Array.get() and Packed*Array.get() methods 2025-05-20 23:47:04 +02:00
Rarysson Guilherme
fe39ffeb7d Add negative index to Array.remove_at and Array.insert 2025-04-08 14:55:39 -03:00
Max Chacon
44d10c576e
Improve documentation for return value of Packed*Array.resize
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2025-03-20 16:21:01 +01:00
Micky
ca4b29b18d Standardize all "Prints" comments in documentation 2024-12-23 21:26:00 +01:00
Raul Santos
072ff85f82
[.NET] Use collection expressions in docs
As of C# 12 we can now use collection expressions to reduce some boilerplate when initializing collections.
2024-12-21 02:28:59 +01:00
Micky
0c2296fb1b Fix C# boolean "Prints" comments in documentation 2024-11-11 21:19:34 +01:00
Aaron Franke
cc9f2b58a0
Bind Array get and set functions 2024-09-26 13:00:17 -07:00
Rémi Verschelde
6bf8a3e3f8
Merge pull request #95449 from SlashScreen/array_functions
Add callable support for `find` and `rfind` `Array` methods
2024-09-20 16:06:13 +02:00
Daylily-Zeleen
c6f7c89149 Fix description of Array.sort_custom() 2024-09-15 15:52:50 +08:00
Slashscreen
89491f4403 Add callable support for find and rfind Array methods 2024-09-13 00:01:53 -07:00
Rémi Verschelde
4a798ad85d
Merge pull request #95749 from Mickeon/documentation-example-pruning
Remove empty `[b]Example:[/b]` lines from the class reference
2024-08-26 23:29:00 +02:00
aaronp64
39ca8b4e23 Fix Array.sort_custom example code
Array.sort_custom descending sort example was comparing index 0, but had expected result based on comparing index 1.  Updated to use index 1 consistently.
2024-08-26 10:38:23 -04:00
Tallivm
b516742358 Fix typo in Array code example 2024-08-24 20:44:01 +03:00
Micky
4ce5856384 Remove empty [b]Example:[/b] lines from the class reference 2024-08-19 01:00:52 +02:00
Eduardo Assis
5ada090d74 Fix typo in Array's sort() method description 2024-07-27 16:13:42 -03:00
Micky
31a9c634d5 Overhaul Array Documentation 2024-07-05 13:48:56 +02: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
Rémi Verschelde
a27d9639f2
Merge pull request #79075 from dalexeev/doc-typed-arrays
Update typed arrays documentation
2024-04-08 11:17:38 +02:00
Rémi Verschelde
ea961d3981
Merge pull request #78257 from Calinou/doc-packed-arrays-vs-typed-arrays
Document the upsides and downsides of packed arrays versus typed arrays
2024-04-08 11:17:31 +02:00
A Thousand Ships
06df4abcd3
[Doc] Clarify bsearch(_custom) behavior
* Added an example for the effect of `before`
* Clarified the arguments to the custom callable can be either order
2024-03-09 13:09:29 +01:00
RedMser
5911a12db1 Update class reference to include some keywords
More should be added in future PRs, wherever there is demand.
2024-02-09 18:13:23 +01:00
Micky
61bdbdd9ee Replace some "uncommon" words in class reference 2024-01-15 18:51:52 +01:00
Hugo Locurcio
ab8c9b678f
Document the upsides and downsides of packed arrays versus typed arrays 2023-11-15 23:30:47 +01:00
MewPurPur
80b636069a Add performance note to Array.resize() 2023-11-10 00:41:39 +02:00
Yuri Sizov
e538843930 Merge pull request #80936 from curious-broccoli/fix-array-doc
Clarify Array class methods that return error
2023-08-25 14:59:00 +02:00
curious-broccoli
d8e7ce58ee Clarify Array class methods that return error
related to #47406
2023-08-24 14:11:56 +00:00
David Turner
30d4d1c6d1 Document pick_random for empty arrays 2023-08-18 17:01:23 -04:00
Ninni Pipping
7752a0d8d1 Fix range error for Array.slice 2023-07-07 23:19:42 +02:00
Rémi Verschelde
81064cc239
Doctool: Remove version attribute from XML header
We don't use that info for anything, and it generates unnecessary diffs
every time we bump the minor version (and CI failures if we forget to
sync some files from opt-in modules (mono, text_server_fb).
2023-07-06 10:08:21 +02:00
Rémi Verschelde
346f1ab86b
Bump version to 4.2-dev
Keep on waitin'
2023-07-05 22:07:03 +02:00
Danil Alexeev
b33c3fa092
Update typed arrays documentation 2023-07-05 20:30:15 +03:00
Peter Anderson
bdffb74f06
Update Array's remove_at() description to cover removing the last element 2023-06-19 23:14:46 +02:00
VolTer
04562662d3 Overhaul the top sections of the class reference (Core classes) 2023-05-19 07:04:48 +02:00
Ninni Pipping
96ab31a711 Document how to make custom min/max for Array 2023-04-10 16:41:11 +02:00
George Marques
d2b1d6e69b
Remove outdated note about const in Dictionary and Array docs 2023-03-08 12:13:17 -03:00
Rémi Verschelde
1c1524a651
Bump version to 4.1-dev
Can't stop, won't stop, they said, huh?
2023-03-01 01:44:37 +01:00
Rémi Verschelde
bbff9fd7a4
Merge pull request #71786 from raulsntos/dotnet/array
Sync C# Array with Core
2023-02-04 00:24:06 +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
Raul Santos
54f8fb010c
Sync C# Array with Core
- Add `AddRange` method.
- Add `Fill` method.
- Add `Max` and `Min` methods.
- Add `PickRandom` method.
- Add `Reverse` method.
- Add `RecursiveEqual` method.
- Add `Sort` method.
- Add `Slice` and `GetSliceRange` methods.
- Add `IndexOf` overload that takes an index parameter.
- Add `LastIndexOf` method.
- Add `BinarySearch` method.
- Add/update documentation.
2023-01-30 05:41:53 +01:00
Dmitrii Maganov
abe6d67232 GDScript: Fix test for read-only state of constants 2023-01-27 05:28:08 +02:00
Raul Santos
97610c8bfc
Add property usage to array indexer
This makes the `Array` indexer show as returning `Variant` instead of `void` in the documentation.
2023-01-19 14:22:11 +01:00
Rémi Verschelde
2d2902b49b
Merge pull request #70745 from rcorre/array_dup_doc
Explain that Array.duplicate will not deep-copy Object.
2023-01-10 10:45:30 +01:00