Commit Graph

62 Commits

Author SHA1 Message Date
f6a35e2a6e Merge pull request #86015 from kitbdev/array-initializer-list
Add list initialization to Array, Variant, and TypedArray
2025-03-19 17:46:06 -05:00
883ca56517 Remove unneeded read_only check for Array const operator. 2025-03-12 07:22:42 +08:00
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08:00
bd1a35ce9e Core: Fix JSON.{from,to}_native() issues 2024-11-29 12:43:06 +03:00
38f9769bc6 [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
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
89491f4403 Add callable support for find and rfind Array methods 2024-09-13 00:01:53 -07:00
27d1fb63e1 Fix Unable to use ResourceLoader in C# after threaded load in GDScript #92798 2024-09-11 19:03:55 -04:00
496b7b8482 Core: Improve vformat error reporting on sprintf failure
And fix a few occurrences of formatting errors that led me to this.
2024-07-04 10:54:55 +02:00
kit
cb17798df3 Add Array and Variant list inializer 2024-05-02 15:35:17 -04:00
64146cb7f3 [Core] Add iteration support to Array 2024-04-10 14:49:34 +02:00
684752e75b Replace error checks against size with is_empty 2024-02-09 12:50:15 +01:00
737c308dcc Merge pull request #74588 from puchik/float-variant-nan-inequality
Support numeric/binary hash comparison for floats derived from Variants (as well as existing semantic comparison)
2023-09-27 14:03:34 +02:00
893f889d74 [Core] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-11 19:45:49 +02:00
ee27254602 Support both semantic (by default) and numeric Variant hash comparison
Hash comparison for Variant continues to perform semantic/logical comparison with NaN's considered equal by default (to prevent #16114, #7354, #6947, #8081), but now optionally allows for numeric comparison that does not consider NaN's equal to support proper value comparison (for #72222)
2023-08-31 09:29:48 -07:00
7752a0d8d1 Fix range error for Array.slice 2023-07-07 23:19:42 +02:00
10f385fb79 Fix Array.slice() rounding for abs(step) != 1 2023-03-14 15:46:45 +01:00
8400308ab3 GDScript: Fix can_reference check for typed arrays 2023-02-06 22:00:16 +02:00
bbff9fd7a4 Merge pull request #71786 from raulsntos/dotnet/array
Sync C# Array with Core
2023-02-04 00:24:06 +01:00
394bb0ee2b Fix various typos with codespell
Finally do the childs -> children rename too.
2023-02-01 08:45:41 +01:00
5909f9f075 GDScript: Fix issues with typed arrays 2023-01-31 11:54:41 +02:00
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
abe6d67232 GDScript: Fix test for read-only state of constants 2023-01-27 05:28:08 +02:00
5e2ac1a31e GDScript: Begin making constants deep, not shallow or flat 2023-01-08 07:29:10 +02:00
d95794ec8a One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
e79be6ce07 Unify String and StringName 2022-12-05 21:46:47 -05:00
67cdac6db8 Remove Array.find_last() 2022-11-25 18:34:50 +01:00
9f4dbf415d add ability to pick random value from array 2022-10-20 08:39:47 -03:00
bf64a068a4 Fix Array.slice() and filter() forgetting Typed Array 2022-10-09 12:34:19 +02:00
d4433ae6d3 Remove Signal connect binds
Remove the optional argument p_binds from `Object::connect` since it was deprecated by Callable.bind().
Changed all uses of it to Callable.bind()
2022-07-29 16:26:13 +02:00
141c375581 Clean up Hash Functions
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934
* Clean up usage of murmur3
* Fixed usages of binary murmur3 on floats (this is invalid)
* Changed DJB2 to use xor (which seems to be better)
2022-06-20 12:54:19 +02:00
fb86430770 Validate every source element separately Array::append_array() 2022-06-15 20:36:20 +02:00
a98e31aa3a Add any() and all() methods to Array
These can be used as faster, more convenient shorthands to
using `filter()` + `size()`.
2022-05-25 16:09:10 +02:00
023b1d7f5a Implement read-only arrays
Arrays can be set as read-only and thus cannot be modified. Assigning
the array will create an editable copy.

Similar to is already done to read-only dictionaries.
2022-05-17 14:14:42 -03:00
9c2bfeb2fb Const Ref Callable for custom sort/search 2022-03-27 22:10:36 -04:00
668d6a1c5c Merge pull request #56337 from cdemirer/fix-array-dictionary-id 2022-01-23 00:46:53 +01:00
c6cefb1b79 Array: Relax slice bound checks to properly handle negative indices
The same is done for `Vector` (and thus `Packed*Array`).

`begin` and `end` can now take any value and will be clamped to
`[-size(), size()]`. Negative values are a shorthand for indexing the array
from the last element upward.

`end` is given a default `INT_MAX` value (which will be clamped to `size()`)
so that the `end` parameter can be omitted to go from `begin` to the max size
of the array.

This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10 22:42:03 +01:00
fe52458154 Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
e2ed9d13eb Fix Array and Dictionary id() and dictionary test bug 2021-12-30 13:14:09 +08:00
dd30253cdc PackedByteArray, Array slice end exclusive, rename subarray to slice 2021-11-26 22:13:12 -06:00
e078f970db Rename remove() to remove_at() when removing by index 2021-11-23 18:58:57 -07:00
f9ba2efe1e Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests) 2021-10-30 13:11:01 +02:00
214bbfbefe Implement bsearch for Vector and Packed*Array 2021-09-30 23:57:26 +00:00
04c64b59a1 Merge pull request #47406 from mashumafi/master-Array-insert-rc
Array::insert consistent with Pool*Array::insert
2021-08-28 21:18:39 +02:00
60116b17b5 Add an Array.pop_at() method to pop an element at an arbitrary index
Negative indices are supported to pop an element relative from the end.
2021-08-27 00:51:17 +02:00
afdc5edb2a Remove alloca from loop and use a single fixed size array declaration 2021-05-21 13:04:55 +01:00
c50acc7339 Add filter, map and reduce to Array 2021-05-05 15:54:57 +02:00
efd27a63c1 Add fill method to Arrays and PackedArrays 2021-04-21 11:33:53 -03:00
4b6e9f3157 Merge pull request #46991 from madmiraal/rename-invert-reverse
Rename Array.invert() to Array.reverse()
2021-04-01 13:32:22 +02:00
c2d1c1c3ee Array::insert consistent with Pool*Array::insert 2021-03-27 17:27:19 -04:00