Commit graph

1457 commits

Author SHA1 Message Date
Rémi Verschelde ea7dd1be36
Merge pull request #43328 from gvekan/better-keyword-completion
Add bracket or space to some keyword completions
2020-12-03 17:14:32 +01:00
Rémi Verschelde 9c30c83aee
Merge pull request #44011 from KoBeWi/red_roses_minus_blue_violets
Fix subtracting colors and quats
2020-12-03 14:44:52 +01:00
Tomasz Chabora 4c232e4222 Fix subtracting colors and quats 2020-12-03 14:22:12 +01:00
Rémi Verschelde 9a0610c1ff
Merge pull request #43959 from dalexeev/gds-doc
Several edits to the GDScript docs
2020-12-03 13:32:32 +01:00
Gustav dff3875ae3 Add bracket or space to some keyword completions 2020-12-03 09:44:42 +01:00
Rafał Mikrut e1811b689b Initialize class/struct variables with default values in platform/ and editor/ 2020-12-02 16:09:11 +01: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
Danil Alexeev bf96056ad0 Several edits to the GDScript docs 2020-12-01 16:05:10 +03:00
Pedro J. Estébanez 86ece881e5 Remove useless check in GDScript
The removed check was adding a protection for the case where a `Reference` has not yet got its reference count initialized and a script is called on it. That would cause the object to be released after the call. The removed code was constructing the `Variant` via the `Object` constructor so it didn't deal with the reference count and so the release was prevented.

However, `Variant` no longer works that way so that check was useless. Now it's just illegal to run GDScript on a Reference whose reference count has not been initialized.
2020-12-01 12:28:52 +01:00
Rémi Verschelde 04bef80b42
Merge pull request #43992 from vnen/variant-internal-object-set
Fix VariantInternal initialization and setting of object
2020-11-30 20:22:15 +01:00
Rémi Verschelde 8f3dde18f1
Merge pull request #43504 from AndreaCatania/gds_fix_2
Implement proper error print, Fixes a crash when no error messages are generated by the analyser.
2020-11-30 19:10:38 +01:00
George Marques 029fd88adb
Fix VariantInternal initialization and setting of object
- Initialize Object pointer to nullptr so it's not used by mistake.
- When setting an Object check if it's a reference so refcounting works
  as intended.
2020-11-30 14:49:52 -03:00
George Marques a604e72dc9
GDScript: Don't construct ref values in compiler
Values that are passed by reference are not suited for being constructed
at compile time because in this case they would be shared across all the
construction statements.
2020-11-30 09:42:22 -03:00
Gustav e995d5c378 Fix missing function hints 2020-11-30 09:26:32 +01:00
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
AndreaCatania 40403b02fb Implement proper error print, Fixes a crash when no error messages are generated by the analyser. 2020-11-28 13:47:52 +01:00
Rémi Verschelde d395f70828
Merge pull request #43500 from AndreaCatania/gds_fixes
Fixes crash when parse_expression returns nullptr.
2020-11-27 16:37:45 +01:00
Rémi Verschelde 9f9b269d32
Merge pull request #43914 from ThakeeNathees/range-argument-type-bug-fix
GDScript: range function type check bug fixed
2020-11-27 15:08:02 +01:00
George Marques cf7a6be1db
Merge pull request #43226 from mateosss/unreachable-prop-crash
Fix crash due to unreachable code in properties
2020-11-27 11:03:20 -03:00
Thakee Nathees f0613a91be GDScript range function typecheck bug fixed
Fix: #43586
2020-11-27 18:23:35 +05:30
George Marques fbb806fd68
Unregister GDScriptFunctionState class
This is not user accessible anymore so it does not need to be show in
documentation.
2020-11-26 21:39:54 -03:00
Rémi Verschelde ed2f84735b
Merge pull request #43895 from vnen/gdscript-operators-fix
GDScript: Improve handling of operators
2020-11-26 21:19:31 +01:00
Rémi Verschelde e5ff2d0ffd
Merge pull request #43894 from vnen/gdscript-some-fixes
Some GDScript fixes
2020-11-26 18:56:42 +01:00
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 627ca7f30e
GDScript: Don't clear depended parsers too soon
It can wait until the analyzer itself is destructed, otherwise other
phases might be using freed parsers.
2020-11-26 14:14:29 -03:00
George Marques 817fb3d702
GDScript: Give an error if dependency can't be parsed
Otherwise this may lead to a crash when the dependency is not present.
2020-11-26 12:27:48 -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
Jordan Schidlowsky afa15c5f15 fixes crash for OPCODE_CAST_TO_NATIVE opcode in gdscript disassemlber 2020-11-25 16:26:32 -06: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 fb3dc2670a
GDScript: Fix range() being treated as array when optimized out
The call of range() in a for loop is optimized to use int or vectors, to
avoid allocating an array, however the type was set as array still. With
the new typed VM this is an issue as the type mismatch the actual value,
resulting in wrong instructions to be selected.
2020-11-25 11:35:07 -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 5518e2a68e
GDScript: Add faster instruction for validated constructor
Only for built-in types.
2020-11-21 13:30:17 -03:00
George Marques e0dca3c6b6
GDScript: Add typed iterate instructions 2020-11-21 13:24:50 -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 5aeb390cd7
GDScript: Add speficic set/get instructions
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.
2020-11-21 13:24:49 -03:00
George Marques 1ad5c926dc
GDScript: Add faster operator for known types
It now uses the direct operator function pointer, which increases
performance in evaluation.
2020-11-21 13:24:49 -03:00
George Marques c707d6fe71
GDScript: Gather instructions arguments beforehand
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.
2020-11-21 13:24:49 -03:00
George Marques b6519d0d03
GDScript: Split Function code into multiple files
To improve organization and reduce the size of compilation units.
2020-11-21 13:24:49 -03:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Andrea Catania 98daa0af6b Fixes crash when returns . 2020-11-13 15:09:52 +01:00
George Marques 8bcd345782
GDScript: Fix native class not set with inheritance 2020-11-13 10:35:24 -03:00
reduz 635d33dc6c Refactor variant built-in methods yet again.
* Using C-style function pointers now, InternalMethod is gone.
* This ensures much better performance in typed code.
* Renamed builtin_funcs to utility_funcs, to avoid naming confusion
2020-11-11 16:36:36 -03:00
Aaron Franke ee79fc627c
Minor clamp and float fixes 2020-11-10 14:30:07 -05:00
Gustav 0ddd4097a6 Fix completion for built-in load function 2020-11-10 12:00:08 +01:00
Rémi Verschelde 68067b8d97
Merge pull request #43423 from Calinou/doc-assert-avoid-side-effects
Clarify that code in `assert()` should avoid side effects
2020-11-10 11:31:28 +01:00
Rémi Verschelde 0f249f5c0a
Variant: Sync docs with new constructors, fixups after #43403
Change DocData comparators for MethodDoc and ArgumentDoc to get a better
ordering of constructors.
2020-11-09 23:39:53 +01:00
Hugo Locurcio d6c7073bd7
Clarify that code in assert() should avoid side effects 2020-11-09 21:48:24 +01:00
Rémi Verschelde 9d2e8f2f27
Variant: Rename Type::_RID to Type::RID
The underscore prefix was used to avoid the conflict between the `RID` class
name and the matching enum value in `Variant::Type`.

