Commit graph

830 commits

Author SHA1 Message Date
Aaron Franke 7f7d97f536
[Core] Expose approximate equality methods to GDScript 2019-04-25 13:20:29 -04:00
jude-lafitteIII d3cc9c0bf1 Support for binary literals in GDScript. Added an error that shows if a point is written in a hex literal. Added highlighting for binary literals in GDScript 2019-04-25 13:44:27 +01:00
Rémi Verschelde a342131eba
Merge pull request #27673 from qarmin/small_fixes
Small fixes, mostly duplicated code
2019-04-22 12:00:34 +02:00
Rémi Verschelde 6af69f851a doc: Drop unused <demos> tag 2019-04-19 11:03:46 +02:00
lupoDharkael 2ad302cec4 Don't allow class_name in built-in scripts 2019-04-17 17:06:21 +02:00
lupoDharkael 145a45fd3f Fix code completion not working with class_name 2019-04-16 22:27:13 +02:00
lupoDharkael c07b49280a Prevent using multiple class_name in a class 2019-04-16 01:41:00 +02:00
lupoDharkael 14078fbb82 GDScript: add variable shadowing warning 2019-04-15 18:19:14 +02:00
Rémi Verschelde e7a1fbe83a
Merge pull request #27863 from bojidar-bg/27460-constant-class-clash
Check subclasses too when checking for name clashes
2019-04-12 11:54:35 +02:00
Rémi Verschelde da65d54649
Merge pull request #27867 from bojidar-bg/27489-as-self-fail
Fix as operator generating opcode 38 errors
2019-04-11 23:23:35 +02:00
George Marques e56f5d5c91
GDScript: Don't allow built-in scripts to use class_name 2019-04-10 18:05:34 -03:00
Rémi Verschelde 07b76c0376
Merge pull request #27170 from timoschwarzer/allow-whitespaces-in-warning-ignore-comments
Allow whitespaces in warning-ignore comments
2019-04-10 18:16:10 +02:00
Bojidar Marinov ece09f9872
Check for subclasses when checking for name clashes
Fixes #27460
2019-04-10 13:19:30 +03: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 c8994b56f9 Style: Apply new changes from clang-format 8.0
It seems to stay compatible with formatting done by clang-format 6.0 and 7.0,
so contributors can keep using those versions for now (they will not undo those
changes).
2019-04-09 17:09:48 +02:00
Rémi Verschelde 918de768a5
Merge pull request #27711 from neikeq/ifdef-clang-tidy
Replace a few #if/#elif with #ifdef and "#elif defined"
2019-04-08 12:24:30 +02:00
qarmin 856a8226a5 Small fixes, mostly dupicated code 2019-04-08 11:03:37 +02:00
Rémi Verschelde 668bf1fd0d
Merge pull request #27710 from Calinou/script-templates-typed-gdscript
Add support for type hints in non-default script editor templates
2019-04-08 10:13:59 +02:00
Rémi Verschelde d211aff777
Merge pull request #27231 from Chaosus/smoothstep
Added smoothstep built-in function
2019-04-08 10:03:42 +02:00
Chaosus 514a3fb96a Added smoothstep built-in function 2019-04-07 14:11:26 +03:00
Ignacio Etcheverry ad2127a3e8 Replace a few #if/#elif with #ifdef and "#elif defined" 2019-04-05 23:41:51 +02:00
Hugo Locurcio 00799fc8c2
Add support for type hints in non-default script editor templates
This also refactors template processing to avoid repetition.

This closes #27074.
2019-04-05 23:19:30 +02:00
Rémi Verschelde fc370b3feb Fix -Wimplicit-fallthrough warnings from GCC 8
Adds `FALLTHROUGH` macro to specify when a fallthrough is intentional.
Can be replaced by `[[fallthrough]]` if/when we switch to C++17.

