Commit graph

17 commits

Author SHA1 Message Date
Clay John
8b06cdf277
Revert "Handle NaN and Infinity in JSON stringify function" 2025-10-10 18:22:24 -07:00
Thaddeus Crews
21e5b41642
Merge pull request #108837 from aaronfranke/json-handle-nan-inf
Handle NaN and Infinity in JSON stringify function
2025-10-10 10:25:55 -05:00
Aaron Franke
a238af4d20
Use num_scientific (Grisu2) when stringifying JSON with full precision 2025-09-24 08:21:37 -07:00
Aaron Franke
e90cea9250
Handle NaN and Infinity in JSON stringify function 2025-08-24 10:09:43 -07:00
Aaron Franke
b626695f70
Fix internal JSON stringify not preserving p_full_precision 2025-07-21 08:36:29 -07:00
aaronp64
f13b4b760a Improve JSON::stringify performance
- Changed stringify to call static function _stringify directly, instead of creating JSON object
- Changed colon and end_statement from String to const char * to avoid extra allocations in each _stringify call
- Pass result String reference to each _stringify call to append to instead of allocating new String in each call

These changes make JSON::stringify around 2-3x faster in most cases
2025-05-06 18:27:32 -04:00
Thaddeus Crews
ad40939b6f
Core: Replace C math headers with C++ equivalents
- Minor restructuring to ensure `math_funcs.h` is the central point for math functions
2025-04-16 15:49:02 -05:00
kobewi
75881f8322 Use initializer list in Arrays 2025-03-26 18:38:15 +01:00
A Thousand Ships
466590d0ec
Use get_slicec instead of get_slice for single character splitters 2025-03-08 20:36:37 +01:00
Thaddeus Crews
324512e11c
Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06: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
bruvzg
84a6f0d232 [String] Fix Unicode parsing error message encoding and related JSON tests. 2023-07-28 12:27:01 +03:00
RedMser
427b293c7d Disallow invalid escape sequences in JSON.parse 2023-06-30 21:28:36 +02:00
Rémi Verschelde
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
Hendrik Brucker
f906ff8f89 [Tests] Replace Math::is_equal_approx with == and doctest::Approx 2022-11-05 02:28:00 +01:00
Rémi Verschelde
fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Aaron Franke
99a282f631
Move and organize tests into subfolders 2021-11-07 00:43:31 -06:00
Renamed from tests/test_json.h (Browse further)