Commit Graph

848 Commits

Author SHA1 Message Date
176e5f42b2 add Static assert checks 2025-01-02 09:02:43 +01:00
4e48b19e1f Add Color.from_rgba8 and deprecate Color8 2024-12-27 11:26:59 +01:00
46c23e1758 Don't set Variant::Type in destructor
When profiling Dome Keeper, I found that in physics_process a HashMap
gets cleared a lot, which ends up calling the Variant destructor.
Calling Variant::clear() dominates this operation.

By not uselessly setting the Type to NIL on destruction we save about
50% of time. This is likely because if there is a simple type in the
Variant that doesn't need destructing, but now we write when we should
just drop the Variant altogether.

Since the value of Variant::type should be unobservable after
destruction this doesn't change any outward behavior.
2024-12-25 23:40:19 +01:00
73d85f46c9 Remove unused headers in scene.
Co-authored-by: Thaddeus Crews <repiteo@outlook.com>

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-12-24 00:40:09 +08:00
fb8d2ee044 Merge pull request #100582 from bruvzg/fix_in_ops
[GDScript] Fix `Packed*Array` `OP_IN` using low precision int and float as input.
2024-12-19 20:00:06 -06:00
bf9ef5f8a5 Merge pull request #100564 from YYF233333/iwyu
Remove unused headers in core
2024-12-19 19:59:55 -06:00
eaf2d7c5b0 [GDScript] Fix Packed*Array OP_IN using low precision int and float as input. 2024-12-18 23:41:27 +02:00
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08:00
851d8e49e8 Merge pull request #100386 from hpvb/core-ubsan
Core: Fix UBSAN reports
2024-12-18 17:23:32 +01:00
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
34fa0bf3ec Add move assignment and move constructor to Variant.
Add `_to_variant` helper functions to `gdvirtual.gen.inc` to work around an MSVC bug.
2024-12-15 14:38:46 +01:00
9c290c4c56 Merge pull request #100033 from Daylily-Zeleen/daylily-zeleen/optimize_callable_to_string
Optimize callable's stringify text.
2024-12-12 16:13:23 -06:00
819db4daf5 Merge pull request #99559 from mayoff/OperatorEvaluatorModNZ-ptr_evaluate
Fix `Variant` modulo operation
2024-12-12 14:09:59 +01:00
8f16f864a6 Merge pull request #99765 from dalexeev/core-fix-json-from-to-native
Core: Fix `JSON.{from,to}_native()` issues
2024-12-10 14:15:53 -06:00
b5c31ebb41 Add contains_char() for single-character 'contains' calls. 2024-12-06 20:23:35 +01:00
b19ebbacb2 Improve ContainerTypeValidate performance for object types
Use const reference for class name instead of copying, to avoid some extra reference counting overhead
2024-12-05 11:16:43 -05:00
614a51f293 Optimize callable's stringify text. 2024-12-05 14:24:39 +08:00
d58b2e879f Get rid of easily removable uses of const_cast 2024-12-01 17:50:13 -08:00
54945c4d28 Add std::initializer_list constructor for Dictionary. 2024-11-29 14:12:40 +02:00
bd1a35ce9e Core: Fix JSON.{from,to}_native() issues 2024-11-29 12:43:06 +03:00
daa665c4cb fix copy/paste error (fixes #99518)
Replace erroneous use of `/` with `%`.
2024-11-22 13:21:02 -06:00
03b05cf9ac Core: Fix built-in enum constant bindings 2024-11-22 14:03:21 +03:00
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
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
30d87229ed Merge pull request #82845 from Hysterelius/master
Color: Expose OKHSL properties
2024-11-11 14:18:04 -06:00
2126df2dfd Color: Expose OKHSL properties 2024-11-11 20:41:57 +01:00
824ddeea3f Fix comparison of callables 2024-11-11 17:15:52 +01:00
e379cc76e5 Core: Fix Callable.get_bound_arguments{,_count}() return incorrect data 2024-11-04 22:41:56 +03:00
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
363c0b5fec Merge pull request #47502 from KoBeWi/add_0
Always add decimal when converting float to string
2024-10-31 20:14:39 -05:00
38f9769bc6 [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
b4ba0f983a Merge pull request #98363 from dustdfg/rid_in_operator_fix
Allow using RID with `in` operator for Arrays and Dictionaries
2024-10-24 19:04:41 -07:00
5c0f2414cd Always add decimal when printing float 2024-10-23 15:00:21 +02:00
ee5d90853f Allow use RID with in operator for Arrays and Dictionaries
Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
2024-10-21 11:50:41 +03:00
79f654ced5 [Core] Fix sorting of Dictionary keys
`StringName` keys were sorted as `StringName` which is unstable.
2024-10-18 08:47:05 +02:00
a7f6ec0e4c Add a sort method to Dictionary and HashMap 2024-10-02 14:26:33 -07:00
9ce149c7a3 Merge pull request #93299 from rune-scape/fix-ref
Fix RefCounted releasing early and not clearing reference
2024-10-02 15:00:47 +02:00
cc9f2b58a0 Bind Array get and set functions 2024-09-26 13:00:17 -07:00
9d5b59b2ae Merge pull request #94864 from rune-scape/add-missing-method-bind
Add missing CallableCustomMethodPointer for const methods
2024-09-26 12:45:27 +02:00
9f9ee0c813 SCons: Add unobtrusive type hints in SCons files 2024-09-25 09:34:35 -05:00
a84c480049 Add missing CallableCustomMethodPointer for const methods 2024-09-23 11:46:10 -07:00
1b19ecb360 Merge pull request #95166 from aaronp64/variant_op_err_return
Assign return value on `Variant` operator failure
2024-09-23 12:27:51 +02:00
cee0e6667a Refactor ref-counting code and fix ref counted releasing before aquiring 2024-09-21 11:36:58 -07:00
203d3be200 [Core] Add way to check if a signal has any connections
Added to `Object` and `Signal`
2024-09-20 16:39:09 +02: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
714357e55c Assign return value on Variant operator failure
Variant operators for String formatting and "in" could result in errors, which would return from validated_evaluate without assigning r_ret.  This would cause scripts using the return value from these operators to get results from previously run code.  Updated to return the original String value in the String formatting case, and false for "in" when an error occurs.
2024-09-19 11:22:35 -04:00
89491f4403 Add callable support for find and rfind Array methods 2024-09-13 00:01:53 -07:00
b3d7960df4 Core: Fix operator[] for typed dictionaries 2024-09-12 11:10:17 -05:00
60ffa9645a Merge pull request #96864 from KoBeWi/dictionerrory
Fix `Dictionary.merge()` type validation
2024-09-12 09:25:42 +02:00
f8fbb860f5 Merge pull request #95840 from raulsntos/char_metadata
Add metadata for `char16_t` and `char32_t`
2024-09-12 09:25:19 +02:00