Commit graph

47 commits

Author SHA1 Message Date
Juan Linietsky 867d073b98 Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr. 2020-02-15 08:36:04 -03:00
Andrea Catania eb07e87981 Optmized data sent during RPC and RSet calls.
- Now is sent the method ID rather the full function name.
- The passed IDs (Node and Method) are compressed so to use less possible space.
- The variant (INT and BOOL) is now encoded and compressed so to use much less data.
- Optimized RPCMode retrieval for GDScript functions.
- Added checksum to assert the methods are the same across peers.

This work has been kindly sponsored by IMVU.
2020-02-12 13:36:47 +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 7d4fc79eb3
Add GDScript warning for standalone expression
This makes the error message clearer as it might be used to call
functions with side effects.
2020-01-09 08:30:14 -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
Geequlim ed7ed52151 Parse more informations for code completion 2019-07-04 14:00:14 +08:00
Rémi Verschelde d6176db271 Unexpose subclasses of ResourceFormatLoader and -Saver
ResourceFormatLoader and ResourceFormatSaver are meant to be overridden
to add support for different formats in ResourceLoader and ResourceSaver.
Those should be exposed as they can be overridden in plugins.

On the other hand, all predefined subclasses of those two base classes
are only meant to register support for new file and resource types, but
should not and cannot be used directly from script, so they should not
be exposed.

Also unexposed ResourceImporterOGGVorbis (and thus its base class
ResourceImporter) which are editor-only.
2019-06-18 17:56:23 +02:00
Rémi Verschelde b9dc2e7e4d
Merge pull request #28099 from lupoDharkael/fix-completion
Fix code completion not working with class_name
2019-06-03 14:01:07 +02:00
Rémi Verschelde defd960276
Merge pull request #27886 from LeonardMeagher2/obj_to_string
Allow overriding how scripted objects are converted to strings
2019-05-20 22:37:01 +02:00
Leonard Meagher f7eb426e2e Allow overriding how scripted objects are converted to strings
solves #26796

