Commit Graph

105 Commits

Author SHA1 Message Date
dbd7a31507 Implement exponential operator (**) to GDScript/Expressions 2022-05-11 16:30:37 +03:00
01d13ab2c1 GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
f851c4aa33 Fix some issues found by cppcheck. 2022-04-06 14:34:37 +03:00
0584387918 Fix autocompletion of static methods in built-in types in GDScript 2022-03-30 17:40:41 +03:00
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
49482966ec Merge pull request #55715 from nathanfranke/enum-ordered 2022-01-10 17:19:52 +01:00
6d4ed65f4c Merge pull request #56483 from vnen/gdscript-warning-annotation
Add annotation to ignore warnings
2022-01-05 09:05:56 +01:00
fd643c903d GDScript: Add annotation to ignore warnings 2022-01-04 09:32:43 -03:00
fe52458154 Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
b5b75cad43 Use OrderedHashMap for enum_values 2021-12-16 21:49:42 -08:00
7da392bcc5 Don't return reference on copy assignment operators
We prefer to prevent using chained assignment (`T a = b = c = T();`) as this
can lead to confusing code and subtle bugs.

According to https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B), C++
allows any arbitrary return type, so this is standard compliant.

This could be re-assessed if/when we have an actual need for a behavior more
akin to that of the C++ STL, for now this PR simply changes a handful of
cases which were inconsistent with the rest of the codebase (`void` return
type was already the most common case prior to this commit).
2021-11-30 16:26:29 +01:00
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
679f70c1e1 Merge pull request #52906 from vnen/gdscript-show-error-on-yield 2021-09-21 20:36:39 +02:00
262d6c6bef GDScript: Show specific error when "yield" is used
To help people porting code, it gives a hint to use "await" instead of a
generic error.
2021-09-21 14:38:14 -03:00
e5ebc9710d GDScript: Allow classes declaration to be done in single line
Incidentally, allow multiple statements in single line functions when
using semicolon as a terminator.
2021-09-21 14:14:46 -03:00
b8fdeb6467 Merge pull request #51671 from RandomShaper/fix_gdscript_crash
Fix some GDScript bugs
2021-09-17 12:29:40 -03:00
d72f12a561 Implement iterator variable typing in GDScript 2021-09-11 11:35:25 +02:00
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
5161c97c9c Remove underscore hacks
Way less cruft. :)

Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2021-08-17 16:10:28 +02:00
ac3322b0af Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
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
04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
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
c201b212c7 GDScript: Implement lambdas compilation and runtime 2021-04-28 11:09:38 -03:00
3155368093 GDScript: Add lambdas to the type analyzer
- Lambdas are always callables (no specific signature match).
- Captures from the current context are evaluated.
2021-04-28 10:56:16 -03:00
c6e66a43b0 GDScript: Add lambda syntax parsing
Lambda syntax is the same as a the function syntax (using the same
`func` keyword) except that the name is optional and it can be embedded
anywhere an expression is expected. E.g.:

    func _ready():
        var my_lambda = func(x):
            print(x)
        my_lambda.call("hello")
2021-04-28 10:56:16 -03:00
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
577a17980d Move GDSript annotation application after type-checking
This ensures that annotations that rely on the datatype (such as
@export) can validated it timely, allowing compound expressions instead
of only literal values.
2021-03-30 08:29:36 -03:00
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
75bfb016f2 Merge pull request #41897 from strank/not-in-conditional-done
Add a "not in" operator to GDScript.
2021-03-02 15:16:52 +01:00
f7209b459b Initialize class/struct variables with default values in modules/ 2021-02-08 10:57:18 +01:00
8363c44265 Merge pull request #44719 from ThakeeNathees/assert-argument-bug-fixed
GDScript assert message parsing bug fixed
2021-01-11 13:51:44 +01:00
0dba21a4d1 Merge pull request #45076 from ThakeeNathees/gdscript-operator-precedence-bug-fix
GDScript operator `+` `-` precedence bug fix
2021-01-11 13:50:00 +01:00
0889f14af9 GDScript operator + - precedence bug fix
Fix: #43265
2021-01-10 18:33:05 +05:30
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
ebade0e454 GDScript assert message parsing bug fixed
Fix: #43540
2020-12-27 13:13:50 +05:30
abfc528439 Merge pull request #43890 from vnen/gdscript-builtin-functions-refactor
GDScript: Refactor builtin functions
2020-12-15 20:51:38 +01:00
42bfa16996 Refactor DocData into core and editor (DocTools) parts 2020-12-02 00:48:39 +05:30
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
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
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
409af31b55 Add a "not in" operator to GDScript. 2020-09-21 17:53:54 -04:00
745ca3059d Change GDScript compiler to use codegen abstraction 2020-09-01 14:36:22 -03:00
35176247af GDScript: Allow enum values to be set to constant expressions
Also allow them to access previous values wihout referencing the enum.
2020-08-18 17:44:20 -03:00
cf05486d8e Merge pull request #41055 from snichols/null-callee-fix
Fix crash with null callee
2020-08-11 15:15:43 +02:00
8a13be50ab Fixing null callee crash. 2020-08-05 14:41:46 -05:00
ee973f5b90 [GDScript] Add static HashMap cleanup. 2020-08-01 22:08:12 +03:00
a0f54cb95e Wrap up GDScript 2.0 base implementation 2020-07-22 11:07:51 -03:00
aa09b4f85d Reintroduce code completion 2020-07-20 11:38:40 -03:00
b6a2628c48 Reenable GDScript LSP server 2020-07-20 11:38:40 -03:00