Commit graph

330 commits

Author SHA1 Message Date
rune-scape 9fa13da16f GDScript: fix segfault on invalid script 2024-05-17 15:26:25 -07:00
Rémi Verschelde bdefe53992
Merge pull request #91909 from KoBeWi/have_fun_reviewing_this
Use Core/Scene stringnames consistently
2024-05-14 12:07:03 +02:00
kobewi 413c11357d Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +02:00
Rémi Verschelde 0a67ee52d1
Revert "GDScript: Implement get_dependencies()"
This reverts commit dc73440f89.

This commit in some form is needed to fix handling of dependencies on
export, but as it's also used for import, it's exposing some pre-existing
issues which we need to solve first.

So reverting for now to give ourselves time to iron this out for a future
Godot release.

Fixes #91726.
2024-05-13 16:59:43 +02:00
kobewi a262d2d881 Add shorthand for using singleton string names 2024-05-11 18:53:08 +02:00
Rémi Verschelde 4d43fe1c96
Merge pull request #91472 from vnen/gdscript-default-static-variables-non-tool
GDScript: Initialize static variables with defaults in-editor
2024-05-03 01:21:40 +02:00
George Marques 22236380c0
GDScript: Initialize static variables with defaults in-editor
When the script is not marked as `@tool` the static constructor is not
called and thus the variables contain `null` by default. But since some
validated operations requires a valid value, this would cause a crash.

This commit solves this by initializing the static variables with a
default value based on their types in the editor, when they are not
marked as `@tool`, so if some `@tool` script access them, they will have
a valid typed value, avoiding the crash.
2024-05-02 15:09:22 -03:00
George Marques 99b702ea3d
GDScript: Call implicit ready on base script first
It is generally expected that the base class is called before the
inherited clas. This commit implements this behavior for the implicit
ready function (`@onready` annotation) to make it consistent with the
expectations.
2024-05-02 11:25:52 -03:00
Rémi Verschelde c4733e8003
Merge pull request #90860 from vnen/gdscript-get-dependencies
GDScript: Implement `get_dependencies()`
2024-04-29 12:30:12 +02:00
rune-scape 6b88c86cec GDScript: invalidate GDScriptParserRef when reloading 2024-04-18 14:05:58 -07:00
George Marques dc73440f89
GDScript: Implement get_dependencies()
The parser and analyzer now track the dependencies of the script and
return the list when the resource loader ask for them.

What is considered a dependency:

- Any `preload()` call.
- The base script this one extends.
- Any identifier, including types, that refers to global scripts.
- Any autoload singleton reference.
2024-04-18 11:54:37 -03:00
A Thousand Ships 59bcc2888c
Add methods to get argument count of methods
Added to:
* `Callable`s
* `Object`s
* `ClassDB`
* `Script(Instance)`s
2024-03-10 11:02:43 +01:00
Danil Alexeev 0908ad4005
GDScript: Fix paths in ResourceFormatLoaderGDScript::load() 2024-02-29 16:04:31 +03:00
Pedro J. Estébanez 5e144022e7 Enhance cache modes in resource loading
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from #87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see #59669, #82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
2024-02-26 14:59:04 +01:00
Danil Alexeev 8ffc50ee8c
GDScript: Canonicalize script path in FQCN 2024-02-26 10:46:24 +03:00
Rémi Verschelde b652a81da7
Merge pull request #82554 from dsnopek/gdextension-placeholders
Allow registering "runtime classes" from GDExtension
2024-02-20 17:13:24 +01:00
David Snopek ea75307a11 Allow registering "runtime classes" 2024-02-20 09:20:58 -06:00
Rémi Verschelde 6f805dee2a
Merge pull request #88365 from dalexeev/gds-fix-gdc-export
GDScript: Fix extension comparison for exported scripts
2024-02-15 17:35:58 +01:00
Danil Alexeev a2e3e31e80
GDScript: Fix extension comparison for exported scripts 2024-02-15 17:53:24 +03:00
Muller-Castro a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
Rémi Verschelde 986c8af29d
Merge pull request #81629 from rune-scape/more-gdscript-deps
GDScript: Include lambda dependencies
2024-02-12 13:33:22 +01:00
George Marques 72e5f8c31e
GDScript: Enable compression on export
Besides the regular option to export GDScript as binary tokens, this
also includes a compression option on top of it. The binary format
needs to encode some information which generally makes it bigger than
the source text. This option reduces that difference by using Zstandard
compression on the buffer.
2024-02-08 11:20:07 -03: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
Rémi Verschelde 41564aaf77
Merge pull request #86999 from AThousandShips/init_note
Improve error message when a GDScript instance fails to be constructed
2024-02-08 13:49:44 +01:00
Rémi Verschelde 745f8e112f
Revert "Add UID support to GDScript files"
This reverts commit c7f68a27ec.

