Commit graph

121 commits

Author SHA1 Message Date
Lukas Tenbrink
f678729f89 Clean up hashfuncs.h: Move long functions to hashfuncs.cpp and replace static with inline. Remove hash_make_uint64_t and hash_make_uint32_t. 2025-10-07 13:50:18 +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
d1083c9722
Improve error messages for method calls expecting only 1 argument 2025-06-12 17:02:59 +02:00
Lukas Tenbrink
e2931a5c19 Make conversions from NodePath to String explicit. 2025-06-11 16:50:27 +02:00
Lukas Tenbrink
d2f9d31270 Make more types (Callable, Signal) conversion to String explicit. 2025-06-10 23:55:35 +02:00
Lukas Tenbrink
ed836df150 Make conversions from math types to String explicit, to avoid accidental conversions. 2025-06-09 01:58:18 +02:00
Thaddeus Crews
8a93218aab
Core: Natively convert enum/BitField with Variant 2025-04-05 12:35:34 -05:00
Yufeng Ying
4f4031a675 Replace size() == 0 with is_empty(). 2025-04-02 19:18:43 +08:00
Thaddeus Crews
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
rune-scape
0c7d78f455 StringLikeVariantOrder: Compare in-place 2025-03-18 11:21:30 -07:00
Yufeng Ying
bebe037abf Add ConstIterator to Dictionary. 2025-03-13 01:28:46 +08:00
A Thousand Ships
e825085978
[Core] Add is_same to types that have float components
Compares `NaN` as equal.

Added to:
* `AABB`
* `Basis`
* `Color`
* `Plane`
* `Projection`
* `Quaternion`
* `Rect2`
* `Transform2D`
* `Transform3D`
* `Vector2`
* `Vector3`
* `Vector4`

And added as a method in `Math`
2025-02-03 19:25:50 +01:00
Rémi Verschelde
b857c2f3e6 Merge pull request #101016 from kiroxas/AddVariantStaticAssert
Add static assert checks in `Variant` constructors
2025-01-08 15:53:23 +01:00
Lukas Tenbrink
0e72967244 Consolidate Variant int and float conversion functions to reduce duplicate logic. 2025-01-03 20:16:43 +01:00
Kiro
176e5f42b2 add Static assert checks 2025-01-02 09:02:43 +01:00
Thaddeus Crews
bf9ef5f8a5
Merge pull request #100564 from YYF233333/iwyu
Remove unused headers in core
2024-12-19 19:59:55 -06:00
Yufeng Ying
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08:00
HP van Braam
240f510fa7 Core ubsan fixes
This fixes UBSAN errors reported by running our testsuite, importing the
TPS demo, and running the TPS demo. I have tried, wherever possible, to
fix issues related to reported issues but not directly reported by UBSAN
because thse code paths just happened to not have been exercised in
these cases.

These fixes apply only to errors reported, and caused by, core/

The following things have been changed:

* Make sure there are no implicit sign changing casts in core.
* Explicitly type enums that are part of a public API such that users of
  the API cannot pass in wrongly-sized values leading to potential stack
  corruption.
* Ensure that memcpy is never called with invalid or null pointers as
  this is undefined behavior, and when the engine is built with
  optimizations turned on leads to memory corruption and hard to debug
  crashes.
* Replace enum values only used as static values with constexpr static
  const values instead. This has no runtime overhead. This makes it so
  that the size of the enums is explicit.
* Make sure that nan and inf is handled consistently in String.
* Implement a _to_int template to ensure that all of the paths use the
  same algorhithm, and correct the negative integer case.
* Changed the way the json serializer precision work, and added tests to
  verify the new behavior. The behavior doesn't quite match master in
  particulary for negative doubles as the original code tried to cast -inf
  to an int. This then led to negative doubles losing all but one of
  their decimal points when serializing. Behavior in GDScript remains
  unchanged.
