summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript.h
AgeCommit message (Collapse)Author
2020-11-07Reorganized core/ directory, it was too fatty alreadyreduz
-Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
2020-08-23GDScript: Properly resolve external inner classes from preloadGeorge Marques
This gets the correct parser and class node when resolving from a full GDScript reference.
2020-07-24Remove multilevel callsGeorge Marques
In general they are more confusing to users because they expect inheritance to fully override parent methods. This behavior can be enabled by script writers using a simple super() call.
2020-07-20Add warning checks in GDScript analyzerGeorge Marques
Reenable checking those when validating code.
2020-07-20New GDScript tokenizer and parserGeorge Marques
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-10Add override keywords.Marcel Admiraal
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
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-14Port member initialization from constructor to declaration (C++11)Rémi Verschelde
Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists.
2020-05-10fixed: saving gdscript with cyclic inheritance crash the editorThakee Nathees
Fix: #9609
2020-05-05Fix object leaks caused by unfulfilled yieldsPedro J. Estébanez
Now the stack saved in a `GDScriptFunctionState` is cleared as soon as the `yield()` operation is known not to be resumed because either the script, the instance or both are deleted. This clears problems like leaked objects by eliminating cases of circular references between `GDScriptFunctionState`s preventing them and the objects they refer to in their saved stacks from being released. As an example, this makes using `SceneTreeTimer` safer. Furthermore, with this change it's now possible to print early warnings about `yield()`s to released script/instances, as now we know they won't be successfully resumed as the condition for that happens. However, this PR doesn't add such messages, to keep the observed behavior the same for the time being. Also, now a backup of the function name in `GDScriptFunctionState` is used, since the script may not be valid by the time the function name is needed for the resume-after-yield error messages.
2020-04-21Add ability to bind typed arrays to script APIJuan Linietsky
Note: Only replaced 2 instances to test, Node.get_children and TileMap.get_used_cells Note: Will do a mass replace on later PRs of whathever I can find, but probably need a tool to grep through doc. Warning: Mono will break, needs to be fixed (and so do TypeScript and NativeScript, need to ask respective maintainers)
2020-04-20Exposed RenderingDevice to script APIJuan Linietsky
Also added an easier way to load native GLSL shaders. Extras: Had to fix no-cache for subresources in resource loader, it was not properly working, making shaders not properly reload. Note: The precommit hooks are broken because they don't seem to support enums from one class being used in another. Feel free to fix this after merging this PR.
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
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-13Merge pull request #36599 from AndreaCatania/gen_rpc_data_exportRémi Verschelde
Generates the rpc and rset info for exported GDScript.
2020-03-08Refactor ScriptDebugger.Fabio Alessandrelli
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-02-28Removed interactive loader, added proper thread loading.Juan Linietsky
2020-02-28Generates the rpc and rset info for exported GDScript.Andrea Catania
Improved the send rpc log message when fail. This work has been kindly sponsored by IMVU.
2020-02-26Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-20Reworked signal connection system, added support for Callable and Signal ↵Juan Linietsky
objects and made them default.
2020-02-19GDScript: Remove self static reference and create one on callsGeorge Marques
This is needed because of the new changes to Variant. The reference counter is increased by adding it to a Variant, which means no GDScript will be freed (or will be double freed if manually freed somewhere).
2020-02-18PoolVector is gone, replaced by VectorJuan Linietsky
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
2020-02-15Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr.Juan Linietsky
2020-02-12Optmized data sent during RPC and RSet calls.Andrea Catania
- 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-01-15Keep a weak reference to orphan subclasses to reuse on class reloadChibiDenDen
2020-01-14Add fully_qualified_name for GDScript classDani Frank
2020-01-09Add GDScript warning for standalone expressionGeorge Marques
This makes the error message clearer as it might be used to call functions with side effects.
2020-01-01Update copyright statements to 2020Rémi Verschelde
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.
2019-07-04Parse more informations for code completionGeequlim
2019-06-18Unexpose subclasses of ResourceFormatLoader and -SaverRémi Verschelde
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-03Merge pull request #28099 from lupoDharkael/fix-completionRémi Verschelde
Fix code completion not working with class_name
2019-05-20Merge pull request #27886 from LeonardMeagher2/obj_to_stringRémi Verschelde
Allow overriding how scripted objects are converted to strings
2019-05-03Allow overriding how scripted objects are converted to stringsLeonard Meagher
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-01Merge pull request #27676 from qarmin/small_fixes_2Rémi Verschelde
Small fixes to static analyzer bugs
2019-04-17Don't allow class_name in built-in scriptslupoDharkael
2019-04-16Fix code completion not working with class_namelupoDharkael
2019-04-15GDScript: add variable shadowing warninglupoDharkael
2019-04-05Add support for type hints in non-default script editor templatesHugo Locurcio
This also refactors template processing to avoid repetition. This closes #27074.
2019-04-04Small fixes to static analyzer bugsqarmin
2019-03-03Add a dependency search mode for GDScript parserGeorge Marques
- 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-01-10Merge pull request #24877 from neikeq/issue-24280Rémi Verschelde
Fix properties being lost when reloading placeholder GDScript instance
2019-01-10Fix properties being lost when reloading placeholder GDScript instanceIgnacio Etcheverry
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-01Update copyright statements to 2019Rémi Verschelde
Happy new year to the wonderful Godot community!
2018-12-15Added basic support for custom resource savers and loadersMarc Gilleron
2018-11-27Allow signal connecting even if script is invalid (only when compiled with ↵Juan Linietsky
tools), fixes #17070
2018-09-28Fix warnings about wrong member initialization order [-Wreorder]Rémi Verschelde
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-27Fix various warnings: [-Waddress], [-Wpointer-arith], [-Wwrite-strings], ↵Rémi Verschelde
[-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-15Add GDScript slave keyword deprecation warning.Fabio Alessandrelli
2018-09-13Merge pull request #21982 from luzpaz/misc-typosRémi Verschelde
Misc. typos