Commit graph

2097 commits

Author SHA1 Message Date
Rémi Verschelde
b863c40356
Merge pull request #62468 from V-Sekai/core-const-expressions
Add a const call mode to Object, Variant and Script.
2022-06-28 01:08:24 +02:00
George Marques
9490146a16
GDScript: Enable exporting nodes to the inspector
Also fix an small issue in the property editor for NodePath trying to
use the meta property when not needed.
2022-06-27 18:42:52 -03:00
Rémi Verschelde
c4a426d6ec
Merge pull request #62462 from vnen/gdscript-setter-chaining
GDScript: Fix setter being called in chains for shared types
2022-06-27 23:25:53 +02:00
K. S. Ernest (iFire) Lee
9ddebc0c22 Add a const call mode to Object, Variant and Script.
For this to work safely (user not call queue_free or something in the expression), a const call mode was added to Object and Variant (and optionally Script).

This mode ensures only const functions can be called, making it safe to use from the editor.

Co-Authored-By: reduz <reduzio@gmail.com>
2022-06-27 13:33:06 -07:00
George Marques
511a4b761c
GDScript: Fix setter being called in chains for shared types
When a type is shared (i.e. passed by reference) it doesn't need to be
called in a setter chain (e.g. `a.b.c = 0`) since it will be updated in
place.

