Commit graph

677 commits

Author SHA1 Message Date
Rémi Verschelde bca2d3ad40 Fix invalid comparison warnings: [-Wbool-compare] and [-Wenum-compare]
Fixes the following GCC 5 warnings and actual bugs:
```
drivers/unix/net_socket_posix.cpp:562:28: warning: comparison between 'enum IP::Type' and 'enum NetSocket::Type' [-Wenum-compare]
modules/gdscript/gdscript_function.cpp:792:26: warning: comparison of constant '17' with boolean expression is always true [-Wbool-compare]
modules/gdscript/gdscript_function.cpp:792:26: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
modules/gdscript/gdscript_parser.cpp:5082:58: warning: comparison of constant '6' with boolean expression is always false [-Wbool-compare]
modules/gdscript/gdscript_parser.cpp:5082:58: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
modules/mbedtls/stream_peer_mbed_tls.cpp:286:45: warning: comparison between 'enum StreamPeerTCP::Status' and 'enum StreamPeerSSL::Status' [-Wenum-compare]
modules/mbedtls/stream_peer_mbed_tls.cpp:313:45: warning: comparison between 'enum StreamPeerTCP::Status' and 'enum StreamPeerSSL::Status' [-Wenum-compare]
```
2018-09-27 16:25:24 +02:00
George Marques b1187b9a2f
GDScript: Revert extra deletion when creating instance
Revert part of e4af39cbc0 that was causing
a crash.
2018-09-19 11:17:47 -03:00
George Marques 825e85ab23
GDScript: Error on empty blocks at the end of file
Fix #15415
2018-09-19 11:17:46 -03:00
George Marques 02acb07d81
GDScript: Fix autocompletion inference after is check
Fix #21915
2018-09-19 11:17:46 -03:00
George Marques 726e836cd9
GDScript: Fix infinite loop in autocomplete
It happened when the definition of the variable contained the variable
itself.
2018-09-19 11:17:46 -03:00
George Marques e6a6ea65c7
GDScript: Forbid enum values to shadow constants
- Don't allow constants to shadow parent members.
- Fix a spelling mistake.

