Commit graph

275 commits

Author SHA1 Message Date
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 5704055d30 Fix cyclic references in GDScript 2.0 2022-11-18 16:41:31 -05:00
Rune 61df8f4484 GDScript Compiler: regression fix 2022-11-15 22:20:49 -06:00
Rune bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
Yuri Rubinsky f11b66b084 Fix named enums to use int64 type 2022-11-08 11:20:28 +03:00
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
Andy Maloney 127e2333f4 Remove redundant "if" condition in GDScriptCompiler::_parse_function()
Looking at the original PR, I believe this is the original intent, but it now means that previously dead code is now executed.
2022-09-24 12:30:43 -04:00
Fabio Alessandrelli ca7d572908 [Net] Modularize multiplayer, expose MultiplayerAPI to extensions.
- RPC configurations are now dictionaries.
- Script.get_rpc_methods renamed to Script.get_rpc_config.
- Node.rpc[_id] and Callable.rpc now return an Error.
- Refactor MultiplayerAPI to allow extension.
- New MultiplayerAPI.rpc method with Array argument (for scripts).
- Move the default MultiplayerAPI implementation to a module.
2022-07-26 09:31:12 +02:00
cdemirer 52781535a3 Check for parameters shadowing class members 2022-07-18 00:28:27 +03:00
Yuri Sizov f85bafaa11 Add grouping annotations for class properties in GDScript 2022-07-05 22:01:40 +03:00
cdemirer a0608bd891 Fix set chain bug with jump_if_shared 2022-06-28 18:45:27 +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
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
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
bruvzg 860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +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
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
Yuri Rubinsky 5d95a5a024 Fix crash when extending inner class in GDScript 2022-05-18 16:53:24 +03: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
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
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
George Marques 01d13ab2c1
GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
George Marques cdbd6056ef
GDScript: Fix method call on singletons 2022-04-08 12:20:57 -03:00
George Marques 4710e2b278
GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
Rémi Verschelde 79bbe57244
Merge pull request #56830 from strank/parent-signals 2022-03-04 17:29:49 +01:00
Rémi Verschelde 4bbd7417c4
Merge pull request #58320 from mphe/fix_object_typed_arrays 2022-03-04 14:49:06 +01:00
cdemirer 3afe50c2fa Fix logic errors in match-statement Array & Dictionary Patterns 2022-03-02 19:05:18 +08:00
Marvin Ewald cea0630fef Fix typed arrays for Object based types
Fixes https://github.com/godotengine/godot/issues/53771.
2022-02-19 16:27:06 +01:00
SaracenOne ab2a8bd1d8 Fix using typed arrays based on script classes 2022-02-17 17:34:53 +00:00
strank dcf19f8914 Fix "Identifier not found" compiler error when accessing inherited signals or functions as callables. 2022-02-11 20:45:04 -05:00
George Marques ceafdf347e
GDScript: Treat enum values as int and enum types as dictionary
Since enums resolve to a dictionary at runtime, calling dictionary
methods on an enum type is a valid use case. This ensures this is true
by adding test cases. This also makes enum values be treated as ints
when used in operations.
2022-02-03 13:32:34 -03:00
George Marques ad6e2e82a9
GDScript: Consolidate behavior for assigning enum types
This makes sure that assigning values to enum-typed variables are
consistent. Same enum is always valid, different enum is always
invalid (without casting) and assigning `int` creates a warning
if there is no casting.