This commit adds an instruction that jumps when the value is shared so
it can be used to skip those cases and avoid redundant calls of setters.
It also solves issues when assigning to sub-properties of read-only
properties.
2022-06-27 12:09:51 -03:00
Rémi Verschelde
dd3de622d8
Merge pull request #62372 from MarcusElg/nosliderrename
Rename @export_range's noslider option to no_slider
2022-06-25 14:03:44 +02:00
George Marques
cf015673d3
GDScript: Use implicit method for @onready variables
Initialize them with the implicit method so they're not related to the
overriding of the `_ready` method of the script but instead are always
set.
2022-06-24 14:49:21 -03:00
George Marques
81cac4907f
GDScript: Don't add implicit constructor to the list of functions
So it's not shown on docs or when listing the methods. This also avoids
being able to call it using the `call()` function.
2022-06-24 14:48:46 -03:00
Marcus Elg
6c1ac9f3be Rename export_range's noslider option to no_slider 2022-06-24 10:45:34 +02:00
Rémi Verschelde
471050e6a7
Merge pull request #62342 from reduz/methodinfo-varargs
Implement varargs in Methodinfo
2022-06-23 22:49:16 +02:00
reduz
dd8c0522a6 Implement varargs in Methodinfo
Variadic templates are an awful thing. Implements #62233 using them in MethodInfo so less changes are required.
2022-06-23 14:50:38 +02:00
Black Cat
5c365713ca Do not reset return value in release build 2022-06-22 20:55:09 +04:00
reduz
141c375581 Clean up Hash Functions
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934
* Clean up usage of murmur3
* Fixed usages of binary murmur3 on floats (this is invalid)
* Changed DJB2 to use xor (which seems to be better)
2022-06-20 12:54:19 +02:00
Marcus Elg
46bbbd9770 Allow autocompletion of "noslider" in export_range 2022-06-19 17:11:49 +02:00
bruvzg
860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
Rémi Verschelde
78944fef82
Merge pull request #61510 from Calinou/script-tweak-stack-overflow-message 2022-06-17 13:03:05 +02:00
Raul Santos
525b5e0e16
Fix EditorScenePostImport templates for C# 2022-06-16 19:29:59 +02:00
Johannes Witt
8c7d4996c9
Document how to load Images and MP3 files at run-time 2022-06-16 13:18:36 +02:00
Rémi Verschelde
d82c227e2b
Merge pull request #61486 from jtnicholl/import_script_templates
Add script templates for EditorScenePostImport
2022-06-15 21:07:42 +02:00
Jonathan Nicholl
912d8e23ca Add script templates for EditorScenePostImport 2022-06-15 12:41:37 -04:00
Yuri Rubinsky
c9ad370f20 Add a null checking to GDScript::_super_implicit_constructor 2022-06-15 17:28:40 +03:00
Hugo Locurcio
cceeb671db
Improve stack overflow error message in GDScript and VisualScript
Stack overflow errors are generally the result of infinite recursion
within a script.
2022-06-15 16:20:01 +02:00
George Marques
68b86220c8
Merge pull request #57513 from trollodel/gdscript_get_propertyinfo_classname
Allow setting the PropertyInfo class_name from GDScript custom properties
2022-06-15 10:48:01 -03:00
George Marques
1aa6e33bf5
Merge pull request #59358 from strank/debug-inner-classes 2022-06-15 10:37:18 -03:00
Rémi Verschelde
9839761e24
Merge pull request #59482 from kurtlachmann/lsp_better_parentheses 2022-06-15 15:31:35 +02:00
George Marques
67156aa4c2
Merge pull request #61666 from nathanfranke/fix-match-bind
gdscript: use correct error for unused bind match, suppress with underscore
2022-06-15 10:21:34 -03:00
George Marques
15740c37a3
Merge pull request #57151 from cdemirer/fix-match-array-dict-pattern-logic-error
Fix logic errors in match-statement Array & Dictionary patterns
2022-06-14 21:30:05 -03:00
strank
2079e19899 Extend test_compiler to also disassemble inner classes 2022-06-12 16:30:04 -04:00
Nathan Franke
3d61246bc4
use correct error for unused bind match, suppress with underscore 2022-06-03 13:28:33 -05:00
Rémi Verschelde
c881f607a9
Merge pull request #61463 from vnen/gdscript-await-stack
GDScript: Fix stack overflow when using multiple `await`
2022-05-31 12:44:50 +02:00
Rémi Verschelde
68bf4eb100
Merge pull request #61440 from vnen/gdscript-scene-unique-nodes
GDScript: Support `%` in shorthand for `get_node`
2022-05-31 12:36:37 +02:00
George Marques
eba3e0a9fc
GDScript: Support % in shorthand for get_node
The `%` is used in scene unique nodes. Now `%` can also be used instead
of `$` for the shorthand, besides being allowed generally anywhere in
the path as the prefix for a node name.
2022-05-27 13:46:18 -03:00
George Marques
328aadc0ef
GDScript: Fix stack overflow when using multiple await 2022-05-27 09:31:37 -03:00
Rémi Verschelde
f2a7bb6b51
Merge pull request #59943 from jordigcs/gdscript_warning_enums
Add enum values (Ignore, Warn, Error) to GDScript warnings
2022-05-26 00:52:01 +02:00
Rémi Verschelde
410b6b5f7d
Merge pull request #55099 from dalexeev/desc-by-blank-line
Use blank line instead of `@desc:` for doc comments
2022-05-25 19:14:43 +02:00
Rémi Verschelde
e465b72b9b
Merge pull request #61389 from snailrhymer/lookup-fix 2022-05-25 18:38:29 +02:00
Danil Alexeev
320cf5d84c
Use blank line instead of @desc: for doc comments 2022-05-25 19:01:41 +03:00
SnailRhymer
3a87d1acae Make Lookup Symbol recognize assert and preload in the script editor 2022-05-25 16:41:10 +01:00
Rémi Verschelde
6369e495fd
Merge pull request #61279 from Trioct/fix-typed-array-assignment 2022-05-25 17:28:22 +02:00
Trioct
bcbfa641ec Fix const typed array assignment 2022-05-25 09:02:11 -05:00
SnailRhymer
688a62d841 Fix lookup_code to properly handle symbols at start of assignments 2022-05-25 11:45:57 +01:00
George Marques
24bcbe971a
GDScript: Don't show redundant await warning on unknown types
Also avoid it when the type is known to be a signal.
2022-05-24 14:37:50 -03:00
George Marques
1b76a9d705
GDScript: Fix lambda captures in default argument values 2022-05-23 21:38:31 -03:00
George Marques
969f1980d2
GDScript: Fix if after lambda being seen as ternary 2022-05-23 21:13:25 -03:00
George Marques
0a28b4cd94
GDScript: Do not allow standalone lambdas
They cannot be accessed in this case, so an error is shown to avoid
misleading the uses, especially in case of named lambdas.
2022-05-23 12:25:03 -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
Aaron Record
900c676b02 Use range iterators for RBSet in most cases 2022-05-19 12:09:16 +02:00
Rémi Verschelde
cdc5da7460
Merge pull request #61025 from Chaosus/gds_fix_extend_crash 2022-05-18 16:17:18 +02:00
Rémi Verschelde
e22255edaf
Merge pull request #55201 from Scony/fix-unreachable-code-false-positive 2022-05-18 16:04:12 +02:00
Yuri Rubinsky
5d95a5a024 Fix crash when extending inner class in GDScript 2022-05-18 16:53:24 +03:00
Rémi Verschelde
5b02415fd0
Merge pull request #55134 from KoBeWi/script_pillow_or_something
Always soft-reload scripts
2022-05-17 15:09:09 +02:00
Rémi Verschelde
c41f62c3df
Merge pull request #61003 from vnen/gdscript-await-stack-fix 2022-05-16 14:10:29 +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
George Marques
102c312497
GDScript: Fix stack manipulation for await
The stack now contains three special addresses that should no be copied
to the state, since it contains references that creates cycles. They can
be recreated when the function is resumed.

