Commit graph

74 commits

Author SHA1 Message Date
bruvzg
0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
Micky
dd26ecdd31 Rename CONNECT_ONESHOT TO CONNECT_ONE_SHOT
For consistency. Every other exposed `one_shot` is spaced out like this.
2022-09-06 19:00:33 +02:00
Juan Linietsky
d4433ae6d3 Remove Signal connect binds
Remove the optional argument p_binds from `Object::connect` since it was deprecated by Callable.bind().
Changed all uses of it to Callable.bind()
2022-07-29 16:26:13 +02:00
Rémi Verschelde
fb086d44cf
Merge pull request #63560 from V-Sekai/named_global_crashfix 2022-07-28 09:03:01 +02:00
SaracenOne
1307577932 Prevent hard crash in GDScriptVM when a named global can not be found. 2022-07-27 23:37:42 +01:00
reduz
455c06ecd4 Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.

* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.

These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.

**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-23 14:00:01 +02:00
kobewi
e9344f5154 Remove outdated code path 2022-07-10 20:48:33 +02:00
Rémi Verschelde
622b656c40
Merge pull request #53135 from briansemrau/fix-ref-leak 2022-06-28 17:26:44 +02:00
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
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
Black Cat
5c365713ca Do not reset return value in release build 2022-06-22 20:55:09 +04:00
George Marques
328aadc0ef
GDScript: Fix stack overflow when using multiple await 2022-05-27 09:31:37 -03: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
George Marques
01d13ab2c1
GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
Aaron Franke
f3eca5abef
GDScript: Rename OPCODE_TYPE_ADJUST_TRANSFORM to have a 3D suffix 2022-04-07 23:32:56 -05:00
George Marques
4710e2b278
GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
reduz
21637dfc25 Remove VARIANT_ARG* macros
* Very old macros from the time Godot was created.
* Limited arguments to 5 (then later changed to 8) in many places.
* They were replaced by C++11 Variadic Templates.
* Renamed methods that take argument pointers to have a "p" suffix. This was used in some places and not in others, so made it standard.
* Also added a dereference check for Variant*. Helped catch a couple of bugs.
2022-03-09 18:39:13 +01:00
SaracenOne
62d87fbd8b Return a correctly typed variant in case of a function error to prevent hard crashes 2022-02-17 15:45:19 +00:00
Pedro J. Estébanez
7b0ed2aa5e Rename Variant::is_ref() to is_ref_counted() 2022-01-20 18:46:25 +01:00
Rémi Verschelde
b3d208385f
Merge pull request #56409 from cdemirer/fix-unexpected-copying-when-parameter-is-typed 2022-01-10 17:03:47 +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
cdemirer
511e699fee Fix unexpected Packed Array copying when parameter is typed 2022-01-02 05:43:52 +08: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
Hugo Locurcio
605784f019
Remove hash symbol in front of opcode error messages in GDScript
The hash symbol creates spurious issue references on GitHub if
the message is posted outside a code block, which means some issues
have a lot more references than originally intended.
2021-11-09 12:20:16 +01:00
Rémi Verschelde
3b11e33a09
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 15:19:35 +02:00
Rémi Verschelde
4387f9645b
Merge pull request #52940 from groud/toast_notification 2021-10-19 09:57:13 +02:00
George Marques
056a54db7b
GDScript: Properly return value with await on non-coroutine
If the keyword `await` is used without a coroutine, it should still
return the value synchronally.
2021-10-14 19:58:10 -03:00
Gilles Roudière
0587e5e018 Implement toast notifications in the editor 2021-10-14 13:30:54 +02:00
George Marques
082f624ef4
GDScript: Fix method ptrcall on release 2021-10-07 15:08:21 -03:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Brian Semrau
6141ce2cb8 GDScript Don't double-reference Refs returned from native function 2021-09-28 12:40:23 -04:00
Pedro J. Estébanez
0fa574c051 Fix check for freed object during cast 2021-09-27 19:35:26 +02:00
Pedro J. Estébanez
ee238b2a4d Fix inverted error messages about null object 2021-09-27 13:58:46 +02:00
kobewi
7bf5fc709e Remove binds from Signal.connect 2021-09-24 17:07:33 +02:00
Rémi Verschelde
1c7aec9d9c
Merge pull request #51094 from RandomShaper/error_cast_freed_object
Complain if casting a freed object in a debug session
2021-09-14 21:48:10 +02:00
Pedro J. Estébanez
ddc7d7ee66 Complain if casting a freed object in a debug session
The idea is to give the user a chance to realize a mistake that will cause a crash in a release build (or with no debugger attached).
2021-09-14 21:07:00 +02:00
George Marques
3d13588057
GDScript: Fix loading of interdependent autoloads
Move the autoload resolution to runtime by loading it into the stack
with an extra instruction. This allows an autoload to use another
autoload singleton independent of load order.
2021-09-01 16:06:30 -03:00
George Marques
a685535ad5
Fix initialization of objects in VariantInternal 2021-08-19 20:19:47 -03:00
Julien Nguyen
d6ae7edd80 Fix "super" call when having at least one argument 2021-06-13 17:46:03 +02:00
Marcel Admiraal
8acd13a456 Rename Quat to Quaternion 2021-06-04 18:14:32 +01:00
Aaron Franke
08a85352fb
Rename Variant TRANSFORM to TRANSFORM3D
Also _transform to _transform3d
2021-06-03 07:30:01 -04:00
Aaron Franke
de3f6699a5
Rename Transform to Transform3D in core 2021-06-03 07:30:01 -04:00
Rémi Verschelde
4219a4cb6f
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:38:56 +02:00
Rémi Verschelde
2fcfc83da9
Merge pull request #48793 from vnen/gdscript-fix-temp-type-adjust
GDScript: Fix crash caused by uninitialized temp stack slots
2021-05-17 17:34:19 +02:00
George Marques
10a1f64968
GDScript: Fix crash caused by uninitialized temp stack slots
This adds initialization to every typed temporary stack slot at the
beginning of the function call instead of emitting instructions, since
those might be in a conditional branch and not be called.
2021-05-17 10:59:43 -03:00
George Marques
ec783dd885
GDScript: Add support for builtin static method calls 2021-05-16 11:54:33 -03:00
George Marques
c201b212c7
GDScript: Implement lambdas compilation and runtime 2021-04-28 11:09:38 -03:00