2024-12-18 14:31:12 +01:00
Danil Alexeev
bd1a35ce9e
Core: Fix JSON.{from,to}_native() issues 2024-11-29 12:43:06 +03:00
Danil Alexeev
03b05cf9ac
Core: Fix built-in enum constant bindings 2024-11-22 14:03:21 +03:00
Thaddeus Crews
cc6ee3e956
Merge pull request #98713 from dalexeev/core-fix-callable-get-bound-arguments
Core: Fix `Callable.get_bound_arguments{,_count}()` return incorrect data
2024-11-12 12:13:04 -06:00
Thaddeus Crews
f233d186ef
Merge pull request #93885 from dalexeev/core-fix-freed-object-booleanization
Core: Fix `Freed Object` booleanization
2024-11-11 14:18:18 -06:00
Danil Alexeev
e379cc76e5
Core: Fix Callable.get_bound_arguments{,_count}() return incorrect data 2024-11-04 22:41:56 +03:00
Thaddeus Crews
89a311205f
Style: Apply clang-tidy fixes
• `modernize-use-default-member-init` and `readability-redundant-member-init`
• Minor adjustments to `.clang-tidy` to improve syntax & remove redundancies
2024-11-04 12:11:06 -06:00
kobewi
5c0f2414cd Always add decimal when printing float 2024-10-23 15:00:21 +02:00
rune-scape
cee0e6667a Refactor ref-counting code and fix ref counted releasing before aquiring 2024-09-21 11:36:58 -07:00
Danil Alexeev
49bcdf78a7
Core: Сheck r_error after calling callp() 2024-08-30 21:09:30 +03:00
rune-scape
c8b697c64c Remove unused initialize_ref 2024-07-03 13:32:50 -07:00
Danil Alexeev
68481b6cdb
Core: Fix Freed Object booleanization 2024-07-03 09:49:47 +03:00
Rémi Verschelde
152d7c1bba
Revert "Make freed object different than null in comparison operators"
This reverts commit 150b50cfcd.

As discussed with the GDScript team, this has some implications which aren't
fully consensual yet, and which we want to revisit.

For now we revert to the 4.2 behavior for the 4.3 release, to avoid breaking
user expectations.
2024-07-01 14:11:43 +02:00
kobewi
413c11357d Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +02:00
kobewi
a262d2d881 Add shorthand for using singleton string names 2024-05-11 18:53:08 +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
kit
cb17798df3 Add Array and Variant list inializer 2024-05-02 15:35:17 -04:00
A Thousand Ships
c4e24d2b3b
[GDScript] Correctly report invalid read-only access 2024-05-01 12:28:47 +02:00
kobewi
f647888006 Make varray() variadic 2024-04-26 14:33:11 +02:00
Thaddeus Crews
b95e7fcecd
Core: Integrate initalizer lists for Variant 2024-04-19 08:52:17 -05:00
Thaddeus Crews
b0cda1f85f
Core: Use fixed-width integer types in Variant 2024-04-04 08:54:11 -05:00
Thaddeus Crews
9903e6779b
Enforce template syntax typename over class 2024-03-07 22:39:09 -06:00
Muller-Castro
a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
Micky
3edb671b8a Use Packed*Array over Vector<T> in Variant
Also shuffles some method definitions and declarations to be more consistent with the way the Variant types are ordered across the codebase.

And removes an unnecessary JSON assign (`JSON::stringify` can now be accessed statically)
2024-02-06 12:53:19 +01:00
A Thousand Ships
15369fdb1d
Remove unnecessary this-> expressions 2024-01-29 09:59:18 +01:00
Yuri Sizov
ca19d34bde Merge pull request #73896 from vnen/object-null-boolean-consistency
Make freed object different than null in comparison operators
2023-12-16 17:49:05 +01:00
kobewi
275e9d7028 Keep Variant type after zero() 2023-11-08 12:13:36 +01:00
A Thousand Ships
f18aa00e85 Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-10-08 17:23:33 +02:00
Arman Elgudzhyan
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
George Marques
150b50cfcd
Make freed object different than null in comparison operators
This is so everything is consistent, as a freed object is not equivalent
to `null` in general. The booleanization of a freed object still returns
`false` to work as an easy check for validity of objects. Similarly, the
negation of a freed object returns `true`.

Also makes freed objects different from each other (if they are not the
same reference).
2023-08-21 10:45:26 -03:00
Danil Alexeev
bb40bd9aaa
Core: Fix recursion level check for array stringification 2023-07-12 14:59:44 +03:00
kleonc
7a871212ed Fix expected argument count in Callable call error text 2023-04-19 16:06:00 +02:00
Ninni Pipping
e6a9e0cdec Fix Variant hashing for floats
Incorrectly hashed floats as single precision
2023-03-08 12:52:50 +01:00