Commit graph

83 commits

Author SHA1 Message Date
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
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