- ADD `String to_string()` method to Object which can be overriden by `String _to_string()` in scripts
- ADD `String to_string(r_valid)` method to ScriptInstance to allow langauges to control how scripted objects are converted to strings
- IMPLEMENT to_string for GDScriptInstance, VisualScriptInstance, and NativeScriptInstance
- ADD Documentation about `Object.to_string` and `Object._to_string`
- Changed `Variant::operator String` to use `obj->to_string()`
2019-05-03 15:06:05 -07:00
Rémi Verschelde ae41e35191
Merge pull request #27676 from qarmin/small_fixes_2
Small fixes to static analyzer bugs
2019-05-01 08:19:04 +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 14078fbb82 GDScript: add variable shadowing warning 2019-04-15 18:19:14 +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
qarmin 8460d0678c Small fixes to static analyzer bugs 2019-04-04 22:00:16 +02: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
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
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
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Marc Gilleron 065e2670af Added basic support for custom resource savers and loaders 2018-12-15 05:34:53 +00:00
Juan Linietsky 3a93499f89 Allow signal connecting even if script is invalid (only when compiled with tools), fixes #17070 2018-11-27 19:55:37 -03:00
Rémi Verschelde 2091f20443 Fix warnings about wrong member initialization order [-Wreorder]
Fixes the following GCC 5 warnings:
```
core/object.h:193:11: warning: 'MethodInfo::flags' will be initialized after [-Wreorder]
core/object.h:192:15: warning:   'PropertyInfo MethodInfo::return_val' [-Wreorder]
core/object.cpp:278:1: warning:   when initialized here [-Wreorder]
core/script_debugger_remote.h:97:6: warning: 'ScriptDebuggerRemote::max_cps' will be initialized after [-Wreorder]
core/script_debugger_remote.h:91:6: warning:   'int ScriptDebuggerRemote::max_messages_per_frame' [-Wreorder]
core/script_debugger_remote.cpp:1086:1: warning:   when initialized here [-Wreorder]
core/script_debugger_remote.h:98:6: warning: 'ScriptDebuggerRemote::char_count' will be initialized after [-Wreorder]
core/script_debugger_remote.h:92:6: warning:   'int ScriptDebuggerRemote::n_messages_dropped' [-Wreorder]
core/script_debugger_remote.cpp:1086:1: warning:   when initialized here [-Wreorder]
modules/bullet/area_bullet.h:102:7: warning: 'AreaBullet::isScratched' will be initialized after [-Wreorder]
modules/bullet/area_bullet.h:92:39: warning:   'PhysicsServer::AreaSpaceOverrideMode AreaBullet::spOv_mode' [-Wreorder]
modules/bullet/area_bullet.cpp:46:1: warning:   when initialized here [-Wreorder]
modules/bullet/collision_object_bullet.h:127:15: warning: 'CollisionObjectBullet::space' will be initialized after [-Wreorder]
modules/bullet/collision_object_bullet.h:117:7: warning:   'CollisionObjectBullet::Type CollisionObjectBullet::type' [-Wreorder]
modules/bullet/collision_object_bullet.cpp:67:1: warning:   when initialized here [-Wreorder]
modules/bullet/godot_ray_world_algorithm.h:48:7: warning: 'GodotRayWorldAlgorithm::m_ownManifol1d' will be initialized after [-Wreorder]
modules/bullet/godot_ray_world_algorithm.h:46:33: warning:   'const btDiscreteDynamicsWorld* GodotRayWorldAlgorithm::m_world' [-Wreorder]
modules/bullet/godot_ray_world_algorithm.cpp:50:1: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:91:18: warning: 'GodotAllConvexResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:89:6: warning:   'int GodotAllConvexResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:93:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:142:18: warning: 'GodotAllContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:140:6: warning:   'int GodotAllContactResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:147:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:168:18: warning: 'GodotContactPairContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:166:6: warning:   'int GodotContactPairContactResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:173:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:195:18: warning: 'GodotRestInfoContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:191:7: warning:   'bool GodotRestInfoContactResultCallback::m_collided' [-Wreorder]
modules/bullet/godot_result_callbacks.h:199:2: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:200:9: warning: 'RigidBodyBullet::gravity_scale' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:199:9: warning:   'real_t RigidBodyBullet::mass' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:222:28: warning: 'RigidBodyBullet::force_integration_callback' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:219:7: warning:   'bool RigidBodyBullet::isTransformChanged' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:220:7: warning: 'RigidBodyBullet::previousActiveState' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:208:6: warning:   'int RigidBodyBullet::maxCollisionsDetection' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/soft_body_bullet.h:69:9: warning: 'SoftBodyBullet::total_mass' will be initialized after [-Wreorder]
modules/bullet/soft_body_bullet.h:68:6: warning:   'int SoftBodyBullet::simulation_precision' [-Wreorder]
modules/bullet/soft_body_bullet.cpp:38:1: warning:   when initialized here [-Wreorder]
modules/bullet/soft_body_bullet.h:76:9: warning: 'SoftBodyBullet::drag_coefficient' will be initialized after [-Wreorder]
modules/bullet/soft_body_bullet.h:61:14: warning:   'btSoftBody* SoftBodyBullet::bt_soft_body' [-Wreorder]
modules/bullet/soft_body_bullet.cpp:38:1: warning:   when initialized here [-Wreorder]
modules/bullet/space_bullet.h:97:22: warning: 'SpaceBullet::solver' will be initialized after [-Wreorder]
modules/bullet/space_bullet.h:95:35: warning:   'btDefaultCollisionConfiguration* SpaceBullet::collisionConfiguration' [-Wreorder]
modules/bullet/space_bullet.cpp:333:1: warning:   when initialized here [-Wreorder]
modules/bullet/space_bullet.h:101:23: warning: 'SpaceBullet::soft_body_world_info' will be initialized after [-Wreorder]
modules/bullet/space_bullet.h:99:23: warning:   'btGhostPairCallback* SpaceBullet::ghostPairCallback' [-Wreorder]
modules/bullet/space_bullet.cpp:333:1: warning:   when initialized here [-Wreorder]
modules/gdnative/nativescript/nativescript.h:79:13: warning: 'NativeScriptDesc::base_native_type' will be initialized after [-Wreorder]
modules/gdnative/nativescript/nativescript.h:73:9: warning:   'String NativeScriptDesc::documentation' [-Wreorder]
modules/gdnative/nativescript/nativescript.h:88:9: warning:   when initialized here [-Wreorder]
modules/gdscript/gdscript.h:296:6: warning: 'GDScriptWarning::line' will be initialized after [-Wreorder]
modules/gdscript/gdscript.h:294:4: warning:   'GDScriptWarning::Code GDScriptWarning::code' [-Wreorder]
modules/gdscript/gdscript.h:303:2: warning:   when initialized here [-Wreorder]
scene/3d/physics_body.h:544:7: warning: 'PhysicalBone::simulate_physics' will be initialized after [-Wreorder]
scene/3d/physics_body.h:543:7: warning:   'bool PhysicalBone::_internal_static_body' [-Wreorder]
scene/3d/physics_body.cpp:2502:1: warning:   when initialized here [-Wreorder]
scene/3d/physics_body.h:546:6: warning: 'PhysicalBone::bone_id' will be initialized after [-Wreorder]
scene/3d/physics_body.h:539:12: warning:   'Skeleton* PhysicalBone::parent_skeleton' [-Wreorder]
scene/3d/physics_body.cpp:2502:1: warning:   when initialized here [-Wreorder]
scene/3d/spring_arm.h:44:11: warning: 'SpringArm::mask' will be initialized after [-Wreorder]
scene/3d/spring_arm.h:43:8: warning:   'float SpringArm::current_spring_length' [-Wreorder]
scene/3d/spring_arm.cpp:37:1: warning:   when initialized here [-Wreorder]
scene/animation/skeleton_ik.h:159:11: warning: 'SkeletonIK::target_node_override' will be initialized after [-Wreorder]
scene/animation/skeleton_ik.h:152:7: warning:   'bool SkeletonIK::use_magnet' [-Wreorder]
scene/animation/skeleton_ik.cpp:418:1: warning:   when initialized here [-Wreorder]
scene/resources/tile_set.h:84:9: warning: 'TileSet::AutotileData::size' will be initialized after [-Wreorder]
scene/resources/tile_set.h:83:7: warning:   'int TileSet::AutotileData::spacing' [-Wreorder]
scene/resources/tile_set.h:92:12: warning:   when initialized here [-Wreorder]
scene/resources/tile_set.h:115:12: warning: 'TileSet::TileData::tile_mode' will be initialized after [-Wreorder]
scene/resources/tile_set.h:114:9: warning:   'Color TileSet::TileData::modulate' [-Wreorder]
scene/resources/tile_set.h:120:12: warning:   when initialized here [-Wreorder]
servers/physics/body_sw.h:84:19: warning: 'BodySW::direct_state_query_list' will be initialized after [-Wreorder]
servers/physics/body_sw.h:57:11: warning:   'uint16_t BodySW::locked_axis' [-Wreorder]
servers/physics/body_sw.cpp:756:1: warning:   when initialized here [-Wreorder]
```

