summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_function.cpp
AgeCommit message (Collapse)Author
2020-07-20New GDScript tokenizer and parserGeorge Marques
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-05-29Actually set GDScript static referenceGeorge Marques
2020-05-27Merge pull request #39074 from vnen/gdscript-assert-messageRémi Verschelde
Fix assert message when no custom message is set
2020-05-26GDScript: Fix assert message when no custom message is setGeorge Marques
2020-05-19Fix too eager GDScriptFunctionState stack cleanupPedro J. Estébanez
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
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-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
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-14Modernize remaining uses of 0/NULL instead of nullptr (C++11)Rémi Verschelde
Using clang-tidy's `modernize-use-nullptr`. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2020-05-05Fix object leaks caused by unfulfilled yieldsPedro J. Estébanez
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.
2020-04-29Fix leaked objects when game ends with yields in progressPedro J. Estébanez
2020-04-22Merge pull request #37318 from ttencate/fix/argument_nulled_37312Rémi Verschelde
Revert "Allow parameters passed to GDScript functions to be nulled"
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-26Revert "Allow parameters passed to GDScript functions to be nulled"Thomas ten Cate
This reverts commit f0efc7521e7302e60ebaab31a42fafd3ea2bda68. Fixes #37312.
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
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-08Refactor ScriptDebugger.Fabio Alessandrelli
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-02-26Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-20Reworked signal connection system, added support for Callable and Signal ↵Juan Linietsky
objects and made them default.
2020-02-19GDScript: Remove self static reference and create one on callsGeorge Marques
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).
2020-02-15Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr.Juan Linietsky
2020-02-12ObjectID converted to a structure, fixes many bugs where used incorrectly as ↵Juan Linietsky
32 bits.
2020-01-21Remove unused #if 0'ed codeRémi Verschelde
2020-01-17Fix constant access in base class through subclass instanceChibiDenDen
Fixes as issue where a subclass calls a base class method that tries to access a constant from the script. The original code went through every ower class, and for each owner, went through its inheritance tree. This seems like the wrong order, the modified code goes to each base class, and for each base class goes through the owner tree. This is more in line with what the parser does, as the current impelemtation allows an access that the parser does not support. This change should not negatively affect existing code due to the way the parser works
2020-01-09GDScript: Validate object instance on `is` operationGeorge Marques
Avoids crashes on debug mode. Instead it now breaks the execution and show the error in-editor. Will still crash on release. Also add a similar check to Marshalls to ensure the debugger doesn't crash when trying to serialize the invalid instance.
2020-01-01Update copyright statements to 2020Rémi Verschelde
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.
2019-12-13GDScript: Fix type conversion in assignment with operationGeorge Marques
2019-11-11Remove ERR_EXPLAIN macros and the scaffolding they needed.Marcel Admiraal
2019-11-01GDScript: validate instance before accessing it on errorGeorge Marques
Make sure the instance is valid before trying to access the script in after an error happened. If the instance is not valid it's possible that the script is invalid as well. Fix #29623
2019-10-05Fixed some obvious typos in error messagesnoname1477
In some errors, there were closing quotation marks but no opening (e. g. "Unable to iterate on object of type " + Variant::get_type_name(container->get_type()) + "'."
2019-09-11GDScript: add an optional message parameter to assert()Mitch Curtis
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-08-28Fix yield check in GDScriptFunctionBojidar Marinov
Fixes #31455
2019-08-09Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in "platform", ↵Robin Hübner
"modules/gdnative", "modules/gdscript" directories.
2019-07-17Fix stack underflows when yielding twiceBojidar Marinov
Also, refactor GDScriptFunctionState::_signal_callback, removing some excessive repetition. Fixes #30269.
2019-07-01Merge pull request #28884 from vnen/yield-resume-stackRémi Verschelde
Keep GDScript functions in stack while yielding
2019-07-01fix some crashesFurkan Türkal
2019-06-18GDScript: Improve error on Object to Object invalid argument callsRémi Verschelde
Fixes #27804.
2019-05-14Show function name in debugger stack traceGeorge Marques
Also show script and line when the instance is gone when resuming from yield.
2019-05-14Keep GDScript functions in stack while yieldingGeorge Marques
This prevents GDScript functions from leaving the stack too soon when they are resuming from yield, allowing the ones expecting it to finish to know the caller. Helps debugging cases when you use: `yield(function_which_yields(), "completed")` since now it shows the call that resumed that function.
2019-03-04Revert "Forbid implicit type conversion in GDScript"Rémi Verschelde
2019-03-03GDScript: Forbid implicit type conversionGeorge Marques
Since types are not present in release builds, this could cause issues where a variable does not have the exact defined type.
2019-03-03Allow parameters passed to GDScript functions to be nulledBojidar Marinov
Previous version resulted in confusing (but actually right) errors about converting "from Object to Object", since CallError does not include information about the actual types involved.
2019-01-31Fix wrong error messages for invalid arguments when calling functions ↵Bojidar Marinov
through call Fixes #25505
2019-01-01Update copyright statements to 2019Rémi Verschelde
Happy new year to the wonderful Godot community!
2018-11-26Merge pull request #23959 from RandomShaper/fix-dangling-script-fixRémi Verschelde
Fix dangling script fix
2018-11-25Fix crash on signal/resume to dangling targetPedro J. Estébanez
2018-11-24Revert "Fix crash on signal/resume to dangling target"Pedro J. Estébanez
This reverts commit 54bdc1e1f6a7fb85a5b193c9b8ecf0dcf06949e6.
2018-11-17Allow primitives to be compared to Object types with `is`George Marques
2018-10-17Fix crash on signal/resume to dangling targetPedro J. Estébanez
Fixes #22443.
2018-10-06Fix compiler warnings in GDScript moduleGeorge Marques
2018-10-06Revert cause of #22794Mariusz Chwalba