Fix #13175
2018-09-19 11:17:46 -03:00
George Marques 6c70c4c358
GDScript: Fix autocomplete crash when searching default values
Fix #21700
2018-09-19 11:17:46 -03:00
George Marques b530031442
GDScript: Allow Object constants to be used with qualifier
Fix #15125
2018-09-19 11:17:46 -03:00
George Marques 4907a1cd28
GDScript: Fix stack address test in compiler 2018-09-19 11:17:45 -03:00
Rémi Verschelde 4075c80ea9
Merge pull request #22165 from DualMatrix/atan2_plain_wrong
Fixed argument names having wrong order for atan2
2018-09-17 12:33:26 +02:00
DualMatrix 4bad2beeed Fixed argument names being swapped for atan2
The arguments of atan2() should be y,x instead of x,y This was just wrong since the internal atan2 already had y,x as parameters, so if you followed the autocomplete the result would just be wrong.
2018-09-16 21:27:54 +02:00
Mariusz Chwalba 47bf26c40d test for depreciacion warnings only on debug builds
Fix adherence to clang-format rules
2018-09-16 19:37:51 +02:00
Fabio Alessandrelli c0e4d7efca Add GDScript slave keyword deprecation warning. 2018-09-15 01:50:34 +02:00
Fabio Alessandrelli 1e9b46d687 Clearly deprecate sync too in favor of remotesync.
NOTE: This changes the RPC_MODE_* enum values.
Games should be re-exported. GDNative rebuilt.
2018-09-15 00:06:03 +02:00
Fabio Alessandrelli d6b31daec6 Rename slave keyword to puppet
The slave keyword will still be available as deprecated in 3.1 but will
be dropped from future releases.
2018-09-15 00:06:03 +02:00
Rémi Verschelde 1a16dabfb5
Merge pull request #21982 from luzpaz/misc-typos
Misc. typos
2018-09-13 10:59:00 +02:00
luz.paz 08bde5b2de Misc. typos
Found via `codespell -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"`
2018-09-12 21:39:17 -04:00
Rémi Verschelde 277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Rémi Verschelde 0faafa6f4d Fix crash when extending non-existing GDScript file
Fixes #21682 with a partial revert of #21411.
The ~Ref() destructor (from 'scriptres') already takes care
of freeing the 'script' resource.
2018-09-10 20:46:20 +02:00
Paulb23 f051f5110e Fixed scientific notaion not highlighting correctly, issue 21435 2018-09-08 13:42:11 +01:00
WiggleWizard d227a9ae12 Fixed return type for get_stack() function call 2018-09-05 11:29:06 +01:00
Rémi Verschelde f06b7d40c8
Merge pull request #21449 from vnen/gdscript-builtin-is
Allow `is` operator to test built-in types
2018-08-27 17:48:11 +02:00
Rémi Verschelde 5b87864385
Merge pull request #21369 from Noshyaar/exportflag
Deprecating bit flags export with no hint text
2018-08-27 17:47:21 +02:00
Rémi Verschelde 49cf675ef4
Merge pull request #21450 from vnen/gdscript-type-space
Remove space before colon on type hints
2018-08-27 10:42:19 +02:00
George Marques de45b18ddb
GDScript: Remove space before colon on type hints 2018-08-26 13:43:13 -03:00
George Marques 4b974a36b7
GDScript: Allow is operator to test built-in types 2018-08-26 13:31:23 -03:00
Crazy-P e4af39cbc0 Fixes several resource leaks in ...
- gdscript
- gdscript_compiler
- regex
- android/export
- gles3/rasterizer (scene and storage)
2018-08-26 09:19:02 +08:00
Poommetee Ketson cee6d5620a Deprecating bit flags export with no hint text 2018-08-24 20:46:04 +07:00
Rémi Verschelde 52466d57e9 Make some debug prints verbose-only, remove others 2018-08-24 14:59:01 +02:00
George Marques 94d662ad55
GDScript: Ignore unused arguments/local vars that start with _
Makes it simple to ignore particular arguments without adding special
comments, especially in engine-defined functions.
2018-08-21 20:29:43 -03:00
George Marques 4d2b9a4b35
GDScript: Show warning messages only on debugger
Don't show on console/output anymore.
2018-08-21 20:29:33 -03:00
George Marques fdf18a4198
GDScript: Fix undefined behavior on GDScriptTokenizerBuffer 2018-08-21 13:54:52 -03:00
George Marques abbdb9d951
GDScript: Forbid invalid identifiers in match bindings
Also forbid shadowing a variable from an upper scope.
2018-08-21 13:38:18 -03:00
George Marques d97624e295
GDSCript: Fix cyclic class dependency detection 2018-08-21 13:14:11 -03:00
Hugo Locurcio 649c3bee3b
Highlight multiline strings as strings instead of comments
Since multiline comments are not officially supported in GDScript, it is
more common to see multiline strings being used as strings rather than
as comments (which are actually standalone expressions here).

This closes #21142.
2018-08-19 13:47:57 +02:00
Will Nations 3ed9231117 Fix error spam from loading script class icons 2018-08-15 10:17:28 -05:00
Will Nations 6d9cc032e7 Add custom icons to script classes. 2018-08-14 14:18:05 -05:00
Rémi Verschelde b4f579b5ba
Merge pull request #20583 from neikeq/issue-15371
Fix case where exported properties value is lost
2018-08-14 21:08:56 +02:00
Chaosus 179e15f876 Remove usage console spam 2018-08-13 16:51:17 +03:00
George Marques eb48119821
Added system for GDScript warnings
- Count and panel per script.
- Ability to disable warnings per script using special comments.
- Ability to disable warnings globally using Project Settings.
- Option to treat enabled warnings as errors.
2018-08-10 16:00:47 -03:00
Bernhard Liebl ba974b8d1e Allow some non-integer built-in constants in gdscript 2018-07-31 17:56:48 +02:00
Ignacio Etcheverry f3c7527225 Fix case where exported properties value is lost
Fixes exported property modified values lost when creating a placeholder script instance with a failed script compilation