We still think GDScript files need UIDs to allow safe refactoring,
but we're still debating what form those should take exactly.

So far there seems to be agreement that it shouldn't be done via an
annotation as implemented here, so we're reverting this one for now,
to revisit the feature in a future PR.
2024-01-29 21:00:26 +01:00
A Thousand Ships 15369fdb1d
Remove unnecessary this-> expressions 2024-01-29 09:59:18 +01:00
Rémi Verschelde d3003c48b3
Merge pull request #67132 from KoBeWi/This_commit_message_is_auto-generated._Do_not_modify_it-
Add UID support to GDScript files
2024-01-18 16:33:14 +01:00
kobewi c7f68a27ec Add UID support to GDScript files 2024-01-17 22:30:56 +01:00
Yuri Sizov c027aecc2e Merge pull request #86676 from rune-scape/sparse-script-reload
GDScript: Hot-reload changed scripts only
2024-01-17 18:52:54 +01:00
A Thousand Ships cae3b822c3
Improve error message when a GDScript instance fails to be constructed
Co-authored-by: Slashscreen <SlashScreen@users.noreply.github.com>
2024-01-09 13:32:22 +01:00
rune-scape 49bce5c9ef GDScript: Lambda hotswap fixes 2024-01-04 16:33:54 -08:00
rune-scape cde478bda6 Hot-reload only changed scripts 2024-01-02 17:56:52 -08:00
rune-scape e4242f9b40 GDScript: Include lambda dependencies 2023-12-26 13:02:03 -08:00
msreis f1cc14d525 Fix missing time for some script functions in profiler
Fixes the issue by adding a mechanism by which the functions that were
previously disappearing can be profiled too. This is optional with
an editor setting, since collecting more information naturally slows the engine
further while profiling.

Fixes #23715, #40251, #29049
2023-12-19 19:42:21 +01:00
Yuri Sizov f4b32b228a Merge pull request #85603 from eldidou/speed-up-get-must-clear-dependencies
Speed up `GDScript::get_must_clear_dependencies()`
2023-12-16 17:49:47 +01:00
Wilson E. Alvarez 80fb8db31f
Remove unnecessary assignments
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2023-12-13 11:06:26 -05:00
eldidou 0d77c3e092 Speed up GDScript::get_must_clear_dependencies()
get_must_clear_dependencies() has a N^3*log(N) time complexity, and this can very quickly slow down the quitting process as more gdscripts are added in a project.
This change improves it to N^2*log(N).
Instead of using all the inverted dependencies, we do the same with all (non-inverted) dependencies, which is N times faster.

Fixes #85435
2023-12-09 13:02:38 +01:00
Rémi Verschelde d75c44658c
Merge pull request #85373 from DmitriySalnikov/update_singletons
Fix updating cached singletons when reloading GDScripts
2023-12-04 23:13:13 +01:00
DmitriySalnikov 8cdbec0434 Update cached singletons when reloading GDScripts 2023-11-30 04:07:21 +03:00
Pedro J. Estébanez cfa7e72057 Fix GDScript thread-exit routine assuming thread-enter was called 2023-11-27 13:01:37 +01:00
Pedro J. Estébanez bfe66ab7cd Fixup thread-owned lambda bookkeeping on thread exit (take 2) 2023-11-23 18:50:20 +01:00
Pedro J. Estébanez f26328e9a3 Revert recently added approach to cross-thread lambda survival
Commits reverted:
- 1ed6919148
- 271511726b
2023-11-22 20:07:01 +01:00
Pedro J. Estébanez 1ed6919148 Fix leak in the bookkeeping of GDScript lambdas 2023-11-21 12:52:55 +01:00
Rémi Verschelde bc80776618
Merge pull request #84659 from RandomShaper/fix_lambda_cross_thread
Fix lambda cross-thread dynamics
2023-11-12 12:14:42 +01:00
kobewi a3627b6e37 Assign temporary path to preloaded resources 2023-11-10 00:43:30 +01:00
Pedro J. Estébanez 271511726b Fixup thread-owned lambda bookkeeping on thread exit 2023-11-10 00:05:38 +01:00
rune-scape 9fb8862d73
GDScript: Lambda hot reloading
Co-authored-by: Adam Scott <ascott.ca@gmail.com>
2023-10-17 15:52:52 -04:00
Rémi Verschelde 6a0716dedd
Merge pull request #83123 from astillich/82998-propagate-base-class-exports
Fix modifying base script exports not propagating to derived scripts
2023-10-16 18:43:39 +02:00
Alexander Stillich 99f8751878 Fix editing exports in a base script not propagating the change to the opened property editor
This patch fixes the user having to navigate away from the selected node which has the derived script attached and back to see the changes of the base script exports reflected in the property editor.
2023-10-16 17:55:19 +02:00
Danil Alexeev ed0b3c08e1
Core: Fix Object::has_method() for script static methods 2023-10-04 19:44:32 +03:00