Commit graph

59 commits

Author SHA1 Message Date
rune-scape 6b88c86cec GDScript: invalidate GDScriptParserRef when reloading 2024-04-18 14:05:58 -07:00
Rémi Verschelde ee5ace10b7
Merge pull request #85501 from /remove-packed-scene-cache 2024-02-25 11:49:27 +01:00
George Marques b4d0a09f15
GDScript: Reintroduce binary tokenization on export
This adds back a function available in 3.x: exporting the GDScript
files in a binary form by converting the tokens recognized by the
tokenizer into a data format.

It is enabled by default on export but can be manually disabled. The
format helps with loading times since, the tokens are easily
reconstructed, and with hiding the source code, since recovering it
would require a specialized tool. Code comments are not stored in this
format.

The `--test` command can also include a `--use-binary-tokens` flag
which will run the GDScript tests with the binary format instead of the
regular source code by converting them in-memory before the test runs.
2024-02-08 11:20:05 -03:00
Jordyfel ef5dcccde7 Stop caching packed scenes in GDScript cache 2023-11-29 12:52:55 +02:00
Rémi Verschelde a9c864dc35
Merge pull request #83039 from KoBeWi/it's_always_the_cache
Fix GDScript cache assigning UID as scene path
2023-11-10 10:44:33 +01:00
Matthew Borkowski 2d262c072b Fix GDScriptCache::get_full_script eating parsing errors because of early exit
Fixes #75545.
2023-10-18 18:21:59 -04:00
kobewi 6849cf48d1 Fix GDScript cache assigning UID as scene path 2023-10-09 13:57:31 +02:00
A Thousand Ships 517e9f8aef [Modules] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-26 16:44:52 +02:00
ocean (they/them) 955049670f GDScript: Add static analysis error reporting in GDScriptCache::get_full_script() 2023-07-07 11:16:22 -04:00
Rémi Verschelde 5f9175f969
Merge pull request #76954 from Rindbee/return-null-on-fail-load-script
Returns null and does not cache when the source code of the script fails to load
2023-06-19 21:17:47 +02:00
Rindbee cbce374f68 Returns null and does not cache when the source code of the script fails to load
This usually means that an `ERR_FILE*` error occurred.

Previously, using `GDScriptCache::get_full_script()` would ignore errors during loading.
Now, all errors are not ignored.

Judging in which period the error occurred, it can be judged based on the return value:
1. null + err : Error during script loading (load_source_code()).
2. script + err: Error during script parsing.
2023-06-15 21:06:10 +08:00
Rémi Verschelde 25b2f1780a
Style: Harmonize header includes in modules
This applies our existing style guide, and adds a new rule to that style
guide for modular components such as platform ports and modules:

Includes from the platform port or module ("local" includes) should be listed
first in their own block using relative paths, before Godot's "core" includes
which use "absolute" (project folder relative) paths, and finally thirdparty
includes.

Includes in `#ifdef`s come after their relevant section, i.e. the overall
structure is:

- Local includes
  * Conditional local includes
- Core includes
  * Conditional core includes
- Thirdparty includes
  * Conditional thirdparty includes
2023-06-15 14:35:45 +02:00
George Marques 0ba6048ad3
Add support for static variables in GDScript
Which allows editable data associated with a particular class instead of
the instance. Scripts with static variables are kept in memory
indefinitely unless the `@static_unload` annotation is used or the
`static_unload()` method is called on the GDScript.