This can be fixed differently by prefixing uses of the `RID` class in `Variant`
with the scope resolution operator, as done already for `AABB`.
2020-11-09 16:29:04 +01:00
reduz 221a2a1742 Refactored variant constructor logic 2020-11-09 08:54:43 -03:00
reduz 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
reduz 05de7ce6ca Refactored variant setters/getters
-Discern between named, indexed and keyed
-Get direct access to functions for typed GDScript and GDNative bindings
-Small changes to some classes in order to work with the new setget binder
2020-11-07 15:16:15 -03:00
Yuri Roubinsky 38fb26794b Exposed randi_range to global funcs + renamed rand_range to randf_range 2020-11-06 17:06:26 +03:00
Rémi Verschelde c35517f07e
Merge pull request #42724 from theoway/error_message_fix_call_recursive
Fixes the misleading message when a non-existing function name is passed to TreeItem.call_recursive()
2020-11-05 00:46:28 +01:00
Rémi Verschelde bd13e82080
Merge pull request #41516 from Lunatoid/allow-object-new
Fixed ParseError when calling Object.new()
2020-11-03 13:08:48 +01:00
Mateo de Mayo 531958b2f0 Fix crash due to unreachable code in properties 2020-10-30 22:21:50 -03:00
Mateo de Mayo f388177aed Fix crash by adding nullcheck for uninitialized constants 2020-10-29 01:11:19 -03:00
Hugo Locurcio a1d9c67f43
Optimize SVG using svgcleaner --multipass
This decreases the editor binary size by about 8 KB.
2020-10-25 10:02:37 +01:00
Yuri Roubinsky 4c65dc975c Shows ColorRect in Color constants autocompletion 2020-10-23 19:03:50 +03:00
Rémi Verschelde ef62e93677
Merge pull request #42943 from vnen/gdscript-local-scope-fix
Fix handling of scope for local GDScript variables
2020-10-20 21:00:57 +02:00
George Marques 96884ef41e
Merge pull request #41983 from ThakeeNathees/array-const-folding-bug-fix
Array/Dictionary Nodes no more reduced to array/dictionary variant
2020-10-20 15:43:07 -03:00
George Marques 11c05642fe
GDScript: Fix handling of scope for local variables 2020-10-20 14:57:31 -03:00
George Marques 48b91b900d
GDScript: Add initialization for the language before debug tests
This ensures that the tests will use a full environment with correct
settings so global classes and autoloads can be properly found.
2020-10-20 10:07:03 -03:00
George Marques 5ddfc657ab
Merge pull request #42067 from ThakeeNathees/for-loop-stack-overriden-fix
GDScript: for loop override stack variable bug fix
2020-10-19 20:21:14 -03:00
Umang Kalra c37f633216 Fixes the misleading error message for call_recursive method for TreeItems 2020-10-17 12:30:36 +05:30
Hugo Locurcio 802c1e4df1
Link the Random number generation tutorial in the class reference 2020-10-14 18:03:29 +02:00
George Marques fe6109101f
Merge pull request #41881 from ThakeeNathees/crash-on-builtin-constructor
GDScript crash on builtin type constructor fix
2020-10-08 19:35:35 -03:00
Rémi Verschelde 3556bc48a1
Merge pull request #42439 from Xrayez/doc-gdscript-load-and-resloader-xref
Cross-reference GDScript `load` and `ResourceLoader.load` in classref
2020-10-04 20:48:07 +02:00
Paulb23 ee4a1c99a7 Switch from recursion to iterative for backfilling colour regions 2020-10-03 14:58:55 +01:00
Serhat 9f2cdfea82 Fixed padding bug of sprintf function 2020-10-02 00:25:42 +03:00
Rémi Verschelde 39ea52f36f
Merge pull request #41829 from RandomShaper/fix_40353
Avoid warning about harmless unfulfilled yields
2020-10-01 14:17:34 +02:00
Andrii Doroshenko (Xrayez) a8404cf56c Cross-reference GDScript load and ResourceLoader.load in classref
The GDScript `load` mention is moved from the class `ResourceLoader`
description to the `ResourceLoader.load` method description instead,
where it is more likely to be found.
2020-09-30 23:03:36 +03:00
Pedro J. Estébanez de4e54dd91 Avoid infinite loop in GDScript at shutdown 2020-09-26 19:21:09 +02:00
Hugo Locurcio 50f3a8e312
Improve documentation related to printing error/warning messages 2020-09-24 14:23:53 +02:00
strank 409af31b55 Add a "not in" operator to GDScript. 2020-09-21 17:53:54 -04:00
Rémi Verschelde cff43e5326
Merge pull request #41930 from RandomShaper/fix_gdscript_leaks
Fix leaks in GDScript
2020-09-18 16:18:57 +02:00
Rémi Verschelde 3e78963bb9
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2020-09-18 13:44:25 +02:00
Thakee Nathees 119936d939 GDScript: for loop override stack variable bug fix
Fix: #42050
2020-09-18 01:22:22 +05:30
Danil Alexeev a4c5790350 Several documentation improvements 2020-09-14 20:02:19 +03:00
Thakee Nathees e4d5393ecf GDScript export array/dictionary type infer bug fix
Fix : #41980
2020-09-13 19:36:20 +05:30
Thakee Nathees 3886a2f9f6 Array/Dictinoary no more reduced to array/dictionary variant
Fix: #41377
Fix: #20436
Fix: #41953
2020-09-11 19:46:20 +05:30
Pedro J. Estébanez e25f5e791e Ensure cyclic dependencies between scripts are broken at exit 2020-09-10 01:34:42 +02:00
Pedro J. Estébanez 95828161d4 Prevent cyclic reference between script and its members 2020-09-10 01:26:07 +02:00
Rémi Verschelde 1c881c973b
GDScript: Fix MutexLock usage, fixes Clang 6 compat
Fixes #41852.
2020-09-09 14:56:57 +02:00
Rémi Verschelde 2410016638
Merge pull request #41709 from ThakeeNathees/dictionary-indexing-bug-fix
Fixed parser error when indexing a dictionary.
2020-09-08 21:38:14 +02:00
Thakee Nathees 279a11bbda GDScript crash on builtin type constructor fix
Fix: #41848
2020-09-08 18:33:53 +05:30
Rémi Verschelde 3c42d5789f
Merge pull request #38308 from bruvzg/sad_security_circus
Adds PCK encryption support (using script encryption key for export).
2020-09-07 17:12:01 +02:00
Pedro J. Estébanez f76a13dea0 Avoid warning about harmless unfulfilled yields 2020-09-06 22:30:46 +02:00
Rémi Verschelde 859322343c
Merge pull request #41803 from ThakeeNathees/parameter-type-infer-bug-fix
GDScript: parameter infer type bug fix
2020-09-06 15:22:44 +02:00
Thakee Nathees 89489a3cac GDScript: parameter infer type bug fix
Fix: #41772
2020-09-06 13:26:52 +05:30
bruvzg f043eabdd8
Adds PCK encryption support (using script encryption key for export).
Change default encryption mode from ECB to CFB.
2020-09-05 14:53:39 +03:00
Rémi Verschelde 605d7b7e82
Merge pull request #41760 from ThakeeNathees/null-dereference-on-gdscript-function-fix
null pointer dereference at GDScriptFunction::call crash fix
2020-09-04 14:45:31 +02:00
Thakee Nathees 75d4511cb5 null pointer dereference at GDScriptFunction::call fix 2020-09-04 15:24:09 +05:30
bruvzg 80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00
Thakee Nathees 4fc14e8e11 fixed parser error when indexing a dictionary.
Fix: #41707
2020-09-03 18:04:54 +05:30
Rémi Verschelde d84954a281
Merge pull request #41459 from Paulb23/nested_color_regions
Fix colour region end key seach and start key order
2020-09-03 11:32:04 +02:00