Commit Graph

52 Commits

Author SHA1 Message Date
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
Marcel Admiraal da5d7db610 Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
Pedro J. Estébanez 469fa47e06
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-17 15:06:19 +02:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Rémi Verschelde 1c881c973b
GDScript: Fix MutexLock usage, fixes Clang 6 compat
Fixes #41852.
2020-09-09 14:56:57 +02:00
George Marques d36d7e2a1c
GDScript: Use pointer instead of references in cache
They are not supposed to be kept alive and this is cleaner and less
error-prone than unreferencing the elements.
2020-08-23 12:55:27 -03:00
George Marques 3abb3c0d6e
GDScript: Fix crash when superclass file is non-existent
Incidentally, allow EOF to be an end of statement.
2020-08-17 21:30:39 -03:00