If the custom function `_static_init()` exists it will be called when
the class is loaded, after the static variables are set.
2023-04-27 09:51:44 -03: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
Adam Scott c3f12592da Cache script when reloading even if there's errors. 2023-01-01 14:09:17 -05:00
rune-scape 2dfc6d5b69 GDScript: Allow out of order member resolution 2022-12-14 21:44:05 -05:00
Adam Scott 0139bd04b2 Fix GDScriptCache::clear() crash when clearing packed scenes 2022-12-10 19:10:12 -05:00
Adam Scott ff544df926 Fix GDScriptCache to not remove scripts/scenes individually when clearing 2022-12-10 12:48:07 -05:00
Adam Scott 59c6642f2a Add missing packed scene cache clear inside GDScriptCache::clear() 2022-12-07 15:29:18 -05:00
Adam Scott 88f3045301 Move GDScript uninitialization to GDScriptLanguage::finalize()
Co-authored-by: Ricardo Buring <ricardo.buring@gmail.com>
Co-authored-by: kleonc <9283098+kleonc@users.noreply.github.com>
2022-12-06 09:35:39 -05:00
Rémi Verschelde 4555ccdf98
Merge pull request #69224 from adamscott/fix-PackedScene-reload_from_file
Add `PackedScene::reload_from_file()` override
2022-11-28 16:53:36 +01:00
Adam Scott a34a26eb66 Add PackedScene::reload_from_file() override 2022-11-28 10:23:02 -05:00
Adam Scott 4e60689695 Fix cyclic reference base being loaded but not valid (which is ok) 2022-11-27 15:50:19 -05:00
Adam Scott 69bb7e5b11 Fix singleton scene cyclic loading 2022-11-25 12:43:55 -05:00
Rémi Verschelde c474e2f639
Merge pull request #68987 from adamscott/fix-godot#61386-autoload-scenes-implicit-types
Fix autoload scenes implicit types
2022-11-22 08:31:36 +01:00
Adam Scott eb62d241c0 [godot#61386] Fix autoload scenes implicit types 2022-11-21 23:39:31 -05:00
Adam Scott e86e15571f [godot#68971] Fetch cached scene if it exists in GDScriptCache 2022-11-21 15:57:45 -05:00
Rémi Verschelde 190226098b
Merge pull request #68929 from adamscott/add-rename-check
Add `GDScriptCache::move_script` check before executing logic
2022-11-20 23:25:30 +01:00
Adam Scott 98ceb7ecf5 Add move_script check before executing logic 2022-11-20 15:21:57 -05:00
rune-scape 5ef971da1a GDScript: Cache scripts after parse error 2022-11-20 13:06:14 -05:00
rune-scape a6410878db Fix empty text in editor 2022-11-20 03:17:16 -05:00
Adam Scott 5704055d30 Fix cyclic references in GDScript 2.0 2022-11-18 16:41:31 -05:00
Rune bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
Rindbee f1a4041f52 Load/update GDScript from disk on load if cache mode is CACHE_MODE_IGNORE 2022-09-24 16:06:36 +08:00
Voylin e5814c3f81 Fix for recurring check in gdscript_cach.cpp 2022-09-11 16:56:49 +09:00
bruvzg 0c5431644d
Allows parsing of invalid UTF-16 surrogates (can be encountered in Windows filenames) and some non-standard UTF-8 variants, makes Unicode parse errors more verbose. 2022-07-07 11:07:18 +03:00
reduz 45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
bruvzg 9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
K. S. Ernest (iFire) Lee b69b526b7c GDScript cache crashfix. 2022-01-22 17:42:54 -08: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
Rémi Verschelde f19a1e28c8
Revert "Fix auto reload scripts on external change" 2021-12-10 22:40:20 +01:00
Nathan Franke 49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Rémi Verschelde 1a8741aaca
Merge pull request #49473 from cptchuckles/fix-auto-reload-scripts 2021-12-09 10:06:22 +01:00
George Marques dfe3a2fad0
GDScript: Set status on parsing steps beforehand
To avoid potential dependency cycles. If any happens it will not get
into infinite recursion anymore and errors will cascade later on.
2021-10-06 21:24:27 -03:00
Pedro J. Estébanez 10c9c2ccd4 Avoid crash after a parsing error in GDScript 2021-09-11 11:35:25 +02:00
Jonathan Gollnick b0c807c75a
Fix auto reload scripts on external change 2021-09-02 20:28:02 -05:00
PouleyKetchoupp 9973bf93ed Fix crash when failing to load script from cache 2021-08-16 16:27:25 -07:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Rémi Verschelde 9e328bb5b7
Core: Move DirAccess and FileAccess to core/io
File handling APIs are typically considered part of I/O, and we did have most
`FileAccess` implementations in `core/io` already.
2021-06-11 14:52:39 +02:00