Nothing really relevant for us, but it's not a bad consistency
improvement anyway so worth taking.
2018-09-28 17:30:28 +02:00
Rémi Verschelde cdc411fd54 Fix various warnings: [-Waddress], [-Wpointer-arith], [-Wwrite-strings], [-Wreturn-local-addr] and more
Fixes the following GCC 5 warnings:
```
core/os/file_access.cpp:49:19: warning: the address of 'FileAccess::create_func' will always evaluate as 'true' [-Waddress]
servers/audio_server.cpp:192:70: warning: comparison with string literal results in unspecified behaviour [-Waddress]

drivers/gles2/rasterizer_storage_gles2.cpp:4095:90: warning: NULL used in arithmetic [-Wpointer-arith]

modules/gdnative/register_types.cpp:237:3: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
platform/android/export/export.cpp:207:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

modules/gdscript/gdscript.h:150:67: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:119:56: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:123:56: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:127:50: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:131:52: warning: returning reference to temporary [-Wreturn-local-addr]

editor/plugins/skeleton_editor_plugin.cpp:34:36: warning: extra tokens at end of #include directive
modules/bullet/bullet_types_converter.cpp:31:9: warning: #pragma once in main file

editor/import/editor_scene_importer_gltf.cpp:1996:51: warning: name lookup of 'i' changed
modules/visual_script/visual_script_property_selector.cpp:402:45: warning: name lookup of 'E' changed
scene/gui/tree.cpp:1268:25: warning: name lookup of 'i' changed
scene/resources/visual_shader.cpp:808:32: warning: name lookup of 'i' changed
```
2018-09-27 16:33:52 +02:00
Fabio Alessandrelli c0e4d7efca Add GDScript slave keyword deprecation warning. 2018-09-15 01:50:34 +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
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
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
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
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 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 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 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
Juan Linietsky a3f1ee5c57 Global class names (and GDScript support for it) 2018-07-15 19:29:00 -03: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
Fabio Alessandrelli 9de4ffde61 Refactor RPCMode enum and checks 2018-05-26 10:43:43 +02:00
George Marques decf178033
Enable autoload in editor
- Tool scripts will be executed and can be accessed by plugins.
- Other script languages can implement add/remove_named_global_constant
to make use of this functionality.
2018-05-01 11:44:08 -03:00
Ignacio Etcheverry 5be356b72f Mono: Implement stack info for errors and exceptions 2018-01-09 17:19:03 +01:00
Rémi Verschelde e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
geequlim 475cee9c0f Abstract some method for script system 2017-11-17 09:20:32 +08:00
Rémi Verschelde 4cfc29611e GDScript: Refactor "GD" class prefix to "GDScript" 2017-11-16 18:54:56 +01:00
Renamed from modules/gdscript/gd_script.h (Browse further)