This commit also removes the clearing of stack from the
GDScriptFunctionState destructor, since it should be cleared when the
function exits. The state stack should only be cleared manually if the
instance is freed before the state resumes (which is already being
done). Otherwise this would destruct the stack twice, causing crashes.
2022-05-13 20:15:34 -03:00
JoJoX
8870e1c75d Fix first value update 2022-05-12 19:11:33 -04:00
Yuri Rubinsky
a439832035 Fix signal completion in GDScript editor 2022-05-12 16:10:48 +03:00
reduz
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Yuri Rubinsky
be8eb6625e Fix incorrect precedence of pow operator in GDScript 2022-05-12 10:09:51 +03:00
Yuri Roubinsky
dbd7a31507 Implement exponential operator (**) to GDScript/Expressions 2022-05-11 16:30:37 +03:00
Rémi Verschelde
9963ae3553
Merge pull request #59863 from cdemirer/fix-match-multiple-bind-single-pattern
Fix issues with multiple bind patterns in match statement
2022-05-11 14:18:02 +02:00
Rémi Verschelde
c171f675c8
Merge pull request #60229 from Dorodri/improve-gdscript-range-description 2022-05-11 14:17:39 +02:00
Rémi Verschelde
505e15c523
Merge pull request #60732 from CalebJohn/matching_signature_regression_test 2022-05-11 14:15:48 +02:00
Rémi Verschelde
f4ece7e736
Merge pull request #60609 from nathanfranke/string-quotes 2022-05-06 08:59:08 +02:00
Rémi Verschelde
84f64ddde9
Merge pull request #60723 from reduz/refactor-module-initialization 2022-05-04 19:08:43 +02:00
reduz
de0ca3b999 Refactor module initialization
* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
2022-05-04 17:34:51 +02:00
CalebJohn
06a2d83e30 Add regression test for gdscript valid function signature
Previously, there was an issue where the gdscript analyzer incorrectly
riased a validation error for code that had a default Dictionary, Array,
or custom type.
2022-05-03 12:46:09 -07:00
Nathan Franke
58fcad20ef
quote strings inside arrays and dictionaries 2022-05-03 13:37:13 -05:00
Hugo Locurcio
180e5d3028
Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
Rémi Verschelde
c273ddc3ee Style: Partially apply clang-tidy's cppcoreguidelines-pro-type-member-init
Didn't commit all the changes where it wants to initialize a struct
with `{}`. Should be reviewed in a separate PR.

Option `IgnoreArrays` enabled for now to be conservative, can be
disabled to see if it proposes more useful changes.

Also fixed manually a handful of other missing initializations / moved
some from constructors.
2022-05-02 16:28:25 +02:00
Eduardo Rodrigues
b2841ce194 Improve description for GDScript built-in range
Rewrites the definition of how the function works.
Reworks the style of the examples and adds a negative range example.
Changes the while loop to a range loop in the array backwards example.
2022-04-30 15:17:17 -03:00
Markus Sauermann
a793960a10 Fix cppcheck const parameters
Convert method signature parameters to const where it is possible