- Object set/get will call PlaceHolderScriptInstance's new fallback set/get methods as a last resort. This way, placeholder script instances can keep the values for storage or until the script is compiled successfuly.
- Script::can_instance() will only return true if a real script instance can be created. Otherwise, in the case of placeholder script instances, it will return false.
- Object::set_script(script) is now in charge of requesting the creation of placeholder script instances. It's no longer Script::instance_create(owner)'s duty.
- PlaceHolderScriptInstance has a new method set_build_failed(bool) to determine whether it should call into its script methods or not.
- Fixed a few problems during reloading of C# scripts.
2018-07-29 22:40:12 +02:00
George Marques e8da2a60b3
GDScript: Fix parse error in string formatting 2018-07-26 10:52:11 -03:00
George Marques 0b78e4f9e3
GDScript: Add type inference syntax for function arguments 2018-07-25 21:06:35 -03:00
George Marques 7db7b43cb0
GDScript: Fix type detection for String formatting operator 2018-07-25 20:50:13 -03:00
George Marques aeb0b3114d
GDScript: Fix type detection on Object typed assign
Also make typed assigns a debug-only thing, so release builds are more
lenient on errors.
2018-07-25 20:50:12 -03:00
George Marques a3ae4a9510
GDScript: Allow accessing constants of outer classes 2018-07-25 20:50:12 -03:00
George Marques a62f4af7ba
GDScript: Enable built-in function introspection in non-tools
Only for debug builds. Fix problems in non-tools targets.
2018-07-25 20:50:12 -03:00
George Marques 3d6609303b
GDScript: Fix bogus error when a cursor token is found on class 2018-07-25 20:50:12 -03:00
George Marques 1ac9c0fe3a
GDScript: Allow strict conversion when assigning typed variables 2018-07-25 20:50:12 -03:00
George Marques 96ee93e8c7
GDScript: Fix mismatching between export hint and type hint 2018-07-25 20:50:12 -03:00
George Marques 4cb17191b8
GDScript: Allow inherited method to add optional arguments
Also show the parent method signature in the error message.
2018-07-25 20:50:11 -03:00
George Marques cd6ad5462c
GDScript: Fix returned value of get_default_argument_count() 2018-07-25 20:50:11 -03:00
George Marques 65c069c8d9
GDScript: Fix main script detection 2018-07-25 20:50:11 -03:00
George Marques b7bd85e70c
GDScript: Look up local scope first for detecting type 2018-07-25 20:50:11 -03:00
Hein-Pieter van Braam 0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
George Marques 3e87ad5187
Rewrite code completion
- Use data type struct from the parser.
- Avail from type hints when type can't be guessed.
- Consider inner classes and other scripts when looking for candidates.
2018-07-20 21:55:18 -03:00
George Marques 3445dca01d
Add ability to infer variable type from assigned value
Syntax: var x : = 42
Infers the type of "x" to be an integer.
2018-07-20 21:55:18 -03:00
George Marques 03746da73f
Add editor highlight for type-safe lines
The line number is hightlighted to indicate that the line contains only
type-safe code.
2018-07-20 21:55:18 -03:00
George Marques a2305cd8b2
Fix line number detection in some parser nodes 2018-07-20 21:55:17 -03:00
George Marques 75f395c2a0
Use type hints to improve completion
- Allow type hints to be completed.
- Use type information to infer completion candidates.
- Show typed function signature in tooltip.
- Add type hints when completing declaration from virtual functions
(optional).
2018-07-20 21:55:17 -03:00
George Marques 95351ac867
Add syntax highlighting to type hints 2018-07-20 21:55:17 -03:00
George Marques e3d72d14ff
Use type information to enable GDScript introspection
This makes the Script API provide accurate information when requesting
property or method info.
2018-07-20 21:55:17 -03:00
George Marques 4b18c4e448
Add typed instructions to GDScript
- Typed assignment (built-in, native, and script).
- Cast (built-in conversion; native and script checks).
- Check type of functions arguments on call.
- Check type of members on set.
2018-07-20 21:55:17 -03:00
George Marques 743053734f
Add static type checks in the parser
- Resolve types for all identifiers.
- Error when identifier is not found.
- Match return type and error when not returning a value when it should.
- Check unreachable code (code after sure return).
- Match argument count and types for function calls.
- Determine if return type of function call matches the assignment.
- Do static type check with match statement when possible.
- Use type hints to determine export type.
- Check compatibility between type hint and explicit export type.
2018-07-20 21:55:16 -03:00
George Marques f7793fc5c9
Store type hint of declared identifiers 2018-07-20 21:55:16 -03:00
George Marques b7a00aead0
Move inheritance resolution to the parser 2018-07-20 21:55:16 -03:00
George Marques 8aab9a06d4
Add typing syntax 2018-07-20 21:55:16 -03:00
Rémi Verschelde 7c9f7452f4 Style: Format code with clang-format 6.0.1 2018-07-18 16:27:03 +02:00
Juan Linietsky a3f1ee5c57 Global class names (and GDScript support for it) 2018-07-15 19:29:00 -03:00
Max Hilbrunner 3f272c6ae6
Merge pull request #19637 from dragmz/19548
Fix onready vars / vars accessing class members if _ready / _init not present
2018-07-05 04:15:47 +02:00
Max Hilbrunner d988d188ad
Merge pull request #18966 from chanon/new-debug-print
Add new debug print method that shows line number where the print came from
2018-07-04 23:50:45 +02:00
Max Hilbrunner aad475937b
Merge pull request #19828 from jjay/fix_yield_leak
Fix memory leak in GDScript during infinnity loops with yields
2018-07-03 18:51:13 +02:00
Max Hilbrunner 5885e1c6dd
Merge pull request #18976 from chanon/new-get-stack
Add new get_stack function to get GDScript stack trace as array
2018-07-03 17:50:05 +02:00
Max Hilbrunner 0705eb904a
Merge pull request #19251 from YeldhamDev/script_templates_changes
Small changes to the comments in the script templates
2018-07-03 16:48:03 +02:00
Yasha Borevich 30317296af Fix memory leak in GDScript during infinnity loops with yields 2018-06-28 23:55:30 +03:00
Marcin Zawiejski 317dcb084b Fix onready vars / vars accessing class members if _ready / _init not present 2018-06-18 23:31:48 +02:00
Bojidar Marinov 8ecef3496c
Add proper type information to array property
Part of #19158
2018-06-18 22:24:31 +03:00
Paulb23 08c036b706 Removed duplicate default colours and removed GDScriptHighligher colours from main editor. 2018-06-13 18:25:02 +01:00
Rémi Verschelde f0fa590210
Merge pull request #19526 from robojumper/fix_tutorials
Add support for tutorial links to makerst.py
2018-06-13 14:29:45 +02:00
robojumper 98b59cf2a3 Add support for tutorial links to makerst.py
Also change the <tutorials> structure to make use of individual <link> tags
2018-06-12 17:40:24 +02:00
Jairo Honorio afcac41d31 Inner classes' functions now appear in the editor's functions panel
Fixes #19386
2018-06-12 10:43:37 -03:00
Michael Alexsander Silva Dias fd17b960e9 Small changes to the comments in the script templates. 2018-06-11 02:04:51 -03:00
Rémi Verschelde 3334209a73 SCons: Pass env to modules can_build method
This allows to disable modules based on the environment,
in particular `env[tools]` which tells us if we are
building the editor or not.
2018-05-30 19:11:36 +02:00
Fabio Alessandrelli 8e35d937a9 New sync keywords in GDScript, NativeScript, Mono 2018-05-29 20:26:41 +02:00
Fabio Alessandrelli 1400f6fdc4 Refactor RPCMode enum and checks 2018-05-29 20:26:41 +02:00
Max Hilbrunner 4c69a495c9
Revert "RPCMode refactor, more sync modes" 2018-05-29 11:47:52 +02:00
Max Hilbrunner d0b62ce155
Merge pull request #19021 from Faless/rpc_sync_fix
RPCMode refactor, more sync modes
2018-05-29 09:44:03 +02:00
George Marques 38284bc6da
Enable singletons to be recognized as constant expressions
Fix #14681
2018-05-28 13:40:16 -03:00
chanon 3ea6d9f37d add new print_debug method which shows source and line number 2018-05-28 18:37:07 +07:00
Fabio Alessandrelli a5e8a3be5e New sync keywords in GDScript, NativeScript, Mono 2018-05-26 10:49:33 +02:00
Fabio Alessandrelli 9de4ffde61 Refactor RPCMode enum and checks 2018-05-26 10:43:43 +02:00
Max Hilbrunner aee8d26252
Merge pull request #19131 from YeldhamDev/connection_comment_capitalize
Capitalized comments of methods created by the Connect Signal dialog
2018-05-24 01:21:17 +02:00
Michael Alexsander Silva Dias 4e257293d9 Capitalized comments of methods created by the Connect Signal dialog. 2018-05-23 18:11:00 -03:00
George Marques 3cec24baa8
Fix positive operator in GDScript compiler 2018-05-23 17:43:56 -03:00
chanon a56d6ff35f add new get_stack function to get GDScript stack trace as array 2018-05-17 21:06:30 +07:00
Rémi Verschelde b0649d2718
Merge pull request #18405 from flashyincceo/gdscript-constants-help
Fix Ctrl+click on @GDScript constants
2018-05-17 09:36:55 +02:00
Juan Linietsky 47d4a011d8
Merge pull request #18545 from vnen/editor-autoload
Enable autoload in editor
2018-05-14 17:59:34 -03:00
Rémi Verschelde 919d802e66
Merge pull request #18183 from Paulb23/gdscript_highlighter_inital_changes
GDScript function definition and get_node shortcut syntax highlighting
2018-05-10 01:25:51 +02:00
Juan Linietsky 299d8a80ba
Merge pull request #16106 from poke1024/gdscript-lerp
GDScript: generalize lerp
2018-05-07 20:36:31 -03:00