The warning is now enabled by default for GCC on `extra` warnings level
(part of GCC's `-Wextra`). It's not enabled in Clang's `-Wextra` yet,
but we could enable it manually once we switch to C++11. There's no
equivalent feature in MSVC for now.

Fixes #26135.
2019-04-05 15:14:53 +02:00
qarmin 8460d0678c Small fixes to static analyzer bugs 2019-04-04 22:00:16 +02:00
Rémi Verschelde e3bd84fa57
Merge pull request #27485 from Faless/io/encode_decode_safety_pr
Safer encode/decode variant.
2019-04-01 17:00:40 +02:00
Fabio Alessandrelli 393e62b98a Add object encoding param to serialization methods
Network peers get_var/put_var
File get_var/store_var
GDScript/Mono/VisualScript bytes2var/var2bytes
Add MultiplayerAPI.allow_object_decoding member which deprecates PacketPeer.allow_object_decoding.

Break ABI compatibaility (API compatibility for GDNative).
2019-04-01 15:53:19 +02:00
Rémi Verschelde 39c868171e doc: Bump version to 3.2 2019-04-01 12:33:56 +02:00
Rémi Verschelde 4ec384f9d4
Merge pull request #26097 from danielspaniol/25955-wrong-unreachable-warning-after-returning-from-matchs-wildcard-pattern
Fix: Wrong unreachable warning after returning from match's wildcard pattern #25955
2019-04-01 12:17:17 +02: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
Timo Schwarzer 7a0dfc04aa
Allow whitespaces in warning-ignore comments 2019-03-17 18:42:59 +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
Hugo Locurcio 5a574a4f29
Fix typo in GDScript narrowing conversion warning message
This closes #26790.
2019-03-08 14:28:33 +01:00
Bojidar Marinov 9637e42705
Fix enums coming from other classes without preload
Fix #19704, fix #26001
2019-03-05 23:19:02 +02:00
Juan Linietsky b63c506ad8 Close file handles after use of new get_as_utf8_strings, fixes #26578 2019-03-04 09:53:02 -03:00
Rémi Verschelde 425ec6914c
Revert "Forbid implicit type conversion in GDScript" 2019-03-04 12:25:59 +01:00
Rémi Verschelde 7889e9b7ca
Merge pull request #26562 from vnen/gdscript-no-implicit-cast
Forbid implicit type conversion in GDScript
2019-03-04 10:19:00 +01:00
George Marques 67fee40483
GDScript: Fix issue when detecting file class in inner class 2019-03-03 22:53:50 -03:00
George Marques d0b08342b8
GDScript: Forbid implicit type conversion
Since types are not present in release builds, this could cause issues
where a variable does not have the exact defined type.
2019-03-03 22:25:22 -03:00
George Marques b24cb92240
GDScript: Allow for iterator to be rededefined 2019-03-03 21:39:42 -03:00
Juan Linietsky a9fe834a8e
Merge pull request #26547 from vnen/gdscript-dependency-parse
Add a parse mode for GDScript which doesn't load dependencies
2019-03-03 18:00:12 -03:00
George Marques bda60bfa29
Add a dependency search mode for GDScript parser
- This mode avoids loading any other resource.
- Search for class_name now uses this mode, to avoid loading in the scan
thread.
- Implement get_dependencies() for GDScript loader, now exporting
dependencies only should include the preloaded resources.
2019-03-03 16:51:54 -03:00
George Marques 9db96d9f81
Merge pull request #26528 from bojidar-bg/26047-gdscript-object-argument
Allow parameters passed to GDScript functions to be nulled
2019-03-03 11:39:25 -03:00
Bojidar Marinov f0efc7521e
Allow parameters passed to GDScript functions to be nulled
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-03-03 15:24:06 +02:00
Bojidar Marinov f207b2fe0e
Fix GDScript checking for assigning to a constant only in release 2019-03-03 12:36:27 +02:00
Rémi Verschelde f2003b1a7e
Merge pull request #26034 from QbieShay/issue_25596
Inheriting from virtual class no longer causes the engine to crash.
2019-02-28 11:00:20 +01:00
QbieShay 8f22c2684f Inheriting from virtual class no longer causes the engine to crash, it prints an error instead.
Co-authored-by: Hein-Pieter van Braam <hp@tmm.cx>
2019-02-27 20:42:20 +01:00
Rémi Verschelde 426a6fdc17
Merge pull request #26134 from marxin/fix-Wsign-compare
Fix -Wsign-compare warnings.
2019-02-27 09:22:47 +01:00
marxin e5f665c718 Fix -Wsign-compare warnings.
I decided to modify code in a defensive way. Ideally functions
like size() or length() should return an unsigned type.
2019-02-27 07:45:57 +01:00
Bojidar Marinov db7864c1fd
Fix GDScript exports having the wrong type of default value by converting it
Also, initialize elements of PoolArrays when resizing them in the editor.
Fixes #26066.
2019-02-26 14:58:39 +02:00
George Marques 755c690252
Merge pull request #25018 from AllanDaemon/#24895
Fix support for optional parameters in setters
2019-02-24 10:45:50 -03:00
Rémi Verschelde 726f31e992
Merge pull request #26132 from marxin/fix-Wignored-qualifiers
Fix warnings seen with -Wignored-qualifiers.
2019-02-22 09:55:27 +01:00
Rémi Verschelde 60fe9321ac
Merge pull request #26099 from marxin/fix-Wtype-limits-warnings
Fix all -Wtype-limits warnings.
2019-02-22 09:44:59 +01:00
Juan Linietsky d13ac2a413 Request to use load when cyclic reference is found, closes #26119 2019-02-21 17:27:07 -03:00
marxin c11e7ffd0e Fix warnings seen with -Wignored-qualifiers. 2019-02-21 20:24:29 +01:00
marxin 7de7f0ef17 Fix all -Wtype-limits warnings. 2019-02-21 19:34:35 +01:00
Daniel Spaniol 79176decd5 Require return in all match branches
Before the parser only checked if the catch-all branch has a return in
order to determine if the entire match block has a return.

This code block was assumed to always return.

    match value:
        "test":
            print("test")
        _:
            return

Now as soon as one of the branches has no return, the entire match block
is marked to not have a return.
2019-02-20 21:38:11 +01:00
marxin 8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
Rémi Verschelde d35003d92a GDScript: Remove unused switch, case and do CF keywords
They had been reserved for future implementation, but we now have the
`match` CF keyword which does the same and more.

According to @reduz `do` was even added by mistake when copying from
the shader language parser, it was never intended to add support for
`do`... `while` loops, as the syntax would be awkward in GDScript,
and the added sugar is not worth it.

Fixes #25787.
2019-02-20 14:05:08 +01:00
Rémi Verschelde fd60724c3d
Merge pull request #25715 from hpvb/fix-25598
Add a maximum recusion depth to _guess_expression_type
2019-02-16 14:39:57 +01:00
Rémi Verschelde 89ca15693e
Merge pull request #25866 from neikeq/issue-25121
Fix exported property values being lost if base GDScript fails to parse
2019-02-14 09:21:19 +01:00
Ignacio Etcheverry 2f8d1a321a Fix exported property values being lost if base GDScript fails to parse 2019-02-14 02:36:19 +01:00
Rémi Verschelde 5fc86026ca Fix typos with codespell
Using codespell 1.14.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
doubleclick
lod
nd
numer
que
te
unselect
EOF
$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2019-02-13 09:23:29 +01:00
Rémi Verschelde b7cc2bb1e2 Core: Ensure classes match their header filename
Also drop some unused files.

Renamed:
- `core/dvector.h` -> `pool_vector.h`
- `core/io/resource_import.h` -> `resource_importer.h`
- `core/sort.h` -> `sort_array.h`
- `core/string_db.h` -> `string_name.h`

Dropped:
- `core/allocators.h`
- `core/os/shell.h`
- `core/variant_construct_string.cpp`
2019-02-12 13:34:25 +01:00
Rémi Verschelde 13c50e8aa5
Merge pull request #25481 from hpvb/fix-ubsan-asan-reports
Fix many asan and ubsan reported issues
2019-02-12 12:21:01 +01:00
Rémi Verschelde e40395669c
Merge pull request #25550 from DualMatrix/fix-25357
Fixed Null appearing inside export variables with type hints and no default value
2019-02-12 12:01:22 +01:00
Rémi Verschelde 6c243326bd
Merge pull request #25650 from willnationsdev/script-icon
Fix script class icons looking for paths at runtime
2019-02-09 12:22:51 +01:00
Hein-Pieter van Braam e937e74b69 Add a maximum recusion depth to _guess_expression_type
When a recursive declaration ends up in a GDScript file the
_guess_expression_type function would start looping and eventually run
out of stack space.

We now cap recusion for this function to 100 frames.

This fixes #25598
2019-02-08 22:39:08 +01:00
Will Nations c4ff433b17 Fix script class icon filepath lookups at runtime. 2019-02-06 16:17:56 -06:00
DualMatrix ff508dfede Fixed Null appearing inside export variables with type hints and no default value
The default value of the type is now used to initialise it.

export(int) A

Will now have A be 0 istead of Null even though it still showed as 0 before in the inspector, fixes #25357
2019-02-01 21:18:14 +01:00
Bojidar Marinov d2e43475b5
Fix wrong error messages for invalid arguments when calling functions through call
Fixes #25505
2019-01-31 17:02:18 +02:00
Hein-Pieter van Braam d308eb091a Fix many asan and ubsan reported issues
This allows most demos to run without any ubsan or asan errors. There
are still some things in thirdpart/ and some things in AudioServer that
needs a look but this fixes a lot of issues. This should help debug less
obvious issues, hopefully.

This fixes #25217 and fixes #25218
2019-01-30 06:43:56 +01:00
Juan Linietsky 6504b88547 Ensure get script method list also checks base classes, fixes #23384 2019-01-25 10:09:44 -03:00
George Marques 587c1c90cf GDScript: do second pass of parsing on release
Some construct (like match) actually depends on the second pass. This
adds some extra checks to not perform specific type-checks on release
since not all type information is available.
2019-01-23 18:45:33 -02:00
George Marques 8464cce857 GDScript: fix default value for autoexported typed vars 2019-01-23 18:06:58 -02:00
George Marques f439397126 GDScript: read constants from parent scripts
This is needed to create export variables from enums defined in a parent
class.
2019-01-23 17:42:06 -02:00
George Marques f4546fc0cd GDScript: don't allow calling non-static function from script 2019-01-23 17:42:06 -02:00
George Marques ba13aae9af GDScript: allow local classes to be used as types 2019-01-23 17:42:06 -02:00
Allan Daemon 465842d8ea Fix #24895 (support for optional parameters in setters) 2019-01-23 14:01:49 -02:00
Rémi Verschelde d024979e84 GDScript: Fix return value of "lerp" builtin
Fixes #25082, fixes #24709.
2019-01-18 10:47:04 +01:00
Hein-Pieter van Braam f958ba5abc
Merge pull request #25069 from vnen/gdscript-fixes
A bit more of GDScript fixes
2019-01-17 18:54:42 +01:00
George Marques 30f02dd421 GDScript compiler: check if subclass exists before comparison
Otherwise these checks might trigger the insertion of an empty value,
leading to crashes.
2019-01-17 14:38:28 -02:00
George Marques ced9fcafd4 GDScript: clarify error message about cycles
They may happen with any cyclic dependency, not only with inheritance.
2019-01-16 16:39:44 -02:00
George Marques 20e6ff263a GDScript: fix type-check of indexed values 2019-01-16 16:02:56 -02:00
Rémi Verschelde b910b22d74
Merge pull request #25001 from jlahman/gdscript-export-var-fix
Fixes export PackedScene "reset to default" throwing errors
2019-01-16 13:17:53 +01:00
jlahman 6661ceadcc Fixes export PackedScene "reset to default" throwing errors
When exporting variables from a gdscript, default values of uninitialized variables would never be set. This caused the default value to be Variant::NIL, and when a user tried to reset the variable through the editor, an error would be thrown because too few arguments would be counted(end of argument list for calls are detected by NIL values).

Fixed by simply setting default value to an empty variant of the proper type in gdscript parser.
2019-01-15 22:20:36 -05:00
George Marques 31433ae8e4 GDScript: check for underscore prefix when type-checking
Some classes are represented internally with an underscore prefix, so we
need to make sure we match this representation when type-checking,
otherwise the check might fail on a valid scenario.
2019-01-15 19:50:48 -02:00
George Marques 4f72c6be8a GDScript: consider constructors as always existing
There's always a constructor, even if implicit, especially for native
types.

Also don't check for signature match on function call, since this
information is not available in release builds.
2019-01-15 19:15:19 -02:00
George Marques b0c3a3f2da GDScript: allow objects to be keys of dictionaries
The engine allows this already, so the parser should not fail in this
case.
2019-01-15 18:18:03 -02:00
George Marques 573fab7447 GDScript: don't check types on release builds
A lot of information is missing on release, and the checks might take a
performance hit. Also, having GDScript more lenient on release is
usually desirable.
2019-01-15 17:02:15 -02:00
George Marques 4d1551dbb5 GDScript autocomplete: don't carry values when guessing from is
Guessing the type from an `is` operator should no be considered an
assigment. This would cause crashes in certain scenarios.
2019-01-15 16:03:56 -02:00
Rémi Verschelde 658296856c
Merge pull request #24877 from neikeq/issue-24280
Fix properties being lost when reloading placeholder GDScript instance
2019-01-10 18:02:57 +01:00
Rémi Verschelde 899ad484e3
Merge pull request #24883 from akien-mga/resourceformat-unregister
Consistency in resource format saver/loader de-registration
2019-01-10 14:25:09 +01:00
Andrii Doroshenko (Xrayez) c0cc032799 Fix broken encrypted scripts during export
Use temporary cache directory instead of editor settings directory
in order to resolve encrypted file access needed for encrypting scripts
on all platforms.
2019-01-10 13:53:12 +02:00
Rémi Verschelde e5f1d19352 Consistency in resource format saver/loader de-registration
Some used 'is_valid()' checks, others not. Validity is already checked in 'unref()',
and 'remove_resource_format_*()' has an ERR_FAIL condition on 'is_null()' already
(which shouldn't happen since we're only unregistering things that we previously
registered.

Also add missing GDCLASS statement in ResourceFormatLoaderVideoStreamGDNative,
missed in #20552 which was last amended before #19501 was merged.
2019-01-10 12:45:57 +01:00
Ignacio Etcheverry ea85ff0dc2 Fix properties being lost when reloading placeholder GDScript instance
During reloading in `GDScriptLanguage::reload_all_scripts` a placeholder instance that must remain so is replaced with a new placeholder instance. The state is then restored by calling `ScriptInstance::set` for each property. This does not work if the script is missing the properties due to build/parse failing.
The fix for such cases is to call `placeholder_set_fallback` instead of `set` on the script instance.

I took this chance to move the `build_failed` flag from `PlaceHolderScriptInstance` to `Script`. That improves the code a lot. I also renamed it to `placeholder_fallback_enabled` which is a much better name (`build_failed` could lead to misunderstandings).
2019-01-10 01:58:50 +01:00
Timo Schwarzer 56000929fd
Fix code completion on nodes in current scene 2019-01-05 23:17:02 +01:00
Rémi Verschelde 1ba0b2bc0b
Merge pull request #24741 from timoschwarzer/24697-fix-autocomplete-segfault-in-inner-classes
Fix segfault when trying to autocomplete in inner classes
2019-01-04 19:41:24 +01:00
Rémi Verschelde 5809be9641
Merge pull request #24582 from Xrayez/script-encrypt
Bring back script encryption in export preset
2019-01-04 16:34:38 +01:00
Timo Schwarzer d77643562b
Fix segfault when trying to autocomplete in inner classes
Fixes #24697
2019-01-03 15:51:34 +01:00