summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_function.h
Commit message (Collapse)AuthorAgeFilesLines
* Replace most uses of Map by HashMapreduz2022-05-161-1/+1
| | | | | | | | | | | | * 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!
* GDScript: Allow using self in lambdasGeorge Marques2022-04-241-0/+1
|
* GDScript: Rename OPCODE_TYPE_ADJUST_TRANSFORM to have a 3D suffixAaron Franke2022-04-071-1/+1
|
* GDScript: Add support for static method calls in native typesGeorge Marques2022-04-061-0/+1
|
* Return a correctly typed variant in case of a function error to prevent hard ↵SaracenOne2022-02-171-0/+2
| | | | crashes
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Don't return reference on copy assignment operatorsRémi Verschelde2021-11-301-2/+1
| | | | | | | | | | | | | 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).
* Merge pull request #52323 from vnen/gdscript-singleton-interdependence-fixRémi Verschelde2021-09-131-0/+1
|\ | | | | Fix loading of interdependent autoloads
| * GDScript: Fix loading of interdependent autoloadsGeorge Marques2021-09-011-0/+1
| | | | | | | | | | | | 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.
* | [Net] Move multiplayer to core subdir, split RPCManager.Fabio Alessandrelli2021-09-071-2/+2
|/ | | | | | | | | | | 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".
* Remove underscore hacksMax Hilbrunner2021-08-171-5/+1
| | | | | | Way less cruft. :) Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
* [Net] Single `rpc` annotation. "sync" no longer part of mode.Fabio Alessandrelli2021-07-201-2/+2
| | | | | | | | | | | | | | | | - 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).
* Rename Reference to RefCountedPedro J. Estébanez2021-06-111-3/+3
|
* Rename Quat to QuaternionMarcel Admiraal2021-06-041-2/+2
|
* Rename Variant TRANSFORM to TRANSFORM3DAaron Franke2021-06-031-1/+1
| | | Also _transform to _transform3d
* Merge pull request #48793 from vnen/gdscript-fix-temp-type-adjustRémi Verschelde2021-05-171-0/+2
|\ | | | | GDScript: Fix crash caused by uninitialized temp stack slots
| * GDScript: Fix crash caused by uninitialized temp stack slotsGeorge Marques2021-05-171-0/+2
| | | | | | | | | | | | 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.
* | GDScript: Add support for builtin static method callsGeorge Marques2021-05-161-0/+1
|/
* GDScript: Implement lambdas compilation and runtimeGeorge Marques2021-04-281-0/+4
|
* GDScript: Adjust type of temporaries when neededGeorge Marques2021-04-161-0/+34
|
* Reduce number of addressing modes in GDScript VMGeorge Marques2021-04-081-11/+13
| | | | | | | | | | | | | | 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.
* GDScript: Properly validate return typeGeorge Marques2021-04-051-0/+4
| | | | | | | When the type cannot be validated at compile time, the runtime must do a check to ensure type safety is kept, as the code might be assuming the return type is correct in another place, leading to crashes if the contract is broken.
* Add typed arrays to GDScriptGeorge Marques2021-03-291-3/+68
| | | | | | | | - 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.
* Initialize class/struct variables with default values in modules/Rafał Mikrut2021-02-081-8/+8
|
* Update copyright statements to 2021Rémi Verschelde2021-01-011-2/+2
| | | | | | | | | | | | | | 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 🎆
* Merge pull request #43890 from vnen/gdscript-builtin-functions-refactorRémi Verschelde2020-12-151-1/+10
|\ | | | | GDScript: Refactor builtin functions
| * GDScript: Refactor builtin functionsGeorge Marques2020-11-261-1/+10
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Documentation generation for GDScriptThakee Nathees2020-11-291-0/+6
|/ | | | | | | | | | | | | | | | | | - 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
* GDScript: Add faster instruction for validated constructorGeorge Marques2020-11-211-1/+5
| | | | Only for built-in types.
* GDScript: Add typed iterate instructionsGeorge Marques2020-11-211-0/+38
|
* GDScript: Add faster call instructions for builtin methodsGeorge Marques2020-11-211-0/+4
| | | | | Methods from builtin types can be called by using the function pointer when the argument and base types are known at compile time.
* GDScript: Add faster call instructions for native methodsGeorge Marques2020-11-211-0/+43
|
* GDScript: Add speficic set/get instructionsGeorge Marques2020-11-211-2/+26
| | | | | When the base type is known at compile-time, we can get a direct function pointer that is faster than the regular set/get paths.
* GDScript: Add faster operator for known typesGeorge Marques2020-11-211-0/+4
| | | | | It now uses the direct operator function pointer, which increases performance in evaluation.
* GDScript: Gather instructions arguments beforehandGeorge Marques2020-11-211-27/+33
| | | | | | | | | Almost all instructions need variant arguments. With this change they are loaded in an array before each instruction call. This makes the addressing code be localized to less places, improving compilation overhead and binary size by a small margin. This should not affect performance.
* Reorganized core/ directory, it was too fatty alreadyreduz2020-11-071-6/+6
| | | | | | -Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
* Prevent cyclic reference between script and its membersPedro J. Estébanez2020-09-101-1/+2
|
* Add GDScript disassemblerGeorge Marques2020-09-011-8/+4
|
* Add GDScript code generation interfaceGeorge Marques2020-09-011-0/+1
| | | | Implement the abstraction by targeting the current VM.
* New GDScript tokenizer and parserGeorge Marques2020-07-201-3/+3
| | | | | | | | | | 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.
* Style: Enforce braces around if blocks and loopsRémi Verschelde2020-05-141-1/+2
| | | | | Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-141-3/+0
| | | | | | | | | | | | | | 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.
* Port member initialization from constructor to declaration (C++11)Rémi Verschelde2020-05-141-8/+8
| | | | | | | | | | Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists.
* Style: clang-format: Disable AllowShortIfStatementsOnASingleLineRémi Verschelde2020-05-101-1/+2
| | | | | | | 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.
* Fix object leaks caused by unfulfilled yieldsPedro J. Estébanez2020-05-051-2/+9
| | | | | | | | | | Now the stack saved in a `GDScriptFunctionState` is cleared as soon as the `yield()` operation is known not to be resumed because either the script, the instance or both are deleted. This clears problems like leaked objects by eliminating cases of circular references between `GDScriptFunctionState`s preventing them and the objects they refer to in their saved stacks from being released. As an example, this makes using `SceneTreeTimer` safer. Furthermore, with this change it's now possible to print early warnings about `yield()`s to released script/instances, as now we know they won't be successfully resumed as the condition for that happens. However, this PR doesn't add such messages, to keep the observed behavior the same for the time being. Also, now a backup of the function name in `GDScriptFunctionState` is used, since the script may not be valid by the time the function name is needed for the resume-after-yield error messages.
* Fix leaked objects when game ends with yields in progressPedro J. Estébanez2020-04-291-2/+4
|
* Replace NULL with nullptrlupoDharkael2020-04-021-2/+2
|
* Style: Set clang-format Standard to Cpp11Rémi Verschelde2020-03-171-1/+1
| | | | | | | | | | 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`.
* Reworked signal connection system, added support for Callable and Signal ↵Juan Linietsky2020-02-201-3/+3
| | | | objects and made them default.
* GDScript: Remove self static reference and create one on callsGeorge Marques2020-02-191-1/+1
| | | | | | This is needed because of the new changes to Variant. The reference counter is increased by adding it to a Variant, which means no GDScript will be freed (or will be double freed if manually freed somewhere).