There are new test cases to ensure this behavior doesn't break in
the future.
2022-02-03 13:32:16 -03:00
strank 960a26f6c0 GDScript: Fix parsing default parameter values from function calls 2022-01-13 19:28:39 -05:00
SaracenOne 64d8b3aef2 Assign member type when parsing setters to prevent
'Compiler bug: unresolved assign' errors
2022-01-11 11:23:17 +00:00
Rémi Verschelde cc7f634066
Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation 2022-01-10 17:12:34 +01:00
Rémi Verschelde c8b4fe3b8d
Merge pull request #56287 from cdemirer/fix-member-property-only-getter-cant-be-set 2022-01-10 17:12:06 +01:00
Rémi Verschelde 1fd5954962
Merge pull request #56288 from cdemirer/fix-member-property-getter-dont-update-subscript-chain-root 2022-01-10 17:10:57 +01:00
Ger Hean 609964848d Fix leak when function returning self type
Leak is caused by cyclic reference
2022-01-10 02:14:48 +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
cdemirer bb9469aa65 Fix member properties with getters don't update as subscript chain root 2021-12-28 07:52:44 +08:00
cdemirer e8305e17ff Fix member properties with only getters can't be set 2021-12-28 07:51:18 +08:00
cdemirer 067b4c8c07 Fix type mutation upon compound assignment 2021-12-27 03:32:22 +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
George Marques d36213bab8
GDScript: Make sure calls don't use return when not needed 2021-10-14 19:55:45 -03:00
ZuBsPaCe 551ceb590b GDScript: Report property type errors
Inline getters & setters are now FunctionNodes.
Their names are set in the parser, not in the compiler.
GDScript-Analyzer will now run through getter and setter.
Also report wrong type or signature errors regarding getset properties.
Added GDScript tests for getters and setters.
#53102
2021-10-08 22:06:15 +02:00
Brian Semrau c18a27a9cd GDScript fix wrong base class assignment 2021-10-04 20:38:08 -04:00
George Marques 84956fee4b
GDScript: Fix member assignment with operation
It was wrongly updating the assigned value with the result of the
operation.
2021-10-04 14:09:54 -03:00
Lightning_A c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
George Marques 991f4d8527
GDScript: Fix assignment with operation for properties 2021-09-29 10:54:16 -03:00
George Marques 5a612d61b9
Merge pull request #49765 from Blackiris/fix-assignment-with-operator-on-type-member
Fix assignment with operator on type member
2021-09-15 10:56:20 -03:00
George Marques 5d31ce4b16
GDScript: Allow string keys on Lua-style dictionaries
Which is useful when the key isn't a valid identifier, such as keys with
spaces or numeric keys.
2021-09-15 09:56:24 -03:00
Rémi Verschelde ffe8412291
Merge pull request #52323 from vnen/gdscript-singleton-interdependence-fix
Fix loading of interdependent autoloads
2021-09-13 21:10:34 +02:00
Fabio Alessandrelli bf9aae09ba [Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir.

Move the RPCConfig and enums (TransferMode, RPCMode) to a separate
file (multiplayer.h), and bind them to the global namespace.

Move the RPC handling code to its own class (RPCManager).

Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-09-07 11:14:30 +02:00
SaracenOne 84852585b9 Check for GDScript member and class naming conflicts in a variety of conditions. 2021-09-02 07:16:06 +01: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
Julien Nguyen 9bc5119d4e Fix assignment with operator on type member 2021-08-21 21:56:11 +02:00
George Marques 89695da337
GDScript: Fix memory leak when using self class as type 2021-08-18 18:58:45 -03:00
Julien Nguyen 51b7179b5a Fix infinite loop when creating a newly inherited GdScript file 2021-08-09 23:52:31 +02:00
Rémi Verschelde ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Aaron Franke 4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Fabio Alessandrelli ddb68f76ff [Net] Single rpc annotation. "sync" no longer part of mode.
- Move the "sync" property for RPCs to RPCConfig.

- Unify GDScript annotations into a single one:
  - `@rpc(master)` # default
  - `@rpc(puppet)`
  - `@rpc(any)` # former `@remote`

- Implement three additional `@rpc` options:
  - The second parameter is the "sync" option (which also calls the
    function locally when RPCing). One of "sync", "nosync".
  - The third parameter is the transfer mode (reliable, unreliable,
    ordered).
  - The third parameter is the channel (unused for now).
2021-07-20 11:17:59 +02:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Pedro J. Estébanez 04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
Lyuma 771190a9db Fix regression from 160c260 causing export of non-@export properties. 2021-06-10 20:35:58 -07:00
Rémi Verschelde 59b524ae4c
Merge pull request #49067 from JFonS/fix_gcc_warnings
Fix some warnings raised by GCC-11.1
2021-06-01 10:47:37 +02:00
George Marques c7459e3855
GDScript: Use analyzer data to decide assignment conversion
Since there might be tricky cases in the analyzer (in the case of unsafe
lines) which would need to be properly checked again. Instead, this
splits the code generator in two functions and use information set by
the analyzer to tell which function to use, without a need to re-check.
2021-05-26 14:09:00 -03:00
jfons f8e34209af Fix some warnings raised by GCC-11.1 2021-05-25 17:23:53 +02:00
George Marques cdb3726fe6
Merge pull request #48347 from Blackiris/fix-temporary-key-not-released
GDScript: Fix temporary value not released when used as a dictionary key
2021-05-17 18:50:25 -03:00
George Marques ec783dd885
GDScript: Add support for builtin static method calls 2021-05-16 11:54:33 -03:00
Julien Nguyen 82522662f8 Fix temporary value not released when used as a dictionary key 2021-05-06 22:13:05 +02:00
George Marques c201b212c7
GDScript: Implement lambdas compilation and runtime 2021-04-28 11:09:38 -03:00
George Marques 1e4ff2ede6
GDScript: Make sure Lua-style dicts use StringName as keys 2021-04-23 16:00:23 -03:00
George Marques c7511de02e
GDScript: Fix resolution of dictionary keys
There was a mixup between String and StringName keys. Now they're
clearly separated. This also means you have to consider which type
you're using for the dictionary keys and how you are accessing them.
2021-04-23 15:42:33 -03:00
George Marques 40502a1689
GDScript: Pool temporary values by type on the stack
So the stack slots perform less type changes, which is useful for
future optimizations.
2021-04-14 14:35:51 -03:00
George Marques cf4079cb5f
Reduce number of addressing modes in GDScript VM
There's now only 3 addressing modes: stack, constant, and member.

Self, class, and nil are now present respectively in the first 3 stack
slots. Global and class constants are moved to local constants when
compiling. Named globals is only present on editor to use on tool
singletons, so its use now emits a new instruction to copy the global to
the stack.

This allow us to further optimize the VM later by embedding the
addressing modes in the instructions themselves, which is better done
with less permutations.
2021-04-08 14:29:55 -03:00
Julien Nguyen 43c1c680f0 Fix stack overflow in setter 2021-04-06 19:00:08 +02:00
Julien Nguyen 3168c2a513 Fix GDScript variables addresses getting mixed 2021-04-04 19:03:15 +02:00
George Marques 160c260495
GDScript: Allow export of enum variables
Also fix the enum type in variables to be integer.
2021-03-30 08:29:38 -03:00
George Marques 85e316a5d5
Add typed arrays to GDScript
- Use `Array[type]` for type-hints. e.g.:
  `var array: Array[int] = [1, 2, 3]`
- Array literals are typed if their storage is typed (variable
  asssignment of as argument in function all). Otherwise they are
  untyped.
2021-03-29 10:45:48 -03:00
Rémi Verschelde 6edb0a75ab
Merge pull request #46936 from DavidSichma/match_temp_header
Fixed match test expression for temporaries
2021-03-14 15:46:53 +01:00
David Sichma 762bb5843b
Fixed match test expression for temporaries
Fixed that a potentially popped temporary was used for the value in
match statements.
2021-03-12 15:04:45 +01:00
Anshul7sp1 91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
David Sichma 66a5002750
Fixed match for expression pattern
equality comparison now writes to right target address
2021-03-02 19:18:29 +01:00
Thakee Nathees 9869522e6a false positive "Identifier not found" error or signals fixed 2021-02-24 19:34:01 +05:30
Rémi Verschelde c17413f159
Merge pull request #44104 from nekomatata/coroutine-await-fix
Fix error when calling coroutine with await in _ready
2021-01-11 13:54:04 +01: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
Marcel Admiraal 5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
PouleyKetchoupp 2e4ee06b7a Fix error when calling coroutine with await in _ready
The code paths for calling async functions seemed to be missing in some
cases, causing a debug break and false positive error.
2020-12-17 09:01:39 -07:00
Rémi Verschelde abfc528439
Merge pull request #43890 from vnen/gdscript-builtin-functions-refactor
GDScript: Refactor builtin functions
2020-12-15 20:51:38 +01:00
PouleyKetchoupp 87d73faa66 Fix base script not initialized properly in some cases
Storing script references to pointer only in result.script_type could
lead to losing the last reference, causing further conversions from
Script* to Ref<Script> to fail.

Now result.script_type_ref is always set first, and then cleared in the
specific case of the script being the owner, to avoid cyclic reference
issues.
2020-12-06 08:20:33 -07:00
Rémi Verschelde d1231be1c8
Merge pull request #41095 from ThakeeNathees/GDScript-Documentation
GDScript(2.0) Documentation generation system
2020-12-02 14:15:38 +01:00
George Marques 0019aa940e
Merge pull request #41773 from ThakeeNathees/default-argument-override-buf-fix
GDScript default argument override bug fix
2020-12-02 09:54:47 -03:00
Thakee Nathees 42bfa16996 Refactor DocData into core and editor (DocTools) parts 2020-12-02 00:48:39 +05:30
Thakee Nathees d0e7d9b62f Documentation generation for GDScript
- ClassDoc added to GDScript and property reflection data were extracted
from parse tree

- GDScript comments are collected from tokenizer for documentation and
applied to the ClassDoc by the GDScript compiler

- private docs were excluded (name with underscore prefix and doesn't
have any doc comments)

- default values (of non exported vars), arguments are extraced from the
parser

- Integrated with GDScript 2.0 and new enums were added.

- merge conflicts fixed
2020-11-29 19:45:36 +05:30
Thakee Nathees d42b305377 GDScript default argument override bug fix
Fix: #41766
2020-11-28 20:42:57 +05:30
George Marques 0cb185927c
GDScript: Improve handling of operators
- Use the new functions in Variant to determine the validity and resulting
  type of operators.
- Split the operator function in codegen between binary and unary, since
  the unary ones have now a special requirement of having the second
  argument to be the NIL type when requesting info.
2020-11-26 14:41:55 -03:00
George Marques c7b6a7adcc
GDScript: Refactor builtin functions
They are now called "utility functions" to avoid confusion with methods
of builtin types, and be consistent with the naming in Variant.

Core utility functions are now available in GDScript. The ones missing
in core are added specifically to GDScript as helpers for convenience.

Some functions were remove when there are better ways to do, reducing
redundancy and cleaning up the global scope.
2020-11-26 12:05:42 -03:00
Rémi Verschelde fc28de64c4
Merge pull request #43856 from vnen/gdscript-some-fixes
A couple of GDScript fixes
2020-11-25 17:13:41 +01:00
George Marques ed3d8f31df
GDScript: Fix return of cast expression on compilation
It was mistakenly returning the source instead of the result.
2020-11-25 11:37:51 -03:00
George Marques 2e528ef382
GDScript: Fix mishandling of stack pointers
- Replace the for loop temporaries by locals. They cause conflicts with
  the stack when being popped, while locals are properly handled in the
  scope.
- Change the interface for the codegen so the for loop list doesn't live
  through the whole block if it's a temporary.
- Keep track of the actual amount of local variables in the stack. Using
  the size of the map is misleading in cases where multiple locals have
  the same name (which is allowed when there's no shadowing).
- Added a few debug checks for temporaries, to avoid them being wrongly
  manipulated in the future. They should not live more than a line of
  code.
- Rearrange some of compiler code to make sure the temporaries don't
  live across blocks.
2020-11-25 11:24:13 -03:00
George Marques 52ab64db69
GDScript: Add faster call instructions for builtin methods
Methods from builtin types can be called by using the function pointer
when the argument and base types are known at compile time.
2020-11-21 13:24:50 -03:00
George Marques d8b22097f2
GDScript: Add faster call instructions for native methods 2020-11-21 13:24:50 -03:00
George Marques 8bcd345782
GDScript: Fix native class not set with inheritance 2020-11-13 10:35:24 -03:00
Pedro J. Estébanez 95828161d4 Prevent cyclic reference between script and its members 2020-09-10 01:26:07 +02:00
bruvzg d73609c774
Fix GDScript codegen leak. 2020-09-02 22:42:49 +03:00
George Marques 745ca3059d
Change GDScript compiler to use codegen abstraction 2020-09-01 14:36:22 -03:00
George Marques 8ccf88a206
GDScript: Fix issues when deriving from other scripts 2020-08-26 14:50:27 -03:00
George Marques 722be9aaef
GDScript: Don't fail to load constants if they're not a literal
It's still okay as long as it's a constant value. This should already
been validated by the analyzer.
2020-08-24 09:15:33 -03:00
George Marques e6b44b93c3
GDScript: Allow "new()" to be called in non-static functions 2020-07-24 13:45:23 -03:00
George Marques a0f54cb95e
Wrap up GDScript 2.0 base implementation 2020-07-22 11:07:51 -03:00
George Marques aa09b4f85d
Reintroduce code completion 2020-07-20 11:38:40 -03:00
George Marques 9a76ab8b6a
Add new GDScript type checker 2020-07-20 11:38:40 -03:00
George Marques 886732ac2b
Add support for properties 2020-07-20 11:38:39 -03:00
George Marques 5d6e853806
New GDScript tokenizer and parser
Sometimes to fix something you have to break it first.

This get GDScript mostly working with the new tokenizer and parser but
a lot of things isn't working yet. It compiles and it's usable, and that
should be enough for now.

Don't worry: other huge commits will come after this.
2020-07-20 11:38:39 -03:00
Rémi Verschelde d341181f30
Merge pull request #38067 from ThakeeNathees/elif-error-line-fixed
GDScript debugger incorrect error line fixed
2020-06-17 19:17:44 +02:00
Thakee Nathees 9325671faa GDScript debugger incorrect error line fixed
if the first line of an else or an elif throws a runtime error the
debugger shows incorrect line number.
2020-06-17 21:24:01 +05:30
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 69de7ce38c Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine
Part of #33027.
2020-05-10 13:13:54 +02:00
Rémi Verschelde e956e80c1f Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
2020-05-10 13:12:16 +02:00
lupoDharkael 95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde cb282c6ef0 Style: Set clang-format Standard to Cpp11
For us, it practically only changes the fact that `A<A<int>>` is now
used instead of the C++03 compatible `A<A<int> >`.

Note: clang-format 10+ changed the `Standard` arguments to fully
specified `c++11`, `c++14`, etc. versions, but we can't use `c++17`
now if we want to preserve compatibility with clang-format 8 and 9.
`Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-17 07:36:24 +01:00
Fabio Alessandrelli b8ddaf9c33 Refactor ScriptDebugger.
EngineDebugger is the new interface to access the debugger.
It tries to be as agnostic as possible on the data that various
subsystems can expose.

It allows 2 types of interactions:

- Profilers:
  A subsystem can register a profiler, assigning it a unique name.
  That name can be used to activate the profiler or add data to it.
  The registered profiler can be composed of up to 3 functions:
    - Toggle: called when the profiler is activated/deactivated.
    - Add: called whenever data is added to the debugger
      (via `EngineDebugger::profiler_add_frame_data`)
    - Tick: called every frame (during idle), receives frame times.

- Captures: (Only relevant in remote debugger for now)
  A subsystem can register a capture, assigning it a unique name.
  When receiving a message, the remote debugger will check if it starts
  with `[prefix]:` and call the associated capture with name `prefix`.

Port MultiplayerAPI, Servers, Scripts, Visual, Performance to the new
profiler system.

Port SceneDebugger and RemoteDebugger to the new capture system.
The LocalDebugger also uses the new profiler system for scripts
profiling.
2020-03-08 12:36:39 +01:00
Juan Linietsky 69c95f4b4c Reworked signal connection system, added support for Callable and Signal objects and made them default. 2020-02-20 08:24:50 +01:00
ChibiDenDen 86aa12e806 Keep a weak reference to orphan subclasses to reuse on class reload 2020-01-15 22:54:01 +02:00
Dani Frank d6f10cd08e Add fully_qualified_name for GDScript class 2020-01-14 17:33:33 +02:00
George Marques cc9ca9eb34
GDScript: Don't re-evaluate index on assigment with operation
Pass the calculated index from the stack and use the same to get and set
the value. This avoids a function with side effects being evaluated
twice when using indexing in an assignment with operation statement
(e.g. a[function()] += 1).
2020-01-09 10:43:29 -03:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
George Marques 475d7f0e52
GDScript: Fix type conversion in assignment with operation 2019-12-13 12:51:08 -03:00
Rémi Verschelde fdc2463a1b
Merge pull request #32150 from luzpaz/typos
Fix misc. source comment typos
2019-09-20 17:09:05 +02:00
luz.paz 91ecd7b6a6 Fix misc. source comment typos
Found using `codespell -q 3 -S ./thirdparty,*.po -L ang,ba,cas,dof,doubleclick,fave,hist,leapyear,lod,nd,numer,ois,paket,seeked,sinc,switchs,te,uint -D ~/Projects/codespell/codespell_lib/data/dictionary.txt `
2019-09-19 14:36:52 -04:00
Mitch Curtis aa8e3e7b0f GDScript: add an optional message parameter to assert()
Before this patch, assert() only took the condition to assert on:

    assert(item_data)

Now, it can optionally take a string that will be printed upon failure:

    assert(item_data, item_name + " has no item data in ItemDatabase")

This makes it easier to immediately see what the issue is by being
able to write informative failure messages.

Thanks to @wiped1 for sharing their patch, upon which this is based.

Closes #17082
2019-09-11 15:37:11 +02:00
Robin Hübner 6ab118c464 Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in "platform", "modules/gdnative", "modules/gdscript" directories. 2019-08-09 11:13:24 +02:00
qarmin 3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
qarmin 4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
geequlim eed5967c02 Fix GDSCript inner classes be freed after compile 2019-06-02 19:57:33 +08:00
Bojidar Marinov f04f127680
Fix as operator generating opcode 38 errors
Closes #27489
Fixup of 466a76ac2c

Additionally, update `GDScriptCompiler` test to use Ref and to include `as` expressions.
2019-04-10 13:18:50 +03:00
Rémi Verschelde 492153878f
Merge pull request #27128 from bojidar-bg/27111-gdscript-confounding-class
Fix GDScriptCompiler bugging out with identically-named inner class
2019-03-27 16:57:04 +01:00
Bojidar Marinov 466a76ac2c
Fix GDScriptCompiler bugging out with identically-named inner class
Fixes #27111
2019-03-16 20:41:16 +02:00
Bojidar Marinov b64f9f03f8
Fix duplicated lines in GDScript bytecode
Fixes #26789
2019-03-14 18:38:07 +02:00
marxin 8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
Rémi Verschelde d35003d92a GDScript: Remove unused switch, case and do CF keywords
They had been reserved for future implementation, but we now have the
`match` CF keyword which does the same and more.

According to @reduz `do` was even added by mistake when copying from
the shader language parser, it was never intended to add support for
`do`... `while` loops, as the syntax would be awkward in GDScript,
and the added sugar is not worth it.

Fixes #25787.
2019-02-20 14:05:08 +01:00
George Marques 30f02dd421 GDScript compiler: check if subclass exists before comparison
Otherwise these checks might trigger the insertion of an empty value,
leading to crashes.
2019-01-17 14:38:28 -02:00
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Aaron Franke cb01268562 Fix many errors found by PVS-Studio
Fix errors 2, 3, 4, 6, 8, 9, 11, 12, 13, 14, and 15.
2018-11-28 05:03:24 -05:00
Pedro J. Estébanez b499537e68 Revert "Fix crash on signal/resume to dangling target"
This reverts commit 54bdc1e1f6.
2018-11-24 23:46:13 +01:00
Pedro J. Estébanez 54bdc1e1f6 Fix crash on signal/resume to dangling target
Fixes #22443.
2018-10-17 20:44:47 +02:00
George Marques 4907a1cd28
GDScript: Fix stack address test in compiler 2018-09-19 11:17:45 -03:00