# Conflicts:
#	drivers/gles3/rasterizer_canvas_gles3.cpp
#	drivers/gles3/rasterizer_canvas_gles3.h
#	editor/plugins/animation_state_machine_editor.cpp
#	editor/plugins/animation_state_machine_editor.h
2022-04-28 11:35:39 +02:00
Rémi Verschelde
f626e8ef91
Merge pull request #60396 from vnen/gdscript-self-lambda 2022-04-27 13:11:24 +02:00
Rémi Verschelde
3dd550e1ca
Merge pull request #59613 from PastMoments/dict-arr-const-fix 2022-04-27 12:45:30 +02:00
Rémi Verschelde
cb5f3a39b9
Merge pull request #60418 from ShimmyShaman/master 2022-04-26 11:11:08 +02:00
Rémi Verschelde
bef00b2b0d
Merge pull request #60445 from nathanfranke/minor-changes
small changes: improve OS.get_name classref, misc/scripts fixes, remove trailing quote
2022-04-25 23:10:48 +02:00
George Marques
01d13ab2c1
GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
Nathan Franke
1304d72fc1
improve OS.get_name classref, misc/scripts fixes, remove trailing quote 2022-04-22 17:13:08 -05:00
ShimmyShaman
b3922a42e9 improved error msg for gdscript load_source_code 2022-04-22 16:10:48 +12:00
Yuri Roubinsky
540fca147d Fix typo in GDScript::range doc 2022-04-20 19:38:49 +03:00
PastMoments
b3704e664d Fixes GDScript define nested dictionary and array as constants #50285 2022-04-19 08:57:23 -04:00
Rémi Verschelde
7032b111ce
Merge pull request #60007 from aaronfranke/gds-op-adj-tr3d
GDScript: Rename OPCODE_TYPE_ADJUST_TRANSFORM to have a 3D suffix
2022-04-15 08:17:27 +02:00
bruvzg
4bf99f4af2 Narrow FileAccess scope to prevent deadlocks. 2022-04-12 10:54:39 +03:00
bruvzg
9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
George Marques
cdbd6056ef
GDScript: Fix method call on singletons 2022-04-08 12:20:57 -03:00
Aaron Franke
f3eca5abef
GDScript: Rename OPCODE_TYPE_ADJUST_TRANSFORM to have a 3D suffix 2022-04-07 23:32:56 -05:00
David Maziarka
1f62965d26 Add built-in Variant types to autocompletion list
Co-authored-by: Gustav <gusan092@student.liu.se>
2022-04-07 11:10:19 -05:00
Rémi Verschelde
4d0fdf2e98
Merge pull request #59947 from vnen/gdscript-static-methods-classdb 2022-04-06 20:57:34 +02:00
George Marques
4710e2b278
GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
jordi
14bad75206 Add enum values (Ignore, Warn, Error) to GDScript warnings 2022-04-06 10:57:33 -05:00
bruvzg
f851c4aa33
Fix some issues found by cppcheck. 2022-04-06 14:34:37 +03:00
Rémi Verschelde
db8e6bd83f
Merge pull request #59885 from Jayman2000/autoload-inheritance-message 2022-04-04 23:56:20 +02:00
Jason Yundt
1cc7e7ec33 Improve autoload inheritance error message
Autoloaded scripts should always inherit from Node. When you run a
project that tries to autoload a script which doesn’t inherit from Node,
then Godot gives an error.

Before this change, the error said “Script does not inherit a Node”.
That error message is a little bit misleading. If a class inherits a
Node, then one of its superclasses has a Node. If a class inherits
_from_ Node, then one of its superclasses is Node. This change corrects
that mistake.

Fixes #59884.
2022-04-04 15:51:02 -04:00
Rémi Verschelde
f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +02:00
cdemirer
3c5b9d1be3 Fix issues with multiple bind patterns in match statement 2022-04-04 15:47:08 +08:00
Rémi Verschelde
c630c2001d
Merge pull request #59633 from EricEzaM/better-code-complete-update
Improve sorting of Code Completion options.
2022-04-03 12:34:00 +02:00
Eric M
4ab605d14d Improve sorting of Code Completion options.
Done by ordering options by their location in the code - e.g. local, parent class, global, etc.
2022-04-01 20:39:09 +10:00
bruvzg
947d7c8329
Fix some issues found by clang sanitizers. 2022-03-31 18:35:56 +03:00
Rémi Verschelde
a647fb3e62 Fix typos with codespell
Using codespell 2.2-dev from current git.

Fix a couple incorrect uses of gendered pronouns.
2022-03-31 14:07:29 +02:00
Rémi Verschelde
5ba3b993d5
Merge pull request #59694 from vnen/gdscript-better-call-super 2022-03-30 17:58:11 +02:00
George Marques
be718285f7
GDScript: Fix issues with completion and super calls
- Make call errors use the call node instead of the calle, which will be
  empty on super calls.
- Don't allow `super()` to be used within lambdas.
2022-03-30 11:58:29 -03:00