summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/SCsub8
-rw-r--r--modules/bullet/SCsub24
-rw-r--r--modules/bullet/SCsub_with_lib33
-rw-r--r--modules/bullet/area_bullet.cpp17
-rw-r--r--modules/bullet/area_bullet.h7
-rw-r--r--modules/bullet/btRayShape.cpp13
-rw-r--r--modules/bullet/btRayShape.h13
-rw-r--r--modules/bullet/bullet_physics_server.cpp42
-rw-r--r--modules/bullet/bullet_physics_server.h14
-rw-r--r--modules/bullet/bullet_types_converter.cpp7
-rw-r--r--modules/bullet/bullet_types_converter.h14
-rw-r--r--modules/bullet/bullet_utilities.h7
-rw-r--r--modules/bullet/collision_object_bullet.cpp40
-rw-r--r--modules/bullet/collision_object_bullet.h12
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp11
-rw-r--r--modules/bullet/cone_twist_joint_bullet.h7
-rw-r--r--modules/bullet/constraint_bullet.cpp20
-rw-r--r--modules/bullet/constraint_bullet.h14
-rw-r--r--modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml2
-rw-r--r--modules/bullet/doc_classes/BulletPhysicsServer.xml2
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp11
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.h7
-rw-r--r--modules/bullet/godot_collision_configuration.cpp13
-rw-r--r--modules/bullet/godot_collision_configuration.h9
-rw-r--r--modules/bullet/godot_collision_dispatcher.cpp8
-rw-r--r--modules/bullet/godot_collision_dispatcher.h8
-rw-r--r--modules/bullet/godot_motion_state.h12
-rw-r--r--modules/bullet/godot_ray_world_algorithm.cpp24
-rw-r--r--modules/bullet/godot_ray_world_algorithm.h15
-rw-r--r--modules/bullet/godot_result_callbacks.cpp8
-rw-r--r--modules/bullet/godot_result_callbacks.h14
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp11
-rw-r--r--modules/bullet/hinge_joint_bullet.h7
-rw-r--r--modules/bullet/joint_bullet.cpp8
-rw-r--r--modules/bullet/joint_bullet.h7
-rw-r--r--modules/bullet/pin_joint_bullet.cpp11
-rw-r--r--modules/bullet/pin_joint_bullet.h7
-rw-r--r--modules/bullet/register_types.cpp8
-rw-r--r--modules/bullet/register_types.h7
-rw-r--r--modules/bullet/rid_bullet.h7
-rw-r--r--modules/bullet/rigid_body_bullet.cpp37
-rw-r--r--modules/bullet/rigid_body_bullet.h22
-rw-r--r--modules/bullet/shape_bullet.cpp24
-rw-r--r--modules/bullet/shape_bullet.h31
-rw-r--r--modules/bullet/shape_owner_bullet.cpp7
-rw-r--r--modules/bullet/shape_owner_bullet.h9
-rw-r--r--modules/bullet/slider_joint_bullet.cpp11
-rw-r--r--modules/bullet/slider_joint_bullet.h7
-rw-r--r--modules/bullet/soft_body_bullet.cpp9
-rw-r--r--modules/bullet/soft_body_bullet.h13
-rw-r--r--modules/bullet/space_bullet.cpp133
-rw-r--r--modules/bullet/space_bullet.h31
-rw-r--r--modules/dds/register_types.cpp1
-rw-r--r--modules/dds/register_types.h1
-rw-r--r--modules/dds/texture_loader_dds.cpp1
-rw-r--r--modules/dds/texture_loader_dds.h1
-rw-r--r--modules/enet/SCsub4
-rw-r--r--modules/enet/doc_classes/NetworkedMultiplayerENet.xml20
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp7
-rw-r--r--modules/enet/networked_multiplayer_enet.h2
-rw-r--r--modules/enet/register_types.cpp1
-rw-r--r--modules/enet/register_types.h1
-rw-r--r--modules/etc/image_etc.cpp21
-rw-r--r--modules/etc/image_etc.h1
-rw-r--r--modules/etc/register_types.cpp1
-rw-r--r--modules/etc/register_types.h1
-rw-r--r--modules/etc/texture_loader_pkm.cpp1
-rw-r--r--modules/etc/texture_loader_pkm.h1
-rw-r--r--modules/freetype/register_types.cpp1
-rw-r--r--modules/freetype/register_types.h1
-rw-r--r--modules/gdnative/SCsub60
-rw-r--r--modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml2
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml2
-rw-r--r--modules/gdnative/doc_classes/GDNativeLibrary.xml4
-rw-r--r--modules/gdnative/doc_classes/NativeScript.xml38
-rw-r--r--modules/gdnative/doc_classes/PluginScript.xml2
-rw-r--r--modules/gdnative/gdnative.cpp38
-rw-r--r--modules/gdnative/gdnative.h10
-rw-r--r--modules/gdnative/gdnative/aabb.cpp3
-rw-r--r--modules/gdnative/gdnative/array.cpp1
-rw-r--r--modules/gdnative/gdnative/basis.cpp1
-rw-r--r--modules/gdnative/gdnative/color.cpp1
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp1
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp1
-rw-r--r--modules/gdnative/gdnative/node_path.cpp1
-rw-r--r--modules/gdnative/gdnative/plane.cpp1
-rw-r--r--modules/gdnative/gdnative/pool_arrays.cpp57
-rw-r--r--modules/gdnative/gdnative/quat.cpp1
-rw-r--r--modules/gdnative/gdnative/rect2.cpp1
-rw-r--r--modules/gdnative/gdnative/rid.cpp1
-rw-r--r--modules/gdnative/gdnative/string.cpp265
-rw-r--r--modules/gdnative/gdnative/string_name.cpp5
-rw-r--r--modules/gdnative/gdnative/transform.cpp5
-rw-r--r--modules/gdnative/gdnative/transform2d.cpp1
-rw-r--r--modules/gdnative/gdnative/variant.cpp1
-rw-r--r--modules/gdnative/gdnative/vector2.cpp1
-rw-r--r--modules/gdnative/gdnative/vector3.cpp1
-rw-r--r--modules/gdnative/gdnative_api.json283
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h3
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.cpp3
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.h3
-rw-r--r--modules/gdnative/include/arvr/godot_arvr.h1
-rw-r--r--modules/gdnative/include/gdnative/aabb.h3
-rw-r--r--modules/gdnative/include/gdnative/basis.h1
-rw-r--r--modules/gdnative/include/gdnative/color.h1
-rw-r--r--modules/gdnative/include/gdnative/dictionary.h1
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h3
-rw-r--r--modules/gdnative/include/gdnative/node_path.h1
-rw-r--r--modules/gdnative/include/gdnative/plane.h1
-rw-r--r--modules/gdnative/include/gdnative/pool_arrays.h15
-rw-r--r--modules/gdnative/include/gdnative/quat.h1
-rw-r--r--modules/gdnative/include/gdnative/rect2.h1
-rw-r--r--modules/gdnative/include/gdnative/rid.h1
-rw-r--r--modules/gdnative/include/gdnative/string.h33
-rw-r--r--modules/gdnative/include/gdnative/string_name.h5
-rw-r--r--modules/gdnative/include/gdnative/transform.h5
-rw-r--r--modules/gdnative/include/gdnative/transform2d.h1
-rw-r--r--modules/gdnative/include/gdnative/variant.h3
-rw-r--r--modules/gdnative/include/gdnative/vector2.h1
-rw-r--r--modules/gdnative/include/gdnative/vector3.h1
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h49
-rw-r--r--modules/gdnative/include/pluginscript/godot_pluginscript.h3
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp1
-rw-r--r--modules/gdnative/nativescript/api_generator.h1
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp165
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp302
-rw-r--r--modules/gdnative/nativescript/nativescript.h35
-rw-r--r--modules/gdnative/nativescript/register_types.cpp2
-rw-r--r--modules/gdnative/nativescript/register_types.h1
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.cpp7
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp11
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp51
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h6
-rw-r--r--modules/gdnative/pluginscript/register_types.cpp3
-rw-r--r--modules/gdnative/pluginscript/register_types.h3
-rw-r--r--modules/gdnative/register_types.cpp1
-rw-r--r--modules/gdnative/register_types.h1
-rw-r--r--modules/gdscript/doc_classes/GDScript.xml3
-rw-r--r--modules/gdscript/doc_classes/GDScriptFunctionState.xml2
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml2
-rw-r--r--modules/gdscript/gdscript.cpp3
-rw-r--r--modules/gdscript/gdscript.h5
-rw-r--r--modules/gdscript/gdscript_compiler.cpp39
-rw-r--r--modules/gdscript/gdscript_compiler.h1
-rw-r--r--modules/gdscript/gdscript_editor.cpp21
-rw-r--r--modules/gdscript/gdscript_function.cpp1
-rw-r--r--modules/gdscript/gdscript_function.h1
-rw-r--r--modules/gdscript/gdscript_functions.cpp9
-rw-r--r--modules/gdscript/gdscript_functions.h1
-rw-r--r--modules/gdscript/gdscript_parser.cpp9
-rw-r--r--modules/gdscript/gdscript_parser.h1
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp1
-rw-r--r--modules/gdscript/gdscript_tokenizer.h1
-rw-r--r--modules/gdscript/register_types.cpp1
-rw-r--r--modules/gdscript/register_types.h1
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml119
-rw-r--r--modules/gridmap/grid_map.cpp61
-rw-r--r--modules/gridmap/grid_map.h3
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp1
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h1
-rw-r--r--modules/gridmap/register_types.cpp1
-rw-r--r--modules/gridmap/register_types.h1
-rw-r--r--modules/hdr/image_loader_hdr.cpp1
-rw-r--r--modules/hdr/image_loader_hdr.h1
-rw-r--r--modules/hdr/register_types.cpp1
-rw-r--r--modules/hdr/register_types.h1
-rw-r--r--modules/jpg/image_loader_jpegd.cpp1
-rw-r--r--modules/jpg/image_loader_jpegd.h1
-rw-r--r--modules/jpg/register_types.cpp1
-rw-r--r--modules/jpg/register_types.h1
-rwxr-xr-xmodules/mbedtls/SCsub91
-rwxr-xr-x[-rw-r--r--]modules/mbedtls/config.py (renamed from modules/openssl/config.py)0
-rwxr-xr-x[-rw-r--r--]modules/mbedtls/register_types.cpp (renamed from modules/openssl/register_types.cpp)13
-rwxr-xr-x[-rw-r--r--]modules/mbedtls/register_types.h (renamed from modules/openssl/register_types.h)5
-rwxr-xr-xmodules/mbedtls/stream_peer_mbed_tls.cpp325
-rwxr-xr-x[-rw-r--r--]modules/mbedtls/stream_peer_mbed_tls.h (renamed from modules/openssl/stream_peer_openssl.h)64
-rw-r--r--modules/mobile_vr/doc_classes/MobileVRInterface.xml2
-rw-r--r--modules/mobile_vr/mobile_interface.cpp4
-rw-r--r--modules/mobile_vr/mobile_interface.h3
-rw-r--r--modules/mobile_vr/register_types.cpp1
-rw-r--r--modules/mobile_vr/register_types.h1
-rw-r--r--modules/mono/SCsub4
-rw-r--r--modules/mono/config.py1
-rw-r--r--modules/mono/csharp_script.cpp143
-rw-r--r--modules/mono/csharp_script.h11
-rw-r--r--modules/mono/doc_classes/@C#.xml2
-rw-r--r--modules/mono/doc_classes/CSharpScript.xml2
-rw-r--r--modules/mono/doc_classes/GodotSharp.xml2
-rw-r--r--modules/mono/editor/bindings_generator.cpp170
-rw-r--r--modules/mono/editor/bindings_generator.h13
-rw-r--r--modules/mono/editor/csharp_project.cpp1
-rw-r--r--modules/mono/editor/csharp_project.h1
-rw-r--r--modules/mono/editor/godotsharp_builds.cpp1
-rw-r--r--modules/mono/editor/godotsharp_builds.h1
-rw-r--r--modules/mono/editor/godotsharp_editor.cpp94
-rw-r--r--modules/mono/editor/godotsharp_editor.h9
-rw-r--r--modules/mono/editor/mono_bottom_panel.cpp3
-rw-r--r--modules/mono/editor/mono_bottom_panel.h1
-rw-r--r--modules/mono/editor/mono_build_info.h1
-rw-r--r--modules/mono/editor/monodevelop_instance.cpp3
-rw-r--r--modules/mono/editor/monodevelop_instance.h3
-rw-r--r--modules/mono/editor/net_solution.cpp1
-rw-r--r--modules/mono/editor/net_solution.h1
-rw-r--r--modules/mono/glue/builtin_types_glue.h59
-rw-r--r--modules/mono/glue/cs_files/Color.cs26
-rw-r--r--modules/mono/glue/cs_files/DebuggingUtils.cs83
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs2
-rw-r--r--modules/mono/glue/cs_files/Plane.cs2
-rw-r--r--modules/mono/glue/glue_header.h19
-rw-r--r--modules/mono/godotsharp_defs.h1
-rw-r--r--modules/mono/godotsharp_dirs.cpp1
-rw-r--r--modules/mono/godotsharp_dirs.h1
-rw-r--r--modules/mono/mono_gc_handle.cpp1
-rw-r--r--modules/mono/mono_gc_handle.h1
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp15
-rw-r--r--modules/mono/mono_gd/gd_mono.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp32
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.h3
-rw-r--r--modules/mono/mono_gd/gd_mono_class.cpp15
-rw-r--r--modules/mono/mono_gd/gd_mono_class.h9
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_field.h3
-rw-r--r--modules/mono/mono_gd/gd_mono_header.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp3
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.h3
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_log.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp17
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h2
-rw-r--r--modules/mono/mono_gd/gd_mono_method.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_method.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_property.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp100
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h35
-rw-r--r--modules/mono/register_types.cpp1
-rw-r--r--modules/mono/register_types.h1
-rw-r--r--modules/mono/signal_awaiter_utils.cpp3
-rw-r--r--modules/mono/signal_awaiter_utils.h1
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp1
-rw-r--r--modules/mono/utils/mono_reg_utils.h1
-rw-r--r--modules/mono/utils/path_utils.cpp1
-rw-r--r--modules/mono/utils/path_utils.h1
-rw-r--r--modules/mono/utils/string_utils.cpp1
-rw-r--r--modules/mono/utils/string_utils.h1
-rw-r--r--modules/ogg/register_types.cpp1
-rw-r--r--modules/ogg/register_types.h1
-rw-r--r--modules/openssl/SCsub696
-rw-r--r--modules/openssl/stream_peer_openssl.cpp631
-rw-r--r--modules/opus/audio_stream_opus.cpp7
-rw-r--r--modules/opus/audio_stream_opus.h6
-rw-r--r--modules/opus/register_types.cpp1
-rw-r--r--modules/opus/register_types.h1
-rw-r--r--modules/opus/stub/register_types.cpp3
-rw-r--r--modules/opus/stub/register_types.h3
-rw-r--r--modules/pbm/SCsub8
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp236
-rw-r--r--modules/pvr/register_types.cpp1
-rw-r--r--modules/pvr/register_types.h1
-rw-r--r--modules/pvr/texture_loader_pvr.cpp1
-rw-r--r--modules/pvr/texture_loader_pvr.h1
-rw-r--r--modules/regex/doc_classes/RegEx.xml2
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml34
-rw-r--r--modules/regex/regex.cpp31
-rw-r--r--modules/register_module_types.h1
-rw-r--r--modules/squish/image_compress_squish.cpp1
-rw-r--r--modules/squish/image_compress_squish.h1
-rw-r--r--modules/squish/register_types.cpp1
-rw-r--r--modules/squish/register_types.h1
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp19
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h5
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml50
-rw-r--r--modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml2
-rw-r--r--modules/stb_vorbis/register_types.cpp1
-rw-r--r--modules/stb_vorbis/register_types.h1
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp1
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.h1
-rw-r--r--modules/svg/image_loader_svg.cpp1
-rw-r--r--modules/svg/image_loader_svg.h1
-rw-r--r--modules/svg/register_types.cpp1
-rw-r--r--modules/svg/register_types.h1
-rw-r--r--modules/tga/image_loader_tga.cpp1
-rw-r--r--modules/tga/image_loader_tga.h1
-rw-r--r--modules/tga/register_types.cpp1
-rw-r--r--modules/tga/register_types.h1
-rw-r--r--modules/thekla_unwrap/register_types.cpp1
-rw-r--r--modules/thekla_unwrap/register_types.h1
-rw-r--r--modules/theora/doc_classes/ResourceImporterTheora.xml2
-rw-r--r--modules/theora/doc_classes/VideoStreamTheora.xml2
-rw-r--r--modules/theora/register_types.cpp1
-rw-r--r--modules/theora/register_types.h1
-rw-r--r--modules/theora/resource_importer_theora.cpp3
-rw-r--r--modules/theora/resource_importer_theora.h3
-rw-r--r--modules/theora/video_stream_theora.cpp3
-rw-r--r--modules/theora/video_stream_theora.h1
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp1
-rw-r--r--modules/tinyexr/image_loader_tinyexr.h1
-rw-r--r--modules/tinyexr/register_types.cpp1
-rw-r--r--modules/tinyexr/register_types.h1
-rw-r--r--modules/visual_script/doc_classes/VisualScript.xml3
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptClassConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptComment.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptCondition.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptConstructor.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptCustomNode.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptDeconstruct.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEditor.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEmitSignal.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptExpression.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunction.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionCall.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionState.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptIndexGet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptIndexSet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptInputAction.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptIterator.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVar.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptMathConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptNode.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptOperator.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPreload.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertyGet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertySet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptResourcePath.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptReturn.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSceneNode.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSceneTree.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSelect.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSelf.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSequence.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSubCall.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSwitch.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptTypeCast.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptVariableGet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptVariableSet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptWhile.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptYield.xml18
-rw-r--r--modules/visual_script/doc_classes/VisualScriptYieldSignal.xml2
-rw-r--r--modules/visual_script/register_types.cpp1
-rw-r--r--modules/visual_script/register_types.h1
-rw-r--r--modules/visual_script/visual_script.cpp5
-rw-r--r--modules/visual_script/visual_script.h7
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp17
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h1
-rw-r--r--modules/visual_script/visual_script_editor.cpp4
-rw-r--r--modules/visual_script/visual_script_editor.h1
-rw-r--r--modules/visual_script/visual_script_expression.cpp1
-rw-r--r--modules/visual_script/visual_script_expression.h1
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp1
-rw-r--r--modules/visual_script/visual_script_flow_control.h1
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp15
-rw-r--r--modules/visual_script/visual_script_func_nodes.h1
-rw-r--r--modules/visual_script/visual_script_nodes.cpp7
-rw-r--r--modules/visual_script/visual_script_nodes.h1
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp1
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h1
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp1
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.h1
-rw-r--r--modules/vorbis/register_types.cpp1
-rw-r--r--modules/vorbis/register_types.h1
-rw-r--r--modules/vorbis/stub/register_types.cpp3
-rw-r--r--modules/vorbis/stub/register_types.h3
-rw-r--r--modules/webm/doc_classes/ResourceImporterWebm.xml2
-rw-r--r--modules/webm/doc_classes/VideoStreamWebm.xml2
-rw-r--r--modules/webm/libvpx/SCsub4
-rw-r--r--modules/webm/register_types.cpp1
-rw-r--r--modules/webm/register_types.h1
-rw-r--r--modules/webm/resource_importer_webm.cpp3
-rw-r--r--modules/webm/resource_importer_webm.h3
-rw-r--r--modules/webm/video_stream_webm.cpp3
-rw-r--r--modules/webm/video_stream_webm.h6
-rw-r--r--modules/webp/image_loader_webp.cpp1
-rw-r--r--modules/webp/image_loader_webp.h1
-rw-r--r--modules/webp/register_types.cpp1
-rw-r--r--modules/webp/register_types.h1
-rw-r--r--modules/websocket/SCsub81
-rw-r--r--modules/websocket/config.py (renamed from modules/pbm/config.py)2
-rw-r--r--modules/websocket/emws_client.cpp224
-rw-r--r--modules/websocket/emws_client.h62
-rw-r--r--modules/websocket/emws_peer.cpp173
-rw-r--r--modules/websocket/emws_peer.h85
-rw-r--r--modules/websocket/emws_server.cpp (renamed from modules/pbm/register_types.cpp)44
-rw-r--r--modules/websocket/emws_server.h (renamed from modules/pbm/bitmap_loader_pbm.h)39
-rw-r--r--modules/websocket/lws_client.cpp203
-rw-r--r--modules/websocket/lws_client.h61
-rw-r--r--modules/websocket/lws_helper.h214
-rw-r--r--modules/websocket/lws_peer.cpp200
-rw-r--r--modules/websocket/lws_peer.h92
-rw-r--r--modules/websocket/lws_server.cpp177
-rw-r--r--modules/websocket/lws_server.h63
-rw-r--r--modules/websocket/register_types.cpp79
-rw-r--r--modules/websocket/register_types.h (renamed from modules/pbm/register_types.h)8
-rw-r--r--modules/websocket/websocket_client.cpp124
-rw-r--r--modules/websocket/websocket_client.h68
-rw-r--r--modules/websocket/websocket_macros.h63
-rw-r--r--modules/websocket/websocket_multiplayer.cpp361
-rw-r--r--modules/websocket/websocket_multiplayer.h110
-rw-r--r--modules/websocket/websocket_peer.cpp49
-rw-r--r--modules/websocket/websocket_peer.h73
-rw-r--r--modules/websocket/websocket_server.cpp94
-rw-r--r--modules/websocket/websocket_server.h63
410 files changed, 6139 insertions, 2830 deletions
diff --git a/modules/SCsub b/modules/SCsub
index e3c535e981..74a5267355 100644
--- a/modules/SCsub
+++ b/modules/SCsub
@@ -17,6 +17,10 @@ for x in env.module_list:
env_modules.Append(CPPFLAGS=["-DMODULE_" + x.upper() + "_ENABLED"])
SConscript(x + "/SCsub")
-lib = env_modules.add_library("modules", env.modules_sources)
+if env.split_modules:
+ env.split_lib("modules", env_lib = env_modules)
+else:
-env.Prepend(LIBS=[lib])
+ lib = env_modules.add_library("modules", env.modules_sources)
+
+ env.Prepend(LIBS=[lib])
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub
index 0967bca3f2..d8d0b930a5 100644
--- a/modules/bullet/SCsub
+++ b/modules/bullet/SCsub
@@ -3,12 +3,15 @@
Import('env')
Import('env_modules')
-# build only version 2
-# Bullet 2.87
-
env_bullet = env_modules.Clone()
-bullet_src__2_x = [
+# Thirdparty source files
+
+if env['builtin_bullet']:
+ # Build only version 2 for now (as of 2.87)
+ thirdparty_dir = "#thirdparty/bullet/"
+
+ bullet2_src = [
# BulletCollision
"BulletCollision/BroadphaseCollision/btAxisSweep3.cpp"
, "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp"
@@ -179,17 +182,10 @@ bullet_src__2_x = [
, "LinearMath/btVector3.cpp"
]
-thirdparty_dir = "#thirdparty/bullet/"
-thirdparty_src = thirdparty_dir + "src/"
+ thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]
-bullet_sources = [thirdparty_src + file for file in bullet_src__2_x]
-
-# include headers
-env_bullet.Append(CPPPATH=[thirdparty_src])
-
-env_bullet.add_source_files(env.modules_sources, bullet_sources)
+ env_bullet.add_source_files(env.modules_sources, thirdparty_sources)
+ env_bullet.Append(CPPPATH=[thirdparty_dir])
# Godot source files
env_bullet.add_source_files(env.modules_sources, "*.cpp")
-
-Export('env')
diff --git a/modules/bullet/SCsub_with_lib b/modules/bullet/SCsub_with_lib
deleted file mode 100644
index b362a686ff..0000000000
--- a/modules/bullet/SCsub_with_lib
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-thirdparty_dir = "#thirdparty/bullet/"
-thirdparty_lib = thirdparty_dir + "Win64/lib/"
-
-bullet_libs = [
- "Bullet2FileLoader",
- "Bullet3Collision",
- "Bullet3Common",
- "Bullet3Dynamics",
- "Bullet3Geometry",
- "Bullet3OpenCL_clew",
- "BulletCollision",
- "BulletDynamics",
- "BulletInverseDynamics",
- "BulletSoftBody",
- "LinearMath"
- ]
-
-thirdparty_src = thirdparty_dir + "src/"
-# include headers
-env.Append(CPPPATH=[thirdparty_src])
-
-# lib
-env.Append(LIBPATH=[thirdparty_dir + "/Win64/lib/"])
-
-bullet_libs = [file+'.lib' for file in bullet_libs]
-# LIBS doesn't work in windows
-env.Append(LINKFLAGS=bullet_libs)
-
-env.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index 195d89d0c0..648919e612 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* area_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,13 +29,19 @@
/*************************************************************************/
#include "area_bullet.h"
-#include "BulletCollision/CollisionDispatch/btGhostObject.h"
-#include "btBulletCollisionCommon.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "collision_object_bullet.h"
#include "space_bullet.h"
+#include <BulletCollision/CollisionDispatch/btGhostObject.h>
+#include <btBulletCollisionCommon.h>
+
+/**
+ @author AndreaCatania
+*/
+
AreaBullet::AreaBullet() :
RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA),
monitorable(true),
@@ -231,7 +236,7 @@ void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &
set_spOv_gravityPointAttenuation(p_value);
break;
default:
- print_line("The Bullet areas dosn't suppot this param: " + itos(p_param));
+ print_line("The Bullet areas doesn't suppot this param: " + itos(p_param));
}
}
@@ -254,7 +259,7 @@ Variant AreaBullet::get_param(PhysicsServer::AreaParameter p_param) const {
case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return spOv_gravityPointAttenuation;
default:
- print_line("The Bullet areas dosn't suppot this param: " + itos(p_param));
+ print_line("The Bullet areas doesn't suppot this param: " + itos(p_param));
return Variant();
}
}
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index 3e0913b891..78136d574b 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* area_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -37,6 +36,10 @@
#include "servers/physics_server.h"
#include "space_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class btGhostObject;
class AreaBullet : public RigidCollisionObjectBullet {
diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp
index 8f6434b46b..4164450cd2 100644
--- a/modules/bullet/btRayShape.cpp
+++ b/modules/bullet/btRayShape.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
-/* btRayShape.h */
-/* Author: AndreaCatania */
+/* btRayShape.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,9 +29,15 @@
/*************************************************************************/
#include "btRayShape.h"
-#include "LinearMath/btAabbUtil2.h"
+
#include "math/math_funcs.h"
+#include <LinearMath/btAabbUtil2.h>
+
+/**
+ @author AndreaCatania
+*/
+
btRayShape::btRayShape(btScalar length) :
btConvexInternalShape(),
m_shapeAxis(0, 0, 1) {
diff --git a/modules/bullet/btRayShape.h b/modules/bullet/btRayShape.h
index be7acaa01f..99a9412dbe 100644
--- a/modules/bullet/btRayShape.h
+++ b/modules/bullet/btRayShape.h
@@ -1,10 +1,9 @@
/*************************************************************************/
-/* btRayShape.h */
-/* Author: AndreaCatania */
+/* btRayShape.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,12 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-/// IMPORTANT The class name and filename was created by following Bullet writing rules for an easy (eventually ) porting to bullet
+/// IMPORTANT The class name and filename was created by following Bullet writing rules for an easy (eventually) porting to bullet
/// This shape is a custom shape that is not present to Bullet physics engine
#ifndef BTRAYSHAPE_H
#define BTRAYSHAPE_H
-#include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
+#include <BulletCollision/CollisionShapes/btConvexInternalShape.h>
+
+/**
+ @author AndreaCatania
+*/
/// Ray shape around z axis
ATTRIBUTE_ALIGNED16(class)
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 679e4def82..b646fc164d 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* bullet_physics_server.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,7 +29,7 @@
/*************************************************************************/
#include "bullet_physics_server.h"
-#include "LinearMath/btVector3.h"
+
#include "bullet_utilities.h"
#include "class_db.h"
#include "cone_twist_joint_bullet.h"
@@ -41,8 +40,15 @@
#include "pin_joint_bullet.h"
#include "shape_bullet.h"
#include "slider_joint_bullet.h"
+
+#include <LinearMath/btVector3.h>
+
#include <assert.h>
+/**
+ @author AndreaCatania
+*/
+
#define CreateThenReturnRID(owner, ridData) \
RID rid = owner.make_rid(ridData); \
ridData->set_self(rid); \
@@ -64,8 +70,8 @@
return RID(); \
}
-#define AddJointToSpace(body, joint, disableCollisionsBetweenLinkedBodies) \
- body->get_space()->add_constraint(joint, disableCollisionsBetweenLinkedBodies);
+#define AddJointToSpace(body, joint) \
+ body->get_space()->add_constraint(joint, joint->is_disabled_collisions_between_bodies());
// <--------------- Joint creation asserts
btEmptyShape *BulletPhysicsServer::emptyShape(ShapeBullet::create_shape_empty());
@@ -981,6 +987,20 @@ int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const {
return 0;
}
+void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
+ JointBullet *joint = joint_owner.get(p_joint);
+ ERR_FAIL_COND(!joint);
+
+ joint->disable_collisions_between_bodies(p_disable);
+}
+
+bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
+ JointBullet *joint(joint_owner.get(p_joint));
+ ERR_FAIL_COND_V(!joint, false);
+
+ return joint->is_disabled_collisions_between_bodies();
+}
+
RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -997,7 +1017,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A
ERR_FAIL_COND_V(body_A == body_B, RID());
JointBullet *joint = bulletnew(PinJointBullet(body_A, p_local_A, body_B, p_local_B));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
@@ -1065,7 +1085,7 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin
ERR_FAIL_COND_V(body_A == body_B, RID());
JointBullet *joint = bulletnew(HingeJointBullet(body_A, body_B, p_hinge_A, p_hinge_B));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
@@ -1085,7 +1105,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &
ERR_FAIL_COND_V(body_A == body_B, RID());
JointBullet *joint = bulletnew(HingeJointBullet(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
@@ -1137,7 +1157,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo
ERR_FAIL_COND_V(body_A == body_B, RID());
JointBullet *joint = bulletnew(SliderJointBullet(body_A, body_B, p_local_frame_A, p_local_frame_B));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
@@ -1171,7 +1191,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &
}
JointBullet *joint = bulletnew(ConeTwistJointBullet(body_A, body_B, p_local_frame_A, p_local_frame_B));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
@@ -1207,7 +1227,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform
ERR_FAIL_COND_V(body_A == body_B, RID());
JointBullet *joint = bulletnew(Generic6DOFJointBullet(body_A, body_B, p_local_frame_A, p_local_frame_B, true));
- AddJointToSpace(body_A, joint, true);
+ AddJointToSpace(body_A, joint);
CreateThenReturnRID(joint_owner, joint);
}
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 006ad0f821..764ec2387c 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* bullet_physics_server.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -41,6 +40,10 @@
#include "soft_body_bullet.h"
#include "space_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class BulletPhysicsServer : public PhysicsServer {
GDCLASS(BulletPhysicsServer, PhysicsServer)
@@ -151,7 +154,7 @@ public:
/// AREA_PARAM_GRAVITY_VECTOR
/// Otherwise you can set area parameters
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value);
- virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const;
+ virtual Variant area_get_param(RID p_area, AreaParameter p_param) const;
virtual void area_set_transform(RID p_area, const Transform &p_transform);
virtual Transform area_get_transform(RID p_area) const;
@@ -287,6 +290,9 @@ public:
virtual void joint_set_solver_priority(RID p_joint, int p_priority);
virtual int joint_get_solver_priority(RID p_joint) const;
+ virtual void joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable);
+ virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const;
+
virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B);
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value);
@@ -298,7 +304,7 @@ public:
virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B);
virtual Vector3 pin_joint_get_local_b(RID p_joint) const;
- virtual RID joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B);
+ virtual RID joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B);
virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B);
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value);
diff --git a/modules/bullet/bullet_types_converter.cpp b/modules/bullet/bullet_types_converter.cpp
index 42a6f156a5..a0fe598227 100644
--- a/modules/bullet/bullet_types_converter.cpp
+++ b/modules/bullet/bullet_types_converter.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* bullet_types_converter.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,6 +32,10 @@
#include "bullet_types_converter.h"
+/**
+ @author AndreaCatania
+*/
+
// ++ BULLET to GODOT ++++++++++
void B_TO_G(btVector3 const &inVal, Vector3 &outVal) {
outVal[0] = inVal[0];
diff --git a/modules/bullet/bullet_types_converter.h b/modules/bullet/bullet_types_converter.h
index 349cad65aa..84321fe837 100644
--- a/modules/bullet/bullet_types_converter.h
+++ b/modules/bullet/bullet_types_converter.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* bullet_types_converter.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,14 +31,19 @@
#ifndef BULLET_TYPES_CONVERTER_H
#define BULLET_TYPES_CONVERTER_H
-#include "LinearMath/btMatrix3x3.h"
-#include "LinearMath/btTransform.h"
-#include "LinearMath/btVector3.h"
#include "core/math/matrix3.h"
#include "core/math/transform.h"
#include "core/math/vector3.h"
#include "core/typedefs.h"
+#include <LinearMath/btMatrix3x3.h>
+#include <LinearMath/btTransform.h>
+#include <LinearMath/btVector3.h>
+
+/**
+ @author AndreaCatania
+*/
+
// Bullet to Godot
extern void B_TO_G(btVector3 const &inVal, Vector3 &outVal);
extern void INVERT_B_TO_G(btVector3 const &inVal, Vector3 &outVal);
diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h
index 1a44f48844..2841dfbe69 100644
--- a/modules/bullet/bullet_utilities.h
+++ b/modules/bullet/bullet_utilities.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* bullet_utilities.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,6 +31,10 @@
#ifndef BULLET_UTILITIES_H
#define BULLET_UTILITIES_H
+/**
+ @author AndreaCatania
+*/
+
#pragma once
#define bulletnew(cl) \
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 1350be20b6..34aff68a4a 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* collision_object_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,21 +29,29 @@
/*************************************************************************/
#include "collision_object_bullet.h"
+
#include "area_bullet.h"
-#include "btBulletCollisionCommon.h"
#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "shape_bullet.h"
#include "space_bullet.h"
+#include <btBulletCollisionCommon.h>
+
+/**
+ @author AndreaCatania
+*/
+
#define enableDynamicAabbTree true
#define initialChildCapacity 1
CollisionObjectBullet::ShapeWrapper::~ShapeWrapper() {}
void CollisionObjectBullet::ShapeWrapper::set_transform(const Transform &p_transform) {
+ G_TO_B(p_transform.get_basis().get_scale(), scale);
G_TO_B(p_transform, transform);
+ UNSCALE_BT_BASIS(transform);
}
void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_transform) {
transform = p_transform;
@@ -153,16 +160,13 @@ int CollisionObjectBullet::get_godot_object_flags() const {
void CollisionObjectBullet::set_transform(const Transform &p_global_transform) {
- btTransform btTrans;
- Basis decomposed_basis;
-
- Vector3 decomposed_scale = p_global_transform.get_basis().rotref_posscale_decomposition(decomposed_basis);
+ set_body_scale(p_global_transform.basis.get_scale());
- G_TO_B(p_global_transform.get_origin(), btTrans.getOrigin());
- G_TO_B(decomposed_basis, btTrans.getBasis());
+ btTransform bt_transform;
+ G_TO_B(p_global_transform, bt_transform);
+ UNSCALE_BT_BASIS(bt_transform);
- set_body_scale(decomposed_scale);
- set_transform__bullet(btTrans);
+ set_transform__bullet(bt_transform);
}
Transform CollisionObjectBullet::get_transform() const {
@@ -230,7 +234,7 @@ void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transfor
ERR_FAIL_INDEX(p_index, get_shape_count());
shapes[p_index].set_transform(p_transform);
- on_shapes_changed();
+ on_shape_changed(shapes[p_index].shape);
}
void RigidCollisionObjectBullet::remove_shape(ShapeBullet *p_shape) {
@@ -310,20 +314,22 @@ void RigidCollisionObjectBullet::on_shapes_changed() {
}
// Insert all shapes
-
+ btVector3 body_scale(get_bt_body_scale());
for (i = 0; i < shapes_size; ++i) {
shpWrapper = &shapes[i];
if (shpWrapper->active) {
if (!shpWrapper->bt_shape) {
- shpWrapper->bt_shape = shpWrapper->shape->create_bt_shape();
+ shpWrapper->bt_shape = shpWrapper->shape->create_bt_shape(shpWrapper->scale * body_scale);
}
- compoundShape->addChildShape(shpWrapper->transform, shpWrapper->bt_shape);
+
+ btTransform scaled_shape_transform(shpWrapper->transform);
+ scaled_shape_transform.getOrigin() *= body_scale;
+ compoundShape->addChildShape(scaled_shape_transform, shpWrapper->bt_shape);
} else {
- compoundShape->addChildShape(shpWrapper->transform, BulletPhysicsServer::get_empty_shape());
+ compoundShape->addChildShape(btTransform(), BulletPhysicsServer::get_empty_shape());
}
}
- compoundShape->setLocalScaling(get_bt_body_scale());
compoundShape->recalculateLocalAabb();
}
diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index 6a3fbe65ff..506976eabf 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* collision_object_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,13 +31,18 @@
#ifndef COLLISION_OBJECT_BULLET_H
#define COLLISION_OBJECT_BULLET_H
-#include "LinearMath/btTransform.h"
#include "core/vset.h"
#include "object.h"
#include "shape_owner_bullet.h"
#include "transform.h"
#include "vector3.h"
+#include <LinearMath/btTransform.h>
+
+/**
+ @author AndreaCatania
+*/
+
class AreaBullet;
class ShapeBullet;
class btCollisionObject;
@@ -68,6 +72,7 @@ public:
ShapeBullet *shape;
btCollisionShape *bt_shape;
btTransform transform;
+ btVector3 scale;
bool active;
ShapeWrapper() :
@@ -98,6 +103,7 @@ public:
shape = otherShape.shape;
bt_shape = otherShape.bt_shape;
transform = otherShape.transform;
+ scale = otherShape.scale;
active = otherShape.active;
}
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index c8944d23c5..472ad3b52c 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* cone_twist_joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,11 +29,17 @@
/*************************************************************************/
#include "cone_twist_joint_bullet.h"
-#include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "rigid_body_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btConeTwistConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) :
JointBullet() {
diff --git a/modules/bullet/cone_twist_joint_bullet.h b/modules/bullet/cone_twist_joint_bullet.h
index 5f0bccbd31..bd6eb49196 100644
--- a/modules/bullet/cone_twist_joint_bullet.h
+++ b/modules/bullet/cone_twist_joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* cone_twist_joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "joint_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class ConeTwistJointBullet : public JointBullet {
diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp
index 0c5ba29cb3..d15fb8de01 100644
--- a/modules/bullet/constraint_bullet.cpp
+++ b/modules/bullet/constraint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* constraint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,12 +29,18 @@
/*************************************************************************/
#include "constraint_bullet.h"
+
#include "collision_object_bullet.h"
#include "space_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
ConstraintBullet::ConstraintBullet() :
space(NULL),
- constraint(NULL) {}
+ constraint(NULL),
+ disabled_collisions_between_bodies(true) {}
void ConstraintBullet::setup(btTypedConstraint *p_constraint) {
constraint = p_constraint;
@@ -49,3 +54,12 @@ void ConstraintBullet::set_space(SpaceBullet *p_space) {
void ConstraintBullet::destroy_internal_constraint() {
space->remove_constraint(this);
}
+
+void ConstraintBullet::disable_collisions_between_bodies(const bool p_disabled) {
+ disabled_collisions_between_bodies = p_disabled;
+
+ if (space) {
+ space->remove_constraint(this);
+ space->add_constraint(this, disabled_collisions_between_bodies);
+ }
+}
diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h
index a753ee0429..ed3a318cbc 100644
--- a/modules/bullet/constraint_bullet.h
+++ b/modules/bullet/constraint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* constraint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,10 +31,15 @@
#ifndef CONSTRAINT_BULLET_H
#define CONSTRAINT_BULLET_H
-#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
#include "bullet_utilities.h"
#include "rid_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btTypedConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class SpaceBullet;
class btTypedConstraint;
@@ -45,6 +49,7 @@ class ConstraintBullet : public RIDBullet {
protected:
SpaceBullet *space;
btTypedConstraint *constraint;
+ bool disabled_collisions_between_bodies;
public:
ConstraintBullet();
@@ -53,6 +58,9 @@ public:
virtual void set_space(SpaceBullet *p_space);
virtual void destroy_internal_constraint();
+ void disable_collisions_between_bodies(const bool p_disabled);
+ _FORCE_INLINE_ bool is_disabled_collisions_between_bodies() const { return disabled_collisions_between_bodies; }
+
public:
virtual ~ConstraintBullet() {
bulletdelete(constraint);
diff --git a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml
index 941a79e8ea..c7909c7d72 100644
--- a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml
+++ b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="BulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" category="Core" version="3.0-beta">
+<class name="BulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/bullet/doc_classes/BulletPhysicsServer.xml b/modules/bullet/doc_classes/BulletPhysicsServer.xml
index 515f0e292e..a59abb0ebb 100644
--- a/modules/bullet/doc_classes/BulletPhysicsServer.xml
+++ b/modules/bullet/doc_classes/BulletPhysicsServer.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="BulletPhysicsServer" inherits="PhysicsServer" category="Core" version="3.0-beta">
+<class name="BulletPhysicsServer" inherits="PhysicsServer" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 674b30b23a..151a79a69f 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* generic_6dof_joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,11 +29,17 @@
/*************************************************************************/
#include "generic_6dof_joint_bullet.h"
-#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "rigid_body_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) :
JointBullet() {
diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h
index df66892d66..ad06582eac 100644
--- a/modules/bullet/generic_6dof_joint_bullet.h
+++ b/modules/bullet/generic_6dof_joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* generic_6dof_joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "joint_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class Generic6DOFJointBullet : public JointBullet {
diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp
index 6d83a9bccb..f4bb9acbd7 100644
--- a/modules/bullet/godot_collision_configuration.cpp
+++ b/modules/bullet/godot_collision_configuration.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_collision_configuration.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,10 +29,16 @@
/*************************************************************************/
#include "godot_collision_configuration.h"
-#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
-#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+
#include "godot_ray_world_algorithm.h"
+#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
+#include <BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
+
+/**
+ @author AndreaCatania
+*/
+
GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) :
btDefaultCollisionConfiguration(constructionInfo) {
diff --git a/modules/bullet/godot_collision_configuration.h b/modules/bullet/godot_collision_configuration.h
index 835edac907..9b30ad0c62 100644
--- a/modules/bullet/godot_collision_configuration.h
+++ b/modules/bullet/godot_collision_configuration.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_collision_configuration.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,7 +31,11 @@
#ifndef GODOT_COLLISION_CONFIGURATION_H
#define GODOT_COLLISION_CONFIGURATION_H
-#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
+#include <BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h>
+
+/**
+ @author AndreaCatania
+*/
class btDiscreteDynamicsWorld;
diff --git a/modules/bullet/godot_collision_dispatcher.cpp b/modules/bullet/godot_collision_dispatcher.cpp
index 31a965869e..1815f2152e 100644
--- a/modules/bullet/godot_collision_dispatcher.cpp
+++ b/modules/bullet/godot_collision_dispatcher.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_collision_dispatcher.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,8 +29,13 @@
/*************************************************************************/
#include "godot_collision_dispatcher.h"
+
#include "collision_object_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
const int GodotCollisionDispatcher::CASTED_TYPE_AREA = static_cast<int>(CollisionObjectBullet::TYPE_AREA);
GodotCollisionDispatcher::GodotCollisionDispatcher(btCollisionConfiguration *collisionConfiguration) :
diff --git a/modules/bullet/godot_collision_dispatcher.h b/modules/bullet/godot_collision_dispatcher.h
index ab3ab2af31..2e5a6c2732 100644
--- a/modules/bullet/godot_collision_dispatcher.h
+++ b/modules/bullet/godot_collision_dispatcher.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_collision_dispatcher.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,8 +32,13 @@
#define GODOT_COLLISION_DISPATCHER_H
#include "int_types.h"
+
#include <btBulletDynamicsCommon.h>
+/**
+ @author AndreaCatania
+*/
+
/// This class is required to implement custom collision behaviour in the narrowphase
class GodotCollisionDispatcher : public btCollisionDispatcher {
private:
diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h
index 79f139898c..fe5d8418b7 100644
--- a/modules/bullet/godot_motion_state.h
+++ b/modules/bullet/godot_motion_state.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_motion_state.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,12 +31,17 @@
#ifndef GODOT_MOTION_STATE_H
#define GODOT_MOTION_STATE_H
-#include "LinearMath/btMotionState.h"
#include "rigid_body_bullet.h"
+#include <LinearMath/btMotionState.h>
+
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
-// This clas is responsible to move kinematic actor
+// This class is responsible to move kinematic actor
// and sincronize rendering engine with Bullet
/// DOC:
/// http://www.bulletphysics.org/mediawiki-1.5.8/index.php/MotionStates#What.27s_a_MotionState.3F
diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp
index 3dd10b9ab3..4a511b39a7 100644
--- a/modules/bullet/godot_ray_world_algorithm.cpp
+++ b/modules/bullet/godot_ray_world_algorithm.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_ray_world_algorithm.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,10 +29,18 @@
/*************************************************************************/
#include "godot_ray_world_algorithm.h"
-#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
+
#include "btRayShape.h"
#include "collision_object_bullet.h"
+#include <BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
+
+#define RAY_STABILITY_MARGIN 0.1
+
+/**
+ @author AndreaCatania
+*/
+
GodotRayWorldAlgorithm::CreateFunc::CreateFunc(const btDiscreteDynamicsWorld *world) :
m_world(world) {}
@@ -92,10 +99,15 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo
m_world->rayTestSingleInternal(ray_transform, to, other_co_wrapper, btResult);
if (btResult.hasHit()) {
- btVector3 ray_normal(to.getOrigin() - ray_transform.getOrigin());
+
+ btVector3 ray_normal(ray_transform.getOrigin() - to.getOrigin());
ray_normal.normalize();
- ray_normal *= -1;
- resultOut->addContactPoint(ray_normal, btResult.m_hitPointWorld, ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1));
+ btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1));
+
+ if (depth >= -RAY_STABILITY_MARGIN)
+ depth = 0;
+
+ resultOut->addContactPoint(ray_normal, btResult.m_hitPointWorld, depth);
}
}
diff --git a/modules/bullet/godot_ray_world_algorithm.h b/modules/bullet/godot_ray_world_algorithm.h
index f2c9008f58..7383dad2bf 100644
--- a/modules/bullet/godot_ray_world_algorithm.h
+++ b/modules/bullet/godot_ray_world_algorithm.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_ray_world_algorithm.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,9 +31,13 @@
#ifndef GODOT_RAY_WORLD_ALGORITHM_H
#define GODOT_RAY_WORLD_ALGORITHM_H
-#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
-#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
-#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
+#include <BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h>
+#include <BulletCollision/CollisionDispatch/btCollisionCreateFunc.h>
+#include <BulletCollision/CollisionDispatch/btCollisionDispatcher.h>
+
+/**
+ @author AndreaCatania
+*/
class btDiscreteDynamicsWorld;
@@ -46,7 +49,7 @@ class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm {
bool m_isSwapped;
public:
- GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *m_world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped);
+ GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped);
virtual ~GodotRayWorldAlgorithm();
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut);
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index a91cbec340..8d4ca6d6a7 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_result_callbacks.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,10 +29,15 @@
/*************************************************************************/
#include "godot_result_callbacks.h"
+
#include "bullet_types_converter.h"
#include "collision_object_bullet.h"
#include "rigid_body_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
bool GodotFilterCallback::test_collision_filters(uint32_t body0_collision_layer, uint32_t body0_collision_mask, uint32_t body1_collision_layer, uint32_t body1_collision_mask) {
return body0_collision_layer & body1_collision_mask || body1_collision_layer & body0_collision_mask;
}
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 407fb79b9a..e1b0b1b421 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* godot_result_callbacks.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,10 +31,15 @@
#ifndef GODOT_RESULT_CALLBACKS_H
#define GODOT_RESULT_CALLBACKS_H
-#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
-#include "btBulletDynamicsCommon.h"
#include "servers/physics_server.h"
+#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
+#include <btBulletDynamicsCommon.h>
+
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
/// This class is required to implement custom collision behaviour in the broadphase
@@ -201,6 +205,6 @@ struct GodotDeepPenetrationContactResultCallback : public btManifoldResult {
return m_pointCollisionObject;
}
- virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth);
+ virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorldOnB, btScalar depth);
};
#endif // GODOT_RESULT_CALLBACKS_H
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index c731a3c134..97ea7ca3df 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* hinge_joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,11 +29,17 @@
/*************************************************************************/
#include "hinge_joint_bullet.h"
-#include "BulletDynamics/ConstraintSolver/btHingeConstraint.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "rigid_body_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btHingeConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) :
JointBullet() {
diff --git a/modules/bullet/hinge_joint_bullet.h b/modules/bullet/hinge_joint_bullet.h
index 72146fca8b..ca87c8dd8c 100644
--- a/modules/bullet/hinge_joint_bullet.h
+++ b/modules/bullet/hinge_joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* hinge_joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "joint_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class HingeJointBullet : public JointBullet {
class btHingeConstraint *hingeConstraint;
diff --git a/modules/bullet/joint_bullet.cpp b/modules/bullet/joint_bullet.cpp
index 8aa15e731d..aaeb9f9ce7 100644
--- a/modules/bullet/joint_bullet.cpp
+++ b/modules/bullet/joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,8 +29,13 @@
/*************************************************************************/
#include "joint_bullet.h"
+
#include "space_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
JointBullet::JointBullet() :
ConstraintBullet() {}
diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h
index 2d4f774345..4a5333fb85 100644
--- a/modules/bullet/joint_bullet.h
+++ b/modules/bullet/joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -35,6 +34,10 @@
#include "constraint_bullet.h"
#include "servers/physics_server.h"
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class btTypedConstraint;
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index 7c44548496..c4e5b8cdbe 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* pin_joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,10 +29,16 @@
/*************************************************************************/
#include "pin_joint_bullet.h"
-#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"
+
#include "bullet_types_converter.h"
#include "rigid_body_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b) :
JointBullet() {
if (p_body_b) {
diff --git a/modules/bullet/pin_joint_bullet.h b/modules/bullet/pin_joint_bullet.h
index 5610e6aa05..648010bf78 100644
--- a/modules/bullet/pin_joint_bullet.h
+++ b/modules/bullet/pin_joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* pin_joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "joint_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class PinJointBullet : public JointBullet {
diff --git a/modules/bullet/register_types.cpp b/modules/bullet/register_types.cpp
index 2a420f424b..b119b7720f 100644
--- a/modules/bullet/register_types.cpp
+++ b/modules/bullet/register_types.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* register_types.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,9 +29,14 @@
/*************************************************************************/
#include "register_types.h"
+
#include "bullet_physics_server.h"
#include "class_db.h"
+/**
+ @author AndreaCatania
+*/
+
PhysicsServer *_createBulletPhysicsCallback() {
return memnew(BulletPhysicsServer);
}
diff --git a/modules/bullet/register_types.h b/modules/bullet/register_types.h
index 4edc3fb839..226bcd9402 100644
--- a/modules/bullet/register_types.h
+++ b/modules/bullet/register_types.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* register_types.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,6 +31,10 @@
#ifndef REGISTER_BULLET_TYPES_H
#define REGISTER_BULLET_TYPES_H
+/**
+ @author AndreaCatania
+*/
+
void register_bullet_types();
void unregister_bullet_types();
#endif
diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h
index 72859b628e..a9351d7728 100644
--- a/modules/bullet/rid_bullet.h
+++ b/modules/bullet/rid_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* rid_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "core/rid.h"
+/**
+ @author AndreaCatania
+*/
+
class BulletPhysicsServer;
class RIDBullet : public RID_Data {
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index c183b012ab..f96218ef46 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
-/* body_bullet.cpp */
-/* Author: AndreaCatania */
+/* rigid_body_bullet.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,18 +29,25 @@
/*************************************************************************/
#include "rigid_body_bullet.h"
-#include "BulletCollision/CollisionDispatch/btGhostObject.h"
-#include "BulletCollision/CollisionShapes/btConvexPointCloudShape.h"
-#include "BulletDynamics/Dynamics/btRigidBody.h"
-#include "btBulletCollisionCommon.h"
+
#include "btRayShape.h"
#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "godot_motion_state.h"
#include "joint_bullet.h"
+
+#include <BulletCollision/CollisionDispatch/btGhostObject.h>
+#include <BulletCollision/CollisionShapes/btConvexPointCloudShape.h>
+#include <BulletDynamics/Dynamics/btRigidBody.h>
+#include <btBulletCollisionCommon.h>
+
#include <assert.h>
+/**
+ @author AndreaCatania
+*/
+
BulletPhysicsDirectBodyState *BulletPhysicsDirectBodyState::singleton = NULL;
Vector3 BulletPhysicsDirectBodyState::get_total_gravity() const {
@@ -198,7 +204,7 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() {
const CollisionObjectBullet::ShapeWrapper *shape_wrapper;
- btVector3 owner_body_scale(owner->get_bt_body_scale());
+ btVector3 owner_scale(owner->get_bt_body_scale());
for (int i = shapes_count - 1; 0 <= i; --i) {
shape_wrapper = &shapes_wrappers[i];
@@ -207,14 +213,14 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() {
}
shapes[i].transform = shape_wrapper->transform;
- shapes[i].transform.getOrigin() *= owner_body_scale;
+ shapes[i].transform.getOrigin() *= owner_scale;
switch (shape_wrapper->shape->get_type()) {
case PhysicsServer::SHAPE_SPHERE:
case PhysicsServer::SHAPE_BOX:
case PhysicsServer::SHAPE_CAPSULE:
case PhysicsServer::SHAPE_CONVEX_POLYGON:
case PhysicsServer::SHAPE_RAY: {
- shapes[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_body_scale, safe_margin));
+ shapes[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_scale * shape_wrapper->scale, safe_margin));
} break;
default:
WARN_PRINT("This shape is not supported to be kinematic!");
@@ -684,7 +690,7 @@ void RigidBodyBullet::set_continuous_collision_detection(bool p_enable) {
/// Calculate using the rule writte below the CCD swept sphere radius
/// CCD works on an embedded sphere of radius, make sure this radius
/// is embedded inside the convex objects, preferably smaller:
- /// for an object of dimentions 1 meter, try 0.2
+ /// for an object of dimensions 1 meter, try 0.2
btVector3 center;
btScalar radius;
btBody->getCollisionShape()->getBoundingSphere(center, radius);
@@ -826,7 +832,8 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
- if (!is_active())
+ // Make sure that kinematic bodies have their total gravity calculated
+ if (!is_active() && PhysicsServer::BODY_MODE_KINEMATIC != mode)
return;
Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude());
@@ -949,7 +956,8 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
const bool isDynamic = p_mass != 0.f;
if (isDynamic) {
- ERR_FAIL_COND(PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode);
+ if (PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode)
+ return;
m_isStatic = false;
compoundShape->calculateLocalInertia(p_mass, localInertia);
@@ -969,7 +977,8 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
}
} else {
- ERR_FAIL_COND(PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode);
+ if (PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode)
+ return;
m_isStatic = true;
if (PhysicsServer::BODY_MODE_STATIC == mode) {
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index ff1596e6f4..c4a9676bdd 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
-/* body_bullet.h */
-/* Author: AndreaCatania */
+/* rigid_body_bullet.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,11 +31,16 @@
#ifndef BODYBULLET_H
#define BODYBULLET_H
-#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
-#include "LinearMath/btTransform.h"
#include "collision_object_bullet.h"
#include "space_bullet.h"
+#include <BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h>
+#include <LinearMath/btTransform.h>
+
+/**
+ @author AndreaCatania
+*/
+
class AreaBullet;
class SpaceBullet;
class btRigidBody;
@@ -44,11 +48,11 @@ class GodotMotionState;
class BulletPhysicsDirectBodyState;
/// This class could be used in multi thread with few changes but currently
-/// is setted to be only in one single thread.
+/// is set to be only in one single thread.
///
/// In the system there is only one object at a time that manage all bodies and is
/// created by BulletPhysicsServer and is held by the "singleton" variable of this class
-/// Each time something require it, the body must be setted again.
+/// Each time something require it, the body must be set again.
class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState {
GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState)
@@ -258,12 +262,12 @@ public:
Variant get_state(PhysicsServer::BodyState p_state) const;
void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
- void apply_central_impulse(const Vector3 &p_force);
+ void apply_central_impulse(const Vector3 &p_impulse);
void apply_torque_impulse(const Vector3 &p_impulse);
void apply_force(const Vector3 &p_force, const Vector3 &p_pos);
void apply_central_force(const Vector3 &p_force);
- void apply_torque(const Vector3 &p_force);
+ void apply_torque(const Vector3 &p_torque);
void set_applied_force(const Vector3 &p_force);
Vector3 get_applied_force() const;
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index d5a89e39e2..c6b9695d96 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* shape_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,24 +29,25 @@
/*************************************************************************/
#include "shape_bullet.h"
-#include "BulletCollision/CollisionShapes/btConvexPointCloudShape.h"
-#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
-#include "btBulletCollisionCommon.h"
+
#include "btRayShape.h"
#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "shape_owner_bullet.h"
+#include <BulletCollision/CollisionShapes/btConvexPointCloudShape.h>
+#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
+#include <btBulletCollisionCommon.h>
+
+/**
+ @author AndreaCatania
+*/
+
ShapeBullet::ShapeBullet() {}
ShapeBullet::~ShapeBullet() {}
-btCollisionShape *ShapeBullet::create_bt_shape() {
- btVector3 s(1, 1, 1);
- return create_bt_shape(s);
-}
-
btCollisionShape *ShapeBullet::create_bt_shape(const Vector3 &p_implicit_scale, real_t p_margin) {
btVector3 s;
G_TO_B(p_implicit_scale, s);
@@ -77,7 +77,7 @@ void ShapeBullet::add_owner(ShapeOwnerBullet *p_owner) {
void ShapeBullet::remove_owner(ShapeOwnerBullet *p_owner, bool p_permanentlyFromThisBody) {
Map<ShapeOwnerBullet *, int>::Element *E = owners.find(p_owner);
- ERR_FAIL_COND(!E);
+ if (!E) return;
E->get()--;
if (p_permanentlyFromThisBody || 0 >= E->get()) {
owners.erase(E);
@@ -282,7 +282,7 @@ PhysicsServer::ShapeType ConvexPolygonShapeBullet::get_type() const {
}
void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) {
- // Make a copy of verticies
+ // Make a copy of vertices
const int n_of_vertices = p_vertices.size();
vertices.resize(n_of_vertices);
for (int i = n_of_vertices - 1; 0 <= i; --i) {
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h
index a9782a9333..e04a3c808a 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* shape_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,14 +31,19 @@
#ifndef SHAPE_BULLET_H
#define SHAPE_BULLET_H
-#include "LinearMath/btAlignedObjectArray.h"
-#include "LinearMath/btScalar.h"
-#include "LinearMath/btVector3.h"
#include "core/variant.h"
#include "geometry.h"
#include "rid_bullet.h"
#include "servers/physics_server.h"
+#include <LinearMath/btAlignedObjectArray.h>
+#include <LinearMath/btScalar.h>
+#include <LinearMath/btVector3.h>
+
+/**
+ @author AndreaCatania
+*/
+
class ShapeBullet;
class btCollisionShape;
class ShapeOwnerBullet;
@@ -58,7 +62,6 @@ public:
ShapeBullet();
virtual ~ShapeBullet();
- btCollisionShape *create_bt_shape();
btCollisionShape *create_bt_shape(const Vector3 &p_implicit_scale, real_t p_margin = 0);
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0) = 0;
@@ -96,7 +99,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(const Plane &p_plane);
@@ -113,7 +116,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(real_t p_radius);
@@ -130,7 +133,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(const Vector3 &p_half_extents);
@@ -149,7 +152,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(real_t p_height, real_t p_radius);
@@ -166,7 +169,7 @@ public:
void get_vertices(Vector<Vector3> &out_vertices);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(const Vector<Vector3> &p_vertices);
@@ -184,7 +187,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(PoolVector<Vector3> p_faces);
@@ -203,7 +206,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_cell_size);
@@ -219,7 +222,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
virtual PhysicsServer::ShapeType get_type() const;
- virtual btCollisionShape *create_bt_shape(const btVector3 &p_scale, real_t p_margin = 0);
+ virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
void setup(real_t p_length);
diff --git a/modules/bullet/shape_owner_bullet.cpp b/modules/bullet/shape_owner_bullet.cpp
index 7b753e1c48..d6ba5d81bc 100644
--- a/modules/bullet/shape_owner_bullet.cpp
+++ b/modules/bullet/shape_owner_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* shape_owner_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,3 +29,7 @@
/*************************************************************************/
#include "shape_owner_bullet.h"
+
+/**
+ @author AndreaCatania
+*/
diff --git a/modules/bullet/shape_owner_bullet.h b/modules/bullet/shape_owner_bullet.h
index 4e81b4be6e..29d42d12f2 100644
--- a/modules/bullet/shape_owner_bullet.h
+++ b/modules/bullet/shape_owner_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* shape_owner_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,11 +33,15 @@
#include "rid_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class ShapeBullet;
class btCollisionShape;
class CollisionObjectBullet;
-/// Each clas that want to use Shapes must inherit this class
+/// Each class that want to use Shapes must inherit this class
/// E.G. BodyShape is a child of this
class ShapeOwnerBullet {
public:
diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp
index 09cbd5032c..9e1cd23989 100644
--- a/modules/bullet/slider_joint_bullet.cpp
+++ b/modules/bullet/slider_joint_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* slider_joint_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,11 +29,17 @@
/*************************************************************************/
#include "slider_joint_bullet.h"
-#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "rigid_body_bullet.h"
+#include <BulletDynamics/ConstraintSolver/btSliderConstraint.h>
+
+/**
+ @author AndreaCatania
+*/
+
SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) :
JointBullet() {
diff --git a/modules/bullet/slider_joint_bullet.h b/modules/bullet/slider_joint_bullet.h
index 4b9a70a323..d532906c0d 100644
--- a/modules/bullet/slider_joint_bullet.h
+++ b/modules/bullet/slider_joint_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* slider_joint_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,6 +33,10 @@
#include "joint_bullet.h"
+/**
+ @author AndreaCatania
+*/
+
class RigidBodyBullet;
class SliderJointBullet : public JointBullet {
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index 268967f014..5c20eb73f1 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* soft_body_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,11 +29,15 @@
/*************************************************************************/
#include "soft_body_bullet.h"
+
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
+#include "scene/3d/immediate_geometry.h"
#include "space_bullet.h"
-#include "scene/3d/immediate_geometry.h"
+/**
+ @author AndreaCatania
+*/
SoftBodyBullet::SoftBodyBullet() :
CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY),
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index 83597ae7d2..9895643b84 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* soft_body_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,14 +31,16 @@
#ifndef SOFT_BODY_BULLET_H
#define SOFT_BODY_BULLET_H
+#include "collision_object_bullet.h"
+#include "scene/resources/material.h" // TODO remove this please
+
#ifdef None
/// This is required to remove the macro None defined by x11 compiler because this word "None" is used internally by Bullet
#undef None
#define x11_None 0L
#endif
-#include "BulletSoftBody/btSoftBodyHelpers.h"
-#include "collision_object_bullet.h"
+#include <BulletSoftBody/btSoftBodyHelpers.h>
#ifdef x11_None
/// This is required to re add the macro None defined by x11 compiler
@@ -47,7 +48,9 @@
#define None 0L
#endif
-#include "scene/resources/material.h" // TODO remove thsi please
+/**
+ @author AndreaCatania
+*/
struct SoftShapeData {};
struct TrimeshSoftShapeData : public SoftShapeData {
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index a67c627ba4..88d9c20eba 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -1,10 +1,9 @@
/*************************************************************************/
/* space_bullet.cpp */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,14 +29,7 @@
/*************************************************************************/
#include "space_bullet.h"
-#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
-#include "BulletCollision/CollisionDispatch/btGhostObject.h"
-#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
-#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
-#include "BulletCollision/NarrowPhaseCollision/btPointCollector.h"
-#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
-#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
-#include "btBulletDynamicsCommon.h"
+
#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
@@ -48,8 +40,22 @@
#include "servers/physics_server.h"
#include "soft_body_bullet.h"
#include "ustring.h"
+
+#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
+#include <BulletCollision/CollisionDispatch/btGhostObject.h>
+#include <BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h>
+#include <BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h>
+#include <BulletCollision/NarrowPhaseCollision/btPointCollector.h>
+#include <BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h>
+#include <BulletSoftBody/btSoftRigidDynamicsWorld.h>
+#include <btBulletDynamicsCommon.h>
+
#include <assert.h>
+/**
+ @author AndreaCatania
+*/
+
BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) :
PhysicsDirectSpaceState(),
space(p_space) {}
@@ -110,7 +116,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
}
}
-int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *p_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask) {
+int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask) {
if (p_result_max <= 0)
return 0;
@@ -132,7 +138,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
collision_object.setCollisionShape(btConvex);
collision_object.setWorldTransform(bt_xform);
- GodotAllContactResultCallback btQuery(&collision_object, p_results, p_result_max, &p_exclude);
+ GodotAllContactResultCallback btQuery(&collision_object, r_results, p_result_max, &p_exclude);
btQuery.m_collisionFilterGroup = 0;
btQuery.m_collisionFilterMask = p_collision_mask;
btQuery.m_closestDistanceThreshold = 0;
@@ -851,31 +857,31 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
btVector3 recover_initial_position(0, 0, 0);
{ /// Phase one - multi shapes depenetration using margin
for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) {
- if (recover_from_penetration(p_body, body_safe_position, RECOVERING_MOVEMENT_SCALE, recover_initial_position)) {
-
- // Add recover position to "From" and "To" transforms
- body_safe_position.getOrigin() += recover_initial_position;
- } else {
+ if (!recover_from_penetration(p_body, body_safe_position, RECOVERING_MOVEMENT_SCALE, recover_initial_position)) {
break;
}
}
+
+ // Add recover movement in order to make it safe
+ body_safe_position.getOrigin() += recover_initial_position;
}
#endif
- btVector3 recovered_motion;
- G_TO_B(p_motion, recovered_motion);
- const int shape_count(p_body->get_shape_count());
+ btVector3 motion;
+ G_TO_B(p_motion, motion);
{ /// phase two - sweep test, from a secure position without margin
+ const int shape_count(p_body->get_shape_count());
+
#if debug_test_motion
-//Vector3 sup_line;
-//B_TO_G(body_safe_position.getOrigin(), sup_line);
-//motionVec->clear();
-//motionVec->begin(Mesh::PRIMITIVE_LINES, NULL);
-//motionVec->add_vertex(sup_line);
-//motionVec->add_vertex(sup_line + p_motion * 10);
-//motionVec->end();
+ Vector3 sup_line;
+ B_TO_G(body_safe_position.getOrigin(), sup_line);
+ motionVec->clear();
+ motionVec->begin(Mesh::PRIMITIVE_LINES, NULL);
+ motionVec->add_vertex(sup_line);
+ motionVec->add_vertex(sup_line + p_motion * 10);
+ motionVec->end();
#endif
for (int shIndex = 0; shIndex < shape_count; ++shIndex) {
@@ -892,7 +898,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
btTransform shape_world_from = body_safe_position * p_body->get_kinematic_utilities()->shapes[shIndex].transform;
btTransform shape_world_to(shape_world_from);
- shape_world_to.getOrigin() += recovered_motion;
+ shape_world_to.getOrigin() += motion;
GodotKinClosestConvexResultCallback btResult(shape_world_from.getOrigin(), shape_world_to.getOrigin(), p_body, IGNORE_AREAS_TRUE);
btResult.m_collisionFilterGroup = p_body->get_collision_layer();
@@ -903,27 +909,30 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
if (btResult.hasHit()) {
/// Since for each sweep test I fix the motion of new shapes in base the recover result,
/// if another shape will hit something it means that has a deepest penetration respect the previous shape
- recovered_motion *= btResult.m_closestHitFraction;
+ motion *= btResult.m_closestHitFraction;
}
}
+
+ body_safe_position.getOrigin() += motion;
}
bool has_penetration = false;
{ /// Phase three - Recover + contact test with margin
+ btVector3 delta_recover_movement(0, 0, 0);
RecoverResult r_recover_result;
bool l_has_penetration;
real_t l_penetration_distance = 1e20;
for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) {
- l_has_penetration = recover_from_penetration(p_body, body_safe_position, RECOVERING_MOVEMENT_SCALE, recovered_motion, &r_recover_result);
+ l_has_penetration = recover_from_penetration(p_body, body_safe_position, RECOVERING_MOVEMENT_SCALE, delta_recover_movement, &r_recover_result);
if (r_result) {
#if PERFORM_INITIAL_UNSTACK
- B_TO_G(recovered_motion + recover_initial_position, r_result->motion);
+ B_TO_G(motion + delta_recover_movement + recover_initial_position, r_result->motion);
#else
- B_TO_G(recovered_motion, r_result->motion);
+ B_TO_G(motion + delta_recover_movement, r_result->motion);
#endif
if (l_has_penetration) {
has_penetration = true;
@@ -936,7 +945,8 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
const btRigidBody *btRigid = static_cast<const btRigidBody *>(r_recover_result.other_collision_object);
CollisionObjectBullet *collisionObject = static_cast<CollisionObjectBullet *>(btRigid->getUserPointer());
- r_result->remainder = p_motion - r_result->motion; // is the remaining movements
+ B_TO_G(motion, r_result->remainder); // is the remaining movements
+ r_result->remainder = p_motion - r_result->remainder;
B_TO_G(r_recover_result.pointWorld, r_result->collision_point);
B_TO_G(r_recover_result.normal, r_result->collision_normal);
B_TO_G(btRigid->getVelocityInLocalPoint(r_recover_result.pointWorld - btRigid->getWorldTransform().getOrigin()), r_result->collider_velocity); // It calculates velocity at point and assign it using special function Bullet_to_Godot
@@ -955,23 +965,22 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
//}
#if debug_test_motion
-//Vector3 sup_line2;
-//B_TO_G(recovered_motion, sup_line2);
-////Vector3 sup_pos;
-////B_TO_G( pt.getPositionWorldOnB(), sup_pos);
-//normalLine->clear();
-//normalLine->begin(Mesh::PRIMITIVE_LINES, NULL);
-//normalLine->add_vertex(r_result->collision_point);
-//normalLine->add_vertex(r_result->collision_point + r_result->collision_normal * 10);
-//normalLine->end();
+ Vector3 sup_line2;
+ B_TO_G(motion, sup_line2);
+ normalLine->clear();
+ normalLine->begin(Mesh::PRIMITIVE_LINES, NULL);
+ normalLine->add_vertex(r_result->collision_point);
+ normalLine->add_vertex(r_result->collision_point + r_result->collision_normal * 10);
+ normalLine->end();
#endif
-
} else {
r_result->remainder = Vector3();
}
} else {
if (!l_has_penetration)
break;
+ else
+ has_penetration = true;
}
}
}
@@ -1013,7 +1022,7 @@ public:
}
};
-bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result) {
+bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) {
RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), p_body->get_collision_mask());
@@ -1037,7 +1046,7 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
body_shape_position = p_body_position * kin_shape.transform;
body_shape_position_recovered = body_shape_position;
- body_shape_position_recovered.getOrigin() += r_recover_position;
+ body_shape_position_recovered.getOrigin() += r_delta_recover_movement;
kin_shape.shape->getAabb(body_shape_position_recovered, minAabb, maxAabb);
dynamicsWorld->getBroadphase()->aabbTest(minAabb, maxAabb, recover_broad_result);
@@ -1054,24 +1063,24 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
for (int x = cs->getNumChildShapes() - 1; 0 <= x; --x) {
if (cs->getChildShape(x)->isConvex()) {
- if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(cs->getChildShape(x)), otherObject, x, body_shape_position_recovered, otherObject->getWorldTransform() * cs->getChildTransform(x), p_recover_movement_scale, r_recover_position, r_recover_result)) {
+ if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(cs->getChildShape(x)), otherObject, x, body_shape_position, otherObject->getWorldTransform() * cs->getChildTransform(x), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
} else {
- if (RFP_convex_world_test(kin_shape.shape, cs->getChildShape(x), p_body->get_bt_collision_object(), otherObject, kinIndex, x, body_shape_position_recovered, otherObject->getWorldTransform() * cs->getChildTransform(x), p_recover_movement_scale, r_recover_position, r_recover_result)) {
+ if (RFP_convex_world_test(kin_shape.shape, cs->getChildShape(x), p_body->get_bt_collision_object(), otherObject, kinIndex, x, body_shape_position, otherObject->getWorldTransform() * cs->getChildTransform(x), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
}
}
} else if (otherObject->getCollisionShape()->isConvex()) { /// Execute GJK test against object shape
- if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(otherObject->getCollisionShape()), otherObject, 0, body_shape_position_recovered, otherObject->getWorldTransform(), p_recover_movement_scale, r_recover_position, r_recover_result)) {
+ if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(otherObject->getCollisionShape()), otherObject, 0, body_shape_position, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
} else {
- if (RFP_convex_world_test(kin_shape.shape, otherObject->getCollisionShape(), p_body->get_bt_collision_object(), otherObject, kinIndex, 0, body_shape_position_recovered, otherObject->getWorldTransform(), p_recover_movement_scale, r_recover_position, r_recover_result)) {
+ if (RFP_convex_world_test(kin_shape.shape, otherObject->getCollisionShape(), p_body->get_bt_collision_object(), otherObject, kinIndex, 0, body_shape_position, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
@@ -1079,26 +1088,15 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
}
}
-#if debug_test_motion
- Vector3 pos;
- B_TO_G(p_body_position.getOrigin(), pos);
- Vector3 sup_line;
- B_TO_G(sum_recover_normals, sup_line);
- motionVec->clear();
- motionVec->begin(Mesh::PRIMITIVE_LINES, NULL);
- motionVec->add_vertex(pos);
- motionVec->add_vertex(pos + (sup_line * 10));
- motionVec->end();
-#endif
-
return penetration;
}
-bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result) {
+bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) {
// Initialize GJK input
btGjkPairDetector::ClosestPointInput gjk_input;
gjk_input.m_transformA = p_transformA;
+ gjk_input.m_transformA.getOrigin() += r_delta_recover_movement;
gjk_input.m_transformB = p_transformB;
// Perform GJK test
@@ -1107,7 +1105,7 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt
gjk_pair_detector.getClosestPoints(gjk_input, result, 0);
if (0 > result.m_distance) {
// Has penetration
- r_recover_position += result.m_normalOnBInWorld * (result.m_distance * -1 * p_recover_movement_scale);
+ r_delta_recover_movement += result.m_normalOnBInWorld * (result.m_distance * -1 * p_recover_movement_scale);
if (r_recover_result) {
if (result.m_distance < r_recover_result->penetration_distance) {
@@ -1124,11 +1122,14 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt
return false;
}
-bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result) {
+bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) {
/// Contact test
- btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, p_transformA, -1, p_shapeId_A);
+ btTransform tA(p_transformA);
+ tA.getOrigin() += r_delta_recover_movement;
+
+ btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, tA, -1, p_shapeId_A);
btCollisionObjectWrapper obB(NULL, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B);
btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CLOSEST_POINT_ALGORITHMS);
@@ -1141,7 +1142,7 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC
dispatcher->freeCollisionAlgorithm(algorithm);
if (contactPointResult.hasHit()) {
- r_recover_position += contactPointResult.m_pointNormalWorld * (contactPointResult.m_penetration_distance * -1 * p_recover_movement_scale);
+ r_delta_recover_movement += contactPointResult.m_pointNormalWorld * (contactPointResult.m_penetration_distance * -1 * p_recover_movement_scale);
if (r_recover_result) {
if (contactPointResult.m_penetration_distance < r_recover_result->penetration_distance) {
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 69ea2fcc58..2b97f0b274 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -1,10 +1,9 @@
/*************************************************************************/
/* space_bullet.h */
-/* Author: AndreaCatania */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,17 +31,22 @@
#ifndef SPACE_BULLET_H
#define SPACE_BULLET_H
-#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
-#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
-#include "LinearMath/btScalar.h"
-#include "LinearMath/btTransform.h"
-#include "LinearMath/btVector3.h"
#include "core/variant.h"
#include "core/vector.h"
#include "godot_result_callbacks.h"
#include "rid_bullet.h"
#include "servers/physics_server.h"
+#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
+#include <BulletCollision/BroadphaseCollision/btOverlappingPairCache.h>
+#include <LinearMath/btScalar.h>
+#include <LinearMath/btTransform.h>
+#include <LinearMath/btVector3.h>
+
+/**
+ @author AndreaCatania
+*/
+
class AreaBullet;
class btBroadphaseInterface;
class btCollisionDispatcher;
@@ -187,15 +191,20 @@ private:
RecoverResult() :
hasPenetration(false),
- penetration_distance(1e20) {}
+ normal(0, 0, 0),
+ pointWorld(0, 0, 0),
+ penetration_distance(1e20),
+ other_compound_shape_index(0),
+ other_collision_object(NULL),
+ local_shape_most_recovered(0) {}
};
- bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_from, btScalar p_recover_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result = NULL);
+ bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
/// This is an API that recover a kinematic object from penetration
/// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions
- bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result = NULL);
+ bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
/// This is an API that recover a kinematic object from penetration
/// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm
- bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_movement_scale, btVector3 &r_recover_position, RecoverResult *r_recover_result = NULL);
+ bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
};
#endif
diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp
index 76244c76a4..d6351fb6fe 100644
--- a/modules/dds/register_types.cpp
+++ b/modules/dds/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "texture_loader_dds.h"
diff --git a/modules/dds/register_types.h b/modules/dds/register_types.h
index 74db58937e..c7f7839c24 100644
--- a/modules/dds/register_types.h
+++ b/modules/dds/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_dds_types();
void unregister_dds_types();
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index d01af20544..9424080b6d 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "texture_loader_dds.h"
#include "os/file_access.h"
diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h
index 0adae2fb2a..14d99ff506 100644
--- a/modules/dds/texture_loader_dds.h
+++ b/modules/dds/texture_loader_dds.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef TEXTURE_LOADER_DDS_H
#define TEXTURE_LOADER_DDS_H
diff --git a/modules/enet/SCsub b/modules/enet/SCsub
index 4790c5099f..7caeafa1d6 100644
--- a/modules/enet/SCsub
+++ b/modules/enet/SCsub
@@ -3,10 +3,10 @@
Import('env')
Import('env_modules')
-# Thirdparty source files
-
env_enet = env_modules.Clone()
+# Thirdparty source files
+
if env['builtin_enet']:
thirdparty_dir = "#thirdparty/enet/"
thirdparty_sources = [
diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
index 25d17542ea..23ee327cc5 100644
--- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
+++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core" version="3.0-beta">
+<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core" version="3.0-stable">
<brief_description>
PacketPeer implementation using the ENet library.
</brief_description>
@@ -47,12 +47,6 @@
Create server that listens to connections via [code]port[/code].
</description>
</method>
- <method name="get_compression_mode" qualifiers="const">
- <return type="int" enum="NetworkedMultiplayerENet.CompressionMode">
- </return>
- <description>
- </description>
- </method>
<method name="set_bind_ip">
<return type="void">
</return>
@@ -61,15 +55,11 @@
<description>
</description>
</method>
- <method name="set_compression_mode">
- <return type="void">
- </return>
- <argument index="0" name="mode" type="int" enum="NetworkedMultiplayerENet.CompressionMode">
- </argument>
- <description>
- </description>
- </method>
</methods>
+ <members>
+ <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="NetworkedMultiplayerENet.CompressionMode">
+ </member>
+ </members>
<constants>
<constant name="COMPRESS_NONE" value="0" enum="CompressionMode">
</constant>
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 2b5dd67938..f3f4acd768 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "networked_multiplayer_enet.h"
#include "io/marshalls.h"
#include "os/os.h"
@@ -35,6 +36,10 @@ void NetworkedMultiplayerENet::set_transfer_mode(TransferMode p_mode) {
transfer_mode = p_mode;
}
+NetworkedMultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const {
+
+ return transfer_mode;
+}
void NetworkedMultiplayerENet::set_target_peer(int p_peer) {
@@ -658,6 +663,8 @@ void NetworkedMultiplayerENet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode);
ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &NetworkedMultiplayerENet::set_bind_ip);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "compression_mode", PROPERTY_HINT_ENUM, "None,Range Coder,FastLZ,ZLib,ZStd"), "set_compression_mode", "get_compression_mode");
+
BIND_ENUM_CONSTANT(COMPRESS_NONE);
BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER);
BIND_ENUM_CONSTANT(COMPRESS_FASTLZ);
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index d6644aed2d..440e9b5400 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef NETWORKED_MULTIPLAYER_ENET_H
#define NETWORKED_MULTIPLAYER_ENET_H
@@ -109,6 +110,7 @@ protected:
public:
virtual void set_transfer_mode(TransferMode p_mode);
+ virtual TransferMode get_transfer_mode() const;
virtual void set_target_peer(int p_peer);
virtual int get_packet_peer() const;
diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp
index 94d0eaa43f..cabaeb692a 100644
--- a/modules/enet/register_types.cpp
+++ b/modules/enet/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "error_macros.h"
#include "networked_multiplayer_enet.h"
diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h
index 03cc2c8525..bcf0893ae4 100644
--- a/modules/enet/register_types.h
+++ b/modules/enet/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_enet_types();
void unregister_enet_types();
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 2224ecc356..8a674bc8c1 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_etc.h"
#include "Etc.h"
#include "EtcFilter.h"
@@ -117,7 +118,6 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
}
uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
- ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh);
Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);
@@ -126,6 +126,25 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
if (img->get_format() != Image::FORMAT_RGBA8)
img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
+ if (img->has_mipmaps()) {
+ if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) {
+ img->resize_to_po2();
+ imgw = img->get_width();
+ imgh = img->get_height();
+ }
+ } else {
+ if (imgw % 4 != 0 || imgh % 4 != 0) {
+ if (imgw % 4) {
+ imgw += 4 - imgw % 4;
+ }
+ if (imgh % 4) {
+ imgh += 4 - imgh % 4;
+ }
+
+ img->resize(imgw, imgh);
+ }
+ }
+
PoolVector<uint8_t>::Read r = img->get_data().read();
int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps() ? -1 : 0);
diff --git a/modules/etc/image_etc.h b/modules/etc/image_etc.h
index fb32a120b1..371c38176f 100644
--- a/modules/etc/image_etc.h
+++ b/modules/etc/image_etc.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_ETC1_H
#define IMAGE_ETC1_H
diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp
index 42baf91dfa..1d1f0e1b77 100644
--- a/modules/etc/register_types.cpp
+++ b/modules/etc/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_etc.h"
diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h
index 1f1336dc10..4a8513a687 100644
--- a/modules/etc/register_types.h
+++ b/modules/etc/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_etc_types();
void unregister_etc_types();
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index 4f6df04341..ac89259c9b 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "texture_loader_pkm.h"
#include "os/file_access.h"
diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h
index 1e8833b547..3c6d9180bd 100644
--- a/modules/etc/texture_loader_pkm.h
+++ b/modules/etc/texture_loader_pkm.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef TEXTURE_LOADER_PKM_H
#define TEXTURE_LOADER_PKM_H
diff --git a/modules/freetype/register_types.cpp b/modules/freetype/register_types.cpp
index c3fa84417d..bde04b714c 100644
--- a/modules/freetype/register_types.cpp
+++ b/modules/freetype/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
void register_freetype_types() {}
diff --git a/modules/freetype/register_types.h b/modules/freetype/register_types.h
index 959d646cd4..0cec0e3951 100644
--- a/modules/freetype/register_types.h
+++ b/modules/freetype/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_freetype_types();
void unregister_freetype_types();
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index c92c3f30a2..acfb83bc10 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -28,7 +28,7 @@ def _build_gdnative_api_struct_header(api):
'\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name))
gdnative_api_init_macro.append('\t_gdnative_wrapper_api_struct = options->api_struct;')
- gdnative_api_init_macro.append('\tfor (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ')
+ gdnative_api_init_macro.append('\tfor (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ')
gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {')
for name in api['extensions']:
@@ -66,19 +66,30 @@ def _build_gdnative_api_struct_header(api):
out += ['};', '']
- for name in api['extensions']:
- out += [
- 'typedef struct godot_gdnative_ext_' + name + '_api_struct {',
+
+ def generate_extension_struct(name, ext, include_version=True):
+ ret_val = []
+ if ext['next']:
+ ret_val += generate_extension_struct(name, ext['next'])
+
+ ret_val += [
+ 'typedef struct godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct {',
'\tunsigned int type;',
'\tgodot_gdnative_api_version version;',
'\tconst godot_gdnative_api_struct *next;'
]
- for funcdef in api['extensions'][name]['api']:
+ for funcdef in ext['api']:
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
- out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+ ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+
+ ret_val += ['} godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct;', '']
+
+ return ret_val
- out += ['} godot_gdnative_ext_' + name + '_api_struct;', '']
+
+ for name in api['extensions']:
+ out += generate_extension_struct(name, api['extensions'][name], False)
out += [
'typedef struct godot_gdnative_core_api_struct {',
@@ -113,18 +124,35 @@ def _build_gdnative_api_struct_source(api):
''
]
- for name in api['extensions']:
- out += [
- 'extern const godot_gdnative_ext_' + name + '_api_struct api_extension_' + name + '_struct = {',
- '\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ',',
- '\t{' + str(api['extensions'][name]['version']['major']) + ', ' + str(api['extensions'][name]['version']['minor']) + '},',
- '\tNULL,'
+ def get_extension_struct_name(name, ext, include_version=True):
+ return 'godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct'
+
+ def get_extension_struct_instance_name(name, ext, include_version=True):
+ return 'api_extension_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_struct'
+
+ def get_extension_struct_definition(name, ext, include_version=True):
+
+ ret_val = []
+
+ if ext['next']:
+ ret_val += get_extension_struct_definition(name, ext['next'])
+
+ ret_val += [
+ 'extern const ' + get_extension_struct_name(name, ext, include_version) + ' ' + get_extension_struct_instance_name(name, ext, include_version) + ' = {',
+ '\tGDNATIVE_EXT_' + ext['type'] + ',',
+ '\t{' + str(ext['version']['major']) + ', ' + str(ext['version']['minor']) + '},',
+ '\t' + ('NULL' if not ext['next'] else ('(const godot_gdnative_api_struct *)&' + get_extension_struct_instance_name(name, ext['next']))) + ','
]
- for funcdef in api['extensions'][name]['api']:
- out.append('\t%s,' % funcdef['name'])
+ for funcdef in ext['api']:
+ ret_val.append('\t%s,' % funcdef['name'])
+
+ ret_val += ['};\n']
- out += ['};\n']
+ return ret_val
+
+ for name in api['extensions']:
+ out += get_extension_struct_definition(name, api['extensions'][name], False)
out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {']
diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
index e4ffa76d36..bceb4f1f4c 100644
--- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
+++ b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-beta">
+<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-stable">
<brief_description>
GDNative wrapper for an ARVR interface
</brief_description>
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index 83953cef49..7e4d956604 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNative" inherits="Reference" category="Core" version="3.0-beta">
+<class name="GDNative" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml
index 647d27929f..a6874c9ae8 100644
--- a/modules/gdnative/doc_classes/GDNativeLibrary.xml
+++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-beta">
+<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
@@ -31,6 +31,8 @@
<members>
<member name="load_once" type="bool" setter="set_load_once" getter="should_load_once">
</member>
+ <member name="reloadable" type="bool" setter="set_reloadable" getter="is_reloadable">
+ </member>
<member name="singleton" type="bool" setter="set_singleton" getter="is_singleton">
</member>
<member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix">
diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml
index 3f6025d02f..6a71cd8d4d 100644
--- a/modules/gdnative/doc_classes/NativeScript.xml
+++ b/modules/gdnative/doc_classes/NativeScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="NativeScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="NativeScript" inherits="Script" category="Core" version="3.1-dev">
<brief_description>
</brief_description>
<description>
@@ -9,10 +9,46 @@
<demos>
</demos>
<methods>
+ <method name="get_class_documentation" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the documentation string that was previously set with [code]godot_nativescript_set_class_documentation[/code].
+ </description>
+ </method>
+ <method name="get_method_documentation" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="method" type="String">
+ </argument>
+ <description>
+ Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code].
+ </description>
+ </method>
+ <method name="get_property_documentation" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code].
+ </description>
+ </method>
+ <method name="get_signal_documentation" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="signal_name" type="String">
+ </argument>
+ <description>
+ Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code].
+ </description>
+ </method>
<method name="new" qualifiers="vararg">
<return type="Object">
</return>
<description>
+ Constructs a new object of the base type with a script of this type already attached.
+ [i]Note[/i]: Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension.
</description>
</method>
</methods>
diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml
index 1a2141247a..fbdd8f09e6 100644
--- a/modules/gdnative/doc_classes/PluginScript.xml
+++ b/modules/gdnative/doc_classes/PluginScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="PluginScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="PluginScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 57db9ac51c..42c3028f2c 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative.h"
#include "global_constants.h"
@@ -37,9 +38,12 @@
#include "scene/main/scene_tree.h"
-const String init_symbol = "gdnative_init";
-const String terminate_symbol = "gdnative_terminate";
-const String default_symbol_prefix = "godot_";
+static const String init_symbol = "gdnative_init";
+static const String terminate_symbol = "gdnative_terminate";
+static const String default_symbol_prefix = "godot_";
+static const bool default_singleton = false;
+static const bool default_load_once = true;
+static const bool default_reloadable = true;
// Defined in gdnative_api_struct.gen.cpp
extern const godot_gdnative_core_api_struct api_struct;
@@ -50,6 +54,9 @@ GDNativeLibrary::GDNativeLibrary() {
config_file.instance();
symbol_prefix = default_symbol_prefix;
+ load_once = default_load_once;
+ singleton = default_singleton;
+ reloadable = default_reloadable;
if (GDNativeLibrary::loaded_libraries == NULL) {
GDNativeLibrary::loaded_libraries = memnew((Map<String, Vector<Ref<GDNative> > >));
@@ -68,14 +75,17 @@ void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("should_load_once"), &GDNativeLibrary::should_load_once);
ClassDB::bind_method(D_METHOD("is_singleton"), &GDNativeLibrary::is_singleton);
ClassDB::bind_method(D_METHOD("get_symbol_prefix"), &GDNativeLibrary::get_symbol_prefix);
+ ClassDB::bind_method(D_METHOD("is_reloadable"), &GDNativeLibrary::is_reloadable);
ClassDB::bind_method(D_METHOD("set_load_once", "load_once"), &GDNativeLibrary::set_load_once);
ClassDB::bind_method(D_METHOD("set_singleton", "singleton"), &GDNativeLibrary::set_singleton);
ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix);
+ ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable);
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton");
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "symbol_prefix"), "set_symbol_prefix", "get_symbol_prefix");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "reloadable"), "set_reloadable", "is_reloadable");
}
GDNative::GDNative() {
@@ -171,13 +181,23 @@ bool GDNative::initialize() {
godot_gdnative_init_fn library_init_fpointer;
library_init_fpointer = (godot_gdnative_init_fn)library_init;
+ static uint64_t core_api_hash = 0;
+ static uint64_t editor_api_hash = 0;
+ static uint64_t no_api_hash = 0;
+
+ if (!(core_api_hash || editor_api_hash || no_api_hash)) {
+ core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
+ editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
+ no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
+ }
+
godot_gdnative_init_options options;
options.api_struct = &api_struct;
options.in_editor = Engine::get_singleton()->is_editor_hint();
- options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
- options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
- options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
+ options.core_api_hash = core_api_hash;
+ options.editor_api_hash = editor_api_hash;
+ options.no_api_hash = no_api_hash;
options.report_version_mismatch = &_gdnative_report_version_mismatch;
options.report_loading_error = &_gdnative_report_loading_error;
options.gd_native_library = (godot_object *)(get_library().ptr());
@@ -317,9 +337,10 @@ RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_or
*r_error = err;
}
- lib->set_singleton(config->get_value("general", "singleton", false));
- lib->set_load_once(config->get_value("general", "load_once", true));
+ lib->set_singleton(config->get_value("general", "singleton", default_singleton));
+ lib->set_load_once(config->get_value("general", "load_once", default_load_once));
lib->set_symbol_prefix(config->get_value("general", "symbol_prefix", default_symbol_prefix));
+ lib->set_reloadable(config->get_value("general", "reloadable", default_reloadable));
String entry_lib_path;
{
@@ -415,6 +436,7 @@ Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_reso
config->set_value("general", "singleton", lib->is_singleton());
config->set_value("general", "load_once", lib->should_load_once());
config->set_value("general", "symbol_prefix", lib->get_symbol_prefix());
+ config->set_value("general", "reloadable", lib->is_reloadable());
return config->save(p_path);
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 26c19dcf22..3298ea950f 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDNATIVE_H
#define GDNATIVE_H
@@ -59,6 +60,7 @@ class GDNativeLibrary : public Resource {
bool singleton;
bool load_once;
String symbol_prefix;
+ bool reloadable;
public:
GDNativeLibrary();
@@ -86,6 +88,10 @@ public:
return symbol_prefix;
}
+ _FORCE_INLINE_ bool is_reloadable() const {
+ return reloadable;
+ }
+
_FORCE_INLINE_ void set_load_once(bool p_load_once) {
load_once = p_load_once;
}
@@ -96,6 +102,10 @@ public:
symbol_prefix = p_symbol_prefix;
}
+ _FORCE_INLINE_ void set_reloadable(bool p_reloadable) {
+ reloadable = p_reloadable;
+ }
+
static void _bind_methods();
};
diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp
index 706e81a606..0597e1cdd6 100644
--- a/modules/gdnative/gdnative/aabb.cpp
+++ b/modules/gdnative/gdnative/aabb.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* aabb.cpp */
+/* aabb.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/aabb.h"
#include "core/math/aabb.h"
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 72020b5361..1fb0ff0500 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/array.h"
#include "core/array.h"
diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 7b9acc6bd0..372bdf3fb1 100644
--- a/modules/gdnative/gdnative/basis.cpp
+++ b/modules/gdnative/gdnative/basis.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/basis.h"
#include "core/math/matrix3.h"
diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp
index 4fd4458bfb..4089f4458a 100644
--- a/modules/gdnative/gdnative/color.cpp
+++ b/modules/gdnative/gdnative/color.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/color.h"
#include "core/color.h"
diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index b2ac8e0426..786e614158 100644
--- a/modules/gdnative/gdnative/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/dictionary.h"
#include "core/variant.h"
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 38fb2ee818..041990e137 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/gdnative.h"
#include "class_db.h"
diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp
index 8c490709c0..f24facaae8 100644
--- a/modules/gdnative/gdnative/node_path.cpp
+++ b/modules/gdnative/gdnative/node_path.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/node_path.h"
#include "core/node_path.h"
diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp
index de272d6f08..be821edcc3 100644
--- a/modules/gdnative/gdnative/plane.cpp
+++ b/modules/gdnative/gdnative/plane.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/plane.h"
#include "core/math/plane.h"
diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp
index dc24bf4d15..6688be1a0d 100644
--- a/modules/gdnative/gdnative/pool_arrays.cpp
+++ b/modules/gdnative/gdnative/pool_arrays.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/pool_arrays.h"
#include "array.h"
@@ -699,6 +700,10 @@ void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self) {
// read accessor functions
//
+godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other) {
+ PoolVector<uint8_t>::Read *other = (PoolVector<uint8_t>::Read *)p_other;
+ return (godot_pool_byte_array_read_access *)memnew(PoolVector<uint8_t>::Read(*other));
+}
const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read) {
const PoolVector<uint8_t>::Read *read = (const PoolVector<uint8_t>::Read *)p_read;
return read->ptr();
@@ -712,6 +717,10 @@ void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_
memdelete((PoolVector<uint8_t>::Read *)p_read);
}
+godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other) {
+ PoolVector<godot_int>::Read *other = (PoolVector<godot_int>::Read *)p_other;
+ return (godot_pool_int_array_read_access *)memnew(PoolVector<godot_int>::Read(*other));
+}
const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read) {
const PoolVector<godot_int>::Read *read = (const PoolVector<godot_int>::Read *)p_read;
return read->ptr();
@@ -725,6 +734,10 @@ void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_ac
memdelete((PoolVector<godot_int>::Read *)p_read);
}
+godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other) {
+ PoolVector<godot_real>::Read *other = (PoolVector<godot_real>::Read *)p_other;
+ return (godot_pool_real_array_read_access *)memnew(PoolVector<godot_real>::Read(*other));
+}
const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read) {
const PoolVector<godot_real>::Read *read = (const PoolVector<godot_real>::Read *)p_read;
return read->ptr();
@@ -738,6 +751,10 @@ void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_
memdelete((PoolVector<godot_real>::Read *)p_read);
}
+godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other) {
+ PoolVector<String>::Read *other = (PoolVector<String>::Read *)p_other;
+ return (godot_pool_string_array_read_access *)memnew(PoolVector<String>::Read(*other));
+}
const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read) {
const PoolVector<String>::Read *read = (const PoolVector<String>::Read *)p_read;
return (const godot_string *)read->ptr();
@@ -751,6 +768,10 @@ void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_r
memdelete((PoolVector<String>::Read *)p_read);
}
+godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other) {
+ PoolVector<Vector2>::Read *other = (PoolVector<Vector2>::Read *)p_other;
+ return (godot_pool_vector2_array_read_access *)memnew(PoolVector<Vector2>::Read(*other));
+}
const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read) {
const PoolVector<Vector2>::Read *read = (const PoolVector<Vector2>::Read *)p_read;
return (const godot_vector2 *)read->ptr();
@@ -764,6 +785,10 @@ void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array
memdelete((PoolVector<Vector2>::Read *)p_read);
}
+godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other) {
+ PoolVector<Vector3>::Read *other = (PoolVector<Vector3>::Read *)p_other;
+ return (godot_pool_vector3_array_read_access *)memnew(PoolVector<Vector3>::Read(*other));
+}
const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read) {
const PoolVector<Vector3>::Read *read = (const PoolVector<Vector3>::Read *)p_read;
return (const godot_vector3 *)read->ptr();
@@ -777,6 +802,10 @@ void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array
memdelete((PoolVector<Vector2>::Read *)p_read);
}
+godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other) {
+ PoolVector<Color>::Read *other = (PoolVector<Color>::Read *)p_other;
+ return (godot_pool_color_array_read_access *)memnew(PoolVector<Color>::Read(*other));
+}
const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read) {
const PoolVector<Color>::Read *read = (const PoolVector<Color>::Read *)p_read;
return (const godot_color *)read->ptr();
@@ -794,6 +823,10 @@ void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_rea
// write accessor functions
//
+godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other) {
+ PoolVector<uint8_t>::Write *other = (PoolVector<uint8_t>::Write *)p_other;
+ return (godot_pool_byte_array_write_access *)memnew(PoolVector<uint8_t>::Write(*other));
+}
uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write) {
PoolVector<uint8_t>::Write *write = (PoolVector<uint8_t>::Write *)p_write;
return write->ptr();
@@ -807,6 +840,10 @@ void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_writ
memdelete((PoolVector<uint8_t>::Write *)p_write);
}
+godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other) {
+ PoolVector<godot_int>::Write *other = (PoolVector<godot_int>::Write *)p_other;
+ return (godot_pool_int_array_write_access *)memnew(PoolVector<godot_int>::Write(*other));
+}
godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write) {
PoolVector<godot_int>::Write *write = (PoolVector<godot_int>::Write *)p_write;
return write->ptr();
@@ -820,6 +857,10 @@ void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_
memdelete((PoolVector<godot_int>::Write *)p_write);
}
+godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other) {
+ PoolVector<godot_real>::Write *other = (PoolVector<godot_real>::Write *)p_other;
+ return (godot_pool_real_array_write_access *)memnew(PoolVector<godot_real>::Write(*other));
+}
godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write) {
PoolVector<godot_real>::Write *write = (PoolVector<godot_real>::Write *)p_write;
return write->ptr();
@@ -833,6 +874,10 @@ void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_writ
memdelete((PoolVector<godot_real>::Write *)p_write);
}
+godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other) {
+ PoolVector<String>::Write *other = (PoolVector<String>::Write *)p_other;
+ return (godot_pool_string_array_write_access *)memnew(PoolVector<String>::Write(*other));
+}
godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write) {
PoolVector<String>::Write *write = (PoolVector<String>::Write *)p_write;
return (godot_string *)write->ptr();
@@ -846,6 +891,10 @@ void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_
memdelete((PoolVector<String>::Write *)p_write);
}
+godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other) {
+ PoolVector<Vector2>::Write *other = (PoolVector<Vector2>::Write *)p_other;
+ return (godot_pool_vector2_array_write_access *)memnew(PoolVector<Vector2>::Write(*other));
+}
godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write) {
PoolVector<Vector2>::Write *write = (PoolVector<Vector2>::Write *)p_write;
return (godot_vector2 *)write->ptr();
@@ -859,6 +908,10 @@ void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_arra
memdelete((PoolVector<Vector2>::Write *)p_write);
}
+godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other) {
+ PoolVector<Vector3>::Write *other = (PoolVector<Vector3>::Write *)p_other;
+ return (godot_pool_vector3_array_write_access *)memnew(PoolVector<Vector3>::Write(*other));
+}
godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write) {
PoolVector<Vector3>::Write *write = (PoolVector<Vector3>::Write *)p_write;
return (godot_vector3 *)write->ptr();
@@ -872,6 +925,10 @@ void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_arra
memdelete((PoolVector<Vector3>::Write *)p_write);
}
+godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other) {
+ PoolVector<Color>::Write *other = (PoolVector<Color>::Write *)p_other;
+ return (godot_pool_color_array_write_access *)memnew(PoolVector<Color>::Write(*other));
+}
godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write) {
PoolVector<Color>::Write *write = (PoolVector<Color>::Write *)p_write;
return (godot_color *)write->ptr();
diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index 2f577e485a..56ff7fe3a8 100644
--- a/modules/gdnative/gdnative/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/quat.h"
#include "core/math/quat.h"
diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp
index c449a0d14c..83c58db520 100644
--- a/modules/gdnative/gdnative/rect2.cpp
+++ b/modules/gdnative/gdnative/rect2.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/rect2.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp
index fe04f1e92f..4374738f48 100644
--- a/modules/gdnative/gdnative/rid.cpp
+++ b/modules/gdnative/gdnative/rid.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/rid.h"
#include "core/resource.h"
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index a99adb3beb..7f5dbc12be 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/string.h"
#include "core/string_db.h"
@@ -39,6 +40,24 @@
extern "C" {
#endif
+godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) {
+ const CharString *cs = (const CharString *)p_cs;
+
+ return cs->length();
+}
+
+const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs) {
+ const CharString *cs = (const CharString *)p_cs;
+
+ return cs->get_data();
+}
+
+void GDAPI godot_char_string_destroy(godot_char_string *p_cs) {
+ CharString *cs = (CharString *)p_cs;
+
+ cs->~CharString();
+}
+
void GDAPI godot_string_new(godot_string *r_dest) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
@@ -50,35 +69,11 @@ void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src
memnew_placement(dest, String(*src));
}
-void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) {
- String *dest = (String *)r_dest;
- memnew_placement(dest, String(String::utf8(p_contents, p_size)));
-}
-
-void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
+void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String(p_contents, p_size));
}
-void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) {
- String *self = (String *)p_self;
-
- if (p_size) {
- // we have a length pointer, that means we either want to know
- // the length or want to write *p_size bytes into a buffer
-
- CharString utf8_string = self->utf8();
-
- int len = utf8_string.length();
-
- if (p_dest) {
- memcpy(p_dest, utf8_string.get_data(), *p_size);
- } else {
- *p_size = len;
- }
- }
-}
-
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
String *self = (String *)p_self;
return &(self->operator[](p_idx));
@@ -89,7 +84,7 @@ wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, cons
return self->operator[](p_idx);
}
-const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) {
+const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->c_str();
}
@@ -129,6 +124,26 @@ godot_int GDAPI godot_string_length(const godot_string *p_self) {
/* Helpers */
+signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->casecmp_to(*str);
+}
+
+signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->nocasecmp_to(*str);
+}
+signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->naturalnocasecmp_to(*str);
+}
+
godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) {
const String *self = (const String *)p_self;
const String *string = (const String *)p_string;
@@ -533,7 +548,7 @@ godot_string GDAPI godot_string_capitalize(const godot_string *p_self) {
memnew_placement(&result, String(self->capitalize()));
return result;
-};
+}
godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -541,7 +556,7 @@ godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_se
memnew_placement(&result, String(self->camelcase_to_underscore(false)));
return result;
-};
+}
godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -549,45 +564,45 @@ godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_s
memnew_placement(&result, String(self->camelcase_to_underscore()));
return result;
-};
+}
double GDAPI godot_string_char_to_double(const char *p_what) {
return String::to_double(p_what);
-};
+}
godot_int GDAPI godot_string_char_to_int(const char *p_what) {
return String::to_int(p_what);
-};
+}
int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) {
return String::to_int(p_str);
-};
+}
godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) {
return String::to_int(p_what, p_len);
-};
+}
int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) {
return String::to_int(p_str, p_len);
-};
+}
int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hex_to_int64(false);
-};
+}
int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hex_to_int64();
-};
+}
int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->to_int64();
-};
+}
double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
return String::to_double(p_str, r_end);
@@ -600,7 +615,7 @@ godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_stri
memnew_placement(&result, String(self->get_slice(*splitter, p_slice)));
return result;
-};
+}
godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) {
const String *self = (const String *)p_self;
@@ -608,7 +623,7 @@ godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p
memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice)));
return result;
-};
+}
godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -624,7 +639,7 @@ godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_str
}
return result;
-};
+}
godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -640,7 +655,7 @@ godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, con
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -656,7 +671,7 @@ godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const go
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -672,7 +687,7 @@ godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_s
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -695,7 +710,7 @@ godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -718,7 +733,7 @@ godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -734,7 +749,7 @@ godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godo
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -750,7 +765,7 @@ godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_sel
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -773,7 +788,7 @@ godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const g
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -796,7 +811,7 @@ godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_
}
return result;
-};
+}
godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -811,22 +826,22 @@ godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
}
return result;
-};
+}
godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) {
const String *self = (const String *)p_self;
String *splitter = (String *)&p_splitter;
return self->get_slice_count(*splitter);
-};
+}
wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) {
return String::char_lowercase(p_char);
-};
+}
wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) {
return String::char_uppercase(p_char);
-};
+}
godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -834,7 +849,7 @@ godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
memnew_placement(&result, String(self->to_lower()));
return result;
-};
+}
godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -842,7 +857,7 @@ godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
memnew_placement(&result, String(self->to_upper()));
return result;
-};
+}
godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -850,7 +865,7 @@ godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
memnew_placement(&result, String(self->get_basename()));
return result;
-};
+}
godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -858,7 +873,7 @@ godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
memnew_placement(&result, String(self->get_extension()));
return result;
-};
+}
godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) {
const String *self = (const String *)p_self;
@@ -866,13 +881,13 @@ godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos
memnew_placement(&result, String(self->left(p_pos)));
return result;
-};
+}
wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) {
const String *self = (const String *)p_self;
return self->ord_at(p_idx);
-};
+}
godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) {
const String *self = (const String *)p_self;
@@ -881,7 +896,7 @@ godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godo
memnew_placement(&result, String(self->plus_file(*file)));
return result;
-};
+}
godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) {
const String *self = (const String *)p_self;
@@ -889,7 +904,7 @@ godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_po
memnew_placement(&result, String(self->right(p_pos)));
return result;
-};
+}
godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) {
const String *self = (const String *)p_self;
@@ -897,7 +912,7 @@ godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bo
memnew_placement(&result, String(self->strip_edges(p_left, p_right)));
return result;
-};
+}
godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -905,94 +920,96 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
memnew_placement(&result, String(self->strip_escapes()));
return result;
-};
+}
void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) {
String *self = (String *)p_self;
return self->erase(p_pos, p_chars);
-};
+}
-void GDAPI godot_string_ascii(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->ascii();
+godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
+ godot_char_string result;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ memnew_placement(&result, CharString(self->ascii()));
+
+ return result;
}
-void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->ascii(true);
+godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ godot_char_string result;
+
+ memnew_placement(&result, CharString(self->ascii(true)));
+
+ return result;
}
-void GDAPI godot_string_utf8(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->utf8();
+godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ godot_char_string result;
+
+ memnew_placement(&result, CharString(self->utf8()));
+
+ return result;
}
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) {
String *self = (String *)p_self;
return self->parse_utf8(p_utf8);
-};
+}
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) {
String *self = (String *)p_self;
return self->parse_utf8(p_utf8, p_len);
-};
+}
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) {
godot_string result;
memnew_placement(&result, String(String::utf8(p_utf8)));
return result;
-};
+}
godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) {
godot_string result;
memnew_placement(&result, String(String::utf8(p_utf8, p_len)));
return result;
-};
+}
uint32_t GDAPI godot_string_hash(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hash();
-};
+}
uint64_t GDAPI godot_string_hash64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hash64();
-};
+}
uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) {
return String::hash(p_cstr);
-};
+}
uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) {
return String::hash(p_cstr, p_len);
-};
+}
uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) {
return String::hash(p_str);
-};
+}
uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) {
return String::hash(p_str, p_len);
-};
+}
godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1009,7 +1026,7 @@ godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self)
}
return result;
-};
+}
godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1017,7 +1034,7 @@ godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
memnew_placement(&result, String(self->md5_text()));
return result;
-};
+}
godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1034,7 +1051,7 @@ godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_sel
}
return result;
-};
+}
godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1042,13 +1059,13 @@ godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
memnew_placement(&result, String(self->sha256_text()));
return result;
-};
+}
godot_bool godot_string_empty(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->empty();
-};
+}
// path functions
godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
@@ -1058,7 +1075,7 @@ godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1067,7 +1084,7 @@ godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_humanize_size(size_t p_size) {
godot_string result;
@@ -1075,25 +1092,25 @@ godot_string GDAPI godot_string_humanize_size(size_t p_size) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_abs_path();
-};
+}
godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_rel_path();
-};
+}
godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_resource_file();
-};
+}
godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) {
const String *self = (const String *)p_self;
@@ -1103,7 +1120,7 @@ godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) {
const String *self = (const String *)p_self;
@@ -1113,7 +1130,7 @@ godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const g
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1122,7 +1139,7 @@ godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1131,7 +1148,7 @@ godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1140,7 +1157,7 @@ godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1149,7 +1166,7 @@ godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1158,7 +1175,7 @@ godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1167,7 +1184,7 @@ godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1176,7 +1193,7 @@ godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) {
const String *self = (const String *)p_self;
@@ -1185,7 +1202,7 @@ godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1194,7 +1211,7 @@ godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1203,7 +1220,7 @@ godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_sel
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1212,7 +1229,7 @@ godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1221,7 +1238,7 @@ godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1230,43 +1247,43 @@ godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_float();
-};
+}
godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) {
const String *self = (const String *)p_self;
return self->is_valid_hex_number(p_with_prefix);
-};
+}
godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_html_color();
-};
+}
godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_identifier();
-};
+}
godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_integer();
-};
+}
godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_ip_address();
-};
+}
#ifdef __cplusplus
}
diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp
index 86067df433..b2a86b843c 100644
--- a/modules/gdnative/gdnative/string_name.cpp
+++ b/modules/gdnative/gdnative/string_name.cpp
@@ -1,9 +1,9 @@
/*************************************************************************/
-/* string_name.cpp */
+/* string_name.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/string_name.h"
#include "core/string_db.h"
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index 4b6589a209..715f2e3c08 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/transform.h"
#include "core/math/transform.h"
@@ -62,7 +63,7 @@ godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) {
return dest;
}
-void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v) {
+void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v) {
Transform *self = (Transform *)p_self;
const Basis *v = (const Basis *)p_v;
self->basis = *v;
@@ -75,7 +76,7 @@ godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) {
return dest;
}
-void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v) {
+void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v) {
Transform *self = (Transform *)p_self;
const Vector3 *v = (const Vector3 *)p_v;
self->origin = *v;
diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp
index 0ff5420f4f..c69607a18a 100644
--- a/modules/gdnative/gdnative/transform2d.cpp
+++ b/modules/gdnative/gdnative/transform2d.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/transform2d.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 6447641096..423f3312e1 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/variant.h"
#include "core/reference.h"
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index aadce281b3..9e40b42373 100644
--- a/modules/gdnative/gdnative/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/vector2.h"
#include "core/math/math_2d.h"
diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index 4de9889c23..a7e18fa22b 100644
--- a/modules/gdnative/gdnative/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdnative/vector3.h"
#include "core/variant.h"
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 06c6e9f410..a8919f7130 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5,6 +5,7 @@
"major": 1,
"minor": 0
},
+ "next": null,
"api": [
{
"name": "godot_color_new_rgba",
@@ -2090,6 +2091,13 @@
]
},
{
+ "name": "godot_pool_byte_array_read_access_copy",
+ "return_type": "godot_pool_byte_array_read_access *",
+ "arguments": [
+ ["const godot_pool_byte_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_byte_array_read_access_ptr",
"return_type": "const uint8_t *",
"arguments": [
@@ -2112,6 +2120,13 @@
]
},
{
+ "name": "godot_pool_int_array_read_access_copy",
+ "return_type": "godot_pool_int_array_read_access *",
+ "arguments": [
+ ["const godot_pool_int_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_int_array_read_access_ptr",
"return_type": "const godot_int *",
"arguments": [
@@ -2134,6 +2149,13 @@
]
},
{
+ "name": "godot_pool_real_array_read_access_copy",
+ "return_type": "godot_pool_real_array_read_access *",
+ "arguments": [
+ ["const godot_pool_real_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_real_array_read_access_ptr",
"return_type": "const godot_real *",
"arguments": [
@@ -2156,6 +2178,13 @@
]
},
{
+ "name": "godot_pool_string_array_read_access_copy",
+ "return_type": "godot_pool_string_array_read_access *",
+ "arguments": [
+ ["const godot_pool_string_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_string_array_read_access_ptr",
"return_type": "const godot_string *",
"arguments": [
@@ -2178,6 +2207,13 @@
]
},
{
+ "name": "godot_pool_vector2_array_read_access_copy",
+ "return_type": "godot_pool_vector2_array_read_access *",
+ "arguments": [
+ ["const godot_pool_vector2_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_vector2_array_read_access_ptr",
"return_type": "const godot_vector2 *",
"arguments": [
@@ -2200,6 +2236,13 @@
]
},
{
+ "name": "godot_pool_vector3_array_read_access_copy",
+ "return_type": "godot_pool_vector3_array_read_access *",
+ "arguments": [
+ ["const godot_pool_vector3_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_vector3_array_read_access_ptr",
"return_type": "const godot_vector3 *",
"arguments": [
@@ -2222,6 +2265,13 @@
]
},
{
+ "name": "godot_pool_color_array_read_access_copy",
+ "return_type": "godot_pool_color_array_read_access *",
+ "arguments": [
+ ["const godot_pool_color_array_read_access *", "p_read"]
+ ]
+ },
+ {
"name": "godot_pool_color_array_read_access_ptr",
"return_type": "const godot_color *",
"arguments": [
@@ -2244,6 +2294,13 @@
]
},
{
+ "name": "godot_pool_byte_array_write_access_copy",
+ "return_type": "godot_pool_byte_array_write_access *",
+ "arguments": [
+ ["const godot_pool_byte_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_byte_array_write_access_ptr",
"return_type": "uint8_t *",
"arguments": [
@@ -2266,6 +2323,13 @@
]
},
{
+ "name": "godot_pool_int_array_write_access_copy",
+ "return_type": "godot_pool_int_array_write_access *",
+ "arguments": [
+ ["const godot_pool_int_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_int_array_write_access_ptr",
"return_type": "godot_int *",
"arguments": [
@@ -2288,6 +2352,13 @@
]
},
{
+ "name": "godot_pool_real_array_write_access_copy",
+ "return_type": "godot_pool_real_array_write_access *",
+ "arguments": [
+ ["const godot_pool_real_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_real_array_write_access_ptr",
"return_type": "godot_real *",
"arguments": [
@@ -2310,6 +2381,13 @@
]
},
{
+ "name": "godot_pool_string_array_write_access_copy",
+ "return_type": "godot_pool_string_array_write_access *",
+ "arguments": [
+ ["const godot_pool_string_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_string_array_write_access_ptr",
"return_type": "godot_string *",
"arguments": [
@@ -2332,6 +2410,13 @@
]
},
{
+ "name": "godot_pool_vector2_array_write_access_copy",
+ "return_type": "godot_pool_vector2_array_write_access *",
+ "arguments": [
+ ["const godot_pool_vector2_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_vector2_array_write_access_ptr",
"return_type": "godot_vector2 *",
"arguments": [
@@ -2354,6 +2439,13 @@
]
},
{
+ "name": "godot_pool_vector3_array_write_access_copy",
+ "return_type": "godot_pool_vector3_array_write_access *",
+ "arguments": [
+ ["const godot_pool_vector3_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_vector3_array_write_access_ptr",
"return_type": "godot_vector3 *",
"arguments": [
@@ -2376,6 +2468,13 @@
]
},
{
+ "name": "godot_pool_color_array_write_access_copy",
+ "return_type": "godot_pool_color_array_write_access *",
+ "arguments": [
+ ["const godot_pool_color_array_write_access *", "p_write"]
+ ]
+ },
+ {
"name": "godot_pool_color_array_write_access_ptr",
"return_type": "godot_color *",
"arguments": [
@@ -3516,7 +3615,7 @@
"return_type": "void",
"arguments": [
["godot_transform *", "p_self"],
- ["godot_basis *", "p_v"]
+ ["const godot_basis *", "p_v"]
]
},
{
@@ -3531,7 +3630,7 @@
"return_type": "void",
"arguments": [
["godot_transform *", "p_self"],
- ["godot_vector3 *", "p_v"]
+ ["const godot_vector3 *", "p_v"]
]
},
{
@@ -3865,7 +3964,7 @@
"name": "godot_variant_new_bool",
"return_type": "void",
"arguments": [
- ["godot_variant *", "p_v"],
+ ["godot_variant *", "r_dest"],
["const godot_bool", "p_b"]
]
},
@@ -4324,45 +4423,48 @@
]
},
{
- "name": "godot_string_new",
- "return_type": "void",
+ "name": "godot_char_string_length",
+ "return_type": "godot_int",
"arguments": [
- ["godot_string *", "r_dest"]
+ ["const godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_string_new_copy",
+ "name": "godot_char_string_get_data",
+ "return_type": "const char *",
+ "arguments": [
+ ["const godot_char_string *", "p_cs"]
+ ]
+ },
+ {
+ "name": "godot_char_string_destroy",
"return_type": "void",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const godot_string *", "p_src"]
+ ["godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_string_new_data",
+ "name": "godot_string_new",
"return_type": "void",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const char *", "p_contents"],
- ["const int", "p_size"]
+ ["godot_string *", "r_dest"]
]
},
{
- "name": "godot_string_new_unicode_data",
+ "name": "godot_string_new_copy",
"return_type": "void",
"arguments": [
["godot_string *", "r_dest"],
- ["const wchar_t *", "p_contents"],
- ["const int", "p_size"]
+ ["const godot_string *", "p_src"]
]
},
{
- "name": "godot_string_get_data",
+ "name": "godot_string_new_with_wide_string",
"return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["char *", "p_dest"],
- ["int *", "p_size"]
+ ["godot_string *", "r_dest"],
+ ["const wchar_t *", "p_contents"],
+ ["const int", "p_size"]
]
},
{
@@ -4382,7 +4484,7 @@
]
},
{
- "name": "godot_string_unicode_str",
+ "name": "godot_string_wide_str",
"return_type": "const wchar_t *",
"arguments": [
["const godot_string *", "p_self"]
@@ -4420,6 +4522,30 @@
]
},
{
+ "name": "godot_string_casecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
+ "name": "godot_string_nocasecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
+ "name": "godot_string_naturalnocasecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
"name": "godot_string_begins_with",
"return_type": "godot_bool",
"arguments": [
@@ -5125,26 +5251,23 @@
},
{
"name": "godot_string_ascii",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_ascii_extended",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_utf8",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
@@ -5640,6 +5763,104 @@
"major": 1,
"minor": 0
},
+ "next": {
+ "type": "NATIVESCRIPT",
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "next": null,
+ "api": [
+ {
+ "name": "godot_nativescript_set_method_argument_information",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_function_name"],
+ ["int", "p_num_args"],
+ ["const godot_method_arg *", "p_args"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_class_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_method_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_function_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_property_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_path"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_signal_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_signal_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_type_tag",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const void *", "p_type_tag"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_get_type_tag",
+ "return_type": "const void *",
+ "arguments": [
+ ["const godot_object *", "p_object"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_register_instance_binding_data_functions",
+ "return_type": "int",
+ "arguments": [
+ ["godot_instance_binding_functions", "p_binding_functions"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_unregister_instance_binding_data_functions",
+ "return_type": "void",
+ "arguments": [
+ ["int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_get_instance_binding_data",
+ "return_type": "void *",
+ "arguments": [
+ ["int", "p_idx"],
+ ["godot_object *", "p_object"]
+ ]
+ }
+ ]
+ },
"api": [
{
"name": "godot_nativescript_register_class",
@@ -5710,6 +5931,7 @@
"major": 1,
"minor": 0
},
+ "next": null,
"api": [
{
"name": "godot_pluginscript_register_language",
@@ -5726,6 +5948,7 @@
"major": 1,
"minor": 0
},
+ "next": null,
"api": [
{
"name": "godot_arvr_register_interface",
diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h
index 2b635d0937..04d2911d8b 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.h
+++ b/modules/gdnative/gdnative_library_editor_plugin.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
#define GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
@@ -78,7 +79,7 @@ protected:
void _on_library_selected(const String &file);
void _on_dependencies_selected(const PoolStringArray &files);
void _on_filter_selected(int id);
- void _on_item_collapsed(Object *item);
+ void _on_item_collapsed(Object *p_item);
void _on_item_activated();
void _on_create_new_entry();
void _set_target_value(const String &section, const String &target, Variant file);
diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp
index 4c0049f90d..0aafb95e2e 100644
--- a/modules/gdnative/gdnative_library_singleton_editor.cpp
+++ b/modules/gdnative/gdnative_library_singleton_editor.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gdnative_library_singleton_editor.cpp */
+/* gdnative_library_singleton_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifdef TOOLS_ENABLED
#include "gdnative_library_singleton_editor.h"
#include "gdnative.h"
diff --git a/modules/gdnative/gdnative_library_singleton_editor.h b/modules/gdnative/gdnative_library_singleton_editor.h
index d00ddc9211..d3b5ba3846 100644
--- a/modules/gdnative/gdnative_library_singleton_editor.h
+++ b/modules/gdnative/gdnative_library_singleton_editor.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gdnative_library_singleton_editor.h */
+/* gdnative_library_singleton_editor.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_NATIVE_LIBRARY_EDITOR_H
#define GD_NATIVE_LIBRARY_EDITOR_H
diff --git a/modules/gdnative/include/arvr/godot_arvr.h b/modules/gdnative/include/arvr/godot_arvr.h
index fc4626c967..b9aedc0bef 100644
--- a/modules/gdnative/include/arvr/godot_arvr.h
+++ b/modules/gdnative/include/arvr/godot_arvr.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_NATIVEARVR_H
#define GODOT_NATIVEARVR_H
diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h
index a40061ce2e..dca5d4bb14 100644
--- a/modules/gdnative/include/gdnative/aabb.h
+++ b/modules/gdnative/include/gdnative/aabb.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* aabb.h */
+/* aabb.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_AABB_H
#define GODOT_AABB_H
diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h
index ce9ac590d9..53e950b4a2 100644
--- a/modules/gdnative/include/gdnative/basis.h
+++ b/modules/gdnative/include/gdnative/basis.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_BASIS_H
#define GODOT_BASIS_H
diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h
index 14086c1155..1f0ac8354d 100644
--- a/modules/gdnative/include/gdnative/color.h
+++ b/modules/gdnative/include/gdnative/color.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_COLOR_H
#define GODOT_COLOR_H
diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h
index 07ffb3346b..a86d60dc72 100644
--- a/modules/gdnative/include/gdnative/dictionary.h
+++ b/modules/gdnative/include/gdnative/dictionary.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_DICTIONARY_H
#define GODOT_DICTIONARY_H
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index d066df8046..4cf6e99b06 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_GDNATIVE_H
#define GODOT_GDNATIVE_H
@@ -69,7 +70,7 @@ typedef enum {
GODOT_OK,
GODOT_FAILED, ///< Generic fail error
GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
- GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet
+ GODOT_ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet
GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource
GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5)
GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory
diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h
index e58c332cdf..2b55e01d13 100644
--- a/modules/gdnative/include/gdnative/node_path.h
+++ b/modules/gdnative/include/gdnative/node_path.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_NODE_PATH_H
#define GODOT_NODE_PATH_H
diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h
index d40a76374f..6c8a6ae1a4 100644
--- a/modules/gdnative/include/gdnative/plane.h
+++ b/modules/gdnative/include/gdnative/plane.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_PLANE_H
#define GODOT_PLANE_H
diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h
index f91bd4694b..1210039e34 100644
--- a/modules/gdnative/include/gdnative/pool_arrays.h
+++ b/modules/gdnative/include/gdnative/pool_arrays.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_POOL_ARRAYS_H
#define GODOT_POOL_ARRAYS_H
@@ -382,30 +383,37 @@ void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self);
// read accessor functions
//
+godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other);
const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read);
void GDAPI godot_pool_byte_array_read_access_operator_assign(godot_pool_byte_array_read_access *p_read, godot_pool_byte_array_read_access *p_other);
void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_access *p_read);
+godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other);
const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read);
void GDAPI godot_pool_int_array_read_access_operator_assign(godot_pool_int_array_read_access *p_read, godot_pool_int_array_read_access *p_other);
void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_access *p_read);
+godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other);
const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read);
void GDAPI godot_pool_real_array_read_access_operator_assign(godot_pool_real_array_read_access *p_read, godot_pool_real_array_read_access *p_other);
void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_access *p_read);
+godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other);
const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read);
void GDAPI godot_pool_string_array_read_access_operator_assign(godot_pool_string_array_read_access *p_read, godot_pool_string_array_read_access *p_other);
void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_read_access *p_read);
+godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other);
const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read);
void GDAPI godot_pool_vector2_array_read_access_operator_assign(godot_pool_vector2_array_read_access *p_read, godot_pool_vector2_array_read_access *p_other);
void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array_read_access *p_read);
+godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other);
const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read);
void GDAPI godot_pool_vector3_array_read_access_operator_assign(godot_pool_vector3_array_read_access *p_read, godot_pool_vector3_array_read_access *p_other);
void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array_read_access *p_read);
+godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other);
const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read);
void GDAPI godot_pool_color_array_read_access_operator_assign(godot_pool_color_array_read_access *p_read, godot_pool_color_array_read_access *p_other);
void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_read_access *p_read);
@@ -414,30 +422,37 @@ void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_rea
// write accessor functions
//
+godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other);
uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write);
void GDAPI godot_pool_byte_array_write_access_operator_assign(godot_pool_byte_array_write_access *p_write, godot_pool_byte_array_write_access *p_other);
void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_write_access *p_write);
+godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other);
godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write);
void GDAPI godot_pool_int_array_write_access_operator_assign(godot_pool_int_array_write_access *p_write, godot_pool_int_array_write_access *p_other);
void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_access *p_write);
+godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other);
godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write);
void GDAPI godot_pool_real_array_write_access_operator_assign(godot_pool_real_array_write_access *p_write, godot_pool_real_array_write_access *p_other);
void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_write_access *p_write);
+godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other);
godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write);
void GDAPI godot_pool_string_array_write_access_operator_assign(godot_pool_string_array_write_access *p_write, godot_pool_string_array_write_access *p_other);
void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_write_access *p_write);
+godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other);
godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write);
void GDAPI godot_pool_vector2_array_write_access_operator_assign(godot_pool_vector2_array_write_access *p_write, godot_pool_vector2_array_write_access *p_other);
void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_array_write_access *p_write);
+godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other);
godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write);
void GDAPI godot_pool_vector3_array_write_access_operator_assign(godot_pool_vector3_array_write_access *p_write, godot_pool_vector3_array_write_access *p_other);
void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_array_write_access *p_write);
+godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other);
godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write);
void GDAPI godot_pool_color_array_write_access_operator_assign(godot_pool_color_array_write_access *p_write, godot_pool_color_array_write_access *p_other);
void GDAPI godot_pool_color_array_write_access_destroy(godot_pool_color_array_write_access *p_write);
diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h
index 3696a303df..4e86960aaf 100644
--- a/modules/gdnative/include/gdnative/quat.h
+++ b/modules/gdnative/include/gdnative/quat.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_QUAT_H
#define GODOT_QUAT_H
diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h
index 7b223b450e..4adcb73e3d 100644
--- a/modules/gdnative/include/gdnative/rect2.h
+++ b/modules/gdnative/include/gdnative/rect2.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_RECT2_H
#define GODOT_RECT2_H
diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h
index effa89bbbd..0942334ee5 100644
--- a/modules/gdnative/include/gdnative/rid.h
+++ b/modules/gdnative/include/gdnative/rid.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_RID_H
#define GODOT_RID_H
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index 90397b0e40..73245160c1 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_STRING_H
#define GODOT_STRING_H
@@ -37,13 +38,24 @@ extern "C" {
#include <stdint.h>
#include <wchar.h>
+typedef wchar_t godot_char_type;
+
#define GODOT_STRING_SIZE sizeof(void *)
+#define GODOT_CHAR_STRING_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_STRING_SIZE];
} godot_string;
+
+#endif
+
+#ifndef GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_CHAR_STRING_SIZE];
+} godot_char_string;
#endif
// reduce extern "C" nesting for VS2013
@@ -59,16 +71,17 @@ typedef struct {
extern "C" {
#endif
+godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs);
+const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs);
+void GDAPI godot_char_string_destroy(godot_char_string *p_cs);
+
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
-void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size);
-void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
-
-void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size);
+void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx);
-const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self);
+const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self);
godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b);
godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b);
@@ -80,6 +93,10 @@ godot_int GDAPI godot_string_length(const godot_string *p_self);
/* Helpers */
+signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str);
+signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str);
+signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str);
+
godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string);
godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array);
godot_array GDAPI godot_string_bigrams(const godot_string *p_self);
@@ -176,9 +193,9 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self);
void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars);
-void GDAPI godot_string_ascii(godot_string *p_self, char *result);
-void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result);
-void GDAPI godot_string_utf8(godot_string *p_self, char *result);
+godot_char_string GDAPI godot_string_ascii(const godot_string *p_self);
+godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self);
+godot_char_string GDAPI godot_string_utf8(const godot_string *p_self);
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8);
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len);
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8);
diff --git a/modules/gdnative/include/gdnative/string_name.h b/modules/gdnative/include/gdnative/string_name.h
index 287f98d523..5068a3d8f9 100644
--- a/modules/gdnative/include/gdnative/string_name.h
+++ b/modules/gdnative/include/gdnative/string_name.h
@@ -1,9 +1,9 @@
/*************************************************************************/
-/* string_name.h */
+/* string_name.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_STRING_NAME_H
#define GODOT_STRING_NAME_H
diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h
index d5e2e9364f..a646da146a 100644
--- a/modules/gdnative/include/gdnative/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_TRANSFORM_H
#define GODOT_TRANSFORM_H
@@ -63,10 +64,10 @@ void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const g
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self);
-void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v);
+void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v);
godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self);
-void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v);
+void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v);
godot_string GDAPI godot_transform_as_string(const godot_transform *p_self);
diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h
index c92225a110..aed941f139 100644
--- a/modules/gdnative/include/gdnative/transform2d.h
+++ b/modules/gdnative/include/gdnative/transform2d.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_TRANSFORM2D_H
#define GODOT_TRANSFORM2D_H
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index af26ab99db..6779dc4092 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_VARIANT_H
#define GODOT_VARIANT_H
@@ -134,7 +135,7 @@ void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_
void GDAPI godot_variant_new_nil(godot_variant *r_dest);
-void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b);
+void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b);
void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i);
void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i);
void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r);
diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index c7e7926b0a..af97524dac 100644
--- a/modules/gdnative/include/gdnative/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_VECTOR2_H
#define GODOT_VECTOR2_H
diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h
index c117bad380..e0299a8a30 100644
--- a/modules/gdnative/include/gdnative/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_VECTOR3_H
#define GODOT_VECTOR3_H
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index e6fd9d3f84..747328bc41 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_NATIVESCRIPT_H
#define GODOT_NATIVESCRIPT_H
@@ -49,7 +50,7 @@ typedef enum {
GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
- GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
+ GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease)
GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
GODOT_PROPERTY_HINT_SPRITE_FRAME,
GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
@@ -184,6 +185,52 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance);
+/*
+ *
+ *
+ * NativeScript 1.1
+ *
+ *
+ */
+
+// method registering with argument names
+
+typedef struct {
+ godot_string name;
+
+ godot_variant_type type;
+ godot_property_hint hint;
+ godot_string hint_string;
+} godot_method_arg;
+
+void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args);
+
+// documentation
+
+void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation);
+void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation);
+void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation);
+void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation);
+
+// type tag API
+
+void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag);
+const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object);
+
+// instance binding API
+
+typedef struct {
+ void *(*alloc_instance_binding_data)(void *, godot_object *);
+ void (*free_instance_binding_data)(void *, void *);
+ void *data;
+ void (*free_func)(void *);
+} godot_instance_binding_functions;
+
+int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions);
+void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx);
+
+void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h
index fca29b67ca..671be3bbb9 100644
--- a/modules/gdnative/include/pluginscript/godot_pluginscript.h
+++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_nativescript.h */
+/* godot_pluginscript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOT_PLUGINSCRIPT_H
#define GODOT_PLUGINSCRIPT_H
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index 687aa66219..4012e821bb 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "api_generator.h"
#ifdef TOOLS_ENABLED
diff --git a/modules/gdnative/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h
index 23fd0377ad..de234b2f0d 100644
--- a/modules/gdnative/nativescript/api_generator.h
+++ b/modules/gdnative/nativescript/api_generator.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef API_GENERATOR_H
#define API_GENERATOR_H
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index c9434c404e..aea595d0f0 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "nativescript/godot_nativescript.h"
#include "class_db.h"
@@ -105,7 +106,7 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
if (!E) {
- ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_EXPLAIN("Attempted to register method on non-existent class!");
ERR_FAIL();
}
@@ -124,7 +125,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
if (!E) {
- ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_EXPLAIN("Attempted to register method on non-existent class!");
ERR_FAIL();
}
@@ -149,7 +150,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
if (!E) {
- ERR_EXPLAIN("Attempt to register method on non-existant class!");
+ ERR_EXPLAIN("Attempted to register method on non-existent class!");
ERR_FAIL();
}
@@ -200,6 +201,164 @@ void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
return NULL;
}
+/*
+ *
+ *
+ * NativeScript 1.1
+ *
+ *
+ */
+
+void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to add argument information for a method on a non-existent class!");
+ ERR_FAIL();
+ }
+
+ Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
+ if (!method) {
+ ERR_EXPLAIN("Attempted to add argument information to non-existent method!");
+ ERR_FAIL();
+ }
+
+ MethodInfo *method_information = &method->get().info;
+
+ List<PropertyInfo> args;
+
+ for (int i = 0; i < p_num_args; i++) {
+ godot_method_arg arg = p_args[i];
+ String name = *(String *)&arg.name;
+ String hint_string = *(String *)&arg.hint_string;
+
+ Variant::Type type = (Variant::Type)arg.type;
+ PropertyHint hint = (PropertyHint)arg.hint;
+
+ args.push_back(PropertyInfo(type, p_name, hint, hint_string));
+ }
+
+ method_information->arguments = args;
+}
+
+void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to add documentation to a non-existent class!");
+ ERR_FAIL();
+ }
+
+ E->get().documentation = *(String *)&p_documentation;
+}
+
+void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to add documentation to a method on a non-existent class!");
+ ERR_FAIL();
+ }
+
+ Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
+ if (!method) {
+ ERR_EXPLAIN("Attempted to add documentatino to non-existent method!");
+ ERR_FAIL();
+ }
+
+ method->get().documentation = *(String *)&p_documentation;
+}
+
+void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to add documentation to a property on a non-existent class!");
+ ERR_FAIL();
+ }
+
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path);
+ if (!property) {
+ ERR_EXPLAIN("Attempted to add documentation to non-existent property!");
+ ERR_FAIL();
+ }
+
+ property.get().documentation = *(String *)&p_documentation;
+}
+
+void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to add documentation to a signal on a non-existent class!");
+ ERR_FAIL();
+ }
+
+ Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name);
+ if (!signal) {
+ ERR_EXPLAIN("Attempted to add documentation to non-existent signal!");
+ ERR_FAIL();
+ }
+
+ signal->get().documentation = *(String *)&p_documentation;
+}
+
+void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag) {
+ String *s = (String *)p_gdnative_handle;
+
+ Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
+
+ if (!E) {
+ ERR_EXPLAIN("Attempted to set type tag on a non-existent class!");
+ ERR_FAIL();
+ }
+
+ E->get().type_tag = p_type_tag;
+}
+
+const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) {
+
+ const Object *o = (Object *)p_object;
+
+ if (!o->get_script_instance()) {
+ ERR_EXPLAIN("Attempted to get type tag on an object without a script!");
+ ERR_FAIL_V(NULL);
+ } else {
+ NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr());
+ if (!script) {
+ ERR_EXPLAIN("Attempted to get type tag on an object without a nativescript attached");
+ ERR_FAIL_V(NULL);
+ }
+
+ if (script->get_script_desc())
+ return script->get_script_desc()->type_tag;
+ }
+
+ return NULL;
+}
+
#ifdef __cplusplus
}
#endif
+
+int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) {
+ return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions);
+}
+
+void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx) {
+ NativeScriptLanguage::get_singleton()->unregister_binding_functions(p_idx);
+}
+
+void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object) {
+ return NativeScriptLanguage::get_singleton()->get_instance_binding_data(p_idx, (Object *)p_object);
+}
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 823d794f72..f2e9bef467 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "nativescript.h"
#include "gdnative/gdnative.h"
@@ -67,6 +68,11 @@ void NativeScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_library", "library"), &NativeScript::set_library);
ClassDB::bind_method(D_METHOD("get_library"), &NativeScript::get_library);
+ ClassDB::bind_method(D_METHOD("get_class_documentation"), &NativeScript::get_class_documentation);
+ ClassDB::bind_method(D_METHOD("get_method_documentation", "method"), &NativeScript::get_method_documentation);
+ ClassDB::bind_method(D_METHOD("get_signal_documentation", "signal_name"), &NativeScript::get_signal_documentation);
+ ClassDB::bind_method(D_METHOD("get_property_documentation", "path"), &NativeScript::get_property_documentation);
+
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name");
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
@@ -372,6 +378,86 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
}
+String NativeScript::get_class_documentation() const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ ERR_EXPLAIN("Attempt to get class documentation on invalid NativeScript");
+ ERR_FAIL_V("");
+ }
+
+ return script_data->documentation;
+}
+
+String NativeScript::get_method_documentation(const StringName &p_method) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ ERR_EXPLAIN("Attempt to get method documentation on invalid NativeScript");
+ ERR_FAIL_V("");
+ }
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method);
+
+ if (method) {
+ return method->get().documentation;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ ERR_EXPLAIN("Attempt to get method documentation for non-existent method");
+ ERR_FAIL_V("");
+}
+
+String NativeScript::get_signal_documentation(const StringName &p_signal_name) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ ERR_EXPLAIN("Attempt to get signal documentation on invalid NativeScript");
+ ERR_FAIL_V("");
+ }
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name);
+
+ if (signal) {
+ return signal->get().documentation;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ ERR_EXPLAIN("Attempt to get signal documentation for non-existent signal");
+ ERR_FAIL_V("");
+}
+
+String NativeScript::get_property_documentation(const StringName &p_path) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ if (!script_data) {
+ ERR_EXPLAIN("Attempt to get property documentation on invalid NativeScript");
+ ERR_FAIL_V("");
+ }
+
+ while (script_data) {
+
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = script_data->properties.find(p_path);
+
+ if (property) {
+ return property.get().documentation;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ ERR_EXPLAIN("Attempt to get property documentation for non-existent signal");
+ ERR_FAIL_V("");
+}
+
Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
if (lib_path.empty() || class_name.empty() || library.is_null()) {
@@ -397,6 +483,11 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call
owner = memnew(Reference);
}
+ if (!owner) {
+ r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ return Variant();
+ }
+
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
@@ -604,7 +695,7 @@ Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name,
}
void NativeScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
- script->get_method_list(p_list);
+ script->get_script_method_list(p_list);
}
bool NativeScriptInstance::has_method(const StringName &p_method) const {
@@ -789,9 +880,55 @@ NativeScriptInstance::~NativeScriptInstance() {
NativeScriptLanguage *NativeScriptLanguage::singleton;
-void NativeScriptLanguage::_unload_stuff() {
+void NativeScriptLanguage::_unload_stuff(bool p_reload) {
for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) {
- for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) {
+
+ String lib_path = L->key();
+ Map<StringName, NativeScriptDesc> classes = L->get();
+
+ if (p_reload) {
+
+ Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path);
+ Ref<GDNative> gdn;
+
+ if (E) {
+ gdn = E->get();
+ }
+
+ bool should_reload = false;
+
+ if (gdn.is_valid()) {
+ Ref<GDNativeLibrary> lib = gdn->get_library();
+ if (lib.is_valid()) {
+ should_reload = lib->is_reloadable();
+ }
+ }
+
+ if (!should_reload) {
+ continue;
+ }
+ }
+
+ Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path);
+ Ref<GDNative> gdn;
+
+ if (E) {
+ gdn = E->get();
+ }
+
+ if (gdn.is_valid() && gdn->get_library().is_valid()) {
+ Ref<GDNativeLibrary> lib = gdn->get_library();
+ void *terminate_fn;
+ Error err = gdn->get_symbol(lib->get_symbol_prefix() + _terminate_call_name, terminate_fn, true);
+
+ if (err == OK) {
+ void (*terminate)(void *) = (void (*)(void *))terminate_fn;
+
+ terminate((void *)&lib_path);
+ }
+ }
+
+ for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
// free property stuff first
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
@@ -829,12 +966,14 @@ NativeScriptLanguage::~NativeScriptLanguage() {
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
- L->get()->terminate();
- NSL->library_classes.clear();
- NSL->library_gdnatives.clear();
- NSL->library_script_users.clear();
+ if (L->get().is_valid())
+ L->get()->terminate();
}
+ NSL->library_classes.clear();
+ NSL->library_gdnatives.clear();
+ NSL->library_script_users.clear();
+
#ifndef NO_THREADS
memdelete(mutex);
#endif
@@ -896,7 +1035,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
return Ref<NativeScript>(s);
}
bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
- return false;
+ return true;
}
Script *NativeScriptLanguage::create_script() const {
@@ -976,6 +1115,116 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
return 0;
}
+int NativeScriptLanguage::register_binding_functions(godot_instance_binding_functions p_binding_functions) {
+
+ // find index
+
+ int idx = -1;
+
+ for (int i = 0; i < binding_functions.size(); i++) {
+ if (!binding_functions[i].first) {
+ // free, we'll take it
+ idx = i;
+ break;
+ }
+ }
+
+ if (idx == -1) {
+ idx = binding_functions.size();
+ binding_functions.resize(idx + 1);
+ }
+
+ // set the functions
+ binding_functions[idx].first = true;
+ binding_functions[idx].second = p_binding_functions;
+
+ return idx;
+}
+
+void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
+ ERR_FAIL_INDEX(p_idx, binding_functions.size());
+
+ for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
+ Vector<void *> &binding_data = *E->get();
+
+ if (binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
+ binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]);
+ }
+
+ binding_functions[p_idx].first = false;
+
+ if (binding_functions[p_idx].second.free_func)
+ binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data);
+}
+
+void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
+ ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL);
+
+ if (!binding_functions[p_idx].first) {
+ ERR_EXPLAIN("Tried to get binding data for a nativescript binding that does not exist");
+ ERR_FAIL_V(NULL);
+ }
+
+ Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
+
+ if (!binding_data)
+ return NULL; // should never happen.
+
+ if (binding_data->size() <= p_idx) {
+ // okay, add new elements here.
+ int old_size = binding_data->size();
+
+ binding_data->resize(p_idx + 1);
+
+ for (int i = old_size; i <= p_idx; i++) {
+ (*binding_data)[i] = NULL;
+ }
+ }
+
+ if (!(*binding_data)[p_idx]) {
+ // no binding data yet, soooooo alloc new one \o/
+ (*binding_data)[p_idx] = binding_functions[p_idx].second.alloc_instance_binding_data(binding_functions[p_idx].second.data, (godot_object *)p_object);
+ }
+
+ return (*binding_data)[p_idx];
+}
+
+void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
+
+ Vector<void *> *binding_data = new Vector<void *>;
+
+ binding_data->resize(binding_functions.size());
+
+ for (int i = 0; i < binding_functions.size(); i++) {
+ (*binding_data)[i] = NULL;
+ }
+
+ binding_instances.insert(binding_data);
+
+ return (void *)binding_data;
+}
+
+void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
+
+ if (!p_data)
+ return;
+
+ Vector<void *> &binding_data = *(Vector<void *> *)p_data;
+
+ for (int i = 0; i < binding_data.size(); i++) {
+ if (!binding_data[i])
+ continue;
+
+ if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) {
+ binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]);
+ }
+ }
+
+ binding_instances.erase(&binding_data);
+
+ delete &binding_data;
+}
+
#ifndef NO_THREADS
void NativeScriptLanguage::defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script) {
MutexLock lock(mutex);
@@ -1050,6 +1299,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
void NativeScriptLanguage::call_libraries_cb(const StringName &name) {
// library_gdnatives is modified only from the main thread, so it's safe not to use mutex here
for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
+
+ if (L->get().is_null()) {
+ continue;
+ }
+
if (L->get()->is_initialized()) {
void *proc_ptr;
@@ -1107,10 +1361,20 @@ void NativeReloadNode::_notification(int p_what) {
#ifndef NO_THREADS
MutexLock lock(NSL->mutex);
#endif
- NSL->_unload_stuff();
+ NSL->_unload_stuff(true);
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
- L->get()->terminate();
+ Ref<GDNative> gdn = L->get();
+
+ if (gdn.is_null()) {
+ continue;
+ }
+
+ if (!gdn->get_library()->is_reloadable()) {
+ continue;
+ }
+
+ gdn->terminate();
NSL->library_classes.erase(L->key());
}
@@ -1128,21 +1392,27 @@ void NativeReloadNode::_notification(int p_what) {
Set<StringName> libs_to_remove;
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
- if (!L->get()->initialize()) {
+ Ref<GDNative> gdn = L->get();
+
+ if (gdn.is_null()) {
+ continue;
+ }
+
+ if (!gdn->get_library()->is_reloadable()) {
+ continue;
+ }
+
+ if (!gdn->initialize()) {
libs_to_remove.insert(L->key());
continue;
}
NSL->library_classes.insert(L->key(), Map<StringName, NativeScriptDesc>());
- void *args[1] = {
- (void *)&L->key()
- };
-
// here the library registers all the classes and stuff.
void *proc_ptr;
- Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr);
+ Error err = gdn->get_symbol(gdn->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr);
if (err != OK) {
ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data());
} else {
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 5eefdf1567..17b6ddc747 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef NATIVE_SCRIPT_H
#define NATIVE_SCRIPT_H
@@ -52,6 +53,7 @@ struct NativeScriptDesc {
godot_instance_method method;
MethodInfo info;
int rpc_mode;
+ String documentation;
};
struct Property {
godot_property_set_func setter;
@@ -59,12 +61,16 @@ struct NativeScriptDesc {
PropertyInfo info;
Variant default_value;
int rset_mode;
+ String documentation;
};
struct Signal {
MethodInfo signal;
+ String documentation;
};
+ String documentation;
+
Map<StringName, Method> methods;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
@@ -74,6 +80,8 @@ struct NativeScriptDesc {
godot_instance_create_func create_func;
godot_instance_destroy_func destroy_func;
+ const void *type_tag;
+
bool is_tool;
inline NativeScriptDesc() :
@@ -81,7 +89,9 @@ struct NativeScriptDesc {
properties(),
signals_(),
base(),
- base_native_type() {
+ base_native_type(),
+ documentation(),
+ type_tag(NULL) {
zeromem(&create_func, sizeof(godot_instance_create_func));
zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
}
@@ -153,6 +163,11 @@ public:
virtual void get_script_method_list(List<MethodInfo> *p_list) const;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ String get_class_documentation() const;
+ String get_method_documentation(const StringName &p_method) const;
+ String get_signal_documentation(const StringName &p_signal_name) const;
+ String get_property_documentation(const StringName &p_path) const;
+
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
NativeScript();
@@ -203,8 +218,9 @@ class NativeScriptLanguage : public ScriptLanguage {
private:
static NativeScriptLanguage *singleton;
+ int lang_idx;
- void _unload_stuff();
+ void _unload_stuff(bool p_reload = false);
#ifndef NO_THREADS
Mutex *mutex;
@@ -221,6 +237,9 @@ private:
void call_libraries_cb(const StringName &name);
+ Vector<Pair<bool, godot_instance_binding_functions> > binding_functions;
+ Set<Vector<void *> *> binding_instances;
+
public:
// These two maps must only be touched on the main thread
Map<String, Map<StringName, NativeScriptDesc> > library_classes;
@@ -231,6 +250,8 @@ public:
const StringName _init_call_type = "nativescript_init";
const StringName _init_call_name = "nativescript_init";
+ const StringName _terminate_call_name = "nativescript_terminate";
+
const StringName _noarg_call_type = "nativescript_no_arg";
const StringName _frame_call_name = "nativescript_frame";
@@ -249,6 +270,8 @@ public:
void _hacky_api_anchor();
+ _FORCE_INLINE_ void set_language_index(int p_idx) { lang_idx = p_idx; }
+
#ifndef NO_THREADS
virtual void thread_enter();
virtual void thread_exit();
@@ -292,6 +315,14 @@ public:
virtual void profiling_stop();
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
+
+ int register_binding_functions(godot_instance_binding_functions p_binding_functions);
+ void unregister_binding_functions(int p_idx);
+
+ void *get_instance_binding_data(int p_idx, Object *p_object);
+
+ virtual void *alloc_instance_binding_data(Object *p_object);
+ virtual void free_instance_binding_data(void *p_data);
};
inline NativeScriptDesc *NativeScript::get_script_desc() const {
diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index d7d2c11d54..9a0e764391 100644
--- a/modules/gdnative/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "io/resource_loader.h"
@@ -46,6 +47,7 @@ void register_nativescript_types() {
ClassDB::register_class<NativeScript>();
+ native_script_language->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(native_script_language);
resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
diff --git a/modules/gdnative/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h
index 66cd4c33bb..7389010f8e 100644
--- a/modules/gdnative/nativescript/register_types.h
+++ b/modules/gdnative/nativescript/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_nativescript_types();
void unregister_nativescript_types();
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp
index c9e7c60399..931ab0bfe4 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -84,8 +84,9 @@ Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p
godot_variant ret = _desc->call_method(
_data, (godot_string_name *)&p_method, (const godot_variant **)p_args,
p_argcount, (godot_variant_call_error *)&r_error);
- Variant *var_ret = (Variant *)&ret;
- return *var_ret;
+ Variant var_ret = *(Variant *)&ret;
+ godot_variant_destroy(&ret);
+ return var_ret;
}
#if 0 // TODO: Don't rely on default implementations provided by ScriptInstance ?
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h
index 7848739d9b..3c7b360ad9 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.h
+++ b/modules/gdnative/pluginscript/pluginscript_instance.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 382b28a0bb..8018178bd5 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -45,7 +45,11 @@ void PluginScriptLanguage::init() {
}
String PluginScriptLanguage::get_type() const {
- return String(_desc.type);
+ // We should use _desc.type here, however the returned type is used to
+ // query ClassDB which would complain given the type is not registered
+ // from his point of view...
+ // To solve this we just use a more generic (but present in ClassDB) type.
+ return String("PluginScript");
}
String PluginScriptLanguage::get_extension() const {
@@ -99,6 +103,7 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const
if (_desc.get_template_source_code) {
godot_string src = _desc.get_template_source_code(_data, (godot_string *)&p_class_name, (godot_string *)&p_base_class_name);
script->set_source_code(*(String *)&src);
+ godot_string_destroy(&src);
}
return script;
}
@@ -168,7 +173,7 @@ Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_
for (int i = 0; i < options.size(); i++) {
r_options->push_back(String(options[i]));
}
- Error err = *(Error *)tmp;
+ Error err = *(Error *)&tmp;
return err;
}
return ERR_UNAVAILABLE;
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index 5bbd3507e3..709345885b 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp
index 62ba41a24e..acba297fa0 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
index 5e59d25d75..9276ea3ef9 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ b/modules/gdnative/pluginscript/pluginscript_loader.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 876719820b..5ae7926f1b 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -131,13 +131,10 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
#endif
}
- PluginScript *top = this;
- // TODO: can be optimized by storing a PluginScript::_base_parent direct pointer
- while (top->_ref_base_parent.is_valid())
- top = top->_ref_base_parent.ptr();
- if (top->_native_parent) {
- if (!ClassDB::is_parent_class(p_this->get_class_name(), top->_native_parent)) {
- String msg = "Script inherits from native type '" + String(top->_native_parent) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'";
+ StringName base_type = get_instance_base_type();
+ if (base_type) {
+ if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) {
+ String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'";
// TODO: implement PluginscriptLanguage::debug_break_parse
// if (ScriptDebugger::get_singleton()) {
// _language->debug_break_parse(get_path(), 0, msg);
@@ -210,29 +207,31 @@ Error PluginScript::reload(bool p_keep_state) {
// TODO: GDscript uses `ScriptDebugger` here to jump into the parsing error
return err;
}
+
+ // Script's parent is passed as base_name which can make reference to a
+ // ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`)
+ StringName *base_name = (StringName *)&manifest.base;
+ if (*base_name) {
+
+ if (ClassDB::class_exists(*base_name)) {
+ _native_parent = *base_name;
+ } else {
+ Ref<Script> res = ResourceLoader::load(*base_name);
+ if (res.is_valid()) {
+ _ref_base_parent = res;
+ } else {
+ String name = *(StringName *)&manifest.name;
+ ERR_EXPLAIN(_path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'.");
+ ERR_FAIL_V(ERR_PARSE_ERROR);
+ }
+ }
+ }
+
_valid = true;
// Use the manifest to configure this script object
_data = manifest.data;
_name = *(StringName *)&manifest.name;
_tool = manifest.is_tool;
- // Base name is either another PluginScript or a regular class accessible
- // through ClassDB
- StringName *base_name = (StringName *)&manifest.base;
- for (SelfList<PluginScript> *e = _language->_script_list.first(); e != NULL; e = e->next()) {
- if (e->self()->_name == *base_name) {
- // Found you, base is a PluginScript !
- _ref_base_parent = Ref<PluginScript>(e->self());
- break;
- }
- }
- if (!_ref_base_parent.is_valid()) {
- // Base is a native ClassDB
- if (!ClassDB::class_exists(*base_name)) {
- ERR_EXPLAIN("Unknown script '" + String(_name) + "' parent '" + String(*base_name) + "'.");
- ERR_FAIL_V(ERR_PARSE_ERROR);
- }
- _native_parent = *base_name;
- }
Dictionary *members = (Dictionary *)&manifest.member_lines;
for (const Variant *key = members->next(); key != NULL; key = members->next(key)) {
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 9928e115ea..1be9e907c2 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -53,7 +53,7 @@ private:
bool _tool;
bool _valid;
- Ref<PluginScript> _ref_base_parent;
+ Ref<Script> _ref_base_parent;
StringName _native_parent;
SelfList<PluginScript> _script_list;
@@ -112,7 +112,7 @@ public:
virtual void update_exports();
virtual void get_script_method_list(List<MethodInfo> *r_methods) const;
- virtual void get_script_property_list(List<PropertyInfo> *r_propertieslist) const;
+ virtual void get_script_property_list(List<PropertyInfo> *r_properties) const;
virtual int get_member_line(const StringName &p_member) const;
diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp
index b7c8b6f536..8888f9e157 100644
--- a/modules/gdnative/pluginscript/register_types.cpp
+++ b/modules/gdnative/pluginscript/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "core/project_settings.h"
diff --git a/modules/gdnative/pluginscript/register_types.h b/modules/gdnative/pluginscript/register_types.h
index be2b1ca4c8..76651aa986 100644
--- a/modules/gdnative/pluginscript/register_types.h
+++ b/modules/gdnative/pluginscript/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_pluginscript_types();
void unregister_pluginscript_types();
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 21330dfefd..a0b6fbeb75 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "gdnative/gdnative.h"
diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h
index 39d47dccb0..4549687f55 100644
--- a/modules/gdnative/register_types.h
+++ b/modules/gdnative/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_gdnative_types();
void unregister_gdnative_types();
diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml
index cc617c5c67..59cb00e3f6 100644
--- a/modules/gdscript/doc_classes/GDScript.xml
+++ b/modules/gdscript/doc_classes/GDScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="GDScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
A script implemented in the GDScript programming language.
</brief_description>
@@ -8,6 +8,7 @@
[method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
</description>
<tutorials>
+ http://docs.godotengine.org/en/3.0/getting_started/scripting/gdscript/index.html
</tutorials>
<demos>
</demos>
diff --git a/modules/gdscript/doc_classes/GDScriptFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
index 465a4f438b..8510136f68 100644
--- a/modules/gdscript/doc_classes/GDScriptFunctionState.xml
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-beta">
+<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
State of a function call after yielding.
</brief_description>
diff --git a/modules/gdscript/doc_classes/GDScriptNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
index 948254e0ad..48826ec1e0 100644
--- a/modules/gdscript/doc_classes/GDScriptNativeClass.xml
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-beta">
+<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 11c13ce2ea..4e3ee4d22c 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript.h"
#include "engine.h"
@@ -704,7 +705,7 @@ bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const {
- p_properties->push_back(PropertyInfo(Variant::STRING, "script/source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_properties->push_back(PropertyInfo(Variant::STRING, "script/source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
}
void GDScript::_bind_methods() {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index d669fd6664..9566e3b32e 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_H
#define GDSCRIPT_H
@@ -348,7 +349,9 @@ public:
csi.resize(_debug_call_stack_pos);
for (int i = 0; i < _debug_call_stack_pos; i++) {
csi[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
- csi[_debug_call_stack_pos - i - 1].script = Ref<GDScript>(_call_stack[i].function->get_script());
+ if (_call_stack[i].function)
+ csi[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
+ csi[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
}
return csi;
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 360cce9ca0..1649fb52f2 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript_compiler.h"
#include "gdscript.h"
@@ -36,6 +37,9 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringN
if (!codegen.function_node || codegen.function_node->_static)
return false;
+ if (codegen.stack_identifiers.has(p_name))
+ return false; //shadowed
+
return _is_class_member_property(codegen.script, p_name);
}
@@ -183,6 +187,14 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
StringName identifier = in->name;
+ // TRY STACK!
+ if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
+
+ int pos = codegen.stack_identifiers[identifier];
+ return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
+ }
+
+ // TRY CLASS MEMBER
if (_is_class_member_property(codegen, identifier)) {
//get property
codegen.opcodes.push_back(GDScriptFunction::OPCODE_GET_MEMBER); // perform operator
@@ -193,12 +205,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return dst_addr;
}
- // TRY STACK!
- if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
-
- int pos = codegen.stack_identifiers[identifier];
- return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
- }
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
@@ -1335,10 +1341,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s);
- if (_is_class_member_property(codegen, lv->name)) {
- _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(codegen, lv->name)) {
+ // _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
+ // return ERR_ALREADY_EXISTS;
+ //}
codegen.add_stack_identifier(lv->name, p_stack_level++);
codegen.alloc_stack(p_stack_level);
@@ -1375,10 +1383,13 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
if (p_func) {
for (int i = 0; i < p_func->arguments.size(); i++) {
- if (_is_class_member_property(p_script, p_func->arguments[i])) {
- _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
- return ERR_ALREADY_EXISTS;
- }
+ // since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
+ //
+ //if (_is_class_member_property(p_script, p_func->arguments[i])) {
+ // _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
+ // return ERR_ALREADY_EXISTS;
+ //}
+
codegen.add_stack_identifier(p_func->arguments[i], i);
#ifdef TOOLS_ENABLED
argnames.push_back(p_func->arguments[i]);
diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h
index 4b35898bb0..62aafdbe01 100644
--- a/modules/gdscript/gdscript_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_COMPILER_H
#define GDSCRIPT_COMPILER_H
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 9dcaaf828f..505562324f 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript.h"
#include "core/engine.h"
@@ -368,8 +369,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
mi.name = "yield";
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal"));
- mi.default_arguments.push_back(Variant::NIL);
- mi.default_arguments.push_back(Variant::STRING);
+ mi.default_arguments.push_back(Variant());
+ mi.default_arguments.push_back(String());
mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState");
p_functions->push_back(mi);
}
@@ -490,8 +491,8 @@ static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) {
path = context.base_path.plus_file(path);
}
- if (ScriptCodeCompletionCache::get_sigleton())
- script = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(path);
+ if (ScriptCodeCompletionCache::get_singleton())
+ script = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
else
script = ResourceLoader::load(path);
@@ -764,8 +765,8 @@ static bool _guess_expression_type(GDScriptCompletionContext &context, const GDS
//print_line("is a script");
Ref<Script> scr;
- if (ScriptCodeCompletionCache::get_sigleton())
- scr = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(script);
+ if (ScriptCodeCompletionCache::get_singleton())
+ scr = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(script);
else
scr = ResourceLoader::load(script);
@@ -1300,8 +1301,8 @@ static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_lin
//print_line("is a script");
Ref<Script> scr;
- if (ScriptCodeCompletionCache::get_sigleton())
- scr = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(script);
+ if (ScriptCodeCompletionCache::get_singleton())
+ scr = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(script);
else
scr = ResourceLoader::load(script);
@@ -2449,8 +2450,10 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
} break;
case GDScriptParser::COMPLETION_RESOURCE_PATH: {
- if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))
+ if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) {
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);
+ r_forced = true;
+ }
} break;
case GDScriptParser::COMPLETION_ASSIGN: {
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 3023b489e5..a2f449909f 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript_function.h"
#include "gdscript.h"
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index e499820954..9310444c7a 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_FUNCTION_H
#define GDSCRIPT_FUNCTION_H
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index cae3bcadfe..c067d5409f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript_functions.h"
#include "class_db.h"
@@ -1482,7 +1483,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_INVERSE_LERP: {
- MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value"));
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
@@ -1578,12 +1579,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case LOGIC_CLAMP: {
- MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "val"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
+ MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
case LOGIC_NEAREST_PO2: {
- MethodInfo mi("nearest_po2", PropertyInfo(Variant::INT, "val"));
+ MethodInfo mi("nearest_po2", PropertyInfo(Variant::INT, "value"));
mi.return_val.type = Variant::INT;
return mi;
} break;
@@ -1759,12 +1760,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
case COLOR8: {
MethodInfo mi("Color8", PropertyInfo(Variant::INT, "r8"), PropertyInfo(Variant::INT, "g8"), PropertyInfo(Variant::INT, "b8"), PropertyInfo(Variant::INT, "a8"));
+ mi.default_arguments.push_back(255);
mi.return_val.type = Variant::COLOR;
return mi;
} break;
case COLORN: {
MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::REAL, "alpha"));
+ mi.default_arguments.push_back(1.0f);
mi.return_val.type = Variant::COLOR;
return mi;
} break;
diff --git a/modules/gdscript/gdscript_functions.h b/modules/gdscript/gdscript_functions.h
index 5bbd848339..1d54006084 100644
--- a/modules/gdscript/gdscript_functions.h
+++ b/modules/gdscript/gdscript_functions.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_FUNCTIONS_H
#define GDSCRIPT_FUNCTIONS_H
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 4b3feb49b9..1392323d56 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript_parser.h"
#include "gdscript.h"
@@ -94,8 +95,6 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
int indent = tokenizer->get_token_line_indent();
int current = tab_level.back()->get();
if (indent <= current) {
- print_line("current: " + itos(current) + " indent: " + itos(indent));
- print_line("less than current");
return false;
}
@@ -457,9 +456,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!validating) {
//this can be too slow for just validating code
- if (for_completion && ScriptCodeCompletionCache::get_sigleton()) {
- res = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(path);
- } else {
+ if (for_completion && ScriptCodeCompletionCache::get_singleton()) {
+ res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
+ } else { // essential; see issue 15902
res = ResourceLoader::load(path);
}
if (!res.is_valid()) {
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 1b851434db..485ba1263d 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_PARSER_H
#define GDSCRIPT_PARSER_H
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 281aa6ca44..6a844cd651 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gdscript_tokenizer.h"
#include "gdscript_functions.h"
diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index 9a09058cf3..b020c85199 100644
--- a/modules/gdscript/gdscript_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDSCRIPT_TOKENIZER_H
#define GDSCRIPT_TOKENIZER_H
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 50f5da9995..95efcda80f 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "gdscript.h"
diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h
index 21ad85f12e..2b88a67c7e 100644
--- a/modules/gdscript/register_types.h
+++ b/modules/gdscript/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_gdscript_types();
void unregister_gdscript_types();
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index c30c6d77b9..44685220b3 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GridMap" inherits="Spatial" category="Core" version="3.0-beta">
+<class name="GridMap" inherits="Spatial" category="Core" version="3.0-stable">
<brief_description>
Node for 3D tile-based maps.
</brief_description>
@@ -10,6 +10,7 @@
A GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells.
</description>
<tutorials>
+ http://docs.godotengine.org/en/3.0/tutorials/3d/using_gridmaps.html
</tutorials>
<demos>
</demos>
@@ -67,34 +68,6 @@
The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is retuned if the cell is empty.
</description>
</method>
- <method name="get_cell_size" qualifiers="const">
- <return type="Vector3">
- </return>
- <description>
- The dimensions of the grid's cells.
- </description>
- </method>
- <method name="get_center_x" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns whether or not grid items are centered on the X axis.
- </description>
- </method>
- <method name="get_center_y" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns whether or not grid items are centered on the Y axis.
- </description>
- </method>
- <method name="get_center_z" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns whether or not grid items are centered on the Z axis.
- </description>
- </method>
<method name="get_collision_layer_bit" qualifiers="const">
<return type="bool">
</return>
@@ -118,20 +91,6 @@
Array of [Transform] and [Mesh] references corresponding to the non empty cells in the grid. The transforms are specified in world space.
</description>
</method>
- <method name="get_octant_size" qualifiers="const">
- <return type="int">
- </return>
- <description>
- The size of each octant measured in number of cells. This applies to all three axis.
- </description>
- </method>
- <method name="get_theme" qualifiers="const">
- <return type="MeshLibrary">
- </return>
- <description>
- The assigned [MeshLibrary].
- </description>
- </method>
<method name="get_used_cells" qualifiers="const">
<return type="Array">
</return>
@@ -188,42 +147,6 @@
Optionally, the item's orientation can be passed.
</description>
</method>
- <method name="set_cell_size">
- <return type="void">
- </return>
- <argument index="0" name="size" type="Vector3">
- </argument>
- <description>
- Sets the height, width and depth of the grid's cells.
- </description>
- </method>
- <method name="set_center_x">
- <return type="void">
- </return>
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- Set grid items to be centered on the X axis. By default it is enabled.
- </description>
- </method>
- <method name="set_center_y">
- <return type="void">
- </return>
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- Set grid items to be centered on the Y axis. By default it is enabled.
- </description>
- </method>
- <method name="set_center_z">
- <return type="void">
- </return>
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- Set grid items to be centered on the Z axis. By default it is enabled.
- </description>
- </method>
<method name="set_clip">
<return type="void">
</return>
@@ -258,24 +181,6 @@
<description>
</description>
</method>
- <method name="set_octant_size">
- <return type="void">
- </return>
- <argument index="0" name="size" type="int">
- </argument>
- <description>
- Sets the size for each octant measured in number of cells. This applies to all three axis.
- </description>
- </method>
- <method name="set_theme">
- <return type="void">
- </return>
- <argument index="0" name="theme" type="MeshLibrary">
- </argument>
- <description>
- Sets the collection of meshes for the map.
- </description>
- </method>
<method name="world_to_map" qualifiers="const">
<return type="Vector3">
</return>
@@ -286,10 +191,30 @@
</method>
</methods>
<members>
+ <member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x">
+ If [code]true[/code] grid items are centered on the X axis.
+ </member>
+ <member name="cell_center_y" type="bool" setter="set_center_y" getter="get_center_y">
+ If [code]true[/code] grid items are centered on the Y axis.
+ </member>
+ <member name="cell_center_z" type="bool" setter="set_center_z" getter="get_center_z">
+ If [code]true[/code] grid items are centered on the Z axis.
+ </member>
+ <member name="cell_octant_size" type="int" setter="set_octant_size" getter="get_octant_size">
+ The size of each octant measured in number of cells. This applies to all three axis.
+ </member>
+ <member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale">
+ </member>
+ <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size">
+ The dimensions of the grid's cells.
+ </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer">
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
</member>
+ <member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme">
+ The assigned [MeshLibrary].
+ </member>
</members>
<constants>
<constant name="INVALID_CELL_ITEM" value="-1">
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 9a03bc410a..234a59e516 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "grid_map.h"
#include "message_queue.h"
#include "scene/3d/light.h"
@@ -42,28 +43,7 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
- if (name == "theme") {
-
- set_theme(p_value);
- } else if (name == "cell_size") {
- if (p_value.get_type() == Variant::INT || p_value.get_type() == Variant::REAL) {
- //compatibility
- float cs = p_value;
- set_cell_size(Vector3(cs, cs, cs));
- } else {
- set_cell_size(p_value);
- }
- } else if (name == "cell_octant_size") {
- set_octant_size(p_value);
- } else if (name == "cell_center_x") {
- set_center_x(p_value);
- } else if (name == "cell_center_y") {
- set_center_y(p_value);
- } else if (name == "cell_center_z") {
- set_center_z(p_value);
- } else if (name == "cell_scale") {
- set_cell_scale(p_value);
- /* } else if (name=="cells") {
+ /* } else if (name=="cells") {
PoolVector<int> cells = p_value;
int amount=cells.size();
PoolVector<int>::Read r = cells.read();
@@ -80,7 +60,7 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
_recreate_octant_data();*/
- } else if (name == "data") {
+ if (name == "data") {
Dictionary d = p_value;
@@ -133,21 +113,7 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
- if (name == "theme") {
- r_ret = get_theme();
- } else if (name == "cell_size") {
- r_ret = get_cell_size();
- } else if (name == "cell_octant_size") {
- r_ret = get_octant_size();
- } else if (name == "cell_center_x") {
- r_ret = get_center_x();
- } else if (name == "cell_center_y") {
- r_ret = get_center_y();
- } else if (name == "cell_center_z") {
- r_ret = get_center_z();
- } else if (name == "cell_scale") {
- r_ret = cell_scale;
- } else if (name == "data") {
+ if (name == "data") {
Dictionary d;
@@ -183,14 +149,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
- p_list->push_back(PropertyInfo(Variant::NIL, "Cell", PROPERTY_HINT_NONE, "cell_", PROPERTY_USAGE_GROUP));
- p_list->push_back(PropertyInfo(Variant::VECTOR3, "cell_size"));
- p_list->push_back(PropertyInfo(Variant::INT, "cell_octant_size", PROPERTY_HINT_RANGE, "1,1024,1"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_x"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_y"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_z"));
- p_list->push_back(PropertyInfo(Variant::REAL, "cell_scale"));
if (baked_meshes.size()) {
p_list->push_back(PropertyInfo(Variant::ARRAY, "baked_meshes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
}
@@ -894,6 +852,9 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_cell_size", "size"), &GridMap::set_cell_size);
ClassDB::bind_method(D_METHOD("get_cell_size"), &GridMap::get_cell_size);
+ ClassDB::bind_method(D_METHOD("set_cell_scale", "scale"), &GridMap::set_cell_scale);
+ ClassDB::bind_method(D_METHOD("get_cell_scale"), &GridMap::get_cell_scale);
+
ClassDB::bind_method(D_METHOD("set_octant_size", "size"), &GridMap::set_octant_size);
ClassDB::bind_method(D_METHOD("get_octant_size"), &GridMap::get_octant_size);
@@ -928,6 +889,14 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_baked_meshes"), &GridMap::clear_baked_meshes);
ClassDB::bind_method(D_METHOD("make_baked_meshes", "gen_lightmap_uv", "lightmap_uv_texel_size"), &GridMap::make_baked_meshes, DEFVAL(false), DEFVAL(0.1));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_theme", "get_theme");
+ ADD_GROUP("Cell", "cell_");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cell_size"), "set_cell_size", "get_cell_size");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_octant_size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_octant_size", "get_octant_size");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_x"), "set_center_x", "get_center_x");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_y"), "set_center_y", "get_center_y");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_z"), "set_center_z", "get_center_z");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_scale"), "set_cell_scale", "get_cell_scale");
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 7b97fe3183..ed36751fc8 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GRID_MAP_H
#define GRID_MAP_H
@@ -246,7 +247,7 @@ public:
int get_cell_item(int p_x, int p_y, int p_z) const;
int get_cell_item_orientation(int p_x, int p_y, int p_z) const;
- Vector3 world_to_map(const Vector3 &p_pos) const;
+ Vector3 world_to_map(const Vector3 &p_world_pos) const;
Vector3 map_to_world(int p_x, int p_y, int p_z) const;
void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X);
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index dc7dbb0b0d..7b7bc0fa2a 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "grid_map_editor_plugin.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index a49b44e7a2..3fc92bf7aa 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GRID_MAP_EDITOR_PLUGIN_H
#define GRID_MAP_EDITOR_PLUGIN_H
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index 23a8d16497..a3ceea10af 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#ifndef _3D_DISABLED
#include "class_db.h"
diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h
index 0e19f1ce8d..4ff107bec8 100644
--- a/modules/gridmap/register_types.h
+++ b/modules/gridmap/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_gridmap_types();
void unregister_gridmap_types();
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index 2b829ef246..3cc362b5d6 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_hdr.h"
#include "os/os.h"
diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h
index 4d4edc4df7..3cce483745 100644
--- a/modules/hdr/image_loader_hdr.h
+++ b/modules/hdr/image_loader_hdr.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_HDR_H
#define IMAGE_LOADER_HDR_H
diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp
index 469fdfc85e..8688daad69 100644
--- a/modules/hdr/register_types.cpp
+++ b/modules/hdr/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_hdr.h"
diff --git a/modules/hdr/register_types.h b/modules/hdr/register_types.h
index b3f69405f2..e064f5d945 100644
--- a/modules/hdr/register_types.h
+++ b/modules/hdr/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_hdr_types();
void unregister_hdr_types();
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index b90d968753..0168be3a26 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_jpegd.h"
#include "os/os.h"
diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h
index b4bcb11239..3e3ac5217f 100644
--- a/modules/jpg/image_loader_jpegd.h
+++ b/modules/jpg/image_loader_jpegd.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_JPG_H
#define IMAGE_LOADER_JPG_H
diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp
index 809c934be4..450ac065f4 100644
--- a/modules/jpg/register_types.cpp
+++ b/modules/jpg/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_jpegd.h"
diff --git a/modules/jpg/register_types.h b/modules/jpg/register_types.h
index d38fb908d3..6f10c18c12 100644
--- a/modules/jpg/register_types.h
+++ b/modules/jpg/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_jpg_types();
void unregister_jpg_types();
diff --git a/modules/mbedtls/SCsub b/modules/mbedtls/SCsub
new file mode 100755
index 0000000000..b846ae38ad
--- /dev/null
+++ b/modules/mbedtls/SCsub
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+env_mbed_tls = env_modules.Clone()
+
+if env['builtin_mbedtls']:
+ # Thirdparty source files
+ thirdparty_sources = [
+ "aes.c",
+ "aesni.c",
+ "arc4.c",
+ "asn1parse.c",
+ "asn1write.c",
+ "base64.c",
+ "bignum.c",
+ "blowfish.c",
+ "camellia.c",
+ "ccm.c",
+ "certs.c",
+ "cipher.c",
+ "cipher_wrap.c",
+ "cmac.c",
+ "ctr_drbg.c",
+ "debug.c",
+ "des.c",
+ "dhm.c",
+ "ecdh.c",
+ "ecdsa.c",
+ "ecjpake.c",
+ "ecp.c",
+ "ecp_curves.c",
+ "entropy.c",
+ "entropy_poll.c",
+ "error.c",
+ "gcm.c",
+ "havege.c",
+ "hmac_drbg.c",
+ "md2.c",
+ "md4.c",
+ "md5.c",
+ "md.c",
+ "md_wrap.c",
+ "memory_buffer_alloc.c",
+ "net_sockets.c",
+ "oid.c",
+ "padlock.c",
+ "pem.c",
+ "pk.c",
+ "pkcs11.c",
+ "pkcs12.c",
+ "pkcs5.c",
+ "pkparse.c",
+ "pk_wrap.c",
+ "pkwrite.c",
+ "platform.c",
+ "ripemd160.c",
+ "rsa.c",
+ "rsa_internal.c",
+ "sha1.c",
+ "sha256.c",
+ "sha512.c",
+ "ssl_cache.c",
+ "ssl_ciphersuites.c",
+ "ssl_cli.c",
+ "ssl_cookie.c",
+ "ssl_srv.c",
+ "ssl_ticket.c",
+ "ssl_tls.c",
+ "threading.c",
+ "timing.c",
+ "version.c",
+ "version_features.c",
+ "x509.c",
+ "x509_create.c",
+ "x509_crl.c",
+ "x509_crt.c",
+ "x509_csr.c",
+ "x509write_crt.c",
+ "x509write_csr.c",
+ "xtea.c"
+ ]
+
+ thirdparty_dir = "#thirdparty/mbedtls/library/"
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+ env_mbed_tls.add_source_files(env.modules_sources, thirdparty_sources)
+ env_mbed_tls.Append(CPPPATH=["#thirdparty/mbedtls/include/"])
+
+# Module sources
+env_mbed_tls.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/openssl/config.py b/modules/mbedtls/config.py
index 5f133eba90..5f133eba90 100644..100755
--- a/modules/openssl/config.py
+++ b/modules/mbedtls/config.py
diff --git a/modules/openssl/register_types.cpp b/modules/mbedtls/register_types.cpp
index e103b3b9bf..8548275eec 100644..100755
--- a/modules/openssl/register_types.cpp
+++ b/modules/mbedtls/register_types.cpp
@@ -27,17 +27,18 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
-#include "stream_peer_openssl.h"
+#include "stream_peer_mbed_tls.h"
-void register_openssl_types() {
+void register_mbedtls_types() {
- ClassDB::register_class<StreamPeerOpenSSL>();
- StreamPeerOpenSSL::initialize_ssl();
+ ClassDB::register_class<StreamPeerMbedTLS>();
+ StreamPeerMbedTLS::initialize_ssl();
}
-void unregister_openssl_types() {
+void unregister_mbedtls_types() {
- StreamPeerOpenSSL::finalize_ssl();
+ StreamPeerMbedTLS::finalize_ssl();
}
diff --git a/modules/openssl/register_types.h b/modules/mbedtls/register_types.h
index d87f1a31df..3da0b1f1a0 100644..100755
--- a/modules/openssl/register_types.h
+++ b/modules/mbedtls/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_openssl_types();
-void unregister_openssl_types();
+
+void register_mbedtls_types();
+void unregister_mbedtls_types();
diff --git a/modules/mbedtls/stream_peer_mbed_tls.cpp b/modules/mbedtls/stream_peer_mbed_tls.cpp
new file mode 100755
index 0000000000..4135eb40ff
--- /dev/null
+++ b/modules/mbedtls/stream_peer_mbed_tls.cpp
@@ -0,0 +1,325 @@
+/*************************************************************************/
+/* stream_peer_openssl.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "stream_peer_mbed_tls.h"
+
+static void my_debug(void *ctx, int level,
+ const char *file, int line,
+ const char *str) {
+
+ printf("%s:%04d: %s", file, line, str);
+ fflush(stdout);
+}
+
+void _print_error(int ret) {
+ printf("mbedtls error: returned -0x%x\n\n", -ret);
+ fflush(stdout);
+}
+
+int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
+
+ if (buf == NULL || len <= 0) return 0;
+
+ StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
+
+ ERR_FAIL_COND_V(sp == NULL, 0);
+
+ int sent;
+ Error err = sp->base->put_partial_data((const uint8_t *)buf, len, sent);
+ if (err != OK) {
+ return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
+ }
+ if (sent == 0) {
+ return MBEDTLS_ERR_SSL_WANT_WRITE;
+ }
+ return sent;
+}
+
+int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
+
+ if (buf == NULL || len <= 0) return 0;
+
+ StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
+
+ ERR_FAIL_COND_V(sp == NULL, 0);
+
+ int got;
+ Error err = sp->base->get_partial_data((uint8_t *)buf, len, got);
+ if (err != OK) {
+ return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
+ }
+ if (got == 0) {
+ return MBEDTLS_ERR_SSL_WANT_READ;
+ }
+ return got;
+}
+
+Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname) {
+
+ base = p_base;
+ int ret = 0;
+ int authmode = p_validate_certs ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE;
+
+ mbedtls_ssl_init(&ssl);
+ mbedtls_ssl_config_init(&conf);
+ mbedtls_ctr_drbg_init(&ctr_drbg);
+ mbedtls_entropy_init(&entropy);
+
+ ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
+ if (ret != 0) {
+ ERR_PRINTS(" failed\n ! mbedtls_ctr_drbg_seed returned an error" + itos(ret));
+ return FAILED;
+ }
+
+ mbedtls_ssl_config_defaults(&conf,
+ MBEDTLS_SSL_IS_CLIENT,
+ MBEDTLS_SSL_TRANSPORT_STREAM,
+ MBEDTLS_SSL_PRESET_DEFAULT);
+
+ mbedtls_ssl_conf_authmode(&conf, authmode);
+ mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL);
+ mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg);
+ mbedtls_ssl_conf_dbg(&conf, my_debug, stdout);
+ mbedtls_ssl_setup(&ssl, &conf);
+ mbedtls_ssl_set_hostname(&ssl, p_for_hostname.utf8().get_data());
+
+ mbedtls_ssl_set_bio(&ssl, this, bio_send, bio_recv, NULL);
+
+ while ((ret = mbedtls_ssl_handshake(&ssl)) != 0) {
+ if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ ERR_PRINTS("TLS handshake error: " + itos(ret));
+ _print_error(ret);
+ status = STATUS_ERROR_HOSTNAME_MISMATCH;
+ return FAILED;
+ }
+ }
+
+ connected = true;
+ status = STATUS_CONNECTED;
+
+ return OK;
+}
+
+Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base) {
+
+ return ERR_UNAVAILABLE;
+}
+
+Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
+
+ ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
+
+ Error err;
+ int sent = 0;
+
+ while (p_bytes > 0) {
+ err = put_partial_data(p_data, p_bytes, sent);
+
+ if (err != OK) {
+ return err;
+ }
+
+ p_data += sent;
+ p_bytes -= sent;
+ }
+
+ return OK;
+}
+
+Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
+
+ ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
+
+ r_sent = 0;
+
+ if (p_bytes == 0)
+ return OK;
+
+ int ret = mbedtls_ssl_write(&ssl, p_data, p_bytes);
+ if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ ret = 0; // non blocking io
+ } else if (ret <= 0) {
+ _print_error(ret);
+ disconnect_from_stream();
+ return ERR_CONNECTION_ERROR;
+ }
+
+ r_sent = ret;
+ return OK;
+}
+
+Error StreamPeerMbedTLS::get_data(uint8_t *p_buffer, int p_bytes) {
+
+ ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
+
+ Error err;
+
+ int got = 0;
+ while (p_bytes > 0) {
+
+ err = get_partial_data(p_buffer, p_bytes, got);
+
+ if (err != OK) {
+ return err;
+ }
+
+ p_buffer += got;
+ p_bytes -= got;
+ }
+
+ return OK;
+}
+
+Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
+
+ ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
+
+ r_received = 0;
+
+ int ret = mbedtls_ssl_read(&ssl, p_buffer, p_bytes);
+ if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ ret = 0; // non blocking io
+ } else if (ret <= 0) {
+ _print_error(ret);
+ disconnect_from_stream();
+ return ERR_CONNECTION_ERROR;
+ }
+
+ r_received = ret;
+ return OK;
+}
+
+void StreamPeerMbedTLS::poll() {
+
+ ERR_FAIL_COND(!connected);
+ ERR_FAIL_COND(!base.is_valid());
+
+ int ret = mbedtls_ssl_read(&ssl, NULL, 0);
+
+ if (ret < 0 && ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ _print_error(ret);
+ disconnect_from_stream();
+ return;
+ }
+}
+
+int StreamPeerMbedTLS::get_available_bytes() const {
+
+ ERR_FAIL_COND_V(!connected, 0);
+
+ return mbedtls_ssl_get_bytes_avail(&ssl);
+}
+StreamPeerMbedTLS::StreamPeerMbedTLS() {
+
+ connected = false;
+ status = STATUS_DISCONNECTED;
+}
+
+StreamPeerMbedTLS::~StreamPeerMbedTLS() {
+ disconnect_from_stream();
+}
+
+void StreamPeerMbedTLS::disconnect_from_stream() {
+
+ if (!connected)
+ return;
+
+ mbedtls_ssl_free(&ssl);
+ mbedtls_ssl_config_free(&conf);
+ mbedtls_ctr_drbg_free(&ctr_drbg);
+ mbedtls_entropy_free(&entropy);
+
+ base = Ref<StreamPeer>();
+ connected = false;
+ status = STATUS_DISCONNECTED;
+}
+
+StreamPeerMbedTLS::Status StreamPeerMbedTLS::get_status() const {
+
+ return status;
+}
+
+StreamPeerSSL *StreamPeerMbedTLS::_create_func() {
+
+ return memnew(StreamPeerMbedTLS);
+}
+
+mbedtls_x509_crt StreamPeerMbedTLS::cacert;
+
+void StreamPeerMbedTLS::_load_certs(const PoolByteArray &p_array) {
+ int arr_len = p_array.size();
+ PoolByteArray::Read r = p_array.read();
+ int err = mbedtls_x509_crt_parse(&cacert, &r[0], arr_len);
+ if (err != 0) {
+ WARN_PRINTS("Error parsing some certificates: " + itos(err));
+ }
+}
+
+void StreamPeerMbedTLS::initialize_ssl() {
+
+ _create = _create_func;
+ load_certs_func = _load_certs;
+
+ mbedtls_x509_crt_init(&cacert);
+
+#ifdef DEBUG_ENABLED
+ mbedtls_debug_set_threshold(1);
+#endif
+
+ String certs_path = GLOBAL_DEF("network/ssl/certificates", "");
+ ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/certificates", PropertyInfo(Variant::STRING, "network/ssl/certificates", PROPERTY_HINT_FILE, "*.crt"));
+
+ if (certs_path != "") {
+
+ FileAccess *f = FileAccess::open(certs_path, FileAccess::READ);
+ if (f) {
+ PoolByteArray arr;
+ int flen = f->get_len();
+ arr.resize(flen + 1);
+ {
+ PoolByteArray::Write w = arr.write();
+ f->get_buffer(w.ptr(), flen);
+ w[flen] = 0; //end f string
+ }
+
+ memdelete(f);
+
+ _load_certs(arr);
+ print_line("Loaded certs from '" + certs_path);
+ }
+ }
+
+ available = true;
+}
+
+void StreamPeerMbedTLS::finalize_ssl() {
+
+ mbedtls_x509_crt_free(&cacert);
+}
diff --git a/modules/openssl/stream_peer_openssl.h b/modules/mbedtls/stream_peer_mbed_tls.h
index a696e29d6c..ce17614d85 100644..100755
--- a/modules/openssl/stream_peer_openssl.h
+++ b/modules/mbedtls/stream_peer_mbed_tls.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef STREAM_PEER_OPEN_SSL_H
#define STREAM_PEER_OPEN_SSL_H
@@ -34,63 +35,42 @@
#include "os/file_access.h"
#include "project_settings.h"
-#include "thirdparty/misc/curl_hostcheck.h"
-
-#include <openssl/bio.h> // BIO objects for I/O
-#include <openssl/err.h> // Error reporting
-#include <openssl/ssl.h> // SSL and SSL_CTX for SSL connections
-#include <openssl/x509v3.h>
+#include "mbedtls/config.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/debug.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/net.h"
+#include "mbedtls/ssl.h"
#include <stdio.h>
+#include <stdlib.h>
-class StreamPeerOpenSSL : public StreamPeerSSL {
+class StreamPeerMbedTLS : public StreamPeerSSL {
private:
- static int _bio_create(BIO *b);
- static int _bio_destroy(BIO *b);
- static int _bio_read(BIO *b, char *buf, int len);
- static int _bio_write(BIO *b, const char *buf, int len);
- static long _bio_ctrl(BIO *b, int cmd, long num, void *ptr);
- static int _bio_gets(BIO *b, char *buf, int len);
- static int _bio_puts(BIO *b, const char *str);
-
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
- static BIO_METHOD *_bio_method;
-#else
- static BIO_METHOD _bio_method;
-#endif
- static BIO_METHOD *_get_bio_method();
-
- static bool _match_host_name(const char *name, const char *hostname);
- static Error _match_common_name(const char *hostname, const X509 *server_cert);
- static Error _match_subject_alternative_name(const char *hostname, const X509 *server_cert);
-
- static int _cert_verify_callback(X509_STORE_CTX *x509_ctx, void *arg);
-
Status status;
String hostname;
- int max_cert_chain_depth;
- SSL_CTX *ctx;
- SSL *ssl;
- BIO *bio;
+
bool connected;
- int flags;
- bool use_blocking;
- bool validate_certs;
- bool validate_hostname;
Ref<StreamPeer> base;
static StreamPeerSSL *_create_func();
- void _print_error(int err);
-
- static Vector<X509 *> certs;
-
static void _load_certs(const PoolByteArray &p_array);
+ static int bio_recv(void *ctx, unsigned char *buf, size_t len);
+ static int bio_send(void *ctx, const unsigned char *buf, size_t len);
+
protected:
+ static mbedtls_x509_crt cacert;
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+ mbedtls_ssl_context ssl;
+ mbedtls_ssl_config conf;
+
static void _bind_methods();
public:
+ virtual void poll();
virtual Error accept_stream(Ref<StreamPeer> p_base);
virtual Error connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs = false, const String &p_for_hostname = String());
virtual Status get_status() const;
@@ -108,8 +88,8 @@ public:
static void initialize_ssl();
static void finalize_ssl();
- StreamPeerOpenSSL();
- ~StreamPeerOpenSSL();
+ StreamPeerMbedTLS();
+ ~StreamPeerMbedTLS();
};
#endif // STREAM_PEER_SSL_H
diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
index 5d3da0672e..82300e707a 100644
--- a/modules/mobile_vr/doc_classes/MobileVRInterface.xml
+++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0-beta">
+<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0-stable">
<brief_description>
Generic mobile VR implementation
</brief_description>
diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp
index 4e8894f9fb..6b1c7eb279 100644
--- a/modules/mobile_vr/mobile_interface.cpp
+++ b/modules/mobile_vr/mobile_interface.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -345,7 +345,7 @@ Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, co
if (initialized) {
float world_scale = arvr_server->get_world_scale();
- // we don't need to check for the existance of our HMD, doesn't effect our values...
+ // we don't need to check for the existence of our HMD, doesn't effect our values...
// note * 0.01 to convert cm to m and * 0.5 as we're moving half in each direction...
if (p_eye == ARVRInterface::EYE_LEFT) {
transform_for_eye.origin.x = -(intraocular_dist * 0.01 * 0.5 * world_scale);
diff --git a/modules/mobile_vr/mobile_interface.h b/modules/mobile_vr/mobile_interface.h
index 4a2484667d..bb84281b46 100644
--- a/modules/mobile_vr/mobile_interface.h
+++ b/modules/mobile_vr/mobile_interface.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef MOBILE_VR_INTERFACE_H
#define MOBILE_VR_INTERFACE_H
diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp
index 6a513607fa..0655727a4a 100644
--- a/modules/mobile_vr/register_types.cpp
+++ b/modules/mobile_vr/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "mobile_interface.h"
diff --git a/modules/mobile_vr/register_types.h b/modules/mobile_vr/register_types.h
index d9625d1bba..621f8dea80 100644
--- a/modules/mobile_vr/register_types.h
+++ b/modules/mobile_vr/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_mobile_vr_types();
void unregister_mobile_vr_types();
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index 320bbe7090..aa8626e6da 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -57,10 +57,10 @@ if env['tools']:
vars = Variables()
vars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True))
vars.Add(BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False))
-vars.Update(env)
+vars.Update(env_mono)
# Glue sources
-if env['mono_glue']:
+if env_mono['mono_glue']:
env_mono.add_source_files(env.modules_sources, 'glue/*.cpp')
else:
env_mono.Append(CPPDEFINES=['MONO_GLUE_DISABLED'])
diff --git a/modules/mono/config.py b/modules/mono/config.py
index b4e6433256..7c1846dcc2 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -159,6 +159,7 @@ def configure(env):
mono_so_name = ''
tmpenv = Environment()
+ tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
for hint_dir in tmpenv['LIBPATH']:
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index a621c5529d..0dc0018224 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "csharp_script.h"
#include <mono/metadata/threads.h>
@@ -175,7 +176,7 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"fixed",
"float",
"for",
- "forech",
+ "foreach",
"goto",
"if",
"implicit",
@@ -221,14 +222,17 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"ushort",
"using",
"virtual",
- "volatile",
"void",
+ "volatile",
"while",
// Contextual keywords. Not reserved words, but I guess we should include
// them because this seems to be used only for syntax highlighting.
"add",
+ "alias",
"ascending",
+ "async",
+ "await",
"by",
"descending",
"dynamic",
@@ -237,10 +241,10 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"get",
"global",
"group",
- "in",
"into",
"join",
"let",
+ "nameof",
"on",
"orderby",
"partial",
@@ -249,6 +253,7 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"set",
"value",
"var",
+ "when",
"where",
"yield",
0
@@ -444,6 +449,82 @@ String CSharpLanguage::_get_indentation() const {
return "\t";
}
+Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info() {
+
+#ifdef DEBUG_ENABLED
+ // Printing an error here will result in endless recursion, so we must be careful
+
+ if (!gdmono->is_runtime_initialized() || !GDMono::get_singleton()->get_api_assembly() || !GDMonoUtils::mono_cache.corlib_cache_updated)
+ return Vector<StackInfo>();
+
+ MonoObject *stack_trace = mono_object_new(mono_domain_get(), CACHED_CLASS(System_Diagnostics_StackTrace)->get_mono_ptr());
+
+ MonoBoolean need_file_info = true;
+ void *ctor_args[1] = { &need_file_info };
+
+ CACHED_METHOD(System_Diagnostics_StackTrace, ctor_bool)->invoke_raw(stack_trace, ctor_args);
+
+ Vector<StackInfo> si;
+ si = stack_trace_get_info(stack_trace);
+
+ return si;
+#else
+ return Vector<StackInfo>();
+#endif
+}
+
+#ifdef DEBUG_ENABLED
+Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObject *p_stack_trace) {
+
+ // Printing an error here could result in endless recursion, so we must be careful
+
+ MonoObject *exc = NULL;
+
+ GDMonoUtils::StackTrace_GetFrames st_get_frames = CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames);
+ MonoArray *frames = st_get_frames(p_stack_trace, &exc);
+
+ if (exc) {
+ GDMonoUtils::print_unhandled_exception(exc, true /* fail silently to avoid endless recursion */);
+ return Vector<StackInfo>();
+ }
+
+ int frame_count = mono_array_length(frames);
+
+ if (frame_count <= 0)
+ return Vector<StackInfo>();
+
+ GDMonoUtils::DebugUtils_StackFrameInfo get_sf_info = CACHED_METHOD_THUNK(DebuggingUtils, GetStackFrameInfo);
+
+ Vector<StackInfo> si;
+ si.resize(frame_count);
+
+ for (int i = 0; i < frame_count; i++) {
+ StackInfo &sif = si[i];
+ MonoObject *frame = mono_array_get(frames, MonoObject *, i);
+
+ MonoString *file_name;
+ int file_line_num;
+ MonoString *method_decl;
+ get_sf_info(frame, &file_name, &file_line_num, &method_decl, &exc);
+
+ if (exc) {
+ GDMonoUtils::print_unhandled_exception(exc, true /* fail silently to avoid endless recursion */);
+ return Vector<StackInfo>();
+ }
+
+ // TODO
+ // what if the StackFrame method is null (method_decl is empty). should we skip this frame?
+ // can reproduce with a MissingMethodException on internal calls
+
+ sif.file = GDMonoMarshal::mono_string_to_godot(file_name);
+ sif.line = file_line_num;
+ sif.func = GDMonoMarshal::mono_string_to_godot(method_decl);
+ }
+
+ return si;
+}
+#endif
+
void CSharpLanguage::frame() {
const Ref<MonoGCHandle> &task_scheduler_handle = GDMonoUtils::mono_cache.task_scheduler_handle;
@@ -870,19 +951,6 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
#endif
}
-void CSharpInstance::_ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *p_klass, const StringName &p_method, const Variant **p_args, int p_argcount) {
-
- GDMonoClass *base = p_klass->get_parent_class();
- if (base && base != script->native)
- _ml_call_reversed(p_mono_object, base, p_method, p_args, p_argcount);
-
- GDMonoMethod *method = p_klass->get_method(p_method, p_argcount);
-
- if (method) {
- method->invoke(p_mono_object, p_args);
- }
-}
-
CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const Ref<MonoGCHandle> &p_gchandle) {
CSharpInstance *instance = memnew(CSharpInstance);
@@ -951,6 +1019,8 @@ bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
if (ret && GDMonoMarshal::unbox<MonoBoolean>(ret) == true)
return true;
+
+ break;
}
top = top->get_parent_class();
@@ -973,7 +1043,7 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
if (field) {
MonoObject *value = field->get_value(mono_object);
- r_ret = GDMonoMarshal::mono_object_to_variant(value, field->get_type());
+ r_ret = GDMonoMarshal::mono_object_to_variant(value);
return true;
}
@@ -986,7 +1056,7 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
r_ret = Variant();
GDMonoUtils::print_unhandled_exception(exc);
} else {
- r_ret = GDMonoMarshal::mono_object_to_variant(value, property->get_type());
+ r_ret = GDMonoMarshal::mono_object_to_variant(value);
}
return true;
}
@@ -1011,6 +1081,8 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
r_ret = GDMonoMarshal::mono_object_to_variant(ret);
return true;
}
+
+ break;
}
top = top->get_parent_class();
@@ -1048,7 +1120,7 @@ bool CSharpInstance::has_method(const StringName &p_method) const {
GDMonoClass *top = script->script_class;
while (top && top != script->native) {
- if (top->has_method(p_method)) {
+ if (top->has_fetched_method_unknown_params(p_method)) {
return true;
}
@@ -1062,10 +1134,13 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
MonoObject *mono_object = get_mono_object();
- ERR_FAIL_NULL_V(mono_object, Variant());
+ if (!mono_object) {
+ r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ ERR_FAIL_V(Variant());
+ }
if (!script.is_valid())
- return Variant();
+ ERR_FAIL_V(Variant());
GDMonoClass *top = script->script_class;
@@ -1075,8 +1150,10 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
if (method) {
MonoObject *return_value = method->invoke(mono_object, p_args);
+ r_error.error = Variant::CallError::CALL_OK;
+
if (return_value) {
- return GDMonoMarshal::mono_object_to_variant(return_value, method->get_return_type());
+ return GDMonoMarshal::mono_object_to_variant(return_value);
} else {
return Variant();
}
@@ -1108,8 +1185,10 @@ void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringNam
while (top && top != script->native) {
GDMonoMethod *method = top->get_method(p_method, p_argcount);
- if (method)
+ if (method) {
method->invoke(p_mono_object, p_args);
+ return;
+ }
top = top->get_parent_class();
}
@@ -1117,13 +1196,9 @@ void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringNam
void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
- if (script.is_valid()) {
- MonoObject *mono_object = get_mono_object();
-
- ERR_FAIL_NULL(mono_object);
+ // Sorry, the method is the one that controls the call order
- _ml_call_reversed(mono_object, script->script_class, p_method, p_args, p_argcount);
- }
+ call_multilevel(p_method, p_args, p_argcount);
}
void CSharpInstance::_reference_owner_unsafe() {
@@ -1226,7 +1301,7 @@ ScriptInstance::RPCMode CSharpInstance::get_rpc_mode(const StringName &p_method)
GDMonoClass *top = script->script_class;
while (top && top != script->native) {
- GDMonoMethod *method = top->get_method(p_method);
+ GDMonoMethod *method = top->get_fetched_method_unknown_params(p_method);
if (method && !method->is_static())
return _member_get_rpc_mode(method);
@@ -1470,6 +1545,7 @@ bool CSharpScript::_update_exports() {
return false;
}
+#ifdef TOOLS_ENABLED
bool CSharpScript::_get_member_export(GDMonoClass *p_class, GDMonoClassMember *p_member, PropertyInfo &r_prop_info, bool &r_exported) {
StringName name = p_member->get_name();
@@ -1540,6 +1616,7 @@ bool CSharpScript::_get_member_export(GDMonoClass *p_class, GDMonoClassMember *p
return true;
}
+#endif
void CSharpScript::_clear() {
@@ -1562,7 +1639,7 @@ Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, i
MonoObject *result = method->invoke(NULL, p_args);
if (result) {
- return GDMonoMarshal::mono_object_to_variant(result, method->get_return_type());
+ return GDMonoMarshal::mono_object_to_variant(result);
} else {
return Variant();
}
@@ -1609,7 +1686,7 @@ bool CSharpScript::_set(const StringName &p_name, const Variant &p_value) {
void CSharpScript::_get_property_list(List<PropertyInfo> *p_properties) const {
- p_properties->push_back(PropertyInfo(Variant::STRING, CSharpLanguage::singleton->string_names._script_source, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_properties->push_back(PropertyInfo(Variant::STRING, CSharpLanguage::singleton->string_names._script_source, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
}
void CSharpScript::_bind_methods() {
@@ -1847,7 +1924,7 @@ void CSharpScript::set_source_code(const String &p_code) {
bool CSharpScript::has_method(const StringName &p_method) const {
- return script_class->has_method(p_method);
+ return script_class->has_fetched_method_unknown_params(p_method);
}
Error CSharpScript::reload(bool p_keep_state) {
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index f18daacf94..f18e339e18 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef CSHARP_SCRIPT_H
#define CSHARP_SCRIPT_H
@@ -104,7 +105,9 @@ class CSharpScript : public Script {
void _clear();
bool _update_exports();
+#ifdef TOOLS_ENABLED
bool _get_member_export(GDMonoClass *p_class, GDMonoClassMember *p_member, PropertyInfo &r_prop_info, bool &r_exported);
+#endif
CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
@@ -169,8 +172,6 @@ class CSharpInstance : public ScriptInstance {
bool base_ref;
bool ref_dying;
- void _ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount);
-
void _reference_owner_unsafe();
void _unreference_owner_unsafe();
@@ -302,7 +303,7 @@ public:
/* TODO */ virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
/* TODO */ virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
/* TODO */ virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { return ""; }
- /* TODO */ virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
+ virtual Vector<StackInfo> debug_get_current_stack_info();
/* PROFILING FUNCTIONS */
/* TODO */ virtual void profiling_start() {}
@@ -334,6 +335,10 @@ public:
virtual void *alloc_instance_binding_data(Object *p_object);
virtual void free_instance_binding_data(void *p_data);
+#ifdef DEBUG_ENABLED
+ Vector<StackInfo> stack_trace_get_info(MonoObject *p_stack_trace);
+#endif
+
CSharpLanguage();
~CSharpLanguage();
};
diff --git a/modules/mono/doc_classes/@C#.xml b/modules/mono/doc_classes/@C#.xml
index 5fcbf36a2b..0f33c76eb2 100644
--- a/modules/mono/doc_classes/@C#.xml
+++ b/modules/mono/doc_classes/@C#.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="@C#" category="Core" version="3.0-beta">
+<class name="@C#" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml
index 853ef28731..3efe71f1b3 100644
--- a/modules/mono/doc_classes/CSharpScript.xml
+++ b/modules/mono/doc_classes/CSharpScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSharpScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="CSharpScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml
index 2696a0bb4b..1e5edf2a2a 100644
--- a/modules/mono/doc_classes/GodotSharp.xml
+++ b/modules/mono/doc_classes/GodotSharp.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GodotSharp" inherits="Object" category="Core" version="3.0-beta">
+<class name="GodotSharp" inherits="Object" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 0e41e00f30..62c7a94755 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "bindings_generator.h"
#ifdef DEBUG_METHODS_ENABLED
@@ -249,8 +250,15 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
const TypeInterface *return_type = _get_type_by_name_or_placeholder(imethod.return_type);
- String im_sig = "IntPtr " CS_PARAM_METHODBIND ", IntPtr " CS_PARAM_INSTANCE;
- String im_unique_sig = imethod.return_type.operator String() + ",IntPtr,IntPtr";
+ String im_sig;
+ String im_unique_sig;
+
+ if (p_itype.is_object_type) {
+ im_sig += "IntPtr " CS_PARAM_METHODBIND ", ";
+ im_unique_sig += imethod.return_type.operator String() + ",IntPtr,IntPtr";
+ }
+
+ im_sig += "IntPtr " CS_PARAM_INSTANCE;
// Get arguments information
int i = 0;
@@ -262,25 +270,37 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
im_sig += " arg";
im_sig += itos(i + 1);
- im_unique_sig += ",";
- im_unique_sig += get_unique_sig(*arg_type);
+ if (p_itype.is_object_type) {
+ im_unique_sig += ",";
+ im_unique_sig += get_unique_sig(*arg_type);
+ }
i++;
}
- // godot_icall_{argc}_{icallcount}
- String icall_method = ICALL_PREFIX + itos(imethod.arguments.size()) + "_" + itos(method_icalls.size());
+ String icall_method = ICALL_PREFIX;
+
+ if (p_itype.is_object_type) {
+ icall_method += itos(imethod.arguments.size()) + "_" + itos(method_icalls.size()); // godot_icall_{argc}_{icallcount}
+ } else {
+ icall_method += p_itype.name + "_" + imethod.name; // godot_icall_{Type}_{method}
+ }
InternalCall im_icall = InternalCall(p_itype.api_type, icall_method, return_type->im_type_out, im_sig, im_unique_sig);
- List<InternalCall>::Element *match = method_icalls.find(im_icall);
+ if (p_itype.is_object_type) {
+ List<InternalCall>::Element *match = method_icalls.find(im_icall);
- if (match) {
- if (p_itype.api_type != ClassDB::API_EDITOR)
- match->get().editor_only = false;
- method_icalls_map.insert(&E->get(), &match->get());
+ if (match) {
+ if (p_itype.api_type != ClassDB::API_EDITOR)
+ match->get().editor_only = false;
+ method_icalls_map.insert(&E->get(), &match->get());
+ } else {
+ List<InternalCall>::Element *added = method_icalls.push_back(im_icall);
+ method_icalls_map.insert(&E->get(), &added->get());
+ }
} else {
- List<InternalCall>::Element *added = method_icalls.push_back(im_icall);
+ List<InternalCall>::Element *added = builtin_method_icalls.push_back(im_icall);
method_icalls_map.insert(&E->get(), &added->get());
}
}
@@ -447,14 +467,14 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
compile_items.push_back(output_file);
}
- for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
- const TypeInterface &itype = E->get();
+ for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
+ const TypeInterface &itype = E.get();
if (itype.api_type == ClassDB::API_EDITOR)
continue;
- String output_file = path_join(obj_type_dir, E->get().proxy_name + ".cs");
- Error err = _generate_cs_type(E->get(), output_file);
+ String output_file = path_join(obj_type_dir, itype.proxy_name + ".cs");
+ Error err = _generate_cs_type(itype, output_file);
if (err == ERR_SKIP)
continue;
@@ -524,6 +544,8 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
ADD_INTERNAL_CALL(E->get());
for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next())
ADD_INTERNAL_CALL(E->get());
+ for (const List<InternalCall>::Element *E = builtin_method_icalls.front(); E; E = E->next())
+ ADD_INTERNAL_CALL(E->get());
#undef ADD_INTERNAL_CALL
@@ -579,14 +601,14 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir,
if (!solution.set_path(p_output_dir))
return ERR_FILE_NOT_FOUND;
- for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next()) {
- const TypeInterface &itype = E->get();
+ for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
+ const TypeInterface &itype = E.get();
if (itype.api_type != ClassDB::API_EDITOR)
continue;
- String output_file = path_join(obj_type_dir, E->get().proxy_name + ".cs");
- Error err = _generate_cs_type(E->get(), output_file);
+ String output_file = path_join(obj_type_dir, itype.proxy_name + ".cs");
+ Error err = _generate_cs_type(itype, output_file);
if (err == ERR_SKIP)
continue;
@@ -615,6 +637,8 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir,
cs_icalls_content.push_back(m_icall.im_sig + ");\n"); \
}
+ // No need to add builtin_method_icalls. Builtin types are core only
+
for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next())
ADD_INTERNAL_CALL(E->get());
for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next())
@@ -693,9 +717,9 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.push_back(itype.is_singleton ? "static class " : "class ");
output.push_back(itype.proxy_name);
- if (itype.is_singleton || !itype.is_object_type) {
+ if (itype.is_singleton) {
output.push_back("\n");
- } else if (!is_derived_type) {
+ } else if (!is_derived_type || !itype.is_object_type /* assuming only object types inherit */) {
output.push_back(" : IDisposable\n");
} else if (obj_types.has(itype.base_name)) {
output.push_back(" : ");
@@ -837,7 +861,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.push_back(MEMBER_BEGIN "public void Dispose()\n" OPEN_BLOCK_L2 "Dispose(true);\n" INDENT3 "GC.SuppressFinalize(this);\n" CLOSE_BLOCK_L2);
// Add the virtual Dispose
- output.push_back(MEMBER_BEGIN "public virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2
+ output.push_back(MEMBER_BEGIN "protected virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2
"if (disposed) return;\n" INDENT3
"if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3 "NativeCalls.godot_icall_");
output.push_back(itype.proxy_name);
@@ -928,7 +952,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.push_back(MEMBER_BEGIN "public void Dispose()\n" OPEN_BLOCK_L2 "Dispose(true);\n" INDENT3 "GC.SuppressFinalize(this);\n" CLOSE_BLOCK_L2);
// Add the virtual Dispose
- output.push_back(MEMBER_BEGIN "public virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2
+ output.push_back(MEMBER_BEGIN "protected virtual void Dispose(bool disposing)\n" OPEN_BLOCK_L2
"if (disposed) return;\n" INDENT3
"if (" BINDINGS_PTR_FIELD " != IntPtr.Zero)\n" OPEN_BLOCK_L3
"if (" CS_FIELD_MEMORYOWN ")\n" OPEN_BLOCK_L4 CS_FIELD_MEMORYOWN
@@ -944,7 +968,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
return ERR_BUG;
}
- Map<StringName, TypeInterface>::Element *object_itype = obj_types.find("Object");
+ OrderedHashMap<StringName, TypeInterface>::Element object_itype = obj_types.find("Object");
if (!object_itype) {
ERR_PRINT("BUG: Object type interface not found!");
@@ -952,7 +976,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
output.push_back(MEMBER_BEGIN "public " CS_CLASS_SIGNALAWAITER " ToSignal(");
- output.push_back(object_itype->get().cs_type);
+ output.push_back(object_itype.get().cs_type);
output.push_back(" source, string signal)\n" OPEN_BLOCK_L2
"return new " CS_CLASS_SIGNALAWAITER "(source, signal, this);\n" CLOSE_BLOCK_L2);
}
@@ -998,9 +1022,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
// Search it in base types too
const TypeInterface *current_type = &p_itype;
while (!setter && current_type->base_name != StringName()) {
- Map<StringName, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
- ERR_FAIL_NULL_V(base_match, ERR_BUG);
- current_type = &base_match->get();
+ OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name);
+ ERR_FAIL_COND_V(!base_match, ERR_BUG);
+ current_type = &base_match.get();
setter = current_type->find_method_by_name(p_iprop.setter);
}
@@ -1009,9 +1033,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
// Search it in base types too
current_type = &p_itype;
while (!getter && current_type->base_name != StringName()) {
- Map<StringName, TypeInterface>::Element *base_match = obj_types.find(current_type->base_name);
- ERR_FAIL_NULL_V(base_match, ERR_BUG);
- current_type = &base_match->get();
+ OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name);
+ ERR_FAIL_COND_V(!base_match, ERR_BUG);
+ current_type = &base_match.get();
getter = current_type->find_method_by_name(p_iprop.getter);
}
@@ -1121,10 +1145,14 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
String method_bind_field = "method_bind_" + itos(p_method_bind_count);
- String icall_params = method_bind_field + ", " + sformat(p_itype.cs_in, "this");
String arguments_sig;
String cs_in_statements;
+ String icall_params;
+ if (p_itype.is_object_type)
+ icall_params += method_bind_field + ", ";
+ icall_params += sformat(p_itype.cs_in, "this");
+
List<String> default_args_doc;
// Retrieve information from the arguments
@@ -1199,9 +1227,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Generate method
{
- if (!p_imethod.is_virtual && !p_imethod.requires_object_call) {
- p_output.push_back(MEMBER_BEGIN "private ");
- p_output.push_back(p_itype.is_singleton ? "static IntPtr " : "IntPtr ");
+ if (p_itype.is_object_type && !p_imethod.is_virtual && !p_imethod.requires_object_call) {
+ p_output.push_back(MEMBER_BEGIN "private static IntPtr ");
p_output.push_back(method_bind_field + " = " CS_CLASS_NATIVECALLS "." ICALL_GET_METHODBIND "(" BINDINGS_NATIVE_NAME_FIELD ", \"");
p_output.push_back(p_imethod.name);
p_output.push_back("\");\n");
@@ -1323,8 +1350,8 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
generated_icall_funcs.clear();
- for (Map<StringName, TypeInterface>::Element *type_elem = obj_types.front(); type_elem; type_elem = type_elem->next()) {
- const TypeInterface &itype = type_elem->get();
+ for (OrderedHashMap<StringName, TypeInterface>::Element type_elem = obj_types.front(); type_elem; type_elem = type_elem.next()) {
+ const TypeInterface &itype = type_elem.get();
List<InternalCall> &custom_icalls = itype.api_type == ClassDB::API_EDITOR ? editor_custom_icalls : core_custom_icalls;
@@ -1380,6 +1407,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
output.push_back(itos(GDMono::get_singleton()->get_api_editor_hash()) +
"; }\n#endif // TOOLS_ENABLED\n");
output.push_back("void register_generated_icalls() " OPEN_BLOCK);
+ output.push_back("\tgodot_register_header_icalls();");
#define ADD_INTERNAL_CALL_REGISTRATION(m_icall) \
{ \
@@ -1442,6 +1470,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
output.push_back("#endif\n");
}
+ for (const List<InternalCall>::Element *E = builtin_method_icalls.front(); E; E = E->next())
+ ADD_INTERNAL_CALL_REGISTRATION(E->get());
+
#undef ADD_INTERNAL_CALL_REGISTRATION
output.push_back(CLOSE_BLOCK "}\n");
@@ -1517,6 +1548,9 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
i++;
}
+ if (!p_itype.is_object_type)
+ return OK; // no auto-generated icall functions for builtin types
+
const Map<const MethodInterface *, const InternalCall *>::Element *match = method_icalls_map.find(&p_imethod);
ERR_FAIL_NULL_V(match, ERR_BUG);
@@ -1630,20 +1664,20 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_null(const StringName &p_cname) {
- const Map<StringName, TypeInterface>::Element *match = builtin_types.find(p_cname);
+ const Map<StringName, TypeInterface>::Element *builtin_type_match = builtin_types.find(p_cname);
- if (match)
- return &match->get();
+ if (builtin_type_match)
+ return &builtin_type_match->get();
- match = obj_types.find(p_cname);
+ const OrderedHashMap<StringName, TypeInterface>::Element obj_type_match = obj_types.find(p_cname);
- if (match)
- return &match->get();
+ if (obj_type_match)
+ return &obj_type_match.get();
- match = enum_types.find(p_cname);
+ const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(p_cname);
- if (match)
- return &match->get();
+ if (enum_match)
+ return &enum_match->get();
return NULL;
}
@@ -1810,7 +1844,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
imethod.return_type = name_cache.type_void;
// Actually, more methods like this may be added in the future,
- // which could actually will return something differnet.
+ // which could actually will return something different.
// Let's put this to notify us if that ever happens.
if (itype.cname != name_cache.type_Object || imethod.name != "free") {
if (verbose_output) {
@@ -2112,36 +2146,34 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
#undef INSERT_STRUCT_TYPE
-#define INSERT_PRIMITIVE_TYPE(m_type) \
- { \
- itype = TypeInterface::create_value_type(String(#m_type)); \
- itype.c_arg_in = "&%s"; \
- itype.c_type_in = #m_type; \
- itype.c_type_out = #m_type; \
- itype.im_type_in = #m_type; \
- itype.im_type_out = #m_type; \
- builtin_types.insert(itype.cname, itype); \
- }
-
- INSERT_PRIMITIVE_TYPE(bool)
- //INSERT_PRIMITIVE_TYPE(int)
+ // bool
+ itype = TypeInterface::create_value_type(String("bool"));
+ itype.c_arg_in = "&%s";
+ // /* MonoBoolean <---> bool
+ itype.c_in = "\t%0 %1_in = (%0)%1;\n";
+ itype.c_out = "\treturn (%0)%1;\n";
+ itype.c_type = "bool";
+ // */
+ itype.c_type_in = "MonoBoolean";
+ itype.c_type_out = itype.c_type_in;
+ itype.im_type_in = itype.name;
+ itype.im_type_out = itype.name;
+ builtin_types.insert(itype.cname, itype);
// int
itype = TypeInterface::create_value_type(String("int"));
itype.c_arg_in = "&%s_in";
- //* ptrcall only supports int64_t and uint64_t
+ // /* ptrcall only supports int64_t and uint64_t
itype.c_in = "\t%0 %1_in = (%0)%1;\n";
itype.c_out = "\treturn (%0)%1;\n";
itype.c_type = "int64_t";
- //*/
- itype.c_type_in = itype.name;
- itype.c_type_out = itype.name;
+ // */
+ itype.c_type_in = "int32_t";
+ itype.c_type_out = itype.c_type_in;
itype.im_type_in = itype.name;
itype.im_type_out = itype.name;
builtin_types.insert(itype.cname, itype);
-#undef INSERT_PRIMITIVE_TYPE
-
// real_t
itype = TypeInterface();
#ifdef REAL_T_IS_DOUBLE
@@ -2483,8 +2515,8 @@ void BindingsGenerator::initialize() {
_generate_header_icalls();
- for (Map<StringName, TypeInterface>::Element *E = obj_types.front(); E; E = E->next())
- _generate_method_icalls(E->get());
+ for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next())
+ _generate_method_icalls(E.get());
_generate_method_icalls(builtin_types["NodePath"]);
_generate_method_icalls(builtin_types["RID"]);
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 9da7add867..9b5a9cea88 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef BINDINGS_GENERATOR_H
#define BINDINGS_GENERATOR_H
@@ -428,10 +429,11 @@ class BindingsGenerator {
static bool verbose_output;
+ OrderedHashMap<StringName, TypeInterface> obj_types;
+
Map<StringName, TypeInterface> placeholder_types;
Map<StringName, TypeInterface> builtin_types;
Map<StringName, TypeInterface> enum_types;
- Map<StringName, TypeInterface> obj_types;
List<EnumInterface> global_enums;
List<ConstantInterface> global_constants;
@@ -439,6 +441,7 @@ class BindingsGenerator {
Map<StringName, String> extra_members;
List<InternalCall> method_icalls;
+ List<InternalCall> builtin_method_icalls;
Map<const MethodInterface *, const InternalCall *> method_icalls_map;
List<const InternalCall *> generated_icall_funcs;
@@ -501,8 +504,8 @@ class BindingsGenerator {
const TypeInterface *_get_type_by_name_or_null(const StringName &p_cname);
const TypeInterface *_get_type_by_name_or_placeholder(const StringName &p_cname);
- void _default_argument_from_variant(const Variant &p_var, ArgumentInterface &r_iarg);
- void _populate_builtin_type(TypeInterface &r_type, Variant::Type vtype);
+ void _default_argument_from_variant(const Variant &p_val, ArgumentInterface &r_iarg);
+ void _populate_builtin_type(TypeInterface &r_itype, Variant::Type vtype);
void _populate_object_type_interfaces();
void _populate_builtin_type_interfaces();
@@ -511,14 +514,14 @@ class BindingsGenerator {
Error _generate_cs_type(const TypeInterface &itype, const String &p_output_file);
- Error _generate_cs_property(const TypeInterface &p_itype, const PropertyInterface &p_prop_doc, List<String> &p_output);
+ Error _generate_cs_property(const TypeInterface &p_itype, const PropertyInterface &p_iprop, List<String> &p_output);
Error _generate_cs_method(const TypeInterface &p_itype, const MethodInterface &p_imethod, int &p_method_bind_count, List<String> &p_output);
void _generate_global_constants(List<String> &p_output);
Error _generate_glue_method(const TypeInterface &p_itype, const MethodInterface &p_imethod, List<String> &p_output);
- Error _save_file(const String &path, const List<String> &content);
+ Error _save_file(const String &p_path, const List<String> &p_content);
BindingsGenerator() {}
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 89e72e5c4b..e4269b0aec 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "csharp_project.h"
#include "os/os.h"
diff --git a/modules/mono/editor/csharp_project.h b/modules/mono/editor/csharp_project.h
index 59277664b2..381dd17e02 100644
--- a/modules/mono/editor/csharp_project.h
+++ b/modules/mono/editor/csharp_project.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef CSHARP_PROJECT_H
#define CSHARP_PROJECT_H
diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp
index 993e8af581..6b41b10981 100644
--- a/modules/mono/editor/godotsharp_builds.cpp
+++ b/modules/mono/editor/godotsharp_builds.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "godotsharp_builds.h"
#include "main/main.h"
diff --git a/modules/mono/editor/godotsharp_builds.h b/modules/mono/editor/godotsharp_builds.h
index 956f8f6253..5d2390ecd9 100644
--- a/modules/mono/editor/godotsharp_builds.h
+++ b/modules/mono/editor/godotsharp_builds.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOTSHARP_BUILDS_H
#define GODOTSHARP_BUILDS_H
diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp
index f964fac8e9..0ef3adfdd0 100644
--- a/modules/mono/editor/godotsharp_editor.cpp
+++ b/modules/mono/editor/godotsharp_editor.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "godotsharp_editor.h"
#include "core/os/os.h"
@@ -111,6 +112,21 @@ void GodotSharpEditor::_remove_create_sln_menu_option() {
bottom_panel_btn->show();
}
+void GodotSharpEditor::_show_about_dialog() {
+
+ bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start");
+ about_dialog_checkbox->set_pressed(show_on_start);
+ about_dialog->popup_centered_minsize();
+}
+
+void GodotSharpEditor::_toggle_about_dialog_on_start(bool p_enabled) {
+
+ bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start");
+ if (show_on_start != p_enabled) {
+ EditorSettings::get_singleton()->set_setting("mono/editor/show_info_on_start", p_enabled);
+ }
+}
+
void GodotSharpEditor::_menu_option_pressed(int p_id) {
switch (p_id) {
@@ -118,15 +134,37 @@ void GodotSharpEditor::_menu_option_pressed(int p_id) {
_create_project_solution();
} break;
+ case MENU_ABOUT_CSHARP: {
+
+ _show_about_dialog();
+ } break;
default:
ERR_FAIL();
}
}
+void GodotSharpEditor::_notification(int p_notification) {
+
+ switch (p_notification) {
+
+ case NOTIFICATION_READY: {
+
+ bool show_info_dialog = EDITOR_GET("mono/editor/show_info_on_start");
+ if (show_info_dialog) {
+ about_dialog->set_exclusive(true);
+ _show_about_dialog();
+ // Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive then.
+ about_dialog->set_exclusive(false);
+ }
+ }
+ }
+}
+
void GodotSharpEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution);
ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option);
+ ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start);
ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed);
}
@@ -150,7 +188,7 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int
if (p_line >= 0) {
args.push_back("-g");
- args.push_back(script_path + ":" + itos(p_line) + ":" + itos(p_col));
+ args.push_back(script_path + ":" + itos(p_line + 1) + ":" + itos(p_col));
} else {
args.push_back(script_path);
}
@@ -169,6 +207,11 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int
monodevel_instance = memnew(MonoDevelopInstance(GodotSharpDirs::get_project_sln_path()));
String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
+
+ if (p_line >= 0) {
+ script_path += ";" + itos(p_line + 1) + ";" + itos(p_col);
+ }
+
monodevel_instance->execute(script_path);
} break;
default:
@@ -204,6 +247,55 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
menu_button->set_text(TTR("Mono"));
menu_popup = menu_button->get_popup();
+ // TODO: Remove or edit this info dialog once Mono support is no longer in alpha
+ {
+ menu_popup->add_item(TTR("About C# support"), MENU_ABOUT_CSHARP);
+ about_dialog = memnew(AcceptDialog);
+ editor->get_gui_base()->add_child(about_dialog);
+ about_dialog->set_title("Important: C# support is not feature-complete");
+
+ // We don't use set_text() as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
+ // we'll add. Instead we add containers and a new autowrapped Label inside.
+
+ // Main VBoxContainer (icon + label on top, checkbox at bottom)
+ VBoxContainer *about_vbc = memnew(VBoxContainer);
+ about_dialog->add_child(about_vbc);
+
+ // HBoxContainer for icon + label
+ HBoxContainer *about_hbc = memnew(HBoxContainer);
+ about_vbc->add_child(about_hbc);
+
+ TextureRect *about_icon = memnew(TextureRect);
+ about_hbc->add_child(about_icon);
+ Ref<Texture> about_icon_tex = about_icon->get_icon("NodeWarning", "EditorIcons");
+ about_icon->set_texture(about_icon_tex);
+
+ Label *about_label = memnew(Label);
+ about_hbc->add_child(about_label);
+ about_label->set_custom_minimum_size(Size2(600, 150) * EDSCALE);
+ about_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ about_label->set_autowrap(true);
+ String about_text =
+ String("C# support in Godot Engine is a brand new feature and a work in progress.\n") +
+ "It is at the alpha stage and thus not suitable for use in production.\n\n" +
+ "As of Godot 3.0, C# support is not feature-complete and can crash in some situations. " +
+ "Bugs and usability issues will be addressed gradually over 3.0.x and 3.x releases.\n" +
+ "The main missing feature is the ability to export games using C# assemblies - you will therefore be able to develop and run games in the editor, " +
+ "but not to share them as standalone binaries. This feature is of course high on the priority list and should be available in 3.0.1.\n\n" +
+ "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, Mono version, IDE, etc.:\n\n" +
+ " https://github.com/godotengine/godot/issues\n\n" +
+ "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";
+ about_label->set_text(about_text);
+
+ EDITOR_DEF("mono/editor/show_info_on_start", true);
+
+ // CheckBox in main container
+ about_dialog_checkbox = memnew(CheckBox);
+ about_vbc->add_child(about_dialog_checkbox);
+ about_dialog_checkbox->set_text("Show this warning when starting the editor");
+ about_dialog_checkbox->connect("toggled", this, "_toggle_about_dialog_on_start");
+ }
+
String sln_path = GodotSharpDirs::get_project_sln_path();
String csproj_path = GodotSharpDirs::get_project_csproj_path();
diff --git a/modules/mono/editor/godotsharp_editor.h b/modules/mono/editor/godotsharp_editor.h
index f9b4fb42fb..81c49aec30 100644
--- a/modules/mono/editor/godotsharp_editor.h
+++ b/modules/mono/editor/godotsharp_editor.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOTSHARP_EDITOR_H
#define GODOTSHARP_EDITOR_H
@@ -43,6 +44,8 @@ class GodotSharpEditor : public Node {
PopupMenu *menu_popup;
AcceptDialog *error_dialog;
+ AcceptDialog *about_dialog;
+ CheckBox *about_dialog_checkbox;
ToolButton *bottom_panel_btn;
@@ -53,17 +56,21 @@ class GodotSharpEditor : public Node {
bool _create_project_solution();
void _remove_create_sln_menu_option();
+ void _show_about_dialog();
+ void _toggle_about_dialog_on_start(bool p_enabled);
void _menu_option_pressed(int p_id);
static GodotSharpEditor *singleton;
protected:
+ void _notification(int p_notification);
static void _bind_methods();
public:
enum MenuOptions {
- MENU_CREATE_SLN
+ MENU_CREATE_SLN,
+ MENU_ABOUT_CSHARP,
};
enum ExternalEditor {
diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp
index 7c8d822037..ab62c62616 100644
--- a/modules/mono/editor/mono_bottom_panel.cpp
+++ b/modules/mono/editor/mono_bottom_panel.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "mono_bottom_panel.h"
#include "../csharp_script.h"
@@ -196,7 +197,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) {
toolbar_hbc->set_h_size_flags(SIZE_EXPAND_FILL);
panel_builds_tab->add_child(toolbar_hbc);
- ToolButton *build_project_btn = memnew(ToolButton);
+ Button *build_project_btn = memnew(Button);
build_project_btn->set_text(TTR("Build Project"));
build_project_btn->set_focus_mode(FOCUS_NONE);
build_project_btn->connect("pressed", this, "_build_project_pressed");
diff --git a/modules/mono/editor/mono_bottom_panel.h b/modules/mono/editor/mono_bottom_panel.h
index d7573361ab..a44d3a9af8 100644
--- a/modules/mono/editor/mono_bottom_panel.h
+++ b/modules/mono/editor/mono_bottom_panel.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef MONO_BOTTOM_PANEL_H
#define MONO_BOTTOM_PANEL_H
diff --git a/modules/mono/editor/mono_build_info.h b/modules/mono/editor/mono_build_info.h
index 115fc9ea55..4806764a61 100644
--- a/modules/mono/editor/mono_build_info.h
+++ b/modules/mono/editor/mono_build_info.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef MONO_BUILD_INFO_H
#define MONO_BUILD_INFO_H
diff --git a/modules/mono/editor/monodevelop_instance.cpp b/modules/mono/editor/monodevelop_instance.cpp
index 8dc308b113..48a285561d 100644
--- a/modules/mono/editor/monodevelop_instance.cpp
+++ b/modules/mono/editor/monodevelop_instance.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "monodevelop_instance.h"
#include "../mono_gd/gd_mono.h"
@@ -34,6 +35,8 @@
void MonoDevelopInstance::execute(const Vector<String> &p_files) {
+ _GDMONO_SCOPE_DOMAIN_(TOOLS_DOMAIN)
+
ERR_FAIL_NULL(execute_method);
ERR_FAIL_COND(gc_handle.is_null());
diff --git a/modules/mono/editor/monodevelop_instance.h b/modules/mono/editor/monodevelop_instance.h
index 783d12325f..552c10a61d 100644
--- a/modules/mono/editor/monodevelop_instance.h
+++ b/modules/mono/editor/monodevelop_instance.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef MONODEVELOP_INSTANCE_H
#define MONODEVELOP_INSTANCE_H
@@ -42,7 +43,7 @@ class MonoDevelopInstance {
public:
void execute(const Vector<String> &p_files);
- void execute(const String &p_files);
+ void execute(const String &p_file);
MonoDevelopInstance(const String &p_solution);
};
diff --git a/modules/mono/editor/net_solution.cpp b/modules/mono/editor/net_solution.cpp
index b9df5b5327..dab96e44e9 100644
--- a/modules/mono/editor/net_solution.cpp
+++ b/modules/mono/editor/net_solution.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "net_solution.h"
#include "os/dir_access.h"
diff --git a/modules/mono/editor/net_solution.h b/modules/mono/editor/net_solution.h
index 21af1938cb..293e86917a 100644
--- a/modules/mono/editor/net_solution.h
+++ b/modules/mono/editor/net_solution.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef NET_SOLUTION_H
#define NET_SOLUTION_H
diff --git a/modules/mono/glue/builtin_types_glue.h b/modules/mono/glue/builtin_types_glue.h
new file mode 100644
index 0000000000..460de84b65
--- /dev/null
+++ b/modules/mono/glue/builtin_types_glue.h
@@ -0,0 +1,59 @@
+#ifndef BUILTIN_TYPES_GLUE_H
+#define BUILTIN_TYPES_GLUE_H
+
+#include "core/node_path.h"
+#include "core/rid.h"
+
+#include <mono/metadata/object.h>
+
+#include "../mono_gd/gd_mono_marshal.h"
+
+MonoBoolean godot_icall_NodePath_is_absolute(NodePath *p_ptr) {
+ return (MonoBoolean)p_ptr->is_absolute();
+}
+
+uint32_t godot_icall_NodePath_get_name_count(NodePath *p_ptr) {
+ return p_ptr->get_name_count();
+}
+
+MonoString *godot_icall_NodePath_get_name(NodePath *p_ptr, uint32_t p_idx) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_name(p_idx));
+}
+
+uint32_t godot_icall_NodePath_get_subname_count(NodePath *p_ptr) {
+ return p_ptr->get_subname_count();
+}
+
+MonoString *godot_icall_NodePath_get_subname(NodePath *p_ptr, uint32_t p_idx) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_subname(p_idx));
+}
+
+MonoString *godot_icall_NodePath_get_concatenated_subnames(NodePath *p_ptr) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_concatenated_subnames());
+}
+
+NodePath *godot_icall_NodePath_get_as_property_path(NodePath *p_ptr) {
+ return memnew(NodePath(p_ptr->get_as_property_path()));
+}
+
+MonoBoolean godot_icall_NodePath_is_empty(NodePath *p_ptr) {
+ return (MonoBoolean)p_ptr->is_empty();
+}
+
+uint32_t godot_icall_RID_get_id(RID *p_ptr) {
+ return p_ptr->get_id();
+}
+
+void godot_register_builtin_type_icalls() {
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_as_property_path", (void *)godot_icall_NodePath_get_as_property_path);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_concatenated_subnames", (void *)godot_icall_NodePath_get_concatenated_subnames);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_name", (void *)godot_icall_NodePath_get_name);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_name_count", (void *)godot_icall_NodePath_get_name_count);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_subname", (void *)godot_icall_NodePath_get_subname);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_subname_count", (void *)godot_icall_NodePath_get_subname_count);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_is_absolute", (void *)godot_icall_NodePath_is_absolute);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_is_empty", (void *)godot_icall_NodePath_is_empty);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_RID_get_id", (void *)godot_icall_RID_get_id);
+}
+
+#endif // BUILTIN_TYPES_GLUE_H
diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs
index db0e1fb744..f9e31e9703 100644
--- a/modules/mono/glue/cs_files/Color.cs
+++ b/modules/mono/glue/cs_files/Color.cs
@@ -336,7 +336,7 @@ namespace Godot
this.r = (rgba & 0xFF) / 255.0f;
}
- private static float _parse_col(string str, int ofs)
+ private static int _parse_col(string str, int ofs)
{
int ig = 0;
@@ -415,17 +415,17 @@ namespace Godot
if (alpha)
{
- if ((int)_parse_col(color, 0) < 0)
+ if (_parse_col(color, 0) < 0)
return false;
}
int from = alpha ? 2 : 0;
- if ((int)_parse_col(color, from + 0) < 0)
+ if (_parse_col(color, from + 0) < 0)
return false;
- if ((int)_parse_col(color, from + 2) < 0)
+ if (_parse_col(color, from + 2) < 0)
return false;
- if ((int)_parse_col(color, from + 4) < 0)
+ if (_parse_col(color, from + 4) < 0)
return false;
return true;
@@ -467,10 +467,10 @@ namespace Godot
if (alpha)
{
- a = _parse_col(rgba, 0);
+ a = _parse_col(rgba, 0) / 255f;
if (a < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Alpha is " + a + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Alpha part is not valid hexadecimal: " + rgba);
}
else
{
@@ -479,20 +479,20 @@ namespace Godot
int from = alpha ? 2 : 0;
- r = _parse_col(rgba, from + 0);
+ r = _parse_col(rgba, from + 0) / 255f;
if (r < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Red is " + r + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Red part is not valid hexadecimal: " + rgba);
- g = _parse_col(rgba, from + 2);
+ g = _parse_col(rgba, from + 2) / 255f;
if (g < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Green is " + g + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Green part is not valid hexadecimal: " + rgba);
- b = _parse_col(rgba, from + 4);
+ b = _parse_col(rgba, from + 4) / 255f;
if (b < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Blue is " + b + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba);
}
public static bool operator ==(Color left, Color right)
diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs
new file mode 100644
index 0000000000..ffaaf00837
--- /dev/null
+++ b/modules/mono/glue/cs_files/DebuggingUtils.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+
+namespace Godot
+{
+ internal static class DebuggingUtils
+ {
+ internal static void AppendTypeName(this StringBuilder sb, Type type)
+ {
+ if (type.IsPrimitive)
+ sb.Append(type.Name);
+ else if (type == typeof(void))
+ sb.Append("void");
+ else
+ sb.Append(type.ToString());
+
+ sb.Append(" ");
+ }
+
+ public static void GetStackFrameInfo(StackFrame frame, out string fileName, out int fileLineNumber, out string methodDecl)
+ {
+ fileName = frame.GetFileName();
+ fileLineNumber = frame.GetFileLineNumber();
+
+ MethodBase methodBase = frame.GetMethod();
+
+ if (methodBase == null)
+ {
+ methodDecl = string.Empty;
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ if (methodBase is MethodInfo)
+ sb.AppendTypeName(((MethodInfo)methodBase).ReturnType);
+
+ sb.Append(methodBase.DeclaringType.FullName);
+ sb.Append(".");
+ sb.Append(methodBase.Name);
+
+ if (methodBase.IsGenericMethod)
+ {
+ Type[] genericParams = methodBase.GetGenericArguments();
+
+ sb.Append("<");
+
+ for (int j = 0; j < genericParams.Length; j++)
+ {
+ if (j > 0)
+ sb.Append(", ");
+
+ sb.AppendTypeName(genericParams[j]);
+ }
+
+ sb.Append(">");
+ }
+
+ sb.Append("(");
+
+ bool varArgs = (methodBase.CallingConvention & CallingConventions.VarArgs) != 0;
+
+ ParameterInfo[] parameter = methodBase.GetParameters();
+
+ for (int i = 0; i < parameter.Length; i++)
+ {
+ if (i > 0)
+ sb.Append(", ");
+
+ if (i == parameter.Length - 1 && varArgs)
+ sb.Append("params ");
+
+ sb.AppendTypeName(parameter[i].ParameterType);
+ }
+
+ sb.Append(")");
+
+ methodDecl = sb.ToString();
+ }
+ }
+}
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index 6951ace4fc..476396e9a3 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -71,7 +71,7 @@ namespace Godot
public static int Decimals(float step)
{
- return Decimals(step);
+ return Decimals((decimal)step);
}
public static int Decimals(decimal step)
diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs
index 6365e71826..b347c0835a 100644
--- a/modules/mono/glue/cs_files/Plane.cs
+++ b/modules/mono/glue/cs_files/Plane.cs
@@ -91,7 +91,7 @@ namespace Godot
float dist = (normal.Dot(from) - d) / den;
- // This is a ray, before the emiting pos (from) does not exist
+ // This is a ray, before the emitting pos (from) does not exist
if (dist > Mathf.Epsilon)
return new Vector3();
diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h
index 1d64fa4d72..cedc8e9992 100644
--- a/modules/mono/glue/glue_header.h
+++ b/modules/mono/glue/glue_header.h
@@ -27,6 +27,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+#include "builtin_types_glue.h"
+
#include "../csharp_script.h"
#include "../mono_gd/gd_mono_class.h"
#include "../mono_gd/gd_mono_internals.h"
@@ -90,12 +93,6 @@ MonoString *godot_icall_NodePath_operator_String(NodePath *p_np) {
return GDMonoMarshal::mono_string_from_godot(p_np->operator String());
}
-MonoArray *godot_icall_String_md5_buffer(MonoString *p_str) {
- Vector<uint8_t> ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_buffer();
- // TODO Check possible Array/Vector<uint8_t> problem?
- return GDMonoMarshal::Array_to_mono_array(Variant(ret));
-}
-
// -- RID --
RID *godot_icall_RID_Ctor(Object *p_from) {
@@ -114,6 +111,12 @@ void godot_icall_RID_Dtor(RID *p_ptr) {
// -- String --
+MonoArray *godot_icall_String_md5_buffer(MonoString *p_str) {
+ Vector<uint8_t> ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_buffer();
+ // TODO Check possible Array/Vector<uint8_t> problem?
+ return GDMonoMarshal::Array_to_mono_array(Variant(ret));
+}
+
MonoString *godot_icall_String_md5_text(MonoString *p_str) {
String ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_text();
return GDMonoMarshal::mono_string_from_godot(ret);
@@ -302,3 +305,7 @@ MonoObject *godot_icall_Godot_weakref(Object *p_obj) {
return GDMonoUtils::create_managed_for_godot_object(CACHED_CLASS(WeakRef), Reference::get_class_static(), Object::cast_to<Object>(wref.ptr()));
}
+
+void godot_register_header_icalls() {
+ godot_register_builtin_type_icalls();
+}
diff --git a/modules/mono/godotsharp_defs.h b/modules/mono/godotsharp_defs.h
index 1679eb6242..4c26c3e6bd 100644
--- a/modules/mono/godotsharp_defs.h
+++ b/modules/mono/godotsharp_defs.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOTSHARP_DEFS_H
#define GODOTSHARP_DEFS_H
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index a2965080d6..92c5cdc5c1 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "godotsharp_dirs.h"
#include "os/os.h"
diff --git a/modules/mono/godotsharp_dirs.h b/modules/mono/godotsharp_dirs.h
index 0e484fea91..e87b5a4150 100644
--- a/modules/mono/godotsharp_dirs.h
+++ b/modules/mono/godotsharp_dirs.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GODOTSHARP_DIRS_H
#define GODOTSHARP_DIRS_H
diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp
index 5ae12f5ebf..4e82bcd03e 100644
--- a/modules/mono/mono_gc_handle.cpp
+++ b/modules/mono/mono_gc_handle.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "mono_gc_handle.h"
#include "mono_gd/gd_mono.h"
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index 565f5d4f76..9cb3ef0fbb 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef CSHARP_GC_HANDLE_H
#define CSHARP_GC_HANDLE_H
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 1152d70a04..f5febd415b 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono.h"
#include <mono/metadata/exception.h>
@@ -225,7 +226,7 @@ void GDMono::initialize() {
mono_install_unhandled_exception_hook(gdmono_unhandled_exception_hook, NULL);
- OS::get_singleton()->print("Mono: ALL IS GOOD\n");
+ OS::get_singleton()->print("Mono: INITIALIZED\n");
}
#ifndef MONO_GLUE_DISABLED
@@ -695,11 +696,13 @@ bool _GodotSharp::is_domain_loaded() {
return GDMono::get_singleton()->get_scripts_domain() != NULL;
}
-#define ENQUEUE_FOR_DISPOSAL(m_queue, m_inst) \
- m_queue.push_back(m_inst); \
- if (queue_empty) { \
- queue_empty = false; \
- call_deferred("_dispose_callback"); \
+#define ENQUEUE_FOR_DISPOSAL(m_queue, m_inst) \
+ m_queue.push_back(m_inst); \
+ if (queue_empty) { \
+ queue_empty = false; \
+ if (!is_finalizing_domain()) { /* call_deferred may not be safe here */ \
+ call_deferred("_dispose_callback"); \
+ } \
}
void _GodotSharp::queue_dispose(MonoObject *p_mono_object, Object *p_object) {
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 8b753026d7..67251778c6 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_H
#define GD_MONO_H
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index 085216a5b6..ef39b8549d 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_assembly.h"
#include <mono/metadata/mono-debug.h>
@@ -115,6 +116,37 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse
}
}
+ String name = mono_assembly_name_get_name(aname);
+ bool has_extension = name.ends_with(".dll");
+
+ if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") {
+ GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
+ if (stored_assembly) return (*stored_assembly)->get_assembly();
+
+ String path;
+ MonoAssembly *res = NULL;
+
+ for (int i = 0; i < search_dirs.size(); i++) {
+ const String &search_dir = search_dirs[i];
+
+ if (has_extension) {
+ path = search_dir.plus_file(name);
+ if (FileAccess::exists(path)) {
+ res = _load_assembly_from(name.get_basename(), path);
+ break;
+ }
+ } else {
+ path = search_dir.plus_file(name + ".dll");
+ if (FileAccess::exists(path)) {
+ res = _load_assembly_from(name, path);
+ break;
+ }
+ }
+ }
+
+ if (res) return res;
+ }
+
return NULL;
}
diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h
index 9f38202758..8a5fa19626 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.h
+++ b/modules/mono/mono_gd/gd_mono_assembly.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_ASSEMBLY_H
#define GD_MONO_ASSEMBLY_H
@@ -109,7 +110,7 @@ public:
_FORCE_INLINE_ String get_path() const { return path; }
_FORCE_INLINE_ uint64_t get_modified_time() const { return modified_time; }
- GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_class);
+ GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_name);
GDMonoClass *get_class(MonoClass *p_mono_class);
GDMonoClass *get_object_derived_class(const StringName &p_class);
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp
index b94a626f4b..b826352f02 100644
--- a/modules/mono/mono_gd/gd_mono_class.cpp
+++ b/modules/mono/mono_gd/gd_mono_class.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_class.h"
#include <mono/metadata/attrdefs.h>
@@ -88,11 +89,6 @@ Vector<MonoClassField *> GDMonoClass::get_enum_fields() {
}
#endif
-bool GDMonoClass::has_method(const StringName &p_name) {
-
- return get_method(p_name) != NULL;
-}
-
bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) {
#ifdef DEBUG_ENABLED
@@ -224,7 +220,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
methods_fetched = true;
}
-GDMonoMethod *GDMonoClass::get_method(const StringName &p_name) {
+GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p_name) {
ERR_FAIL_COND_V(!methods_fetched, NULL);
@@ -238,6 +234,11 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name) {
return NULL;
}
+bool GDMonoClass::has_fetched_method_unknown_params(const StringName &p_name) {
+
+ return get_fetched_method_unknown_params(p_name) != NULL;
+}
+
GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_count) {
MethodKey key = MethodKey(p_name, p_params_count);
@@ -302,6 +303,8 @@ GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, boo
MonoMethod *method = mono_method_desc_search_in_class(desc, mono_class);
mono_method_desc_free(desc);
+ ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, NULL);
+
return get_method(method);
}
diff --git a/modules/mono/mono_gd/gd_mono_class.h b/modules/mono/mono_gd/gd_mono_class.h
index 32350d5a87..afccf2fc63 100644
--- a/modules/mono/mono_gd/gd_mono_class.h
+++ b/modules/mono/mono_gd/gd_mono_class.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_CLASS_H
#define GD_MONO_CLASS_H
@@ -111,7 +112,8 @@ public:
Vector<MonoClassField *> get_enum_fields();
#endif
- bool has_method(const StringName &p_name);
+ GDMonoMethod *get_fetched_method_unknown_params(const StringName &p_name);
+ bool has_fetched_method_unknown_params(const StringName &p_name);
bool has_attribute(GDMonoClass *p_attr_class);
MonoObject *get_attribute(GDMonoClass *p_attr_class);
@@ -119,12 +121,11 @@ public:
void fetch_attributes();
void fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base);
- GDMonoMethod *get_method(const StringName &p_name);
- GDMonoMethod *get_method(const StringName &p_name, int p_params_count);
+ GDMonoMethod *get_method(const StringName &p_name, int p_params_count = 0);
GDMonoMethod *get_method(MonoMethod *p_raw_method);
GDMonoMethod *get_method(MonoMethod *p_raw_method, const StringName &p_name);
GDMonoMethod *get_method(MonoMethod *p_raw_method, const StringName &p_name, int p_params_count);
- GDMonoMethod *get_method_with_desc(const String &p_description, bool p_includes_namespace);
+ GDMonoMethod *get_method_with_desc(const String &p_description, bool p_include_namespace);
GDMonoField *get_field(const StringName &p_name);
const Vector<GDMonoField *> &get_all_fields();
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index f545dd28a6..3b91777ed4 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_field.h"
#include <mono/metadata/attrdefs.h>
diff --git a/modules/mono/mono_gd/gd_mono_field.h b/modules/mono/mono_gd/gd_mono_field.h
index 4458404a30..a6b368c4d6 100644
--- a/modules/mono/mono_gd/gd_mono_field.h
+++ b/modules/mono/mono_gd/gd_mono_field.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDMONOFIELD_H
#define GDMONOFIELD_H
@@ -62,7 +63,7 @@ public:
void set_value_raw(MonoObject *p_object, void *p_ptr);
void set_value_from_variant(MonoObject *p_object, const Variant &p_value);
- _FORCE_INLINE_ MonoObject *get_value(MonoObject *p_object);
+ MonoObject *get_value(MonoObject *p_object);
bool get_bool_value(MonoObject *p_object);
int get_int_value(MonoObject *p_object);
diff --git a/modules/mono/mono_gd/gd_mono_header.h b/modules/mono/mono_gd/gd_mono_header.h
index ceacc80aba..2b5110f0b9 100644
--- a/modules/mono/mono_gd/gd_mono_header.h
+++ b/modules/mono/mono_gd/gd_mono_header.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_HEADER_H
#define GD_MONO_HEADER_H
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index 95d15c3581..a1a79f957f 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godotsharp_internals.cpp */
+/* gd_mono_internals.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_internals.h"
#include "../csharp_script.h"
diff --git a/modules/mono/mono_gd/gd_mono_internals.h b/modules/mono/mono_gd/gd_mono_internals.h
index 91f6fcbbc7..abec65e7d4 100644
--- a/modules/mono/mono_gd/gd_mono_internals.h
+++ b/modules/mono/mono_gd/gd_mono_internals.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godotsharp_internals.h */
+/* gd_mono_internals.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_INTERNALS_H
#define GD_MONO_INTERNALS_H
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index f954530552..eabea8dc3c 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_log.h"
#include <mono/utils/mono-logger.h>
diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h
index 4ed5f2a255..a7e374858c 100644
--- a/modules/mono/mono_gd/gd_mono_log.h
+++ b/modules/mono/mono_gd/gd_mono_log.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_LOG_H
#define GD_MONO_LOG_H
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index c2dbbc87ff..aa1a8e39c7 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_marshal.h"
#include "gd_mono.h"
@@ -458,11 +459,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
type.type_encoding = mono_type_get_type(raw_type);
type.type_class = tclass;
- return mono_object_to_variant(p_obj, type);
-}
-
-Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
- switch (p_type.type_encoding) {
+ switch (type.type_encoding) {
case MONO_TYPE_BOOLEAN:
return (bool)unbox<MonoBoolean>(p_obj);
@@ -496,7 +493,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
} break;
case MONO_TYPE_VALUETYPE: {
- GDMonoClass *tclass = p_type.type_class;
+ GDMonoClass *tclass = type.type_class;
if (tclass == CACHED_CLASS(Vector2))
RETURN_UNBOXED_STRUCT(Vector2, p_obj);
@@ -534,7 +531,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
- MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(p_type.type_class));
+ MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(type.type_class));
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
return mono_array_to_Array((MonoArray *)p_obj);
@@ -565,7 +562,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
} break;
case MONO_TYPE_CLASS: {
- GDMonoClass *type_class = p_type.type_class;
+ GDMonoClass *type_class = type.type_class;
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
@@ -585,14 +582,14 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
} break;
case MONO_TYPE_GENERICINST: {
- if (CACHED_RAW_MONO_CLASS(Dictionary) == p_type.type_class->get_mono_ptr()) {
+ if (CACHED_RAW_MONO_CLASS(Dictionary) == type.type_class->get_mono_ptr()) {
return mono_object_to_Dictionary(p_obj);
}
} break;
}
ERR_EXPLAIN(String() + "Attempted to convert an unmarshallable managed type to Variant. Name: \'" +
- p_type.type_class->get_name() + "\' Encoding: " + itos(p_type.type_encoding));
+ type.type_class->get_name() + "\' Encoding: " + itos(type.type_encoding));
ERR_FAIL_V(Variant());
}
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index 0570415575..6572408ab5 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GDMONOMARSHAL_H
#define GDMONOMARSHAL_H
@@ -101,7 +102,6 @@ _FORCE_INLINE_ MonoObject *variant_to_mono_object(Variant p_var) {
}
Variant mono_object_to_variant(MonoObject *p_obj);
-Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type);
// Array
diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp
index 467cdbcc20..1f8e9a1926 100644
--- a/modules/mono/mono_gd/gd_mono_method.cpp
+++ b/modules/mono/mono_gd/gd_mono_method.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_method.h"
#include "gd_mono_class.h"
diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h
index b1967a99f0..14df8dcfb4 100644
--- a/modules/mono/mono_gd/gd_mono_method.h
+++ b/modules/mono/mono_gd/gd_mono_method.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONO_METHOD_H
#define GD_MONO_METHOD_H
diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp
index bc5a1d3a39..0fe527b199 100644
--- a/modules/mono/mono_gd/gd_mono_property.cpp
+++ b/modules/mono/mono_gd/gd_mono_property.cpp
@@ -139,7 +139,7 @@ bool GDMonoProperty::has_setter() {
}
void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoObject **r_exc) {
- MonoMethod *prop_method = mono_property_get_get_method(mono_property);
+ MonoMethod *prop_method = mono_property_get_set_method(mono_property);
MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), 1);
mono_array_set(params, MonoObject *, 0, p_value);
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 276a50c348..a2f0819a72 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -27,9 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "gd_mono_utils.h"
#include "os/dir_access.h"
+#include "os/os.h"
#include "project_settings.h"
#include "reference.h"
@@ -42,16 +44,20 @@ namespace GDMonoUtils {
MonoCache mono_cache;
-#define CACHE_AND_CHECK(m_var, m_val) \
- { \
- m_var = m_val; \
- if (!m_var) ERR_PRINT("Mono Cache: Member " #m_var " is null. This is really bad!"); \
+#define CACHE_AND_CHECK(m_var, m_val) \
+ { \
+ m_var = m_val; \
+ if (!m_var) { \
+ ERR_EXPLAIN("Mono Cache: Member " #m_var " is null"); \
+ ERR_FAIL(); \
+ } \
}
#define CACHE_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.class_##m_class, m_val)
#define CACHE_NS_CLASS_AND_CHECK(m_ns, m_class, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.class_##m_ns##_##m_class, m_val)
#define CACHE_RAW_MONO_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.rawclass_##m_class, m_val)
#define CACHE_FIELD_AND_CHECK(m_class, m_field, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.field_##m_class##_##m_field, m_val)
+#define CACHE_METHOD_AND_CHECK(m_class, m_method, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.method_##m_class##_##m_method, m_val)
#define CACHE_METHOD_THUNK_AND_CHECK(m_class, m_method, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.methodthunk_##m_class##_##m_method, m_val)
void MonoCache::clear_members() {
@@ -71,6 +77,13 @@ void MonoCache::clear_members() {
class_String = NULL;
class_IntPtr = NULL;
+#ifdef DEBUG_ENABLED
+ class_System_Diagnostics_StackTrace = NULL;
+ methodthunk_System_Diagnostics_StackTrace_GetFrames = NULL;
+ method_System_Diagnostics_StackTrace_ctor_bool = NULL;
+ method_System_Diagnostics_StackTrace_ctor_Exception_bool = NULL;
+#endif
+
rawclass_Dictionary = NULL;
class_Vector2 = NULL;
@@ -93,6 +106,11 @@ void MonoCache::clear_members() {
class_WeakRef = NULL;
class_MarshalUtils = NULL;
+#ifdef DEBUG_ENABLED
+ class_DebuggingUtils = NULL;
+ methodthunk_DebuggingUtils_GetStackFrameInfo = NULL;
+#endif
+
class_ExportAttribute = NULL;
field_ExportAttribute_hint = NULL;
field_ExportAttribute_hintString = NULL;
@@ -118,6 +136,12 @@ void MonoCache::clear_members() {
task_scheduler_handle = Ref<MonoGCHandle>();
}
+void MonoCache::cleanup() {
+
+ corlib_cache_updated = false;
+ godot_api_cache_updated = false;
+}
+
#define GODOT_API_CLASS(m_class) (GDMono::get_singleton()->get_api_assembly()->get_class(BINDINGS_NAMESPACE, #m_class))
void update_corlib_cache() {
@@ -136,6 +160,15 @@ void update_corlib_cache() {
CACHE_CLASS_AND_CHECK(double, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_double_class()));
CACHE_CLASS_AND_CHECK(String, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_string_class()));
CACHE_CLASS_AND_CHECK(IntPtr, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_intptr_class()));
+
+#ifdef DEBUG_ENABLED
+ CACHE_CLASS_AND_CHECK(System_Diagnostics_StackTrace, GDMono::get_singleton()->get_corlib_assembly()->get_class("System.Diagnostics", "StackTrace"));
+ CACHE_METHOD_THUNK_AND_CHECK(System_Diagnostics_StackTrace, GetFrames, (StackTrace_GetFrames)CACHED_CLASS(System_Diagnostics_StackTrace)->get_method("GetFrames")->get_thunk());
+ CACHE_METHOD_AND_CHECK(System_Diagnostics_StackTrace, ctor_bool, CACHED_CLASS(System_Diagnostics_StackTrace)->get_method_with_desc("System.Diagnostics.StackTrace:.ctor(bool)", true));
+ CACHE_METHOD_AND_CHECK(System_Diagnostics_StackTrace, ctor_Exception_bool, CACHED_CLASS(System_Diagnostics_StackTrace)->get_method_with_desc("System.Diagnostics.StackTrace:.ctor(System.Exception,bool)", true));
+#endif
+
+ mono_cache.corlib_cache_updated = true;
}
void update_godot_api_cache() {
@@ -151,7 +184,7 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color));
CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane));
CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath));
- CACHE_CLASS_AND_CHECK(RID, GODOT_API_CLASS(NodePath));
+ CACHE_CLASS_AND_CHECK(RID, GODOT_API_CLASS(RID));
CACHE_CLASS_AND_CHECK(GodotObject, GODOT_API_CLASS(Object));
CACHE_CLASS_AND_CHECK(GodotReference, GODOT_API_CLASS(Reference));
CACHE_CLASS_AND_CHECK(Node, GODOT_API_CLASS(Node));
@@ -160,6 +193,10 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(WeakRef, GODOT_API_CLASS(WeakRef));
CACHE_CLASS_AND_CHECK(MarshalUtils, GODOT_API_CLASS(MarshalUtils));
+#ifdef DEBUG_ENABLED
+ CACHE_CLASS_AND_CHECK(DebuggingUtils, GODOT_API_CLASS(DebuggingUtils));
+#endif
+
// Attributes
CACHE_CLASS_AND_CHECK(ExportAttribute, GODOT_API_CLASS(ExportAttribute));
CACHE_FIELD_AND_CHECK(ExportAttribute, hint, CACHED_CLASS(ExportAttribute)->get_field("hint"));
@@ -182,6 +219,10 @@ void update_godot_api_cache() {
CACHE_METHOD_THUNK_AND_CHECK(SignalAwaiter, FailureCallback, (SignalAwaiter_FailureCallback)GODOT_API_CLASS(SignalAwaiter)->get_method("FailureCallback", 0)->get_thunk());
CACHE_METHOD_THUNK_AND_CHECK(GodotTaskScheduler, Activate, (GodotTaskScheduler_Activate)GODOT_API_CLASS(GodotTaskScheduler)->get_method("Activate", 0)->get_thunk());
+#ifdef DEBUG_ENABLED
+ CACHE_METHOD_THUNK_AND_CHECK(DebuggingUtils, GetStackFrameInfo, (DebugUtils_StackFrameInfo)GODOT_API_CLASS(DebuggingUtils)->get_method("GetStackFrameInfo", 4)->get_thunk());
+#endif
+
{
/*
* TODO Right now we only support Dictionary<object, object>.
@@ -201,6 +242,8 @@ void update_godot_api_cache() {
MonoObject *task_scheduler = mono_object_new(SCRIPTS_DOMAIN, GODOT_API_CLASS(GodotTaskScheduler)->get_mono_ptr());
mono_runtime_object_init(task_scheduler);
mono_cache.task_scheduler_handle = MonoGCHandle::create_strong(task_scheduler);
+
+ mono_cache.corlib_cache_updated = true;
}
void clear_cache() {
@@ -365,9 +408,50 @@ String get_exception_name_and_message(MonoObject *p_ex) {
return res;
}
-void print_unhandled_exception(MonoObject *p_ex) {
- ERR_PRINT(GDMonoUtils::get_exception_name_and_message(p_ex).utf8());
- mono_print_unhandled_exception(p_ex);
+void print_unhandled_exception(MonoObject *p_exc) {
+ print_unhandled_exception(p_exc, false);
+}
+
+void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) {
+ mono_print_unhandled_exception(p_exc);
+#ifdef DEBUG_ENABLED
+ if (!ScriptDebugger::get_singleton())
+ return;
+
+ GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace);
+ MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr());
+
+ MonoBoolean need_file_info = true;
+ void *ctor_args[2] = { p_exc, &need_file_info };
+
+ MonoObject *unexpected_exc = NULL;
+ CACHED_METHOD(System_Diagnostics_StackTrace, ctor_Exception_bool)->invoke_raw(stack_trace, ctor_args, &unexpected_exc);
+
+ if (unexpected_exc != NULL) {
+ mono_print_unhandled_exception(unexpected_exc);
+
+ if (p_recursion_caution) {
+ // Called from CSharpLanguage::get_current_stack_info,
+ // so printing an error here could result in endless recursion
+ OS::get_singleton()->printerr("Mono: Method GDMonoUtils::print_unhandled_exception failed");
+ return;
+ } else {
+ ERR_FAIL();
+ }
+ }
+
+ Vector<ScriptLanguage::StackInfo> si;
+ if (stack_trace != NULL && !p_recursion_caution)
+ si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
+
+ String file = si.size() ? si[0].file : __FILE__;
+ String func = si.size() ? si[0].func : FUNCTION_STR;
+ int line = si.size() ? si[0].line : __LINE__;
+ String error_msg = "Unhandled exception";
+ String exc_msg = GDMonoUtils::get_exception_name_and_message(p_exc);
+
+ ScriptDebugger::get_singleton()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si);
+#endif
}
} // namespace GDMonoUtils
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index 3135f728ee..259da46c31 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef GD_MONOUTILS_H
#define GD_MONOUTILS_H
@@ -42,16 +43,13 @@ namespace GDMonoUtils {
typedef MonoObject *(*MarshalUtils_DictToArrays)(MonoObject *, MonoArray **, MonoArray **, MonoObject **);
typedef MonoObject *(*MarshalUtils_ArraysToDict)(MonoArray *, MonoArray *, MonoObject **);
-typedef MonoObject *(*SignalAwaiter_SignalCallback)(MonoObject *, MonoArray **, MonoObject **);
+typedef MonoObject *(*SignalAwaiter_SignalCallback)(MonoObject *, MonoArray *, MonoObject **);
typedef MonoObject *(*SignalAwaiter_FailureCallback)(MonoObject *, MonoObject **);
typedef MonoObject *(*GodotTaskScheduler_Activate)(MonoObject *, MonoObject **);
+typedef MonoArray *(*StackTrace_GetFrames)(MonoObject *, MonoObject **);
+typedef void (*DebugUtils_StackFrameInfo)(MonoObject *, MonoString **, int *, MonoString **, MonoObject **);
struct MonoCache {
- // Format for cached classes in the Godot namespace: class_<Class>
- // Macro: CACHED_CLASS(<Class>)
-
- // Format for cached classes in a different namespace: class_<Namespace>_<Class>
- // Macro: CACHED_NS_CLASS(<Namespace>, <Class>)
// -----------------------------------------------
// corlib classes
@@ -72,6 +70,13 @@ struct MonoCache {
GDMonoClass *class_String;
GDMonoClass *class_IntPtr;
+#ifdef DEBUG_ENABLED
+ GDMonoClass *class_System_Diagnostics_StackTrace;
+ StackTrace_GetFrames methodthunk_System_Diagnostics_StackTrace_GetFrames;
+ GDMonoMethod *method_System_Diagnostics_StackTrace_ctor_bool;
+ GDMonoMethod *method_System_Diagnostics_StackTrace_ctor_Exception_bool;
+#endif
+
MonoClass *rawclass_Dictionary;
// -----------------------------------------------
@@ -95,6 +100,11 @@ struct MonoCache {
GDMonoClass *class_WeakRef;
GDMonoClass *class_MarshalUtils;
+#ifdef DEBUG_ENABLED
+ GDMonoClass *class_DebuggingUtils;
+ DebugUtils_StackFrameInfo methodthunk_DebuggingUtils_GetStackFrameInfo;
+#endif
+
GDMonoClass *class_ExportAttribute;
GDMonoField *field_ExportAttribute_hint;
GDMonoField *field_ExportAttribute_hintString;
@@ -119,10 +129,16 @@ struct MonoCache {
Ref<MonoGCHandle> task_scheduler_handle;
+ bool corlib_cache_updated;
+ bool godot_api_cache_updated;
+
void clear_members();
- void cleanup() {}
+ void cleanup();
MonoCache() {
+ corlib_cache_updated = false;
+ godot_api_cache_updated = false;
+
clear_members();
}
};
@@ -166,7 +182,8 @@ MonoDomain *create_domain(const String &p_friendly_name);
String get_exception_name_and_message(MonoObject *p_ex);
-void print_unhandled_exception(MonoObject *p_ex);
+void print_unhandled_exception(MonoObject *p_exc);
+void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution);
} // namespace GDMonoUtils
@@ -174,9 +191,9 @@ void print_unhandled_exception(MonoObject *p_ex);
#define CACHED_CLASS(m_class) (GDMonoUtils::mono_cache.class_##m_class)
#define CACHED_CLASS_RAW(m_class) (GDMonoUtils::mono_cache.class_##m_class->get_mono_ptr())
-#define CACHED_NS_CLASS(m_ns, m_class) (GDMonoUtils::mono_cache.class_##m_ns##_##m_class)
#define CACHED_RAW_MONO_CLASS(m_class) (GDMonoUtils::mono_cache.rawclass_##m_class)
#define CACHED_FIELD(m_class, m_field) (GDMonoUtils::mono_cache.field_##m_class##_##m_field)
+#define CACHED_METHOD(m_class, m_method) (GDMonoUtils::mono_cache.method_##m_class##_##m_method)
#define CACHED_METHOD_THUNK(m_class, m_method) (GDMonoUtils::mono_cache.methodthunk_##m_class##_##m_method)
#ifdef REAL_T_IS_DOUBLE
diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp
index 9bc384063d..4410996546 100644
--- a/modules/mono/register_types.cpp
+++ b/modules/mono/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "engine.h"
diff --git a/modules/mono/register_types.h b/modules/mono/register_types.h
index d4f052b793..ab8a7d6463 100644
--- a/modules/mono/register_types.h
+++ b/modules/mono/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_mono_types();
void unregister_mono_types();
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index bad75224dc..b9d8520ac9 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "signal_awaiter_utils.h"
#include "csharp_script.h"
@@ -101,7 +102,7 @@ Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argc
GDMonoUtils::SignalAwaiter_SignalCallback thunk = CACHED_METHOD_THUNK(SignalAwaiter, SignalCallback);
MonoObject *ex = NULL;
- thunk(get_target(), &signal_args, &ex);
+ thunk(get_target(), signal_args, &ex);
if (ex) {
mono_print_unhandled_exception(ex);
diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h
index 97cf4238da..a6a205ff8d 100644
--- a/modules/mono/signal_awaiter_utils.h
+++ b/modules/mono/signal_awaiter_utils.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef SIGNAL_AWAITER_UTILS_H
#define SIGNAL_AWAITER_UTILS_H
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index 8d91e16c5c..9bb8da8ac0 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "mono_reg_utils.h"
#ifdef WINDOWS_ENABLED
diff --git a/modules/mono/utils/mono_reg_utils.h b/modules/mono/utils/mono_reg_utils.h
index 80270ad794..edf31f5a07 100644
--- a/modules/mono/utils/mono_reg_utils.h
+++ b/modules/mono/utils/mono_reg_utils.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef MONO_REG_UTILS_H
#define MONO_REG_UTILS_H
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp
index dfbb1b9ba4..4b77aeb54e 100644
--- a/modules/mono/utils/path_utils.cpp
+++ b/modules/mono/utils/path_utils.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "path_utils.h"
#include "os/dir_access.h"
diff --git a/modules/mono/utils/path_utils.h b/modules/mono/utils/path_utils.h
index 4e8d8f2815..184cacfac7 100644
--- a/modules/mono/utils/path_utils.h
+++ b/modules/mono/utils/path_utils.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef PATH_UTILS_H
#define PATH_UTILS_H
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 4bea504d28..8691932f9a 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "string_utils.h"
namespace {
diff --git a/modules/mono/utils/string_utils.h b/modules/mono/utils/string_utils.h
index b02abc77be..5dddaee6e8 100644
--- a/modules/mono/utils/string_utils.h
+++ b/modules/mono/utils/string_utils.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef STRING_FORMAT_H
#define STRING_FORMAT_H
diff --git a/modules/ogg/register_types.cpp b/modules/ogg/register_types.cpp
index 993b2f9e1b..dba5dcc6e2 100644
--- a/modules/ogg/register_types.cpp
+++ b/modules/ogg/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
// Dummy module as libogg is needed by other modules (vorbis, theora, opus, ...)
diff --git a/modules/ogg/register_types.h b/modules/ogg/register_types.h
index 39482dc71b..e82c90de0b 100644
--- a/modules/ogg/register_types.h
+++ b/modules/ogg/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_ogg_types();
void unregister_ogg_types();
diff --git a/modules/openssl/SCsub b/modules/openssl/SCsub
deleted file mode 100644
index 84c5e68439..0000000000
--- a/modules/openssl/SCsub
+++ /dev/null
@@ -1,696 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_openssl = env_modules.Clone()
-
-# Thirdparty source files
-if env['builtin_openssl']:
- thirdparty_dir = "#thirdparty/openssl/"
-
- thirdparty_sources = [
- "ssl/t1_lib.c",
- "ssl/t1_ext.c",
- "ssl/s3_srvr.c",
- "ssl/t1_enc.c",
- "ssl/t1_meth.c",
- "ssl/s23_clnt.c",
- "ssl/ssl_asn1.c",
- "ssl/tls_srp.c",
- "ssl/kssl.c",
- "ssl/d1_both.c",
- "ssl/t1_clnt.c",
- "ssl/bio_ssl.c",
- "ssl/d1_srtp.c",
- "ssl/t1_reneg.c",
- "ssl/ssl_cert.c",
- "ssl/s3_lib.c",
- "ssl/d1_srvr.c",
- "ssl/s23_meth.c",
- "ssl/ssl_stat.c",
- "ssl/ssl_err.c",
- "ssl/ssl_algs.c",
- "ssl/s3_cbc.c",
- "ssl/d1_clnt.c",
- "ssl/s3_pkt.c",
- "ssl/d1_meth.c",
- "ssl/s3_both.c",
- "ssl/s2_enc.c",
- "ssl/s3_meth.c",
- "ssl/s3_enc.c",
- "ssl/s23_pkt.c",
- "ssl/s2_pkt.c",
- "ssl/d1_pkt.c",
- "ssl/ssl_rsa.c",
- "ssl/s23_srvr.c",
- "ssl/s2_meth.c",
- "ssl/s3_clnt.c",
- "ssl/s23_lib.c",
- "ssl/t1_srvr.c",
- "ssl/ssl_lib.c",
- "ssl/ssl_txt.c",
- "ssl/s2_srvr.c",
- "ssl/ssl_sess.c",
- "ssl/s2_clnt.c",
- "ssl/d1_lib.c",
- "ssl/s2_lib.c",
- "ssl/ssl_err2.c",
- "ssl/ssl_ciph.c",
- "crypto/dsa/dsa_lib.c",
- "crypto/dsa/dsa_pmeth.c",
- "crypto/dsa/dsa_ossl.c",
- "crypto/dsa/dsa_gen.c",
- "crypto/dsa/dsa_asn1.c",
- "crypto/dsa/dsa_prn.c",
- "crypto/dsa/dsa_sign.c",
- "crypto/dsa/dsa_key.c",
- "crypto/dsa/dsa_vrf.c",
- "crypto/dsa/dsa_err.c",
- "crypto/dsa/dsa_ameth.c",
- "crypto/dsa/dsa_depr.c",
- "crypto/x509/x509_lu.c",
- "crypto/x509/x509cset.c",
- "crypto/x509/x509_set.c",
- "crypto/x509/x509_d2.c",
- "crypto/x509/x509_txt.c",
- "crypto/x509/x509rset.c",
- "crypto/x509/by_dir.c",
- "crypto/x509/x509_vpm.c",
- "crypto/x509/x509_vfy.c",
- "crypto/x509/x509_trs.c",
- "crypto/x509/by_file.c",
- "crypto/x509/x509_obj.c",
- "crypto/x509/x509spki.c",
- "crypto/x509/x509_v3.c",
- "crypto/x509/x509_req.c",
- "crypto/x509/x509_att.c",
- "crypto/x509/x_all.c",
- "crypto/x509/x509_ext.c",
- "crypto/x509/x509type.c",
- "crypto/x509/x509_def.c",
- "crypto/x509/x509_err.c",
- "crypto/x509/x509name.c",
- "crypto/x509/x509_r2x.c",
- "crypto/x509/x509_cmp.c",
- "crypto/asn1/x_pkey.c",
- "crypto/asn1/a_gentm.c",
- "crypto/asn1/x_sig.c",
- "crypto/asn1/t_req.c",
- "crypto/asn1/t_pkey.c",
- "crypto/asn1/p8_pkey.c",
- "crypto/asn1/a_i2d_fp.c",
- "crypto/asn1/x_val.c",
- "crypto/asn1/f_string.c",
- "crypto/asn1/p5_pbe.c",
- "crypto/asn1/bio_ndef.c",
- "crypto/asn1/a_bool.c",
- "crypto/asn1/asn1_gen.c",
- "crypto/asn1/x_algor.c",
- "crypto/asn1/bio_asn1.c",
- "crypto/asn1/asn_mime.c",
- "crypto/asn1/t_x509.c",
- "crypto/asn1/a_strex.c",
- "crypto/asn1/x_nx509.c",
- "crypto/asn1/asn1_err.c",
- "crypto/asn1/x_crl.c",
- "crypto/asn1/a_print.c",
- "crypto/asn1/a_type.c",
- "crypto/asn1/tasn_new.c",
- "crypto/asn1/n_pkey.c",
- "crypto/asn1/x_bignum.c",
- "crypto/asn1/asn_pack.c",
- "crypto/asn1/evp_asn1.c",
- "crypto/asn1/t_bitst.c",
- "crypto/asn1/x_req.c",
- "crypto/asn1/a_time.c",
- "crypto/asn1/x_name.c",
- "crypto/asn1/x_pubkey.c",
- "crypto/asn1/tasn_typ.c",
- "crypto/asn1/asn_moid.c",
- "crypto/asn1/a_utctm.c",
- "crypto/asn1/asn1_lib.c",
- "crypto/asn1/x_x509a.c",
- "crypto/asn1/a_set.c",
- "crypto/asn1/t_crl.c",
- "crypto/asn1/p5_pbev2.c",
- "crypto/asn1/tasn_enc.c",
- "crypto/asn1/a_mbstr.c",
- "crypto/asn1/tasn_dec.c",
- "crypto/asn1/x_x509.c",
- "crypto/asn1/a_octet.c",
- "crypto/asn1/x_long.c",
- "crypto/asn1/a_bytes.c",
- "crypto/asn1/t_x509a.c",
- "crypto/asn1/a_enum.c",
- "crypto/asn1/a_int.c",
- "crypto/asn1/tasn_prn.c",
- "crypto/asn1/i2d_pr.c",
- "crypto/asn1/a_utf8.c",
- "crypto/asn1/t_spki.c",
- "crypto/asn1/a_digest.c",
- "crypto/asn1/a_dup.c",
- "crypto/asn1/i2d_pu.c",
- "crypto/asn1/a_verify.c",
- "crypto/asn1/f_enum.c",
- "crypto/asn1/a_sign.c",
- "crypto/asn1/d2i_pr.c",
- "crypto/asn1/asn1_par.c",
- "crypto/asn1/x_spki.c",
- "crypto/asn1/a_d2i_fp.c",
- "crypto/asn1/f_int.c",
- "crypto/asn1/x_exten.c",
- "crypto/asn1/tasn_utl.c",
- "crypto/asn1/nsseq.c",
- "crypto/asn1/a_bitstr.c",
- "crypto/asn1/x_info.c",
- "crypto/asn1/a_strnid.c",
- "crypto/asn1/a_object.c",
- "crypto/asn1/tasn_fre.c",
- "crypto/asn1/d2i_pu.c",
- "crypto/asn1/ameth_lib.c",
- "crypto/asn1/x_attrib.c",
- "crypto/evp/m_sha.c",
- "crypto/evp/e_camellia.c",
- "crypto/evp/e_aes.c",
- "crypto/evp/bio_b64.c",
- "crypto/evp/m_sigver.c",
- "crypto/evp/m_wp.c",
- "crypto/evp/m_sha1.c",
- "crypto/evp/p_seal.c",
- "crypto/evp/c_alld.c",
- "crypto/evp/p5_crpt.c",
- "crypto/evp/e_rc4.c",
- "crypto/evp/m_ecdsa.c",
- "crypto/evp/bio_enc.c",
- "crypto/evp/e_des3.c",
- "crypto/evp/m_null.c",
- "crypto/evp/bio_ok.c",
- "crypto/evp/pmeth_gn.c",
- "crypto/evp/e_rc5.c",
- "crypto/evp/e_rc2.c",
- "crypto/evp/p_dec.c",
- "crypto/evp/p_verify.c",
- "crypto/evp/e_rc4_hmac_md5.c",
- "crypto/evp/pmeth_lib.c",
- "crypto/evp/m_ripemd.c",
- "crypto/evp/m_md5.c",
- "crypto/evp/e_bf.c",
- "crypto/evp/p_enc.c",
- "crypto/evp/m_dss.c",
- "crypto/evp/bio_md.c",
- "crypto/evp/evp_pbe.c",
- "crypto/evp/e_seed.c",
- "crypto/evp/e_cast.c",
- "crypto/evp/p_open.c",
- "crypto/evp/p5_crpt2.c",
- "crypto/evp/m_dss1.c",
- "crypto/evp/names.c",
- "crypto/evp/evp_acnf.c",
- "crypto/evp/e_des.c",
- "crypto/evp/evp_cnf.c",
- "crypto/evp/evp_lib.c",
- "crypto/evp/digest.c",
- "crypto/evp/evp_err.c",
- "crypto/evp/evp_enc.c",
- "crypto/evp/e_old.c",
- "crypto/evp/c_all.c",
- "crypto/evp/m_md2.c",
- "crypto/evp/e_xcbc_d.c",
- "crypto/evp/pmeth_fn.c",
- "crypto/evp/p_lib.c",
- "crypto/evp/evp_key.c",
- "crypto/evp/encode.c",
- "crypto/evp/e_aes_cbc_hmac_sha1.c",
- "crypto/evp/e_aes_cbc_hmac_sha256.c",
- "crypto/evp/m_mdc2.c",
- "crypto/evp/e_null.c",
- "crypto/evp/p_sign.c",
- "crypto/evp/e_idea.c",
- "crypto/evp/c_allc.c",
- "crypto/evp/evp_pkey.c",
- "crypto/evp/m_md4.c",
- "crypto/ex_data.c",
- "crypto/pkcs12/p12_p8e.c",
- "crypto/pkcs12/p12_crt.c",
- "crypto/pkcs12/p12_utl.c",
- "crypto/pkcs12/p12_attr.c",
- "crypto/pkcs12/p12_npas.c",
- "crypto/pkcs12/p12_decr.c",
- "crypto/pkcs12/p12_init.c",
- "crypto/pkcs12/p12_kiss.c",
- "crypto/pkcs12/p12_add.c",
- "crypto/pkcs12/p12_p8d.c",
- "crypto/pkcs12/p12_mutl.c",
- "crypto/pkcs12/p12_crpt.c",
- "crypto/pkcs12/pk12err.c",
- "crypto/pkcs12/p12_asn.c",
- "crypto/pkcs12/p12_key.c",
- "crypto/ecdh/ech_key.c",
- "crypto/ecdh/ech_ossl.c",
- "crypto/ecdh/ech_lib.c",
- "crypto/ecdh/ech_err.c",
- "crypto/ecdh/ech_kdf.c",
- "crypto/o_str.c",
- "crypto/conf/conf_api.c",
- "crypto/conf/conf_err.c",
- "crypto/conf/conf_def.c",
- "crypto/conf/conf_lib.c",
- "crypto/conf/conf_mall.c",
- "crypto/conf/conf_sap.c",
- "crypto/conf/conf_mod.c",
- "crypto/ebcdic.c",
- "crypto/ecdsa/ecs_lib.c",
- "crypto/ecdsa/ecs_asn1.c",
- "crypto/ecdsa/ecs_ossl.c",
- "crypto/ecdsa/ecs_vrf.c",
- "crypto/ecdsa/ecs_sign.c",
- "crypto/ecdsa/ecs_err.c",
- "crypto/dso/dso_win32.c",
- "crypto/dso/dso_lib.c",
- "crypto/dso/dso_dlfcn.c",
- "crypto/dso/dso_dl.c",
- "crypto/dso/dso_beos.c",
- "crypto/dso/dso_null.c",
- "crypto/dso/dso_vms.c",
- "crypto/dso/dso_err.c",
- "crypto/dso/dso_openssl.c",
- "crypto/cryptlib.c",
- "crypto/md5/md5_one.c",
- "crypto/md5/md5_dgst.c",
- "crypto/pkcs7/pkcs7err.c",
- "crypto/pkcs7/pk7_smime.c",
- "crypto/pkcs7/bio_pk7.c",
- "crypto/pkcs7/pk7_mime.c",
- "crypto/pkcs7/pk7_lib.c",
- "crypto/pkcs7/pk7_asn1.c",
- "crypto/pkcs7/pk7_doit.c",
- "crypto/pkcs7/pk7_attr.c",
- "crypto/md4/md4_one.c",
- "crypto/md4/md4_dgst.c",
- "crypto/o_dir.c",
- "crypto/buffer/buf_err.c",
- "crypto/buffer/buf_str.c",
- "crypto/buffer/buffer.c",
- "crypto/cms/cms_lib.c",
- "crypto/cms/cms_io.c",
- "crypto/cms/cms_err.c",
- "crypto/cms/cms_dd.c",
- "crypto/cms/cms_smime.c",
- "crypto/cms/cms_att.c",
- "crypto/cms/cms_pwri.c",
- "crypto/cms/cms_cd.c",
- "crypto/cms/cms_sd.c",
- "crypto/cms/cms_asn1.c",
- "crypto/cms/cms_env.c",
- "crypto/cms/cms_enc.c",
- "crypto/cms/cms_ess.c",
- "crypto/cms/cms_kari.c",
- "crypto/mem_dbg.c",
- "crypto/uid.c",
- "crypto/stack/stack.c",
- "crypto/ec/ec_ameth.c",
- "crypto/ec/ec_err.c",
- "crypto/ec/ec_lib.c",
- "crypto/ec/ec_curve.c",
- "crypto/ec/ec_oct.c",
- "crypto/ec/ec_asn1.c",
- "crypto/ec/ecp_oct.c",
- "crypto/ec/ec_print.c",
- "crypto/ec/ec2_smpl.c",
- "crypto/ec/ecp_nistp224.c",
- "crypto/ec/ec2_oct.c",
- "crypto/ec/eck_prn.c",
- "crypto/ec/ec_key.c",
- "crypto/ec/ecp_nist.c",
- "crypto/ec/ec_check.c",
- "crypto/ec/ecp_smpl.c",
- "crypto/ec/ec2_mult.c",
- "crypto/ec/ecp_mont.c",
- "crypto/ec/ecp_nistp521.c",
- "crypto/ec/ec_mult.c",
- "crypto/ec/ecp_nistputil.c",
- "crypto/ec/ec_pmeth.c",
- "crypto/ec/ec_cvt.c",
- "crypto/ec/ecp_nistp256.c",
- "crypto/krb5/krb5_asn.c",
- "crypto/hmac/hmac.c",
- "crypto/hmac/hm_ameth.c",
- "crypto/hmac/hm_pmeth.c",
- "crypto/comp/c_rle.c",
- "crypto/comp/c_zlib.c",
- "crypto/comp/comp_lib.c",
- "crypto/comp/comp_err.c",
- "crypto/des/fcrypt.c",
- "crypto/des/str2key.c",
- "crypto/des/cbc_cksm.c",
- "crypto/des/des_enc.c",
- "crypto/des/ofb_enc.c",
- "crypto/des/read2pwd.c",
- "crypto/des/ecb3_enc.c",
- "crypto/des/rand_key.c",
- "crypto/des/cfb64ede.c",
- "crypto/des/rpc_enc.c",
- "crypto/des/ofb64ede.c",
- "crypto/des/qud_cksm.c",
- "crypto/des/enc_writ.c",
- "crypto/des/set_key.c",
- "crypto/des/xcbc_enc.c",
- "crypto/des/fcrypt_b.c",
- "crypto/des/ede_cbcm_enc.c",
- "crypto/des/des_old2.c",
- "crypto/des/cfb_enc.c",
- "crypto/des/ecb_enc.c",
- "crypto/des/enc_read.c",
- "crypto/des/des_old.c",
- "crypto/des/ofb64enc.c",
- "crypto/des/pcbc_enc.c",
- "crypto/des/cbc_enc.c",
- "crypto/des/cfb64enc.c",
- "crypto/lhash/lh_stats.c",
- "crypto/lhash/lhash.c",
- "crypto/x509v3/v3_genn.c",
- "crypto/x509v3/pcy_cache.c",
- "crypto/x509v3/v3_sxnet.c",
- "crypto/x509v3/v3_scts.c",
- "crypto/x509v3/v3err.c",
- "crypto/x509v3/v3_conf.c",
- "crypto/x509v3/v3_utl.c",
- "crypto/x509v3/v3_akeya.c",
- "crypto/x509v3/v3_lib.c",
- "crypto/x509v3/pcy_lib.c",
- "crypto/x509v3/v3_cpols.c",
- "crypto/x509v3/v3_ia5.c",
- "crypto/x509v3/v3_bitst.c",
- "crypto/x509v3/v3_skey.c",
- "crypto/x509v3/v3_info.c",
- "crypto/x509v3/v3_asid.c",
- "crypto/x509v3/pcy_tree.c",
- "crypto/x509v3/v3_pcons.c",
- "crypto/x509v3/v3_bcons.c",
- "crypto/x509v3/v3_pku.c",
- "crypto/x509v3/v3_ocsp.c",
- "crypto/x509v3/pcy_map.c",
- "crypto/x509v3/v3_ncons.c",
- "crypto/x509v3/v3_purp.c",
- "crypto/x509v3/v3_enum.c",
- "crypto/x509v3/v3_pmaps.c",
- "crypto/x509v3/pcy_node.c",
- "crypto/x509v3/v3_pcia.c",
- "crypto/x509v3/v3_crld.c",
- "crypto/x509v3/v3_pci.c",
- "crypto/x509v3/v3_akey.c",
- "crypto/x509v3/v3_addr.c",
- "crypto/x509v3/v3_int.c",
- "crypto/x509v3/v3_alt.c",
- "crypto/x509v3/v3_extku.c",
- "crypto/x509v3/v3_prn.c",
- "crypto/x509v3/pcy_data.c",
- "crypto/aes/aes_ofb.c",
- "crypto/aes/aes_ctr.c",
- "crypto/aes/aes_ecb.c",
- "crypto/aes/aes_cfb.c",
- "crypto/aes/aes_wrap.c",
- "crypto/aes/aes_ige.c",
- "crypto/aes/aes_misc.c",
- "crypto/pqueue/pqueue.c",
- "crypto/sha/sha_one.c",
- "crypto/sha/sha_dgst.c",
- "crypto/sha/sha512.c",
- "crypto/sha/sha1_one.c",
- "crypto/sha/sha1dgst.c",
- "crypto/sha/sha256.c",
- "crypto/whrlpool/wp_dgst.c",
- "crypto/objects/obj_xref.c",
- "crypto/objects/o_names.c",
- "crypto/objects/obj_err.c",
- "crypto/objects/obj_dat.c",
- "crypto/objects/obj_lib.c",
- "crypto/mem.c",
- "crypto/fips_ers.c",
- "crypto/o_fips.c",
- "crypto/engine/eng_rdrand.c",
- "crypto/engine/eng_err.c",
- "crypto/engine/tb_ecdsa.c",
- "crypto/engine/tb_rsa.c",
- "crypto/engine/tb_cipher.c",
- "crypto/engine/tb_dsa.c",
- "crypto/engine/eng_lib.c",
- "crypto/engine/tb_asnmth.c",
- "crypto/engine/tb_ecdh.c",
- "crypto/engine/tb_dh.c",
- "crypto/engine/tb_store.c",
- "crypto/engine/eng_init.c",
- "crypto/engine/eng_cnf.c",
- "crypto/engine/eng_all.c",
- "crypto/engine/tb_digest.c",
- "crypto/engine/tb_pkmeth.c",
- "crypto/engine/eng_table.c",
- "crypto/engine/eng_ctrl.c",
- "crypto/engine/eng_list.c",
- "crypto/engine/eng_cryptodev.c",
- "crypto/engine/eng_pkey.c",
- "crypto/engine/tb_rand.c",
- "crypto/engine/eng_openssl.c",
- "crypto/engine/eng_fat.c",
- "crypto/engine/eng_dyn.c",
- "crypto/ts/ts_rsp_verify.c",
- "crypto/ts/ts_req_print.c",
- "crypto/ts/ts_verify_ctx.c",
- "crypto/ts/ts_req_utils.c",
- "crypto/ts/ts_err.c",
- "crypto/ts/ts_rsp_print.c",
- "crypto/ts/ts_rsp_utils.c",
- "crypto/ts/ts_lib.c",
- "crypto/ts/ts_conf.c",
- "crypto/ts/ts_asn1.c",
- "crypto/ts/ts_rsp_sign.c",
- "crypto/ocsp/ocsp_ext.c",
- "crypto/ocsp/ocsp_cl.c",
- "crypto/ocsp/ocsp_ht.c",
- "crypto/ocsp/ocsp_lib.c",
- "crypto/ocsp/ocsp_srv.c",
- "crypto/ocsp/ocsp_vfy.c",
- "crypto/ocsp/ocsp_err.c",
- "crypto/ocsp/ocsp_prn.c",
- "crypto/ocsp/ocsp_asn.c",
- "crypto/bf/bf_cfb64.c",
- "crypto/bf/bf_ecb.c",
- "crypto/bf/bf_enc.c",
- "crypto/bf/bf_skey.c",
- "crypto/bf/bf_ofb64.c",
- "crypto/idea/i_skey.c",
- "crypto/idea/i_ofb64.c",
- "crypto/idea/i_cbc.c",
- "crypto/idea/i_ecb.c",
- "crypto/idea/i_cfb64.c",
- "crypto/cmac/cm_ameth.c",
- "crypto/cmac/cmac.c",
- "crypto/cmac/cm_pmeth.c",
- "crypto/dh/dh_lib.c",
- "crypto/dh/dh_key.c",
- "crypto/dh/dh_asn1.c",
- "crypto/dh/dh_depr.c",
- "crypto/dh/dh_pmeth.c",
- "crypto/dh/dh_prn.c",
- "crypto/dh/dh_gen.c",
- "crypto/dh/dh_ameth.c",
- "crypto/dh/dh_check.c",
- "crypto/dh/dh_err.c",
- "crypto/dh/dh_kdf.c",
- "crypto/dh/dh_rfc5114.c",
- "crypto/modes/ccm128.c",
- "crypto/modes/ofb128.c",
- "crypto/modes/cts128.c",
- "crypto/modes/ctr128.c",
- "crypto/modes/gcm128.c",
- "crypto/modes/cbc128.c",
- "crypto/modes/cfb128.c",
- "crypto/modes/xts128.c",
- "crypto/modes/wrap128.c",
- "crypto/camellia/cmll_cfb.c",
- "crypto/camellia/cmll_ecb.c",
- "crypto/camellia/cmll_utl.c",
- "crypto/camellia/cmll_misc.c",
- "crypto/camellia/cmll_ofb.c",
- "crypto/camellia/cmll_ctr.c",
- "crypto/seed/seed_ecb.c",
- "crypto/seed/seed_cbc.c",
- "crypto/seed/seed.c",
- "crypto/seed/seed_ofb.c",
- "crypto/seed/seed_cfb.c",
- "crypto/txt_db/txt_db.c",
- "crypto/cpt_err.c",
- "crypto/pem/pem_pk8.c",
- "crypto/pem/pem_lib.c",
- "crypto/pem/pem_sign.c",
- "crypto/pem/pem_all.c",
- "crypto/pem/pem_info.c",
- "crypto/pem/pem_pkey.c",
- "crypto/pem/pem_seal.c",
- "crypto/pem/pem_err.c",
- "crypto/pem/pem_xaux.c",
- "crypto/pem/pvkfmt.c",
- "crypto/pem/pem_x509.c",
- "crypto/pem/pem_oth.c",
- "crypto/rand/rand_lib.c",
- "crypto/rand/randfile.c",
- "crypto/rand/rand_os2.c",
- "crypto/rand/rand_unix.c",
- "crypto/rand/rand_nw.c",
- "crypto/rand/md_rand.c",
- "crypto/rand/rand_err.c",
- "crypto/rand/rand_win.c",
- "crypto/rand/rand_egd.c",
- "crypto/cversion.c",
- "crypto/cast/c_ecb.c",
- "crypto/cast/c_skey.c",
- "crypto/cast/c_ofb64.c",
- "crypto/cast/c_enc.c",
- "crypto/cast/c_cfb64.c",
- "crypto/o_time.c",
- "crypto/mdc2/mdc2dgst.c",
- "crypto/mdc2/mdc2_one.c",
- "crypto/rc4/rc4_utl.c",
- "crypto/ui/ui_compat.c",
- "crypto/ui/ui_util.c",
- "crypto/ui/ui_lib.c",
- "crypto/ui/ui_err.c",
- "crypto/ui/ui_openssl.c",
- "crypto/bio/bf_buff.c",
- "crypto/bio/bss_null.c",
- "crypto/bio/bss_acpt.c",
- "crypto/bio/bss_conn.c",
- "crypto/bio/bss_fd.c",
- "crypto/bio/bf_null.c",
- "crypto/bio/bio_err.c",
- "crypto/bio/bss_sock.c",
- "crypto/bio/bss_mem.c",
- "crypto/bio/b_dump.c",
- "crypto/bio/b_print.c",
- "crypto/bio/b_sock.c",
- "crypto/bio/bss_dgram.c",
- "crypto/bio/bf_nbio.c",
- "crypto/bio/bio_lib.c",
- "crypto/bio/bss_file.c",
- "crypto/bio/bss_bio.c",
- "crypto/bio/bss_log.c",
- "crypto/bio/bio_cb.c",
- "crypto/o_init.c",
- "crypto/rc2/rc2_skey.c",
- "crypto/rc2/rc2_cbc.c",
- "crypto/rc2/rc2cfb64.c",
- "crypto/rc2/rc2_ecb.c",
- "crypto/rc2/rc2ofb64.c",
- "crypto/bn/bn_x931p.c",
- "crypto/bn/bn_blind.c",
- "crypto/bn/bn_gf2m.c",
- "crypto/bn/bn_const.c",
- "crypto/bn/bn_sqr.c",
- "crypto/bn/bn_nist.c",
- "crypto/bn/bn_rand.c",
- "crypto/bn/bn_err.c",
- "crypto/bn/bn_div.c",
- "crypto/bn/bn_kron.c",
- "crypto/bn/bn_ctx.c",
- "crypto/bn/bn_shift.c",
- "crypto/bn/bn_mod.c",
- "crypto/bn/bn_exp2.c",
- "crypto/bn/bn_word.c",
- "crypto/bn/bn_add.c",
- "crypto/bn/bn_exp.c",
- "crypto/bn/bn_mont.c",
- "crypto/bn/bn_print.c",
- "crypto/bn/bn_mul.c",
- "crypto/bn/bn_prime.c",
- "crypto/bn/bn_depr.c",
- "crypto/bn/bn_gcd.c",
- "crypto/bn/bn_mpi.c",
- "crypto/bn/bn_sqrt.c",
- "crypto/bn/bn_recp.c",
- "crypto/bn/bn_lib.c",
- "crypto/ripemd/rmd_dgst.c",
- "crypto/ripemd/rmd_one.c",
- "crypto/rsa/rsa_x931.c",
- "crypto/rsa/rsa_depr.c",
- "crypto/rsa/rsa_saos.c",
- "crypto/rsa/rsa_crpt.c",
- "crypto/rsa/rsa_pss.c",
- "crypto/rsa/rsa_oaep.c",
- "crypto/rsa/rsa_null.c",
- "crypto/rsa/rsa_gen.c",
- "crypto/rsa/rsa_prn.c",
- "crypto/rsa/rsa_pmeth.c",
- "crypto/rsa/rsa_asn1.c",
- "crypto/rsa/rsa_ssl.c",
- "crypto/rsa/rsa_ameth.c",
- "crypto/rsa/rsa_pk1.c",
- "crypto/rsa/rsa_err.c",
- "crypto/rsa/rsa_lib.c",
- "crypto/rsa/rsa_none.c",
- "crypto/rsa/rsa_chk.c",
- "crypto/rsa/rsa_eay.c",
- "crypto/rsa/rsa_sign.c",
- "crypto/srp/srp_lib.c",
- "crypto/srp/srp_vfy.c",
- "crypto/err/err.c",
- "crypto/err/err_prn.c",
- "crypto/err/err_all.c",
- "crypto/mem_clr.c",
- "crypto/rc4/rc4_skey.c",
- "crypto/rc4/rc4_enc.c",
- "crypto/camellia/camellia.c",
- "crypto/camellia/cmll_cbc.c",
- #"crypto/aes/aes_x86core.c",
- "crypto/aes/aes_core.c",
- "crypto/aes/aes_cbc.c",
- "crypto/whrlpool/wp_block.c",
- "crypto/bn/bn_asm.c",
- ]
-
- if "platform" in env and env["platform"] == "uwp":
- thirdparty_sources += ['uwp.cpp']
-
- thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
-
- env_openssl.add_source_files(env.modules_sources, thirdparty_sources)
-
- # FIXME: Clone the environment to make env_openssl and not pollute the modules env
- thirdparty_include_paths = [
- "",
- "crypto",
- "crypto/asn1",
- "crypto/evp",
- "crypto/modes",
- "openssl",
- ]
- env_openssl.Append(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
-
- env_openssl.Append(CPPFLAGS=["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"])
-
- # Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517)
- import os
- import methods
- if not (os.name == "nt" and os.getenv("VCINSTALLDIR")): # not Windows and not MSVC
- env_openssl.Append(CFLAGS=["-Wno-error=implicit-function-declaration"])
-
-
-# Module sources
-env_openssl.add_source_files(env.modules_sources, "*.cpp")
-
-
-# Other thirdparty dependencies
-thirdparty_misc_dir = "#thirdparty/misc/"
-thirdparty_misc_sources = [
- "curl_hostcheck.c",
-]
-thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources]
-env_openssl.add_source_files(env.modules_sources, thirdparty_misc_sources)
-
-
-# platform/uwp need to know openssl is available, pass to main env
-if "platform" in env and env["platform"] == "uwp":
- env.Append(CPPPATH=[thirdparty_dir])
- env.Append(CPPFLAGS=['-DOPENSSL_ENABLED'])
-
-Export('env')
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
deleted file mode 100644
index 30a03f9000..0000000000
--- a/modules/openssl/stream_peer_openssl.cpp
+++ /dev/null
@@ -1,631 +0,0 @@
-/*************************************************************************/
-/* stream_peer_openssl.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "stream_peer_openssl.h"
-
-// Compatibility with OpenSSL 1.1.0.
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
-#define BIO_set_num(b, n)
-#else
-#define BIO_set_num(b, n) ((b)->num = (n))
-
-#define BIO_set_init(b, i) ((b)->init = (i))
-#define BIO_set_data(b, p) ((b)->ptr = (p))
-#define BIO_get_data(b) ((b)->ptr)
-#endif
-
-//hostname matching code from curl
-
-bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname) {
-
- return Tool_Curl_cert_hostcheck(name, hostname) == CURL_HOST_MATCH;
-}
-
-Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {
-
- // Find the position of the CN field in the Subject field of the certificate
- int common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
-
- ERR_FAIL_COND_V(common_name_loc < 0, ERR_INVALID_PARAMETER);
-
- // Extract the CN field
- X509_NAME_ENTRY *common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
-
- ERR_FAIL_COND_V(common_name_entry == NULL, ERR_INVALID_PARAMETER);
-
- // Convert the CN field to a C string
- ASN1_STRING *common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
-
- ERR_FAIL_COND_V(common_name_asn1 == NULL, ERR_INVALID_PARAMETER);
-
- char *common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
-
- // Make sure there isn't an embedded NUL character in the CN
- bool malformed_certificate = (size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str);
-
- ERR_FAIL_COND_V(malformed_certificate, ERR_INVALID_PARAMETER);
-
- // Compare expected hostname with the CN
-
- return _match_host_name(common_name_str, hostname) ? OK : FAILED;
-}
-
-/**
-* Tries to find a match for hostname in the certificate's Subject Alternative Name extension.
-*
-*/
-
-Error StreamPeerOpenSSL::_match_subject_alternative_name(const char *hostname, const X509 *server_cert) {
-
- Error result = FAILED;
- int i;
- int san_names_nb = -1;
- STACK_OF(GENERAL_NAME) *san_names = NULL;
-
- // Try to extract the names within the SAN extension from the certificate
- san_names = (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i((X509 *)server_cert, NID_subject_alt_name, NULL, NULL);
- if (san_names == NULL) {
- return ERR_FILE_NOT_FOUND;
- }
- san_names_nb = sk_GENERAL_NAME_num(san_names);
-
- // Check each name within the extension
- for (i = 0; i < san_names_nb; i++) {
- const GENERAL_NAME *current_name = sk_GENERAL_NAME_value(san_names, i);
-
- if (current_name->type == GEN_DNS) {
- // Current name is a DNS name, let's check it
- char *dns_name = (char *)ASN1_STRING_data(current_name->d.dNSName);
-
- // Make sure there isn't an embedded NUL character in the DNS name
- if ((size_t)ASN1_STRING_length(current_name->d.dNSName) != strlen(dns_name)) {
- result = ERR_INVALID_PARAMETER;
- break;
- } else { // Compare expected hostname with the DNS name
- if (_match_host_name(dns_name, hostname)) {
- result = OK;
- break;
- }
- }
- }
- }
- sk_GENERAL_NAME_pop_free(san_names, GENERAL_NAME_free);
-
- return result;
-}
-
-/* See http://archives.seul.org/libevent/users/Jan-2013/msg00039.html */
-int StreamPeerOpenSSL::_cert_verify_callback(X509_STORE_CTX *x509_ctx, void *arg) {
-
- /* This is the function that OpenSSL would call if we hadn't called
- * SSL_CTX_set_cert_verify_callback(). Therefore, we are "wrapping"
- * the default functionality, rather than replacing it. */
-
- bool base_cert_valid = X509_verify_cert(x509_ctx);
- if (!base_cert_valid) {
- print_line("Cause: " + String(X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_ctx))));
- ERR_print_errors_fp(stdout);
- }
- X509 *server_cert = X509_STORE_CTX_get_current_cert(x509_ctx);
-
- ERR_FAIL_COND_V(!server_cert, 0);
-
- char cert_str[256];
- X509_NAME_oneline(X509_get_subject_name(server_cert),
- cert_str, sizeof(cert_str));
-
- print_line("CERT STR: " + String(cert_str));
- print_line("VALID: " + itos(base_cert_valid));
-
- if (!base_cert_valid)
- return 0;
-
- StreamPeerOpenSSL *ssl = (StreamPeerOpenSSL *)arg;
-
- if (ssl->validate_hostname) {
-
- Error err = _match_subject_alternative_name(ssl->hostname.utf8().get_data(), server_cert);
-
- if (err == ERR_FILE_NOT_FOUND) {
-
- err = _match_common_name(ssl->hostname.utf8().get_data(), server_cert);
- }
-
- if (err != OK) {
-
- ssl->status = STATUS_ERROR_HOSTNAME_MISMATCH;
- return 0;
- }
- }
-
- return 1;
-}
-
-int StreamPeerOpenSSL::_bio_create(BIO *b) {
- BIO_set_init(b, 1);
- BIO_set_num(b, 0);
- BIO_set_data(b, NULL);
- BIO_clear_flags(b, ~0);
- return 1;
-}
-
-int StreamPeerOpenSSL::_bio_destroy(BIO *b) {
- if (b == NULL)
- return 0;
-
- BIO_set_data(b, NULL); /* sb_tls_remove() will free it */
- BIO_set_init(b, 0);
- BIO_clear_flags(b, ~0);
- return 1;
-}
-
-int StreamPeerOpenSSL::_bio_read(BIO *b, char *buf, int len) {
-
- if (buf == NULL || len <= 0) return 0;
-
- StreamPeerOpenSSL *sp = (StreamPeerOpenSSL *)BIO_get_data(b);
-
- ERR_FAIL_COND_V(sp == NULL, 0);
-
- BIO_clear_retry_flags(b);
- if (sp->use_blocking) {
-
- Error err = sp->base->get_data((uint8_t *)buf, len);
- if (err != OK) {
- return -1;
- }
-
- return len;
- } else {
-
- int got;
- Error err = sp->base->get_partial_data((uint8_t *)buf, len, got);
- if (err != OK) {
- return -1;
- }
- if (got == 0) {
- BIO_set_retry_read(b);
- }
- return got;
- }
-
- //unreachable
- return 0;
-}
-
-int StreamPeerOpenSSL::_bio_write(BIO *b, const char *buf, int len) {
-
- if (buf == NULL || len <= 0) return 0;
-
- StreamPeerOpenSSL *sp = (StreamPeerOpenSSL *)BIO_get_data(b);
-
- ERR_FAIL_COND_V(sp == NULL, 0);
-
- BIO_clear_retry_flags(b);
- if (sp->use_blocking) {
-
- Error err = sp->base->put_data((const uint8_t *)buf, len);
- if (err != OK) {
- return -1;
- }
-
- return len;
- } else {
-
- int sent;
- Error err = sp->base->put_partial_data((const uint8_t *)buf, len, sent);
- if (err != OK) {
- return -1;
- }
- if (sent == 0) {
- BIO_set_retry_write(b);
- }
- return sent;
- }
-
- //unreachable
- return 0;
-}
-
-long StreamPeerOpenSSL::_bio_ctrl(BIO *b, int cmd, long num, void *ptr) {
- if (cmd == BIO_CTRL_FLUSH) {
- /* The OpenSSL library needs this */
- return 1;
- }
- return 0;
-}
-
-int StreamPeerOpenSSL::_bio_gets(BIO *b, char *buf, int len) {
- return -1;
-}
-
-int StreamPeerOpenSSL::_bio_puts(BIO *b, const char *str) {
- return _bio_write(b, str, strlen(str));
-}
-
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
-BIO_METHOD *StreamPeerOpenSSL::_bio_method = NULL;
-
-BIO_METHOD *StreamPeerOpenSSL::_get_bio_method() {
- if (_bio_method) // already initialized.
- return _bio_method;
-
- /* it's a source/sink BIO */
- _bio_method = BIO_meth_new(100 | 0x400, "streampeer glue");
- BIO_meth_set_write(_bio_method, _bio_write);
- BIO_meth_set_read(_bio_method, _bio_read);
- BIO_meth_set_puts(_bio_method, _bio_puts);
- BIO_meth_set_gets(_bio_method, _bio_gets);
- BIO_meth_set_ctrl(_bio_method, _bio_ctrl);
- BIO_meth_set_create(_bio_method, _bio_create);
- BIO_meth_set_destroy(_bio_method, _bio_destroy);
-
- return _bio_method;
-}
-#else
-BIO_METHOD StreamPeerOpenSSL::_bio_method = {
- /* it's a source/sink BIO */
- (100 | 0x400),
- "streampeer glue",
- _bio_write,
- _bio_read,
- _bio_puts,
- _bio_gets,
- _bio_ctrl,
- _bio_create,
- _bio_destroy
-};
-
-BIO_METHOD *StreamPeerOpenSSL::_get_bio_method() {
- return &_bio_method;
-}
-#endif
-
-Error StreamPeerOpenSSL::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname) {
-
- if (connected)
- disconnect_from_stream();
-
- hostname = p_for_hostname;
- status = STATUS_DISCONNECTED;
-
- // Set up a SSL_CTX object, which will tell our BIO object how to do its work
- ctx = SSL_CTX_new(SSLv23_client_method());
- base = p_base;
- validate_certs = p_validate_certs;
- validate_hostname = p_for_hostname != "";
-
- if (p_validate_certs) {
-
- if (certs.size()) {
- //yay for undocumented OpenSSL functions
-
- X509_STORE *store = SSL_CTX_get_cert_store(ctx);
- for (int i = 0; i < certs.size(); i++) {
-
- X509_STORE_add_cert(store, certs[i]);
- }
- }
-
- //used for testing
- //int res = SSL_CTX_load_verify_locations(ctx,"/etc/ssl/certs/ca-certificates.crt",NULL);
- //print_line("verify locations res: "+itos(res));
-
- /* Ask OpenSSL to verify the server certificate. Note that this
- * does NOT include verifying that the hostname is correct.
- * So, by itself, this means anyone with any legitimate
- * CA-issued certificate for any website, can impersonate any
- * other website in the world. This is not good. See "The
- * Most Dangerous Code in the World" article at
- * https://crypto.stanford.edu/~dabo/pubs/abstracts/ssl-client-bugs.html
- */
- SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
- /* This is how we solve the problem mentioned in the previous
- * comment. We "wrap" OpenSSL's validation routine in our
- * own routine, which also validates the hostname by calling
- * the code provided by iSECPartners. Note that even though
- * the "Everything You've Always Wanted to Know About
- * Certificate Validation With OpenSSL (But Were Afraid to
- * Ask)" paper from iSECPartners says very explicitly not to
- * call SSL_CTX_set_cert_verify_callback (at the bottom of
- * page 2), what we're doing here is safe because our
- * cert_verify_callback() calls X509_verify_cert(), which is
- * OpenSSL's built-in routine which would have been called if
- * we hadn't set the callback. Therefore, we're just
- * "wrapping" OpenSSL's routine, not replacing it. */
- SSL_CTX_set_cert_verify_callback(ctx, _cert_verify_callback, this);
-
- //Let the verify_callback catch the verify_depth error so that we get an appropriate error in the logfile. (??)
- SSL_CTX_set_verify_depth(ctx, max_cert_chain_depth + 1);
- }
-
- ssl = SSL_new(ctx);
- bio = BIO_new(_get_bio_method());
- BIO_set_data(bio, this);
- SSL_set_bio(ssl, bio, bio);
-
- if (p_for_hostname != String()) {
- SSL_set_tlsext_host_name(ssl, p_for_hostname.utf8().get_data());
- }
-
- use_blocking = true; // let handshake use blocking
- // Set the SSL to automatically retry on failure.
- SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
-
- // Same as before, try to connect.
- int result = SSL_connect(ssl);
-
- print_line("CONNECTION RESULT: " + itos(result));
- if (result < 1) {
- ERR_print_errors_fp(stdout);
- _print_error(result);
- }
-
- X509 *peer = SSL_get_peer_certificate(ssl);
-
- if (peer) {
- bool cert_ok = SSL_get_verify_result(ssl) == X509_V_OK;
- print_line("cert_ok: " + itos(cert_ok));
-
- } else if (validate_certs) {
- status = STATUS_ERROR_NO_CERTIFICATE;
- }
-
- connected = true;
- status = STATUS_CONNECTED;
-
- return OK;
-}
-
-Error StreamPeerOpenSSL::accept_stream(Ref<StreamPeer> p_base) {
-
- return ERR_UNAVAILABLE;
-}
-
-void StreamPeerOpenSSL::_print_error(int err) {
-
- err = SSL_get_error(ssl, err);
- switch (err) {
- case SSL_ERROR_NONE:
- ERR_PRINT("NO ERROR: The TLS/SSL I/O operation completed");
- break;
- case SSL_ERROR_ZERO_RETURN:
- ERR_PRINT("The TLS/SSL connection has been closed.");
- break;
- case SSL_ERROR_WANT_READ:
- case SSL_ERROR_WANT_WRITE:
- ERR_PRINT("The operation did not complete.");
- break;
- case SSL_ERROR_WANT_CONNECT:
- case SSL_ERROR_WANT_ACCEPT:
- ERR_PRINT("The connect/accept operation did not complete");
- break;
- case SSL_ERROR_WANT_X509_LOOKUP:
- ERR_PRINT("The operation did not complete because an application callback set by SSL_CTX_set_client_cert_cb() has asked to be called again.");
- break;
- case SSL_ERROR_SYSCALL:
- ERR_PRINT("Some I/O error occurred. The OpenSSL error queue may contain more information on the error.");
- break;
- case SSL_ERROR_SSL:
- ERR_PRINT("A failure in the SSL library occurred, usually a protocol error.");
- break;
- }
-}
-
-Error StreamPeerOpenSSL::put_data(const uint8_t *p_data, int p_bytes) {
-
- ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
-
- while (p_bytes > 0) {
- int ret = SSL_write(ssl, p_data, p_bytes);
- if (ret <= 0) {
- _print_error(ret);
- disconnect_from_stream();
- return ERR_CONNECTION_ERROR;
- }
- p_data += ret;
- p_bytes -= ret;
- }
-
- return OK;
-}
-
-Error StreamPeerOpenSSL::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
- ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
- if (p_bytes == 0)
- return OK;
-
- Error err = put_data(p_data, p_bytes);
- if (err != OK)
- return err;
-
- r_sent = p_bytes;
- return OK;
-}
-
-Error StreamPeerOpenSSL::get_data(uint8_t *p_buffer, int p_bytes) {
-
- ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
-
- while (p_bytes > 0) {
-
- int ret = SSL_read(ssl, p_buffer, p_bytes);
- if (ret <= 0) {
- _print_error(ret);
- disconnect_from_stream();
- return ERR_CONNECTION_ERROR;
- }
- p_buffer += ret;
- p_bytes -= ret;
- }
-
- return OK;
-}
-
-Error StreamPeerOpenSSL::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
- ERR_FAIL_COND_V(!connected, ERR_UNCONFIGURED);
- if (p_bytes == 0) {
- r_received = 0;
- return OK;
- }
-
- Error err = get_data(p_buffer, p_bytes);
- if (err != OK)
- return err;
- r_received = p_bytes;
- return OK;
-}
-
-int StreamPeerOpenSSL::get_available_bytes() const {
-
- ERR_FAIL_COND_V(!connected, 0);
-
- return SSL_pending(ssl);
-}
-StreamPeerOpenSSL::StreamPeerOpenSSL() {
-
- ctx = NULL;
- ssl = NULL;
- bio = NULL;
- connected = false;
- use_blocking = true; //might be improved int the future, but for now it always blocks
- max_cert_chain_depth = 9;
- flags = 0;
-}
-
-void StreamPeerOpenSSL::disconnect_from_stream() {
-
- if (!connected)
- return;
- SSL_shutdown(ssl);
- SSL_free(ssl);
- SSL_CTX_free(ctx);
- base = Ref<StreamPeer>();
- connected = false;
- validate_certs = false;
- validate_hostname = false;
- status = STATUS_DISCONNECTED;
-}
-
-StreamPeerOpenSSL::Status StreamPeerOpenSSL::get_status() const {
-
- return status;
-}
-
-StreamPeerOpenSSL::~StreamPeerOpenSSL() {
- disconnect_from_stream();
-}
-
-StreamPeerSSL *StreamPeerOpenSSL::_create_func() {
-
- return memnew(StreamPeerOpenSSL);
-}
-
-Vector<X509 *> StreamPeerOpenSSL::certs;
-
-void StreamPeerOpenSSL::_load_certs(const PoolByteArray &p_array) {
-
- PoolByteArray::Read r = p_array.read();
- BIO *mem = BIO_new(BIO_s_mem());
- BIO_puts(mem, (const char *)r.ptr());
- while (true) {
- X509 *cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
- if (!cert)
- break;
- certs.push_back(cert);
- }
- BIO_free(mem);
-}
-
-void StreamPeerOpenSSL::initialize_ssl() {
-
- available = true;
-
- load_certs_func = _load_certs;
-
- _create = _create_func;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
- CRYPTO_malloc_init(); // Initialize malloc, free, etc for OpenSSL's use
-#endif
- SSL_library_init(); // Initialize OpenSSL's SSL libraries
- SSL_load_error_strings(); // Load SSL error strings
- ERR_load_BIO_strings(); // Load BIO error strings
- OpenSSL_add_all_algorithms(); // Load all available encryption algorithms
- String certs_path = GLOBAL_DEF("network/ssl/certificates", "");
- ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/certificates", PropertyInfo(Variant::STRING, "network/ssl/certificates", PROPERTY_HINT_FILE, "*.crt"));
- if (certs_path != "") {
-
- FileAccess *f = FileAccess::open(certs_path, FileAccess::READ);
- if (f) {
- PoolByteArray arr;
- int flen = f->get_len();
- arr.resize(flen + 1);
- {
- PoolByteArray::Write w = arr.write();
- f->get_buffer(w.ptr(), flen);
- w[flen] = 0; //end f string
- }
-
- memdelete(f);
-
- _load_certs(arr);
- print_line("Loaded certs from '" + certs_path + "': " + itos(certs.size()));
- }
- }
- String config_path = GLOBAL_DEF("network/ssl/config", "");
- ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/config", PropertyInfo(Variant::STRING, "network/ssl/config", PROPERTY_HINT_FILE, "*.cnf"));
- if (config_path != "") {
-
- Vector<uint8_t> data = FileAccess::get_file_as_array(config_path);
- if (data.size()) {
- data.push_back(0);
- BIO *mem = BIO_new(BIO_s_mem());
- BIO_puts(mem, (const char *)data.ptr());
-
- while (true) {
- X509 *cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
- if (!cert)
- break;
- certs.push_back(cert);
- }
- BIO_free(mem);
- }
- print_line("Loaded certs from '" + certs_path + "': " + itos(certs.size()));
- }
-}
-
-void StreamPeerOpenSSL::finalize_ssl() {
-
- for (int i = 0; i < certs.size(); i++) {
- X509_free(certs[i]);
- }
- certs.clear();
-}
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index 260612e370..8323ff33ac 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -8,8 +8,6 @@
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
-/* Author: George Marques <george@gmarqu.es> */
-/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
@@ -29,8 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "audio_stream_opus.h"
+/**
+ @author George Marques <george@gmarqu.es>
+*/
+
const float AudioStreamPlaybackOpus::osrate = 48000.0f;
int AudioStreamPlaybackOpus::_op_read_func(void *_stream, unsigned char *_ptr, int _nbytes) {
diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h
index 7be133b5bc..3ffdaf2c18 100644
--- a/modules/opus/audio_stream_opus.h
+++ b/modules/opus/audio_stream_opus.h
@@ -8,8 +8,6 @@
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
-/* Author: George Marques <george@gmarqu.es> */
-/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
@@ -39,6 +37,10 @@
#include <opus/opusfile.h>
+/**
+ @author George Marques <george@gmarqu.es>
+*/
+
class AudioStreamPlaybackOpus : public AudioStreamPlayback {
GDCLASS(AudioStreamPlaybackOpus, AudioStreamPlayback)
diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp
index 41bee6d552..f34555841e 100644
--- a/modules/opus/register_types.cpp
+++ b/modules/opus/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "audio_stream_opus.h"
diff --git a/modules/opus/register_types.h b/modules/opus/register_types.h
index 85a7efbfc0..84335adfc9 100644
--- a/modules/opus/register_types.h
+++ b/modules/opus/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_opus_types();
void unregister_opus_types();
diff --git a/modules/opus/stub/register_types.cpp b/modules/opus/stub/register_types.cpp
index 449edcc0f5..fe2bce63ba 100644
--- a/modules/opus/stub/register_types.cpp
+++ b/modules/opus/stub/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
diff --git a/modules/opus/stub/register_types.h b/modules/opus/stub/register_types.h
index c41cc4818c..84335adfc9 100644
--- a/modules/opus/stub/register_types.h
+++ b/modules/opus/stub/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_opus_types();
void unregister_opus_types();
diff --git a/modules/pbm/SCsub b/modules/pbm/SCsub
deleted file mode 100644
index fa328be025..0000000000
--- a/modules/pbm/SCsub
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_pbm = env_modules.Clone()
-
-env_pbm.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
deleted file mode 100644
index 39d238ae5c..0000000000
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*************************************************************************/
-/* bitmap_loader_pbm.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "bitmap_loader_pbm.h"
-#include "os/file_access.h"
-#include "scene/resources/bit_mask.h"
-
-static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_token, bool p_binary = false, bool p_single_chunk = false) {
-
- int token_max = r_token.size();
- PoolVector<uint8_t>::Write w;
- if (token_max)
- w = r_token.write();
- int ofs = 0;
- bool lf = false;
-
- while (true) {
-
- uint8_t b;
- if (saved) {
- b = saved;
- saved = 0;
- } else {
- b = f->get_8();
- }
- if (f->eof_reached()) {
- if (ofs) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- return true;
- } else {
- return false;
- }
- }
-
- if (!ofs && !p_binary && b == '#') {
- //skip comment
- while (b != '\n') {
- if (f->eof_reached()) {
- return false;
- }
-
- b = f->get_8();
- }
-
- lf = true;
-
- } else if (b <= 32 && !(p_binary && (ofs || lf))) {
-
- if (b == '\n') {
- lf = true;
- }
-
- if (ofs && !p_single_chunk) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- saved = b;
-
- return true;
- }
- } else {
-
- bool resized = false;
- while (ofs >= token_max) {
- if (token_max)
- token_max <<= 1;
- else
- token_max = 1;
- resized = true;
- }
- if (resized) {
- // Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
- // This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
- // See core/dvector.h.
- w = PoolVector<uint8_t>::Write();
- r_token.resize(token_max);
- w = r_token.write();
- }
- w[ofs++] = b;
- }
- }
-
- return false;
-}
-
-static int _get_number_from_token(PoolVector<uint8_t> &r_token) {
-
- int len = r_token.size();
- PoolVector<uint8_t>::Read r = r_token.read();
- return String::to_int((const char *)r.ptr(), len);
-}
-
-RES ResourceFormatPBM::load(const String &p_path, const String &p_original_path, Error *r_error) {
-
-#define _RETURN(m_err) \
- { \
- if (r_error) \
- *r_error = m_err; \
- ERR_FAIL_V(RES()); \
- }
-
- FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
- uint8_t saved = 0;
- if (!f)
- _RETURN(ERR_CANT_OPEN);
-
- PoolVector<uint8_t> token;
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() != 2) {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[0] != 'P') {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[1] != '1' && token[1] != '4') {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- bool bits = token[1] == '4';
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int width = _get_number_from_token(token);
- if (width <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int height = _get_number_from_token(token);
- if (height <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- Ref<BitMap> bm;
- bm.instance();
- bm->create(Size2i(width, height));
-
- if (!bits) {
-
- int required_bytes = width * height;
- if (!_get_token(f, saved, token, false, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- char num = r[i * width + j];
- bm->set_bit(Point2i(j, i), num == '0');
- }
- }
-
- } else {
- //a single, entire token of bits!
- if (!_get_token(f, saved, token, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
- int required_bytes = Math::ceil((width * height) / 8.0);
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
- int bitwidth = width;
- if (bitwidth % 8)
- bitwidth += 8 - (bitwidth % 8);
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- int ofs = bitwidth * i + j;
-
- uint8_t byte = r[ofs / 8];
- bool bit = (byte >> (7 - (ofs % 8))) & 1;
-
- bm->set_bit(Point2i(j, i), !bit);
- }
- }
- }
-
- return bm;
-}
-
-void ResourceFormatPBM::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("pbm");
-}
-bool ResourceFormatPBM::handles_type(const String &p_type) const {
- return p_type == "BitMap";
-}
-String ResourceFormatPBM::get_resource_type(const String &p_path) const {
-
- if (p_path.get_extension().to_lower() == "pbm")
- return "BitMap";
- return "";
-}
diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp
index f1cd481a4a..0991828ef2 100644
--- a/modules/pvr/register_types.cpp
+++ b/modules/pvr/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "texture_loader_pvr.h"
diff --git a/modules/pvr/register_types.h b/modules/pvr/register_types.h
index b53dd8da52..d187ab5334 100644
--- a/modules/pvr/register_types.h
+++ b/modules/pvr/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_pvr_types();
void unregister_pvr_types();
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 5046526d81..76c0b969d8 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "texture_loader_pvr.h"
#include "PvrTcEncoder.h"
#include "RgbaBitmap.h"
diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h
index ae6df3658a..9369178336 100644
--- a/modules/pvr/texture_loader_pvr.h
+++ b/modules/pvr/texture_loader_pvr.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef TEXTURE_LOADER_PVR_H
#define TEXTURE_LOADER_PVR_H
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index 8cd163b0c8..2cf80acd28 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="RegEx" inherits="Reference" category="Core" version="3.0-beta">
+<class name="RegEx" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
Class for searching text for patterns using regular expressions.
</brief_description>
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 0217099ce6..9eba0f738b 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="RegExMatch" inherits="Reference" category="Core" version="3.0-beta">
+<class name="RegExMatch" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
Contains the results of a regex search.
</brief_description>
@@ -28,13 +28,6 @@
Returns the number of capturing groups.
</description>
</method>
- <method name="get_names" qualifiers="const">
- <return type="Dictionary">
- </return>
- <description>
- Returns a dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
- </description>
- </method>
<method name="get_start" qualifiers="const">
<return type="int">
</return>
@@ -55,21 +48,18 @@
Returns an empty string if the group did not match or doesn't exist.
</description>
</method>
- <method name="get_strings" qualifiers="const">
- <return type="Array">
- </return>
- <description>
- Returns an [Array] of the match and its capturing groups.
- </description>
- </method>
- <method name="get_subject" qualifiers="const">
- <return type="String">
- </return>
- <description>
- Returns the source string used with the search pattern to find this matching result.
- </description>
- </method>
</methods>
+ <members>
+ <member name="names" type="Dictionary" setter="" getter="get_names">
+ A dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
+ </member>
+ <member name="strings" type="Array" setter="" getter="get_strings">
+ An [Array] of the match and its capturing groups.
+ </member>
+ <member name="subject" type="String" setter="" getter="get_subject">
+ The source string used with the search pattern to find this matching result.
+ </member>
+ </members>
<constants>
</constants>
</class>
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 9bcbc4c4ea..6f2bb46fc8 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -156,6 +156,10 @@ void RegExMatch::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_string", "name"), &RegExMatch::get_string, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_start", "name"), &RegExMatch::get_start, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_end", "name"), &RegExMatch::get_end, DEFVAL(0));
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "subject"), "", "get_subject");
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "names"), "", "get_names");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "strings"), "", "get_strings");
}
void RegEx::_pattern_info(uint32_t what, void *where) const {
@@ -343,15 +347,20 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
ERR_FAIL_COND_V(!is_valid(), String());
- String output;
- output.resize(p_subject.length());
+ // safety_zone is the number of chars we allocate in addition to the number of chars expected in order to
+ // guard against the PCRE API writing one additional \0 at the end. PCRE's API docs are unclear on whether
+ // PCRE understands outlength in pcre2_substitute() as counting an implicit additional terminating char or
+ // not. always allocating one char more than telling PCRE has us on the safe side.
+ const int safety_zone = 1;
+
+ PCRE2_SIZE olength = p_subject.length() + 1; // space for output string and one terminating \0 character
+ Vector<CharType> output;
+ output.resize(olength + safety_zone);
uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH;
if (p_all)
flags |= PCRE2_SUBSTITUTE_GLOBAL;
- PCRE2_SIZE olength = output.length();
-
PCRE2_SIZE length = p_subject.length();
if (p_end >= 0 && (uint32_t)p_end < length)
length = p_end;
@@ -363,15 +372,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str();
PCRE2_SPTR16 r = (PCRE2_SPTR16)p_replacement.c_str();
- PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.c_str();
+ PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.ptrw();
pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx);
int res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR16 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR16 *)output.ptrw();
res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -388,15 +397,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str();
PCRE2_SPTR32 r = (PCRE2_SPTR32)p_replacement.c_str();
- PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.c_str();
+ PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.ptrw();
pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx);
int res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR32 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR32 *)output.ptrw();
res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -407,7 +416,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
return String();
}
- return output;
+ return String(output.ptr(), olength);
}
bool RegEx::is_valid() const {
diff --git a/modules/register_module_types.h b/modules/register_module_types.h
index 4f9c2eb41f..f4163418e8 100644
--- a/modules/register_module_types.h
+++ b/modules/register_module_types.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef REGISTER_MODULE_TYPES_H
#define REGISTER_MODULE_TYPES_H
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index c97cee6e1d..0cf24dd8d8 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_compress_squish.h"
#include "print_string.h"
diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h
index 83dab024b2..c022063fe5 100644
--- a/modules/squish/image_compress_squish.h
+++ b/modules/squish/image_compress_squish.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_COMPRESS_SQUISH_H
#define IMAGE_COMPRESS_SQUISH_H
diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp
index 600a33cdd6..d4ed676cce 100644
--- a/modules/squish/register_types.cpp
+++ b/modules/squish/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#ifdef TOOLS_ENABLED
diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h
index f9971f4f19..00f5c345c4 100644
--- a/modules/squish/register_types.h
+++ b/modules/squish/register_types.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifdef TOOLS_ENABLED
void register_squish_types();
void unregister_squish_types();
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 786c2bf051..18ab616826 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "audio_stream_ogg_vorbis.h"
#include "os/file_access.h"
@@ -114,7 +115,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
if (!active)
return;
- if (p_time >= get_length()) {
+ if (p_time >= vorbis_stream->get_length()) {
p_time = 0;
}
frames_mixed = uint32_t(vorbis_stream->sample_rate * p_time);
@@ -122,11 +123,6 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
stb_vorbis_seek(ogg_stream, frames_mixed);
}
-float AudioStreamPlaybackOGGVorbis::get_length() const {
-
- return vorbis_stream->length;
-}
-
AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
if (ogg_alloc.alloc_buffer) {
stb_vorbis_close(ogg_stream);
@@ -260,10 +256,15 @@ float AudioStreamOGGVorbis::get_loop_offset() const {
return loop_offset;
}
+float AudioStreamOGGVorbis::get_length() const {
+
+ return length;
+}
+
void AudioStreamOGGVorbis::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamOGGVorbis::set_data);
- ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamOGGVorbis::get_data);
+ ClassDB::bind_method(D_METHOD("_set_data", "data"), &AudioStreamOGGVorbis::set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"), &AudioStreamOGGVorbis::get_data);
ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOGGVorbis::set_loop);
ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOGGVorbis::has_loop);
@@ -271,7 +272,7 @@ void AudioStreamOGGVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset);
ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop", "has_loop");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop_offset", "get_loop_offset");
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index 8644e1ba37..d7bc7cc0d7 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef AUDIO_STREAM_STB_VORBIS_H
#define AUDIO_STREAM_STB_VORBIS_H
@@ -70,8 +71,6 @@ public:
virtual float get_playback_position() const;
virtual void seek(float p_time);
- virtual float get_length() const; //if supported, otherwise return 0
-
AudioStreamPlaybackOGGVorbis() {}
~AudioStreamPlaybackOGGVorbis();
};
@@ -111,6 +110,8 @@ public:
void set_data(const PoolVector<uint8_t> &p_data);
PoolVector<uint8_t> get_data() const;
+ virtual float get_length() const; //if supported, otherwise return 0
+
AudioStreamOGGVorbis();
virtual ~AudioStreamOGGVorbis();
};
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 4533d59cae..827e947a79 100644
--- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="AudioStreamOGGVorbis" inherits="AudioStream" category="Core" version="3.0-beta">
+<class name="AudioStreamOGGVorbis" inherits="AudioStream" category="Core" version="3.0-stable">
<brief_description>
OGG Vorbis audio stream driver.
</brief_description>
@@ -11,49 +11,13 @@
<demos>
</demos>
<methods>
- <method name="get_data" qualifiers="const">
- <return type="PoolByteArray">
- </return>
- <description>
- </description>
- </method>
- <method name="get_loop_offset" qualifiers="const">
- <return type="float">
- </return>
- <description>
- </description>
- </method>
- <method name="has_loop" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- </description>
- </method>
- <method name="set_data">
- <return type="void">
- </return>
- <argument index="0" name="data" type="PoolByteArray">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_loop">
- <return type="void">
- </return>
- <argument index="0" name="enable" type="bool">
- </argument>
- <description>
- </description>
- </method>
- <method name="set_loop_offset">
- <return type="void">
- </return>
- <argument index="0" name="seconds" type="float">
- </argument>
- <description>
- </description>
- </method>
</methods>
+ <members>
+ <member name="loop" type="bool" setter="set_loop" getter="has_loop">
+ </member>
+ <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset">
+ </member>
+ </members>
<constants>
</constants>
</class>
diff --git a/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml b/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml
index 9d541cda58..9a095c3ddd 100644
--- a/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ResourceImporterOGGVorbis" inherits="ResourceImporter" category="Core" version="3.0-beta">
+<class name="ResourceImporterOGGVorbis" inherits="ResourceImporter" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index 992cc1f159..514ef4c071 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "audio_stream_ogg_vorbis.h"
#include "resource_importer_ogg_vorbis.h"
diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h
index 9af22e2374..142be0efdf 100644
--- a/modules/stb_vorbis/register_types.h
+++ b/modules/stb_vorbis/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_stb_vorbis_types();
void unregister_stb_vorbis_types();
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index db4443255d..16ebfa2832 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "resource_importer_ogg_vorbis.h"
#include "io/resource_saver.h"
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
index 9b7bf1946e..a1847545aa 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef RESOURCEIMPORTEROGGVORBIS_H
#define RESOURCEIMPORTEROGGVORBIS_H
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index ea538a2895..8ccd229f3d 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_svg.h"
#include "os/os.h"
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index 61bf390bc7..63854da2f6 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_SVG_H
#define IMAGE_LOADER_SVG_H
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
index ddd63009f7..56426662cd 100644
--- a/modules/svg/register_types.cpp
+++ b/modules/svg/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_svg.h"
diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h
index 8759e3cdd5..015c586c6b 100644
--- a/modules/svg/register_types.h
+++ b/modules/svg/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_svg_types();
void unregister_svg_types();
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index dec8526b0a..7391bed699 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_tga.h"
#include "os/os.h"
diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h
index 2a0b6f4504..c4b10b7f49 100644
--- a/modules/tga/image_loader_tga.h
+++ b/modules/tga/image_loader_tga.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_TGA_H
#define IMAGE_LOADER_TGA_H
diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp
index 81991b1142..ac1b56af16 100644
--- a/modules/tga/register_types.cpp
+++ b/modules/tga/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_tga.h"
diff --git a/modules/tga/register_types.h b/modules/tga/register_types.h
index 1b6f66a4d0..6483f2576e 100644
--- a/modules/tga/register_types.h
+++ b/modules/tga/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_tga_types();
void unregister_tga_types();
diff --git a/modules/thekla_unwrap/register_types.cpp b/modules/thekla_unwrap/register_types.cpp
index eb11325dde..c74cbd9d18 100644
--- a/modules/thekla_unwrap/register_types.cpp
+++ b/modules/thekla_unwrap/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "error_macros.h"
#include "thirdparty/thekla_atlas/thekla/thekla_atlas.h"
diff --git a/modules/thekla_unwrap/register_types.h b/modules/thekla_unwrap/register_types.h
index 7a542592b5..8a0eab9437 100644
--- a/modules/thekla_unwrap/register_types.h
+++ b/modules/thekla_unwrap/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_thekla_unwrap_types();
void unregister_thekla_unwrap_types();
diff --git a/modules/theora/doc_classes/ResourceImporterTheora.xml b/modules/theora/doc_classes/ResourceImporterTheora.xml
index 85c7c6bf89..a280d767c3 100644
--- a/modules/theora/doc_classes/ResourceImporterTheora.xml
+++ b/modules/theora/doc_classes/ResourceImporterTheora.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ResourceImporterTheora" inherits="ResourceImporter" category="Core" version="3.0-beta">
+<class name="ResourceImporterTheora" inherits="ResourceImporter" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/theora/doc_classes/VideoStreamTheora.xml b/modules/theora/doc_classes/VideoStreamTheora.xml
index 6c8806ed72..9da3dc0d02 100644
--- a/modules/theora/doc_classes/VideoStreamTheora.xml
+++ b/modules/theora/doc_classes/VideoStreamTheora.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VideoStreamTheora" inherits="VideoStream" category="Core" version="3.0-beta">
+<class name="VideoStreamTheora" inherits="VideoStream" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp
index c6d125226b..9bc5ed903a 100644
--- a/modules/theora/register_types.cpp
+++ b/modules/theora/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "resource_importer_theora.h"
#include "video_stream_theora.h"
diff --git a/modules/theora/register_types.h b/modules/theora/register_types.h
index 69b43744b5..4a81d7743b 100644
--- a/modules/theora/register_types.h
+++ b/modules/theora/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_theora_types();
void unregister_theora_types();
diff --git a/modules/theora/resource_importer_theora.cpp b/modules/theora/resource_importer_theora.cpp
index 0c9a21c825..ee9bab74a7 100644
--- a/modules/theora/resource_importer_theora.cpp
+++ b/modules/theora/resource_importer_theora.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "resource_importer_theora.h"
#include "io/resource_saver.h"
diff --git a/modules/theora/resource_importer_theora.h b/modules/theora/resource_importer_theora.h
index 913bf87a42..e3c79287ad 100644
--- a/modules/theora/resource_importer_theora.h
+++ b/modules/theora/resource_importer_theora.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef RESOURCEIMPORTEROGGTHEORA_H
#define RESOURCEIMPORTEROGGTHEORA_H
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 2ff3fb6d7a..58c6d73ab2 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "video_stream_theora.h"
#include "os/os.h"
@@ -723,5 +724,5 @@ void VideoStreamTheora::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamTheora::set_file);
ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamTheora::get_file);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_file", "get_file");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_file", "get_file");
}
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index cbcdd34bfc..4bdbbdae20 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VIDEO_STREAM_THEORA_H
#define VIDEO_STREAM_THEORA_H
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index c4d9e7c7e0..0abefe11ee 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_tinyexr.h"
#include "os/os.h"
diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h
index b46c9582e1..6706e0972a 100644
--- a/modules/tinyexr/image_loader_tinyexr.h
+++ b/modules/tinyexr/image_loader_tinyexr.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_TINYEXR_H
#define IMAGE_LOADER_TINYEXR_H
diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp
index 648cc98c25..61217805cf 100644
--- a/modules/tinyexr/register_types.cpp
+++ b/modules/tinyexr/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_tinyexr.h"
diff --git a/modules/tinyexr/register_types.h b/modules/tinyexr/register_types.h
index e2bd8a0cbe..70cd0bfbf8 100644
--- a/modules/tinyexr/register_types.h
+++ b/modules/tinyexr/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_tinyexr_types();
void unregister_tinyexr_types();
diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml
index 46bd35dd73..a6a43f31b8 100644
--- a/modules/visual_script/doc_classes/VisualScript.xml
+++ b/modules/visual_script/doc_classes/VisualScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScript" inherits="Script" category="Core" version="3.0-beta">
+<class name="VisualScript" inherits="Script" category="Core" version="3.0-stable">
<brief_description>
A script implemented in the Visual Script programming environment.
</brief_description>
@@ -9,6 +9,7 @@
You are most likely to use this class via the Visual Script editor or when writing plugins for it.
</description>
<tutorials>
+ http://docs.godotengine.org/en/3.0/getting_started/scripting/visual_script/index.html
</tutorials>
<demos>
</demos>
diff --git a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
index e602214a66..d63a6ad524 100644
--- a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node representing a constant from the base types.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
index 9f7d38e957..da4db29086 100644
--- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node used to call built-in functions.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
index 78757843cd..189a6f6ad8 100644
--- a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptClassConstant" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptClassConstant" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Gets a constant from a given class.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml
index c21a082362..5462c379ad 100644
--- a/modules/visual_script/doc_classes/VisualScriptComment.xml
+++ b/modules/visual_script/doc_classes/VisualScriptComment.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptComment" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptComment" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node used to annotate the script.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptCondition.xml b/modules/visual_script/doc_classes/VisualScriptCondition.xml
index f1f87c010d..bb70a17357 100644
--- a/modules/visual_script/doc_classes/VisualScriptCondition.xml
+++ b/modules/visual_script/doc_classes/VisualScriptCondition.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptCondition" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptCondition" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node which branches the flow.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptConstant.xml b/modules/visual_script/doc_classes/VisualScriptConstant.xml
index 39a1e5eba8..e2ccb50bfd 100644
--- a/modules/visual_script/doc_classes/VisualScriptConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptConstant.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptConstant" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptConstant" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Gets a contant's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptConstructor.xml b/modules/visual_script/doc_classes/VisualScriptConstructor.xml
index cbe8c6c096..da6779b79d 100644
--- a/modules/visual_script/doc_classes/VisualScriptConstructor.xml
+++ b/modules/visual_script/doc_classes/VisualScriptConstructor.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptConstructor" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptConstructor" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node which calls a base type constructor.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
index c321c616af..33d2f1437a 100644
--- a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptCustomNode" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptCustomNode" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A scripted Visual Script node.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
index 0f396564e2..09fcba4314 100644
--- a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
+++ b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node which deconstructs a base type instance into its parts.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptEditor.xml b/modules/visual_script/doc_classes/VisualScriptEditor.xml
index b433f132c1..8e26758a31 100644
--- a/modules/visual_script/doc_classes/VisualScriptEditor.xml
+++ b/modules/visual_script/doc_classes/VisualScriptEditor.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptEditor" inherits="Object" category="Core" version="3.0-beta">
+<class name="VisualScriptEditor" inherits="Object" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
index 71e8c7d93c..30f96011d4 100644
--- a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
+++ b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Emits a specified signal.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
index b9f356412d..0dc0cdf5eb 100644
--- a/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
+++ b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
A Visual Script node returning a singleton from [@GlobalScope]
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptExpression.xml b/modules/visual_script/doc_classes/VisualScriptExpression.xml
index 91c107e069..91f55edb2b 100644
--- a/modules/visual_script/doc_classes/VisualScriptExpression.xml
+++ b/modules/visual_script/doc_classes/VisualScriptExpression.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptExpression" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptExpression" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunction.xml b/modules/visual_script/doc_classes/VisualScriptFunction.xml
index 2c63b98b22..bd59d739ea 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunction.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunction.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptFunction" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptFunction" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
index 03c47dca7c..e2b732a250 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
index 90ec85e4f4..614176498a 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptFunctionState" inherits="Reference" category="Core" version="3.0-beta">
+<class name="VisualScriptFunctionState" inherits="Reference" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
index 4417c8a533..a36f7809c2 100644
--- a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptIndexGet.xml b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml
index c0a83f186a..b2d0a194e0 100644
--- a/modules/visual_script/doc_classes/VisualScriptIndexGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptIndexGet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptIndexGet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptIndexSet.xml b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml
index 8661341919..7ad200afa4 100644
--- a/modules/visual_script/doc_classes/VisualScriptIndexSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptIndexSet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptIndexSet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
index afe72ba564..45c493887b 100644
--- a/modules/visual_script/doc_classes/VisualScriptInputAction.xml
+++ b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptInputAction" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptInputAction" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptIterator.xml b/modules/visual_script/doc_classes/VisualScriptIterator.xml
index 08dfad5acb..28e8a66182 100644
--- a/modules/visual_script/doc_classes/VisualScriptIterator.xml
+++ b/modules/visual_script/doc_classes/VisualScriptIterator.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptIterator" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptIterator" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Steps through items in a given input.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
index a4293adaae..66faf448cb 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptLocalVar" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptLocalVar" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Gets a local variable's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
index c1a279bdb2..8a816e5dd7 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Changes a local variable's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptMathConstant.xml b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
index 2cb053ee5f..45fa471c41 100644
--- a/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptMathConstant" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptMathConstant" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Commonly used mathematical constants.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptNode.xml b/modules/visual_script/doc_classes/VisualScriptNode.xml
index ef7cf7c3b8..e9d1cd949f 100644
--- a/modules/visual_script/doc_classes/VisualScriptNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptNode.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptNode" inherits="Resource" category="Core" version="3.0-beta">
+<class name="VisualScriptNode" inherits="Resource" category="Core" version="3.0-stable">
<brief_description>
A node which is part of a [VisualScript].
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptOperator.xml b/modules/visual_script/doc_classes/VisualScriptOperator.xml
index b7819592d9..4538bd3c78 100644
--- a/modules/visual_script/doc_classes/VisualScriptOperator.xml
+++ b/modules/visual_script/doc_classes/VisualScriptOperator.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptOperator" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptOperator" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptPreload.xml b/modules/visual_script/doc_classes/VisualScriptPreload.xml
index 712ec99fdb..3dae0e4b81 100644
--- a/modules/visual_script/doc_classes/VisualScriptPreload.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPreload.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptPreload" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptPreload" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Creates a new [Resource] or loads one from the filesystem.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
index 11c50f2b97..7555c83960 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
index 2e96ccc1f6..dc6a9efd83 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptPropertySet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptPropertySet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptResourcePath.xml b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
index 36bcf2a460..3789626ed0 100644
--- a/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
+++ b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptResourcePath" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptResourcePath" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptReturn.xml b/modules/visual_script/doc_classes/VisualScriptReturn.xml
index a05c1076a4..1172b7555b 100644
--- a/modules/visual_script/doc_classes/VisualScriptReturn.xml
+++ b/modules/visual_script/doc_classes/VisualScriptReturn.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptReturn" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptReturn" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Exits a function and returns an optional value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSceneNode.xml b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
index 1a73faaf67..4c6181e040 100644
--- a/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSceneNode" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSceneNode" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Node reference.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSceneTree.xml b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml
index 25ae9c26ac..68cc0d0b55 100644
--- a/modules/visual_script/doc_classes/VisualScriptSceneTree.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSceneTree" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSceneTree" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSelect.xml b/modules/visual_script/doc_classes/VisualScriptSelect.xml
index 45ac505110..017efdb07a 100644
--- a/modules/visual_script/doc_classes/VisualScriptSelect.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSelect.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSelect" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSelect" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Chooses between two input values.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSelf.xml b/modules/visual_script/doc_classes/VisualScriptSelf.xml
index 2b0c46a4bb..e9b480bbae 100644
--- a/modules/visual_script/doc_classes/VisualScriptSelf.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSelf.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSelf" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSelf" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Outputs a reference to the current instance.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSequence.xml b/modules/visual_script/doc_classes/VisualScriptSequence.xml
index 624663b0d3..be793ae36e 100644
--- a/modules/visual_script/doc_classes/VisualScriptSequence.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSequence.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSequence" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSequence" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Executes a series of Sequence ports.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSubCall.xml b/modules/visual_script/doc_classes/VisualScriptSubCall.xml
index b7dc5ad65f..85db63b78a 100644
--- a/modules/visual_script/doc_classes/VisualScriptSubCall.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSubCall.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSubCall" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSubCall" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptSwitch.xml b/modules/visual_script/doc_classes/VisualScriptSwitch.xml
index a34754b596..ec7565b31a 100644
--- a/modules/visual_script/doc_classes/VisualScriptSwitch.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSwitch.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptSwitch" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptSwitch" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Branches program flow based on a given input's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
index e61e81c397..d414a95657 100644
--- a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
+++ b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptTypeCast" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptTypeCast" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/doc_classes/VisualScriptVariableGet.xml b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
index 7122d2d3f6..ccd2918ec8 100644
--- a/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptVariableGet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptVariableGet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Gets a variable's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptVariableSet.xml b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
index 3c39da0a8d..e1fc1ba762 100644
--- a/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptVariableSet" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptVariableSet" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Changes a variable's value.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptWhile.xml b/modules/visual_script/doc_classes/VisualScriptWhile.xml
index d8e59a7576..de1ff45746 100644
--- a/modules/visual_script/doc_classes/VisualScriptWhile.xml
+++ b/modules/visual_script/doc_classes/VisualScriptWhile.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptWhile" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptWhile" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
Conditional loop.
</brief_description>
diff --git a/modules/visual_script/doc_classes/VisualScriptYield.xml b/modules/visual_script/doc_classes/VisualScriptYield.xml
index 72ef586c1f..f21b53861a 100644
--- a/modules/visual_script/doc_classes/VisualScriptYield.xml
+++ b/modules/visual_script/doc_classes/VisualScriptYield.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptYield" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptYield" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
@@ -9,22 +9,10 @@
<demos>
</demos>
<methods>
- <method name="get_yield_mode">
- <return type="int" enum="VisualScriptYield.YieldMode">
- </return>
- <description>
- </description>
- </method>
- <method name="set_yield_mode">
- <return type="void">
- </return>
- <argument index="0" name="mode" type="int" enum="VisualScriptYield.YieldMode">
- </argument>
- <description>
- </description>
- </method>
</methods>
<members>
+ <member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode">
+ </member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time">
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
index f69043a685..5075fb6ded 100644
--- a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
+++ b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" category="Core" version="3.0-beta">
+<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index a9c6554198..2809cff362 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "core/engine.h"
diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h
index 3d6eb25d10..27b3bd649a 100644
--- a/modules/visual_script/register_types.h
+++ b/modules/visual_script/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_visual_script_types();
void unregister_visual_script_types();
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 26c3aed465..5987fdf5da 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script.h"
#include "os/os.h"
@@ -129,7 +130,7 @@ void VisualScriptNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_default_input_values", "values"), &VisualScriptNode::_set_default_input_values);
ClassDB::bind_method(D_METHOD("_get_default_input_values"), &VisualScriptNode::_get_default_input_values);
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_default_input_values", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_default_input_values", "_get_default_input_values");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_default_input_values", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_default_input_values", "_get_default_input_values");
ADD_SIGNAL(MethodInfo("ports_changed"));
}
@@ -1318,7 +1319,7 @@ void VisualScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_data", "data"), &VisualScript::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &VisualScript::_get_data);
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
ADD_SIGNAL(MethodInfo("node_ports_changed", PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::INT, "id")));
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 76eadece66..69bb522173 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -27,8 +27,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VSCRIPT_H
-#define VSCRIPT_H
+
+#ifndef VISUAL_SCRIPT_H
+#define VISUAL_SCRIPT_H
#include "os/thread.h"
#include "script_language.h"
@@ -617,4 +618,4 @@ static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
return node;
}
-#endif // VSCRIPT_H
+#endif // VISUAL_SCRIPT_H
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 3ace2de176..7f0a42da82 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_builtin_funcs.h"
#include "class_db.h"
@@ -256,10 +257,10 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_ASIN:
case MATH_ACOS:
case MATH_ATAN:
- case MATH_ATAN2:
case MATH_SQRT: {
- return PropertyInfo(Variant::REAL, "num");
+ return PropertyInfo(Variant::REAL, "s");
} break;
+ case MATH_ATAN2:
case MATH_FMOD:
case MATH_FPOSMOD: {
if (p_idx == 0)
@@ -272,7 +273,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_ROUND:
case MATH_ABS:
case MATH_SIGN: {
- return PropertyInfo(Variant::REAL, "num");
+ return PropertyInfo(Variant::REAL, "s");
} break;
@@ -286,7 +287,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_EXP:
case MATH_ISNAN:
case MATH_ISINF: {
- return PropertyInfo(Variant::REAL, "num");
+ return PropertyInfo(Variant::REAL, "s");
} break;
case MATH_EASE: {
if (p_idx == 0)
@@ -317,7 +318,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
else if (p_idx == 1)
return PropertyInfo(Variant::REAL, "to");
else
- return PropertyInfo(Variant::REAL, "value");
+ return PropertyInfo(Variant::REAL, "weight");
} break;
case MATH_RANGE_LERP: {
if (p_idx == 0)
@@ -414,14 +415,14 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
} break;
case LOGIC_CLAMP: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "a");
- else if (p_idx == 0) // FIXME: is it ok to test p_idx == 0 twice?
+ return PropertyInfo(Variant::REAL, "value");
+ else if (p_idx == 1)
return PropertyInfo(Variant::REAL, "min");
else
return PropertyInfo(Variant::REAL, "max");
} break;
case LOGIC_NEAREST_PO2: {
- return PropertyInfo(Variant::INT, "num");
+ return PropertyInfo(Variant::INT, "value");
} break;
case OBJ_WEAKREF: {
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 1e098535f3..f862d5c26f 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUAL_SCRIPT_BUILTIN_FUNCS_H
#define VISUAL_SCRIPT_BUILTIN_FUNCS_H
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 15131c7b4b..69503e631c 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_editor.h"
#include "core/script_language.h"
@@ -317,7 +318,8 @@ protected:
}
p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT));
- p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,BitFlags,AllFlags,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText"));
+ // Update this when PropertyHint changes
+ p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig"));
p_list->push_back(PropertyInfo(Variant::STRING, "hint_string"));
p_list->push_back(PropertyInfo(Variant::BOOL, "export"));
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 22a45b077c..80bbf142d9 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUALSCRIPT_EDITOR_H
#define VISUALSCRIPT_EDITOR_H
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 2a051b3288..16de04e4cf 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_expression.h"
bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_value) {
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index 628f06fc0b..1f41e442c5 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUALSCRIPTEXPRESSION_H
#define VISUALSCRIPTEXPRESSION_H
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 56aeeac7fb..5c097dfa76 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_flow_control.h"
#include "io/resource_loader.h"
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index c985d1b9a9..40809d488a 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUAL_SCRIPT_FLOW_CONTROL_H
#define VISUAL_SCRIPT_FLOW_CONTROL_H
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 345d2f7df8..187c9b0b9e 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_func_nodes.h"
#include "engine.h"
@@ -424,7 +425,7 @@ void VisualScriptFunctionCall::_update_method_cache() {
#ifdef DEBUG_METHODS_ENABLED
- method_cache.return_val = mb->get_argument_info(-1);
+ method_cache.return_val = mb->get_return_info();
#endif
if (mb->is_vararg()) {
@@ -545,7 +546,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
- property.usage = PROPERTY_USAGE_NOEDITOR;
+ property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
@@ -738,7 +739,7 @@ void VisualScriptFunctionCall::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "singleton"), "set_singleton", "get_singleton");
ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "argument_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_argument_cache", "_get_argument_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "argument_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_argument_cache", "_get_argument_cache");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "function"), "set_function", "get_function"); //when set, if loaded properly, will override argument count.
ADD_PROPERTY(PropertyInfo(Variant::INT, "use_default_args"), "set_use_default_args", "get_use_default_args");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "validate"), "set_validate", "get_validate");
@@ -1349,7 +1350,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
- property.usage = PROPERTY_USAGE_NOEDITOR;
+ property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
@@ -1492,7 +1493,7 @@ void VisualScriptPropertySet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_type_cache", "_get_type_cache");
ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
@@ -2077,7 +2078,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
- property.usage = PROPERTY_USAGE_NOEDITOR;
+ property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
@@ -2216,7 +2217,7 @@ void VisualScriptPropertyGet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_type_cache", "_get_type_cache");
ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 925f3b94aa..0b30eae65a 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUAL_SCRIPT_FUNC_NODES_H
#define VISUAL_SCRIPT_FUNC_NODES_H
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index a41b3fc6c9..e0b4fde237 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_nodes.h"
#include "engine.h"
@@ -3106,8 +3107,8 @@ void VisualScriptConstructor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_constructor", "constructor"), &VisualScriptConstructor::set_constructor);
ClassDB::bind_method(D_METHOD("get_constructor"), &VisualScriptConstructor::get_constructor);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_constructor_type", "get_constructor_type");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "constructor", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_constructor", "get_constructor");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_constructor_type", "get_constructor_type");
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "constructor", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_constructor", "get_constructor");
}
VisualScriptConstructor::VisualScriptConstructor() {
@@ -3721,7 +3722,7 @@ void VisualScriptDeconstruct::_bind_methods() {
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_deconstruct_type", "get_deconstruct_type");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "elem_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_elem_cache", "_get_elem_cache");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "elem_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_elem_cache", "_get_elem_cache");
}
VisualScriptDeconstruct::VisualScriptDeconstruct() {
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index d49f64f3a6..a581e81c8c 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUAL_SCRIPT_NODES_H
#define VISUAL_SCRIPT_NODES_H
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 1961809be0..a96e8408c0 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "visual_script_yield_nodes.h"
#include "os/os.h"
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index b6efd88c0e..4009240581 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef VISUAL_SCRIPT_YIELD_NODES_H
#define VISUAL_SCRIPT_YIELD_NODES_H
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index 999c06f664..bae8f7be5f 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "audio_stream_ogg_vorbis.h"
size_t AudioStreamPlaybackOGGVorbis::_ov_read_func(void *p_dst, size_t p_data, size_t p_count, void *_f) {
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h
index 24102a43ec..01de8a3143 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/vorbis/audio_stream_ogg_vorbis.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef AUDIO_STREAM_OGG_VORBIS_H
#define AUDIO_STREAM_OGG_VORBIS_H
diff --git a/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp
index ffa3971c3e..0ea1fbe8b2 100644
--- a/modules/vorbis/register_types.cpp
+++ b/modules/vorbis/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "audio_stream_ogg_vorbis.h"
diff --git a/modules/vorbis/register_types.h b/modules/vorbis/register_types.h
index 8e54747036..3885502da2 100644
--- a/modules/vorbis/register_types.h
+++ b/modules/vorbis/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_vorbis_types();
void unregister_vorbis_types();
diff --git a/modules/vorbis/stub/register_types.cpp b/modules/vorbis/stub/register_types.cpp
index 39abb9aafc..02ac9518c8 100644
--- a/modules/vorbis/stub/register_types.cpp
+++ b/modules/vorbis/stub/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
diff --git a/modules/vorbis/stub/register_types.h b/modules/vorbis/stub/register_types.h
index a6c51fb3e1..3885502da2 100644
--- a/modules/vorbis/stub/register_types.h
+++ b/modules/vorbis/stub/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_vorbis_types();
void unregister_vorbis_types();
diff --git a/modules/webm/doc_classes/ResourceImporterWebm.xml b/modules/webm/doc_classes/ResourceImporterWebm.xml
index 5dadb83b07..20e0e48187 100644
--- a/modules/webm/doc_classes/ResourceImporterWebm.xml
+++ b/modules/webm/doc_classes/ResourceImporterWebm.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ResourceImporterWebm" inherits="ResourceImporter" category="Core" version="3.0-beta">
+<class name="ResourceImporterWebm" inherits="ResourceImporter" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml
index 6e8120b1de..94aea5c8d2 100644
--- a/modules/webm/doc_classes/VideoStreamWebm.xml
+++ b/modules/webm/doc_classes/VideoStreamWebm.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VideoStreamWebm" inherits="VideoStream" category="Core" version="3.0-beta">
+<class name="VideoStreamWebm" inherits="VideoStream" category="Core" version="3.0-stable">
<brief_description>
</brief_description>
<description>
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index 73ba17d184..aa282338cb 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -333,7 +333,7 @@ if webm_cpu_x86:
if webm_cpu_arm:
if env["platform"] == 'iphone':
env_libvpx["ASFLAGS"] = '-arch armv7'
- elif env["platform"] == 'android' or env["platform"] == 'x11' or env["platform"] == 'server':
+ elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'x11' or env["platform"] == 'server':
env_libvpx["ASFLAGS"] = '-mfpu=neon'
elif env["platform"] == 'uwp':
env_libvpx["AS"] = 'armasm'
@@ -389,5 +389,5 @@ elif webm_cpu_arm:
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms)
elif env["platform"] == 'iphone':
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple)
- else:
+ elif not env["android_arch"] == 'arm64v8':
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas)
diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp
index 10c06ca4e5..1183dd41f7 100644
--- a/modules/webm/register_types.cpp
+++ b/modules/webm/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "resource_importer_webm.h"
#include "video_stream_webm.h"
diff --git a/modules/webm/register_types.h b/modules/webm/register_types.h
index a429a9a398..102da2b0f5 100644
--- a/modules/webm/register_types.h
+++ b/modules/webm/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_webm_types();
void unregister_webm_types();
diff --git a/modules/webm/resource_importer_webm.cpp b/modules/webm/resource_importer_webm.cpp
index 2ea1485437..7124a503e8 100644
--- a/modules/webm/resource_importer_webm.cpp
+++ b/modules/webm/resource_importer_webm.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "resource_importer_webm.h"
#include "io/resource_saver.h"
diff --git a/modules/webm/resource_importer_webm.h b/modules/webm/resource_importer_webm.h
index 7cce805e70..d61e6e2a93 100644
--- a/modules/webm/resource_importer_webm.h
+++ b/modules/webm/resource_importer_webm.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef RESOURCEIMPORTERWEBM_H
#define RESOURCEIMPORTERWEBM_H
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index e915af3e6c..fac47225bc 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "video_stream_webm.h"
#include "OpusVorbisDecoder.hpp"
@@ -435,7 +436,7 @@ void VideoStreamWebm::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamWebm::set_file);
ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamWebm::get_file);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_file", "get_file");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_file", "get_file");
}
void VideoStreamWebm::set_audio_track(int p_track) {
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index c0b4490bf5..dde993d154 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -27,6 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+#ifndef VIDEO_STREAM_WEBM_H
+#define VIDEO_STREAM_WEBM_H
+
#include "io/resource_loader.h"
#include "scene/resources/video_stream.h"
@@ -122,3 +126,5 @@ public:
String get_file();
virtual void set_audio_track(int p_track);
};
+
+#endif // VIDEO_STREAM_WEBM_H
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 903b456540..cdf2d75e96 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "image_loader_webp.h"
#include "io/marshalls.h"
diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h
index b00c8b1b05..f051fed4b8 100644
--- a/modules/webp/image_loader_webp.h
+++ b/modules/webp/image_loader_webp.h
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#ifndef IMAGE_LOADER_WEBP_H
#define IMAGE_LOADER_WEBP_H
diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp
index 86eb558dff..9a2e83c65d 100644
--- a/modules/webp/register_types.cpp
+++ b/modules/webp/register_types.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "register_types.h"
#include "image_loader_webp.h"
diff --git a/modules/webp/register_types.h b/modules/webp/register_types.h
index 025bc49be1..711f5be61d 100644
--- a/modules/webp/register_types.h
+++ b/modules/webp/register_types.h
@@ -27,5 +27,6 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
void register_webp_types();
void unregister_webp_types();
diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub
new file mode 100644
index 0000000000..3b0f920bbf
--- /dev/null
+++ b/modules/websocket/SCsub
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+# Thirdparty source files
+
+env_lws = env_modules.Clone()
+
+thirdparty_dir = "#thirdparty/lws/"
+helper_dir = "win32helpers/"
+thirdparty_sources = [
+ "client/client.c",
+ "client/client-handshake.c",
+ "client/client-parser.c",
+ "client/ssl-client.c",
+
+ "ext/extension.c",
+ "ext/extension-permessage-deflate.c",
+
+ "server/fops-zip.c",
+ "server/lejp-conf.c",
+ "server/parsers.c",
+ "server/ranges.c",
+ "server/server.c",
+ "server/server-handshake.c",
+ "server/ssl-server.c",
+
+ "misc/base64-decode.c",
+ "misc/lejp.c",
+ "misc/sha-1.c",
+
+ "alloc.c",
+ "context.c",
+ "handshake.c",
+ "header.c",
+ "libwebsockets.c",
+ "minilex.c",
+ "output.c",
+ "pollfd.c",
+ "service.c",
+ "ssl.c",
+
+ "mbedtls_wrapper/library/ssl_cert.c",
+ "mbedtls_wrapper/library/ssl_pkey.c",
+ "mbedtls_wrapper/library/ssl_stack.c",
+ "mbedtls_wrapper/library/ssl_methods.c",
+ "mbedtls_wrapper/library/ssl_lib.c",
+ "mbedtls_wrapper/library/ssl_x509.c",
+ "mbedtls_wrapper/platform/ssl_port.c",
+ "mbedtls_wrapper/platform/ssl_pm.c",
+]
+
+if env_lws["platform"] == "android": # Builtin getifaddrs
+ thirdparty_sources += ["misc/getifaddrs.c"]
+
+if env_lws["platform"] == "windows": # Winsock
+ thirdparty_sources += ["plat/lws-plat-win.c", helper_dir + "getopt.c", helper_dir + "getopt_long.c", helper_dir + "gettimeofday.c"]
+else: # Unix socket
+ thirdparty_sources += ["plat/lws-plat-unix.c"]
+
+
+thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+if env_lws["platform"] == "javascript": # No need to add third party libraries at all
+ pass
+else:
+ env_lws.add_source_files(env.modules_sources, thirdparty_sources)
+ env_lws.Append(CPPPATH=[thirdparty_dir])
+
+ wrapper_includes = ["#thirdparty/lws/mbedtls_wrapper/include/" + inc for inc in ["internal", "openssl", "platform", ""]]
+ env_lws.Append(CPPPATH=wrapper_includes)
+
+ if env['builtin_mbedtls']:
+ mbedtls_includes = "#thirdparty/mbedtls/include"
+ env_lws.Append(CPPPATH=[mbedtls_includes])
+
+ if env_lws["platform"] == "windows":
+ env_lws.Append(CPPPATH=[thirdparty_dir + helper_dir])
+
+env_lws.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/pbm/config.py b/modules/websocket/config.py
index 5f133eba90..fb920482f5 100644
--- a/modules/pbm/config.py
+++ b/modules/websocket/config.py
@@ -1,5 +1,7 @@
+
def can_build(platform):
return True
+
def configure(env):
pass
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
new file mode 100644
index 0000000000..38fe520fc1
--- /dev/null
+++ b/modules/websocket/emws_client.cpp
@@ -0,0 +1,224 @@
+/*************************************************************************/
+/* emws_client.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifdef JAVASCRIPT_ENABLED
+
+#include "emws_client.h"
+#include "core/io/ip.h"
+#include "emscripten.h"
+
+extern "C" {
+EMSCRIPTEN_KEEPALIVE void _esws_on_connect(void *obj, char *proto) {
+ EMWSClient *client = static_cast<EMWSClient *>(obj);
+ client->_is_connecting = false;
+ client->_on_connect(String(proto));
+}
+
+EMSCRIPTEN_KEEPALIVE void _esws_on_message(void *obj, uint8_t *p_data, int p_data_size, int p_is_string) {
+ EMWSClient *client = static_cast<EMWSClient *>(obj);
+
+ static_cast<EMWSPeer *>(*client->get_peer(1))->read_msg(p_data, p_data_size, p_is_string == 1);
+ client->_on_peer_packet();
+}
+
+EMSCRIPTEN_KEEPALIVE void _esws_on_error(void *obj) {
+ EMWSClient *client = static_cast<EMWSClient *>(obj);
+ client->_is_connecting = false;
+ client->_on_error();
+}
+
+EMSCRIPTEN_KEEPALIVE void _esws_on_close(void *obj, int code, char *reason, int was_clean) {
+ EMWSClient *client = static_cast<EMWSClient *>(obj);
+ client->_is_connecting = false;
+ client->_on_disconnect();
+}
+}
+
+Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+
+ String str = "ws://";
+ String proto_string = "";
+ int i = 0;
+
+ if (p_ssl)
+ str = "wss://";
+ str += p_host + ":" + itos(p_port) + p_path;
+ for (int i = 0; i < p_protocols.size(); i++) {
+ proto_string += p_protocols[i];
+ proto_string += ",";
+ }
+ if (proto_string == "")
+ proto_string = "binary,";
+
+ proto_string = proto_string.substr(0, proto_string.length() - 1);
+
+ _is_connecting = true;
+ /* clang-format off */
+ int peer_sock = EM_ASM_INT({
+ var socket = new WebSocket(UTF8ToString($1), UTF8ToString($2).split(","));
+ var c_ptr = Module.IDHandler.get($0);
+ socket.binaryType = "arraybuffer";
+
+ // Connection opened
+ socket.addEventListener("open", function (event) {
+ if (!Module.IDHandler.has($0))
+ return; // Godot Object is gone!
+ ccall("_esws_on_connect",
+ "void",
+ ["number", "string"],
+ [c_ptr, socket.protocol]
+ );
+ });
+
+ // Listen for messages
+ socket.addEventListener("message", function (event) {
+ if (!Module.IDHandler.has($0))
+ return; // Godot Object is gone!
+ var buffer;
+ var is_string = 0;
+ if (event.data instanceof ArrayBuffer) {
+
+ buffer = new Uint8Array(event.data);
+
+ } else if (event.data instanceof Blob) {
+
+ alert("Blob type not supported");
+ return;
+
+ } else if (typeof event.data === "string") {
+
+ is_string = 1;
+ var enc = new TextEncoder("utf-8");
+ buffer = new Uint8Array(enc.encode(event.data));
+
+ } else {
+
+ alert("Unknown message type");
+ return;
+
+ }
+ var len = buffer.length*buffer.BYTES_PER_ELEMENT;
+ var out = Module._malloc(len);
+ Module.HEAPU8.set(buffer, out);
+ ccall("_esws_on_message",
+ "void",
+ ["number", "number", "number", "number"],
+ [c_ptr, out, len, is_string]
+ );
+ Module._free(out);
+ });
+
+ socket.addEventListener("error", function (event) {
+ if (!Module.IDHandler.has($0))
+ return; // Godot Object is gone!
+ ccall("_esws_on_error",
+ "void",
+ ["number"],
+ [c_ptr]
+ );
+ });
+
+ socket.addEventListener("close", function (event) {
+ if (!Module.IDHandler.has($0))
+ return; // Godot Object is gone!
+ var was_clean = 0;
+ if (event.was_clean)
+ was_clean = 1;
+ ccall("_esws_on_close",
+ "void",
+ ["number", "number", "string", "number"],
+ [c_ptr, event.code, event.reason, was_clean]
+ );
+ });
+
+ return Module.IDHandler.add(socket);
+ }, _js_id, str.utf8().get_data(), proto_string.utf8().get_data());
+ /* clang-format on */
+
+ static_cast<Ref<EMWSPeer> >(_peer)->set_sock(peer_sock);
+
+ return OK;
+};
+
+void EMWSClient::poll() {
+}
+
+Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const {
+
+ return _peer;
+}
+
+NetworkedMultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
+
+ if (_peer->is_connected_to_host())
+ return CONNECTION_CONNECTED;
+
+ if (_is_connecting)
+ return CONNECTION_CONNECTING;
+
+ return CONNECTION_DISCONNECTED;
+};
+
+void EMWSClient::disconnect_from_host() {
+
+ _peer->close();
+};
+
+IP_Address EMWSClient::get_connected_host() const {
+
+ return IP_Address();
+};
+
+uint16_t EMWSClient::get_connected_port() const {
+
+ return 1025;
+};
+
+EMWSClient::EMWSClient() {
+ _is_connecting = false;
+ _peer = Ref<EMWSPeer>(memnew(EMWSPeer));
+ /* clang-format off */
+ _js_id = EM_ASM_INT({
+ return Module.IDHandler.add($0);
+ }, this);
+ /* clang-format on */
+};
+
+EMWSClient::~EMWSClient() {
+
+ disconnect_from_host();
+ _peer = Ref<EMWSPeer>();
+ /* clang-format off */
+ EM_ASM({
+ Module.IDHandler.remove($0);
+ }, _js_id);
+ /* clang-format on */
+};
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h
new file mode 100644
index 0000000000..8801f37007
--- /dev/null
+++ b/modules/websocket/emws_client.h
@@ -0,0 +1,62 @@
+/*************************************************************************/
+/* emws_client.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef EMWSCLIENT_H
+#define EMWSCLIENT_H
+
+#ifdef JAVASCRIPT_ENABLED
+
+#include "core/error_list.h"
+#include "emws_peer.h"
+#include "websocket_client.h"
+
+class EMWSClient : public WebSocketClient {
+
+ GDCIIMPL(EMWSClient, WebSocketClient);
+
+private:
+ int _js_id;
+
+public:
+ bool _is_connecting;
+
+ Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
+ Ref<WebSocketPeer> get_peer(int p_peer_id) const;
+ void disconnect_from_host();
+ IP_Address get_connected_host() const;
+ uint16_t get_connected_port() const;
+ virtual ConnectionStatus get_connection_status() const;
+ virtual void poll();
+ EMWSClient();
+ ~EMWSClient();
+};
+
+#endif // JAVASCRIPT_ENABLED
+
+#endif // EMWSCLIENT_H
diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp
new file mode 100644
index 0000000000..93665e6428
--- /dev/null
+++ b/modules/websocket/emws_peer.cpp
@@ -0,0 +1,173 @@
+/*************************************************************************/
+/* emws_peer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifdef JAVASCRIPT_ENABLED
+
+#include "emws_peer.h"
+#include "core/io/ip.h"
+
+void EMWSPeer::set_sock(int p_sock) {
+
+ peer_sock = p_sock;
+ in_buffer.clear();
+ queue_count = 0;
+}
+
+void EMWSPeer::set_write_mode(WriteMode p_mode) {
+ write_mode = p_mode;
+}
+
+EMWSPeer::WriteMode EMWSPeer::get_write_mode() const {
+ return write_mode;
+}
+
+void EMWSPeer::read_msg(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
+
+ if (in_buffer.space_left() < p_size + 5) {
+ ERR_EXPLAIN("Buffer full! Dropping data");
+ ERR_FAIL();
+ }
+
+ uint8_t is_string = p_is_string ? 1 : 0;
+ in_buffer.write((uint8_t *)&p_size, 4);
+ in_buffer.write((uint8_t *)&is_string, 1);
+ in_buffer.write(p_data, p_size);
+ queue_count++;
+}
+
+Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+
+ int is_bin = write_mode == WebSocketPeer::WRITE_MODE_BINARY ? 1 : 0;
+
+ /* clang-format off */
+ EM_ASM({
+ var sock = Module.IDHandler.get($0);
+ var bytes_array = new Uint8Array($2);
+ var i = 0;
+
+ for(i=0; i<$2; i++) {
+ bytes_array[i] = getValue($1+i, 'i8');
+ }
+
+ if ($3) {
+ sock.send(bytes_array.buffer);
+ } else {
+ var string = new TextDecoder("utf-8").decode(bytes_array);
+ sock.send(string);
+ }
+ }, peer_sock, p_buffer, p_buffer_size, is_bin);
+ /* clang-format on */
+
+ return OK;
+};
+
+Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+
+ if (queue_count == 0)
+ return ERR_UNAVAILABLE;
+
+ uint32_t to_read = 0;
+ uint32_t left = 0;
+ uint8_t is_string = 0;
+ r_buffer_size = 0;
+
+ in_buffer.read((uint8_t *)&to_read, 4);
+ --queue_count;
+ left = in_buffer.data_left();
+
+ if (left < to_read + 1) {
+ in_buffer.advance_read(left);
+ return FAILED;
+ }
+
+ in_buffer.read(&is_string, 1);
+ _was_string = is_string == 1;
+ in_buffer.read(packet_buffer, to_read);
+ *r_buffer = packet_buffer;
+ r_buffer_size = to_read;
+
+ return OK;
+};
+
+int EMWSPeer::get_available_packet_count() const {
+
+ return queue_count;
+};
+
+bool EMWSPeer::was_string_packet() const {
+
+ return _was_string;
+};
+
+bool EMWSPeer::is_connected_to_host() const {
+
+ return peer_sock != -1;
+};
+
+void EMWSPeer::close() {
+
+ if (peer_sock != -1) {
+ /* clang-format off */
+ EM_ASM({
+ var sock = Module.IDHandler.get($0);
+ sock.close();
+ Module.IDHandler.remove($0);
+ }, peer_sock);
+ /* clang-format on */
+ }
+ peer_sock = -1;
+ queue_count = 0;
+ in_buffer.clear();
+};
+
+IP_Address EMWSPeer::get_connected_host() const {
+
+ return IP_Address();
+};
+
+uint16_t EMWSPeer::get_connected_port() const {
+
+ return 1025;
+};
+
+EMWSPeer::EMWSPeer() {
+ peer_sock = -1;
+ queue_count = 0;
+ _was_string = false;
+ in_buffer.resize(16);
+ write_mode = WRITE_MODE_BINARY;
+};
+
+EMWSPeer::~EMWSPeer() {
+
+ in_buffer.resize(0);
+ close();
+};
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h
new file mode 100644
index 0000000000..a50d1874ba
--- /dev/null
+++ b/modules/websocket/emws_peer.h
@@ -0,0 +1,85 @@
+/*************************************************************************/
+/* emws_peer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef EMWSPEER_H
+#define EMWSPEER_H
+
+#ifdef JAVASCRIPT_ENABLED
+
+#include "core/error_list.h"
+#include "core/io/packet_peer.h"
+#include "core/ring_buffer.h"
+#include "emscripten.h"
+#include "websocket_peer.h"
+
+class EMWSPeer : public WebSocketPeer {
+
+ GDCIIMPL(EMWSPeer, WebSocketPeer);
+
+private:
+ enum {
+ PACKET_BUFFER_SIZE = 65536 - 5 // 4 bytes for the size, 1 for for type
+ };
+
+ int peer_sock;
+ WriteMode write_mode;
+
+ uint8_t packet_buffer[PACKET_BUFFER_SIZE];
+ RingBuffer<uint8_t> in_buffer;
+ int queue_count;
+ bool _was_string;
+
+public:
+ void read_msg(uint8_t *p_data, uint32_t p_size, bool p_is_string);
+ void set_sock(int sock);
+ virtual int get_available_packet_count() const;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size);
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+ virtual int get_max_packet_size() const { return PACKET_BUFFER_SIZE; };
+
+ virtual void close();
+ virtual bool is_connected_to_host() const;
+ virtual IP_Address get_connected_host() const;
+ virtual uint16_t get_connected_port() const;
+
+ virtual WriteMode get_write_mode() const;
+ virtual void set_write_mode(WriteMode p_mode);
+ virtual bool was_string_packet() const;
+
+ void set_wsi(struct lws *wsi);
+ Error read_wsi(void *in, size_t len);
+ Error write_wsi();
+
+ EMWSPeer();
+ ~EMWSPeer();
+};
+
+#endif // JAVASCRIPT_ENABLED
+
+#endif // LSWPEER_H
diff --git a/modules/pbm/register_types.cpp b/modules/websocket/emws_server.cpp
index c2a1585afa..60e9133225 100644
--- a/modules/pbm/register_types.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* register_types.cpp */
+/* emws_server.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,19 +27,41 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "register_types.h"
+#ifdef JAVASCRIPT_ENABLED
-#include "bitmap_loader_pbm.h"
+#include "emws_server.h"
+#include "core/os/os.h"
-static ResourceFormatPBM *pbm_loader = NULL;
+Error EMWSServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_api) {
-void register_pbm_types() {
+ return FAILED;
+}
+
+bool EMWSServer::is_listening() const {
+ return false;
+}
+
+void EMWSServer::stop() {
+}
+
+bool EMWSServer::has_peer(int p_id) const {
+ return false;
+}
+
+Ref<WebSocketPeer> EMWSServer::get_peer(int p_id) const {
+ return NULL;
+}
- pbm_loader = memnew(ResourceFormatPBM);
- ResourceLoader::add_resource_format_loader(pbm_loader);
+PoolVector<String> EMWSServer::get_protocols() const {
+ PoolVector<String> out;
+
+ return out;
}
-void unregister_pbm_types() {
+EMWSServer::EMWSServer() {
+}
- memdelete(pbm_loader);
+EMWSServer::~EMWSServer() {
}
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/pbm/bitmap_loader_pbm.h b/modules/websocket/emws_server.h
index d5955adba3..59f1d76346 100644
--- a/modules/pbm/bitmap_loader_pbm.h
+++ b/modules/websocket/emws_server.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* bitmap_loader_pbm.h */
+/* emws_server.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,21 +27,32 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef BITMAP_LOADER_PBM_H
-#define BITMAP_LOADER_PBM_H
+#ifndef EMWSSERVER_H
+#define EMWSSERVER_H
-#include "io/resource_loader.h"
+#ifdef JAVASCRIPT_ENABLED
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class ResourceFormatPBM : public ResourceFormatLoader {
+#include "core/reference.h"
+#include "emws_peer.h"
+#include "websocket_server.h"
+
+class EMWSServer : public WebSocketServer {
+
+ GDCIIMPL(EMWSServer, WebSocketServer);
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String &p_type) const;
- virtual String get_resource_type(const String &p_path) const;
+ Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
+ void stop();
+ bool is_listening() const;
+ bool has_peer(int p_id) const;
+ Ref<WebSocketPeer> get_peer(int p_id) const;
+ virtual void poll();
+ virtual PoolVector<String> get_protocols() const;
+
+ EMWSServer();
+ ~EMWSServer();
};
#endif
+
+#endif // LWSSERVER_H
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
new file mode 100644
index 0000000000..604b1886ad
--- /dev/null
+++ b/modules/websocket/lws_client.cpp
@@ -0,0 +1,203 @@
+/*************************************************************************/
+/* lws_client.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef JAVASCRIPT_ENABLED
+
+#include "lws_client.h"
+#include "core/io/ip.h"
+
+Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+
+ ERR_FAIL_COND_V(context != NULL, FAILED);
+
+ IP_Address addr;
+
+ if (!p_host.is_valid_ip_address()) {
+ addr = IP::get_singleton()->resolve_hostname(p_host);
+ } else {
+ addr = p_host;
+ }
+
+ ERR_FAIL_COND_V(!addr.is_valid(), ERR_INVALID_PARAMETER);
+
+ // prepare protocols
+ if (p_protocols.size() == 0) // default to binary protocol
+ p_protocols.append("binary");
+ _lws_make_protocols(this, &LWSClient::_lws_gd_callback, p_protocols, &_lws_ref);
+
+ // init lws client
+ struct lws_context_creation_info info;
+ struct lws_client_connect_info i;
+
+ memset(&i, 0, sizeof i);
+ memset(&info, 0, sizeof info);
+
+ info.port = CONTEXT_PORT_NO_LISTEN;
+ info.protocols = _lws_ref->lws_structs;
+ info.gid = -1;
+ info.uid = -1;
+ //info.ws_ping_pong_interval = 5;
+ info.user = _lws_ref;
+ context = lws_create_context(&info);
+
+ if (context == NULL) {
+ _lws_free_ref(_lws_ref);
+ _lws_ref = NULL;
+ ERR_EXPLAIN("Unable to create lws context");
+ ERR_FAIL_V(FAILED);
+ }
+
+ char abuf[1024];
+ char hbuf[1024];
+ char pbuf[2048];
+ String addr_str = (String)addr;
+ strncpy(abuf, addr_str.ascii().get_data(), 1024);
+ strncpy(hbuf, p_host.utf8().get_data(), 1024);
+ strncpy(pbuf, p_path.utf8().get_data(), 2048);
+
+ i.context = context;
+ i.protocol = _lws_ref->lws_names;
+ i.address = abuf;
+ i.host = hbuf;
+ i.path = pbuf;
+ i.port = p_port;
+ i.ssl_connection = p_ssl;
+
+ lws_client_connect_via_info(&i);
+ return OK;
+};
+
+void LWSClient::poll() {
+
+ _lws_poll();
+}
+
+int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) {
+
+ Ref<LWSPeer> peer = static_cast<Ref<LWSPeer> >(_peer);
+ LWSPeer::PeerData *peer_data = (LWSPeer::PeerData *)user;
+
+ switch (reason) {
+
+ case LWS_CALLBACK_CLIENT_ESTABLISHED:
+ peer->set_wsi(wsi);
+ peer_data->peer_id = 0;
+ peer_data->in_size = 0;
+ peer_data->in_count = 0;
+ peer_data->out_count = 0;
+ peer_data->rbw.resize(16);
+ peer_data->rbr.resize(16);
+ peer_data->force_close = false;
+ _on_connect(lws_get_protocol(wsi)->name);
+ break;
+
+ case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
+ _on_error();
+ destroy_context();
+ return -1; // we should close the connection (would probably happen anyway)
+
+ case LWS_CALLBACK_CLOSED:
+ peer_data->in_count = 0;
+ peer_data->out_count = 0;
+ peer_data->rbw.resize(0);
+ peer_data->rbr.resize(0);
+ peer->close();
+ destroy_context();
+ _on_disconnect();
+ return 0; // we can end here
+
+ case LWS_CALLBACK_CLIENT_RECEIVE:
+ peer->read_wsi(in, len);
+ if (peer->get_available_packet_count() > 0)
+ _on_peer_packet();
+ break;
+
+ case LWS_CALLBACK_CLIENT_WRITEABLE:
+ if (peer_data->force_close)
+ return -1;
+
+ peer->write_wsi();
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+Ref<WebSocketPeer> LWSClient::get_peer(int p_peer_id) const {
+
+ return _peer;
+}
+
+NetworkedMultiplayerPeer::ConnectionStatus LWSClient::get_connection_status() const {
+
+ if (context == NULL)
+ return CONNECTION_DISCONNECTED;
+
+ if (_peer->is_connected_to_host())
+ return CONNECTION_CONNECTED;
+
+ return CONNECTION_CONNECTING;
+}
+
+void LWSClient::disconnect_from_host() {
+
+ if (context == NULL)
+ return;
+
+ _peer->close();
+ destroy_context();
+};
+
+IP_Address LWSClient::get_connected_host() const {
+
+ return IP_Address();
+};
+
+uint16_t LWSClient::get_connected_port() const {
+
+ return 1025;
+};
+
+LWSClient::LWSClient() {
+ context = NULL;
+ _lws_ref = NULL;
+ _peer = Ref<LWSPeer>(memnew(LWSPeer));
+};
+
+LWSClient::~LWSClient() {
+
+ invalidate_lws_ref(); // We do not want any more callback
+ disconnect_from_host();
+ _peer = Ref<LWSPeer>();
+};
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/lws_client.h b/modules/websocket/lws_client.h
new file mode 100644
index 0000000000..2e082175df
--- /dev/null
+++ b/modules/websocket/lws_client.h
@@ -0,0 +1,61 @@
+/*************************************************************************/
+/* lws_client.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef LWSCLIENT_H
+#define LWSCLIENT_H
+
+#ifndef JAVASCRIPT_ENABLED
+
+#include "core/error_list.h"
+#include "lws_helper.h"
+#include "lws_peer.h"
+#include "websocket_client.h"
+
+class LWSClient : public WebSocketClient {
+
+ GDCIIMPL(LWSClient, WebSocketClient);
+
+ LWS_HELPER(LWSClient);
+
+public:
+ Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
+ Ref<WebSocketPeer> get_peer(int p_peer_id) const;
+ void disconnect_from_host();
+ IP_Address get_connected_host() const;
+ uint16_t get_connected_port() const;
+ virtual ConnectionStatus get_connection_status() const;
+ virtual void poll();
+
+ LWSClient();
+ ~LWSClient();
+};
+
+#endif // JAVASCRIPT_ENABLED
+
+#endif // LWSCLIENT_H
diff --git a/modules/websocket/lws_helper.h b/modules/websocket/lws_helper.h
new file mode 100644
index 0000000000..ac0c340aa9
--- /dev/null
+++ b/modules/websocket/lws_helper.h
@@ -0,0 +1,214 @@
+/*************************************************************************/
+/* lws_helper.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef LWS_HELPER_H
+#define LWS_HELPER_H
+
+#include "core/io/stream_peer.h"
+#include "core/os/os.h"
+#include "core/reference.h"
+#include "core/ring_buffer.h"
+#include "lws_peer.h"
+
+struct _LWSRef {
+ bool free_context;
+ bool is_polling;
+ bool is_valid;
+ bool is_destroying;
+ void *obj;
+ struct lws_protocols *lws_structs;
+ char *lws_names;
+};
+
+static _LWSRef *_lws_create_ref(void *obj) {
+
+ _LWSRef *out = (_LWSRef *)memalloc(sizeof(_LWSRef));
+ out->is_destroying = false;
+ out->free_context = false;
+ out->is_polling = false;
+ out->obj = obj;
+ out->is_valid = true;
+ out->lws_structs = NULL;
+ out->lws_names = NULL;
+ return out;
+}
+
+static void _lws_free_ref(_LWSRef *ref) {
+ // Free strings and structs
+ memfree(ref->lws_structs);
+ memfree(ref->lws_names);
+ // Free ref
+ memfree(ref);
+}
+
+static bool _lws_destroy(struct lws_context *context, _LWSRef *ref) {
+ if (context == NULL || ref->is_destroying)
+ return false;
+
+ if (ref->is_polling) {
+ ref->free_context = true;
+ return false;
+ }
+
+ ref->is_destroying = true;
+ lws_context_destroy(context);
+ _lws_free_ref(ref);
+ return true;
+}
+
+static bool _lws_poll(struct lws_context *context, _LWSRef *ref) {
+
+ ERR_FAIL_COND_V(context == NULL, false);
+ ERR_FAIL_COND_V(ref == NULL, false);
+
+ ref->is_polling = true;
+ lws_service(context, 0);
+ ref->is_polling = false;
+
+ if (!ref->free_context)
+ return false; // Nothing to do
+
+ bool is_valid = ref->is_valid; // Might have been destroyed by poll
+
+ _lws_destroy(context, ref); // Will destroy context and ref
+
+ return is_valid; // If the object should NULL its context and ref
+}
+
+/*
+ * prepare the protocol_structs to be fed to context
+ * also prepare the protocol string used by the client
+ */
+static void _lws_make_protocols(void *p_obj, lws_callback_function *p_callback, PoolVector<String> p_names, _LWSRef **r_lws_ref) {
+ /* the input strings might go away after this call,
+ * we need to copy them. Will clear them when
+ * detroying the context */
+ int i;
+ int len = p_names.size();
+ size_t data_size = sizeof(struct LWSPeer::PeerData);
+ PoolVector<String>::Read pnr = p_names.read();
+
+ /*
+ * This is a reference connecting the object with lws
+ * keep track of status, mallocs, etc.
+ * Must survive as long the context
+ * Must be freed manually when context creation fails.
+ */
+ _LWSRef *ref = _lws_create_ref(p_obj);
+
+ /* LWS protocol structs */
+ ref->lws_structs = (struct lws_protocols *)memalloc(sizeof(struct lws_protocols) * (len + 2));
+
+ CharString strings = p_names.join(",").ascii();
+ int str_len = strings.length();
+
+ /* Joined string of protocols, double the size: comma separated first, NULL separated last */
+ ref->lws_names = (char *)memalloc((str_len + 1) * 2); /* plus the terminator */
+
+ char *names_ptr = ref->lws_names;
+ struct lws_protocols *structs_ptr = ref->lws_structs;
+
+ copymem(names_ptr, strings.get_data(), str_len);
+ names_ptr[str_len] = '\0'; /* NULL terminator */
+ /* NULL terminated strings to be used in protocol structs */
+ copymem(&names_ptr[str_len + 1], strings.get_data(), str_len);
+ names_ptr[(str_len * 2) + 1] = '\0'; /* NULL terminator */
+ int pos = str_len + 1;
+
+ /* the first protocol is always http-only */
+ structs_ptr[0].name = "http-only";
+ structs_ptr[0].callback = p_callback;
+ structs_ptr[0].per_session_data_size = data_size;
+ structs_ptr[0].rx_buffer_size = 0;
+ /* add user defined protocols */
+ for (i = 0; i < len; i++) {
+ structs_ptr[i + 1].name = (const char *)&names_ptr[pos];
+ structs_ptr[i + 1].callback = p_callback;
+ structs_ptr[i + 1].per_session_data_size = data_size;
+ structs_ptr[i + 1].rx_buffer_size = 0;
+ pos += pnr[i].ascii().length() + 1;
+ names_ptr[pos - 1] = '\0';
+ }
+ /* add protocols terminator */
+ structs_ptr[len + 1].name = NULL;
+ structs_ptr[len + 1].callback = NULL;
+ structs_ptr[len + 1].per_session_data_size = 0;
+ structs_ptr[len + 1].rx_buffer_size = 0;
+
+ *r_lws_ref = ref;
+}
+
+/* clang-format off */
+#define LWS_HELPER(CNAME) \
+protected: \
+ struct _LWSRef *_lws_ref; \
+ struct lws_context *context; \
+ \
+ static int _lws_gd_callback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) { \
+ \
+ if (wsi == NULL) { \
+ return 0; \
+ } \
+ \
+ struct _LWSRef *ref = (struct _LWSRef *)lws_context_user(lws_get_context(wsi)); \
+ if (!ref->is_valid) \
+ return 0; \
+ CNAME *helper = (CNAME *)ref->obj; \
+ return helper->_handle_cb(wsi, reason, user, in, len); \
+ } \
+ \
+ void invalidate_lws_ref() { \
+ if (_lws_ref != NULL) \
+ _lws_ref->is_valid = false; \
+ } \
+ \
+ void destroy_context() { \
+ if (_lws_destroy(context, _lws_ref)) { \
+ context = NULL; \
+ _lws_ref = NULL; \
+ } \
+ } \
+ \
+public: \
+ virtual int _handle_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len); \
+ \
+ void _lws_poll() { \
+ ERR_FAIL_COND(context == NULL); \
+ \
+ if (::_lws_poll(context, _lws_ref)) { \
+ context = NULL; \
+ _lws_ref = NULL; \
+ } \
+ } \
+ \
+protected:
+
+ /* clang-format on */
+
+#endif // LWS_HELPER_H
diff --git a/modules/websocket/lws_peer.cpp b/modules/websocket/lws_peer.cpp
new file mode 100644
index 0000000000..fdaa79f9d4
--- /dev/null
+++ b/modules/websocket/lws_peer.cpp
@@ -0,0 +1,200 @@
+/*************************************************************************/
+/* lws_peer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef JAVASCRIPT_ENABLED
+
+#include "lws_peer.h"
+#include "core/io/ip.h"
+
+void LWSPeer::set_wsi(struct lws *p_wsi) {
+ wsi = p_wsi;
+};
+
+void LWSPeer::set_write_mode(WriteMode p_mode) {
+ write_mode = p_mode;
+}
+
+LWSPeer::WriteMode LWSPeer::get_write_mode() const {
+ return write_mode;
+}
+
+Error LWSPeer::read_wsi(void *in, size_t len) {
+
+ ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
+
+ PeerData *peer_data = (PeerData *)(lws_wsi_user(wsi));
+ uint32_t size = peer_data->in_size;
+ uint8_t is_string = lws_frame_is_binary(wsi) ? 0 : 1;
+
+ if (peer_data->rbr.space_left() < len + 5) {
+ ERR_EXPLAIN("Buffer full! Dropping data");
+ ERR_FAIL_V(FAILED);
+ }
+
+ copymem(&(peer_data->input_buffer[size]), in, len);
+ size += len;
+
+ peer_data->in_size = size;
+ if (lws_is_final_fragment(wsi)) {
+ peer_data->rbr.write((uint8_t *)&size, 4);
+ peer_data->rbr.write((uint8_t *)&is_string, 1);
+ peer_data->rbr.write(peer_data->input_buffer, size);
+ peer_data->in_count++;
+ peer_data->in_size = 0;
+ }
+
+ return OK;
+}
+
+Error LWSPeer::write_wsi() {
+
+ ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
+
+ PeerData *peer_data = (PeerData *)(lws_wsi_user(wsi));
+ PoolVector<uint8_t> tmp;
+ int left = peer_data->rbw.data_left();
+ uint32_t to_write = 0;
+
+ if (left == 0 || peer_data->out_count == 0)
+ return OK;
+
+ peer_data->rbw.read((uint8_t *)&to_write, 4);
+ peer_data->out_count--;
+
+ if (left < to_write) {
+ peer_data->rbw.advance_read(left);
+ return FAILED;
+ }
+
+ tmp.resize(LWS_PRE + to_write);
+ peer_data->rbw.read(&(tmp.write()[LWS_PRE]), to_write);
+ lws_write(wsi, &(tmp.write()[LWS_PRE]), to_write, (enum lws_write_protocol)write_mode);
+ tmp.resize(0);
+
+ if (peer_data->out_count > 0)
+ lws_callback_on_writable(wsi); // we want to write more!
+
+ return OK;
+}
+
+Error LWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+
+ ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
+
+ PeerData *peer_data = (PeerData *)lws_wsi_user(wsi);
+ peer_data->rbw.write((uint8_t *)&p_buffer_size, 4);
+ peer_data->rbw.write(p_buffer, MIN(p_buffer_size, peer_data->rbw.space_left()));
+ peer_data->out_count++;
+
+ lws_callback_on_writable(wsi); // notify that we want to write
+ return OK;
+};
+
+Error LWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+
+ ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
+
+ PeerData *peer_data = (PeerData *)lws_wsi_user(wsi);
+
+ if (peer_data->in_count == 0)
+ return ERR_UNAVAILABLE;
+
+ uint32_t to_read = 0;
+ uint32_t left = 0;
+ uint8_t is_string = 0;
+ r_buffer_size = 0;
+
+ peer_data->rbr.read((uint8_t *)&to_read, 4);
+ peer_data->in_count--;
+ left = peer_data->rbr.data_left();
+
+ if (left < to_read + 1) {
+ peer_data->rbr.advance_read(left);
+ return FAILED;
+ }
+
+ peer_data->rbr.read(&is_string, 1);
+ peer_data->rbr.read(packet_buffer, to_read);
+ *r_buffer = packet_buffer;
+ r_buffer_size = to_read;
+ _was_string = is_string;
+
+ return OK;
+};
+
+int LWSPeer::get_available_packet_count() const {
+
+ if (!is_connected_to_host())
+ return 0;
+
+ return ((PeerData *)lws_wsi_user(wsi))->in_count;
+};
+
+bool LWSPeer::was_string_packet() const {
+
+ return _was_string;
+};
+
+bool LWSPeer::is_connected_to_host() const {
+
+ return wsi != NULL;
+};
+
+void LWSPeer::close() {
+ if (wsi != NULL) {
+ struct lws *tmp = wsi;
+ PeerData *data = ((PeerData *)lws_wsi_user(wsi));
+ data->force_close = true;
+ wsi = NULL;
+ lws_callback_on_writable(tmp); // notify that we want to disconnect
+ }
+};
+
+IP_Address LWSPeer::get_connected_host() const {
+
+ return IP_Address();
+};
+
+uint16_t LWSPeer::get_connected_port() const {
+
+ return 1025;
+};
+
+LWSPeer::LWSPeer() {
+ wsi = NULL;
+ _was_string = false;
+ write_mode = WRITE_MODE_BINARY;
+};
+
+LWSPeer::~LWSPeer() {
+
+ close();
+};
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/lws_peer.h b/modules/websocket/lws_peer.h
new file mode 100644
index 0000000000..0a62b65d24
--- /dev/null
+++ b/modules/websocket/lws_peer.h
@@ -0,0 +1,92 @@
+/*************************************************************************/
+/* lws_peer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef LWSPEER_H
+#define LWSPEER_H
+
+#ifndef JAVASCRIPT_ENABLED
+
+#include "core/error_list.h"
+#include "core/io/packet_peer.h"
+#include "core/ring_buffer.h"
+#include "libwebsockets.h"
+#include "lws_config.h"
+#include "websocket_peer.h"
+
+class LWSPeer : public WebSocketPeer {
+
+ GDCIIMPL(LWSPeer, WebSocketPeer);
+
+private:
+ enum {
+ PACKET_BUFFER_SIZE = 65536 - 5 // 4 bytes for the size, 1 for the type
+ };
+
+ uint8_t packet_buffer[PACKET_BUFFER_SIZE];
+ struct lws *wsi;
+ WriteMode write_mode;
+ bool _was_string;
+
+public:
+ struct PeerData {
+ uint32_t peer_id;
+ bool force_close;
+ RingBuffer<uint8_t> rbw;
+ RingBuffer<uint8_t> rbr;
+ mutable uint8_t input_buffer[PACKET_BUFFER_SIZE];
+ uint32_t in_size;
+ int in_count;
+ int out_count;
+ };
+
+ virtual int get_available_packet_count() const;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size);
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+ virtual int get_max_packet_size() const { return PACKET_BUFFER_SIZE; };
+
+ virtual void close();
+ virtual bool is_connected_to_host() const;
+ virtual IP_Address get_connected_host() const;
+ virtual uint16_t get_connected_port() const;
+
+ virtual WriteMode get_write_mode() const;
+ virtual void set_write_mode(WriteMode p_mode);
+ virtual bool was_string_packet() const;
+
+ void set_wsi(struct lws *wsi);
+ Error read_wsi(void *in, size_t len);
+ Error write_wsi();
+
+ LWSPeer();
+ ~LWSPeer();
+};
+
+#endif // JAVASCRIPT_ENABLED
+
+#endif // LSWPEER_H
diff --git a/modules/websocket/lws_server.cpp b/modules/websocket/lws_server.cpp
new file mode 100644
index 0000000000..8a47ba557d
--- /dev/null
+++ b/modules/websocket/lws_server.cpp
@@ -0,0 +1,177 @@
+/*************************************************************************/
+/* lws_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef JAVASCRIPT_ENABLED
+
+#include "lws_server.h"
+#include "core/os/os.h"
+
+Error LWSServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_api) {
+
+ ERR_FAIL_COND_V(context != NULL, FAILED);
+
+ _is_multiplayer = gd_mp_api;
+
+ struct lws_context_creation_info info;
+ memset(&info, 0, sizeof info);
+
+ if (p_protocols.size() == 0) // default to binary protocol
+ p_protocols.append(String("binary"));
+
+ // Prepare lws protocol structs
+ _lws_make_protocols(this, &LWSServer::_lws_gd_callback, p_protocols, &_lws_ref);
+
+ info.port = p_port;
+ info.user = _lws_ref;
+ info.protocols = _lws_ref->lws_structs;
+ info.gid = -1;
+ info.uid = -1;
+ //info.ws_ping_pong_interval = 5;
+
+ context = lws_create_context(&info);
+
+ if (context == NULL) {
+ _lws_free_ref(_lws_ref);
+ _lws_ref = NULL;
+ ERR_EXPLAIN("Unable to create LWS context");
+ ERR_FAIL_V(FAILED);
+ }
+
+ return OK;
+}
+
+bool LWSServer::is_listening() const {
+ return context != NULL;
+}
+
+int LWSServer::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) {
+
+ LWSPeer::PeerData *peer_data = (LWSPeer::PeerData *)user;
+
+ switch (reason) {
+ case LWS_CALLBACK_HTTP:
+ // no http for now
+ // closing immediately returning -1;
+ return -1;
+
+ case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
+ // check header here?
+ break;
+
+ case LWS_CALLBACK_ESTABLISHED: {
+ int32_t id = _gen_unique_id();
+
+ Ref<LWSPeer> peer = Ref<LWSPeer>(memnew(LWSPeer));
+ peer->set_wsi(wsi);
+ _peer_map[id] = peer;
+
+ peer_data->peer_id = id;
+ peer_data->in_size = 0;
+ peer_data->in_count = 0;
+ peer_data->out_count = 0;
+ peer_data->rbw.resize(16);
+ peer_data->rbr.resize(16);
+ peer_data->force_close = false;
+
+ _on_connect(id, lws_get_protocol(wsi)->name);
+ break;
+ }
+
+ case LWS_CALLBACK_CLOSED: {
+ if (peer_data == NULL)
+ return 0;
+ int32_t id = peer_data->peer_id;
+ if (_peer_map.has(id)) {
+ _peer_map[id]->close();
+ _peer_map.erase(id);
+ }
+ peer_data->in_count = 0;
+ peer_data->out_count = 0;
+ peer_data->rbr.resize(0);
+ peer_data->rbw.resize(0);
+ _on_disconnect(id);
+ return 0; // we can end here
+ }
+
+ case LWS_CALLBACK_RECEIVE: {
+ int32_t id = peer_data->peer_id;
+ if (_peer_map.has(id)) {
+ static_cast<Ref<LWSPeer> >(_peer_map[id])->read_wsi(in, len);
+ if (_peer_map[id]->get_available_packet_count() > 0)
+ _on_peer_packet(id);
+ }
+ break;
+ }
+
+ case LWS_CALLBACK_SERVER_WRITEABLE: {
+ if (peer_data->force_close)
+ return -1;
+
+ int id = peer_data->peer_id;
+ if (_peer_map.has(id))
+ static_cast<Ref<LWSPeer> >(_peer_map[id])->write_wsi();
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+void LWSServer::stop() {
+ if (context == NULL)
+ return;
+
+ _peer_map.clear();
+ destroy_context();
+ context = NULL;
+}
+
+bool LWSServer::has_peer(int p_id) const {
+ return _peer_map.has(p_id);
+}
+
+Ref<WebSocketPeer> LWSServer::get_peer(int p_id) const {
+ ERR_FAIL_COND_V(!has_peer(p_id), NULL);
+ return _peer_map[p_id];
+}
+
+LWSServer::LWSServer() {
+ context = NULL;
+ _lws_ref = NULL;
+}
+
+LWSServer::~LWSServer() {
+ invalidate_lws_ref(); // we do not want any more callbacks
+ stop();
+}
+
+#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/lws_server.h b/modules/websocket/lws_server.h
new file mode 100644
index 0000000000..5f7ac4850a
--- /dev/null
+++ b/modules/websocket/lws_server.h
@@ -0,0 +1,63 @@
+/*************************************************************************/
+/* lws_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef LWSSERVER_H
+#define LWSSERVER_H
+
+#ifndef JAVASCRIPT_ENABLED
+
+#include "core/reference.h"
+#include "lws_helper.h"
+#include "lws_peer.h"
+#include "websocket_server.h"
+
+class LWSServer : public WebSocketServer {
+
+ GDCIIMPL(LWSServer, WebSocketServer);
+
+ LWS_HELPER(LWSServer);
+
+private:
+ Map<int, Ref<LWSPeer> > peer_map;
+
+public:
+ Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
+ void stop();
+ bool is_listening() const;
+ bool has_peer(int p_id) const;
+ Ref<WebSocketPeer> get_peer(int p_id) const;
+ virtual void poll() { _lws_poll(); }
+
+ LWSServer();
+ ~LWSServer();
+};
+
+#endif // JAVASCRIPT_ENABLED
+
+#endif // LWSSERVER_H
diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp
new file mode 100644
index 0000000000..39d03ff1f0
--- /dev/null
+++ b/modules/websocket/register_types.cpp
@@ -0,0 +1,79 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "register_types.h"
+#include "error_macros.h"
+#ifdef JAVASCRIPT_ENABLED
+#include "emscripten.h"
+#include "emws_client.h"
+#include "emws_peer.h"
+#include "emws_server.h"
+#else
+#include "lws_client.h"
+#include "lws_peer.h"
+#include "lws_server.h"
+#endif
+
+void register_websocket_types() {
+#ifdef JAVASCRIPT_ENABLED
+ EM_ASM({
+ var IDHandler = {};
+ IDHandler["ids"] = {};
+ IDHandler["has"] = function(id) {
+ return IDHandler.ids.hasOwnProperty(id);
+ };
+ IDHandler["add"] = function(obj) {
+ var id = crypto.getRandomValues(new Int32Array(32))[0];
+ IDHandler.ids[id] = obj;
+ return id;
+ };
+ IDHandler["get"] = function(id) {
+ return IDHandler.ids[id];
+ };
+ IDHandler["remove"] = function(id) {
+ delete IDHandler.ids[id];
+ };
+ Module["IDHandler"] = IDHandler;
+ });
+ EMWSPeer::make_default();
+ EMWSClient::make_default();
+ EMWSServer::make_default();
+#else
+ LWSPeer::make_default();
+ LWSClient::make_default();
+ LWSServer::make_default();
+#endif
+
+ ClassDB::register_virtual_class<WebSocketMultiplayerPeer>();
+ ClassDB::register_custom_instance_class<WebSocketServer>();
+ ClassDB::register_custom_instance_class<WebSocketClient>();
+ ClassDB::register_custom_instance_class<WebSocketPeer>();
+}
+
+void unregister_websocket_types() {}
diff --git a/modules/pbm/register_types.h b/modules/websocket/register_types.h
index 958e162da1..010d88789b 100644
--- a/modules/pbm/register_types.h
+++ b/modules/websocket/register_types.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,5 +27,5 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_pbm_types();
-void unregister_pbm_types();
+void register_websocket_types();
+void unregister_websocket_types();
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
new file mode 100644
index 0000000000..f92a386988
--- /dev/null
+++ b/modules/websocket/websocket_client.cpp
@@ -0,0 +1,124 @@
+/*************************************************************************/
+/* websocket_client.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "websocket_client.h"
+
+GDCINULL(WebSocketClient);
+
+WebSocketClient::WebSocketClient() {
+}
+
+WebSocketClient::~WebSocketClient() {
+}
+
+Error WebSocketClient::connect_to_url(String p_url, PoolVector<String> p_protocols, bool gd_mp_api) {
+ _is_multiplayer = gd_mp_api;
+
+ String host = p_url;
+ String path = "/";
+ int p_len = -1;
+ int port = 80;
+ bool ssl = false;
+ if (host.begins_with("wss://")) {
+ ssl = true; // we should implement this
+ host = host.substr(6, host.length() - 6);
+ port = 443;
+ } else {
+ ssl = false;
+ if (host.begins_with("ws://"))
+ host = host.substr(5, host.length() - 5);
+ }
+
+ // Path
+ p_len = host.find("/");
+ if (p_len != -1) {
+ path = host.substr(p_len, host.length() - p_len);
+ host = host.substr(0, p_len);
+ }
+
+ // Port
+ p_len = host.find_last(":");
+ if (p_len != -1 && p_len == host.find(":")) {
+ port = host.substr(p_len, host.length() - p_len).to_int();
+ host = host.substr(0, p_len);
+ }
+
+ return connect_to_host(host, path, port, ssl, p_protocols);
+}
+
+bool WebSocketClient::is_server() const {
+
+ return false;
+}
+
+void WebSocketClient::_on_peer_packet() {
+
+ if (_is_multiplayer) {
+ _process_multiplayer(get_peer(1), 1);
+ } else {
+ emit_signal("data_received");
+ }
+}
+
+void WebSocketClient::_on_connect(String p_protocol) {
+
+ if (_is_multiplayer) {
+ // need to wait for ID confirmation...
+ } else {
+ emit_signal("connection_established", p_protocol);
+ }
+}
+
+void WebSocketClient::_on_disconnect() {
+
+ if (_is_multiplayer) {
+ emit_signal("connection_failed");
+ } else {
+ emit_signal("connection_closed");
+ }
+}
+
+void WebSocketClient::_on_error() {
+
+ if (_is_multiplayer) {
+ emit_signal("connection_failed");
+ } else {
+ emit_signal("connection_error");
+ }
+}
+
+void WebSocketClient::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("connect_to_url", "url", "protocols", "gd_mp_api"), &WebSocketClient::connect_to_url, DEFVAL(PoolVector<String>()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("disconnect_from_host"), &WebSocketClient::disconnect_from_host);
+
+ ADD_SIGNAL(MethodInfo("data_received"));
+ ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol")));
+ ADD_SIGNAL(MethodInfo("connection_closed"));
+ ADD_SIGNAL(MethodInfo("connection_error"));
+}
diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h
new file mode 100644
index 0000000000..0e87825222
--- /dev/null
+++ b/modules/websocket/websocket_client.h
@@ -0,0 +1,68 @@
+/*************************************************************************/
+/* websocket_client.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef WEBSOCKET_CLIENT_H
+#define WEBSOCKET_CLIENT_H
+
+#include "core/error_list.h"
+#include "websocket_multiplayer.h"
+#include "websocket_peer.h"
+
+class WebSocketClient : public WebSocketMultiplayerPeer {
+
+ GDCLASS(WebSocketClient, WebSocketMultiplayerPeer);
+ GDCICLASS(WebSocketClient);
+
+protected:
+ Ref<WebSocketPeer> _peer;
+
+ static void _bind_methods();
+
+public:
+ Error connect_to_url(String p_url, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
+
+ virtual void poll() = 0;
+ virtual Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>()) = 0;
+ virtual void disconnect_from_host() = 0;
+ virtual IP_Address get_connected_host() const = 0;
+ virtual uint16_t get_connected_port() const = 0;
+
+ virtual bool is_server() const;
+ virtual ConnectionStatus get_connection_status() const = 0;
+
+ void _on_peer_packet();
+ void _on_connect(String p_protocol);
+ void _on_disconnect();
+ void _on_error();
+
+ WebSocketClient();
+ ~WebSocketClient();
+};
+
+#endif // WEBSOCKET_CLIENT_H
diff --git a/modules/websocket/websocket_macros.h b/modules/websocket/websocket_macros.h
new file mode 100644
index 0000000000..b5c2159806
--- /dev/null
+++ b/modules/websocket/websocket_macros.h
@@ -0,0 +1,63 @@
+/*************************************************************************/
+/* websocket_macros.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef WEBSOCKETMACTOS_H
+#define WEBSOCKETMACTOS_H
+
+/* clang-format off */
+#define GDCICLASS(CNAME) \
+public:\
+ static CNAME *(*_create)();\
+\
+ static Ref<CNAME > create_ref() {\
+\
+ if (!_create)\
+ return Ref<CNAME >();\
+ return Ref<CNAME >(_create());\
+ }\
+\
+ static CNAME *create() {\
+\
+ if (!_create)\
+ return NULL;\
+ return _create();\
+ }\
+protected:\
+
+#define GDCINULL(CNAME) \
+CNAME *(*CNAME::_create)() = NULL;
+
+#define GDCIIMPL(IMPNAME, CNAME) \
+public:\
+ static CNAME *_create() { return memnew(IMPNAME); }\
+ static void make_default() { CNAME::_create = IMPNAME::_create; }\
+protected:\
+/* clang-format on */
+
+#endif // WEBSOCKETMACTOS_H
diff --git a/modules/websocket/websocket_multiplayer.cpp b/modules/websocket/websocket_multiplayer.cpp
new file mode 100644
index 0000000000..8cd4dff38b
--- /dev/null
+++ b/modules/websocket/websocket_multiplayer.cpp
@@ -0,0 +1,361 @@
+/*************************************************************************/
+/* websocket_multiplayer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "websocket_multiplayer.h"
+#include "core/os/os.h"
+
+WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() {
+
+ _is_multiplayer = false;
+ _peer_id = 0;
+ _target_peer = 0;
+ _refusing = false;
+
+ _current_packet.source = 0;
+ _current_packet.destination = 0;
+ _current_packet.size = 0;
+ _current_packet.data = NULL;
+}
+
+WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() {
+
+ _clear();
+}
+
+int WebSocketMultiplayerPeer::_gen_unique_id() const {
+
+ uint32_t hash = 0;
+
+ while (hash == 0 || hash == 1) {
+
+ hash = hash_djb2_one_32(
+ (uint32_t)OS::get_singleton()->get_ticks_usec());
+ hash = hash_djb2_one_32(
+ (uint32_t)OS::get_singleton()->get_unix_time(), hash);
+ hash = hash_djb2_one_32(
+ (uint32_t)OS::get_singleton()->get_data_path().hash64(), hash);
+ hash = hash_djb2_one_32(
+ (uint32_t)((uint64_t)this), hash); //rely on aslr heap
+ hash = hash_djb2_one_32(
+ (uint32_t)((uint64_t)&hash), hash); //rely on aslr stack
+ hash = hash & 0x7FFFFFFF; // make it compatible with unsigned, since negatie id is used for exclusion
+ }
+
+ return hash;
+}
+void WebSocketMultiplayerPeer::_clear() {
+
+ _peer_map.clear();
+ if (_current_packet.data != NULL)
+ memfree(_current_packet.data);
+
+ for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) {
+ memfree(E->get().data);
+ E->get().data = NULL;
+ }
+
+ _incoming_packets.clear();
+}
+
+void WebSocketMultiplayerPeer::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("get_peer", "peer_id"), &WebSocketMultiplayerPeer::get_peer);
+
+ ADD_SIGNAL(MethodInfo("peer_packet", PropertyInfo(Variant::INT, "peer_source")));
+}
+
+//
+// PacketPeer
+//
+int WebSocketMultiplayerPeer::get_available_packet_count() const {
+
+ ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+
+ return _incoming_packets.size();
+}
+
+int WebSocketMultiplayerPeer::get_max_packet_size() const {
+
+ ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+
+ return MAX_PACKET_SIZE;
+}
+
+Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+
+ r_buffer_size = 0;
+ ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+
+ if (_current_packet.data != NULL) {
+ memfree(_current_packet.data);
+ _current_packet.data = NULL;
+ }
+
+ _current_packet = _incoming_packets.front()->get();
+ _incoming_packets.pop_front();
+
+ *r_buffer = _current_packet.data;
+ r_buffer_size = _current_packet.size;
+
+ return OK;
+}
+
+Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+
+ ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+
+ PoolVector<uint8_t> buffer = _make_pkt(SYS_NONE, get_unique_id(), _target_peer, p_buffer, p_buffer_size);
+
+ if (is_server()) {
+ return _server_relay(1, _target_peer, &(buffer.read()[0]), buffer.size());
+ } else {
+ return get_peer(1)->put_packet(&(buffer.read()[0]), buffer.size());
+ }
+}
+
+//
+// NetworkedMultiplayerPeer
+//
+void WebSocketMultiplayerPeer::set_transfer_mode(TransferMode p_mode) {
+
+ // Websocket uses TCP, reliable
+}
+
+NetworkedMultiplayerPeer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
+
+ // Websocket uses TCP, reliable
+ return TRANSFER_MODE_RELIABLE;
+}
+
+void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) {
+
+ _target_peer = p_target_peer;
+}
+
+int WebSocketMultiplayerPeer::get_packet_peer() const {
+
+ ERR_FAIL_COND_V(!_is_multiplayer, 1);
+ ERR_FAIL_COND_V(_incoming_packets.size() == 0, 1);
+
+ return _incoming_packets.front()->get().source;
+}
+
+int WebSocketMultiplayerPeer::get_unique_id() const {
+
+ return _peer_id;
+}
+
+void WebSocketMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
+
+ _refusing = p_enable;
+}
+
+bool WebSocketMultiplayerPeer::is_refusing_new_connections() const {
+
+ return _refusing;
+}
+
+void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id) {
+
+ ERR_FAIL_COND(!p_peer.is_valid());
+ ERR_FAIL_COND(!p_peer->is_connected_to_host());
+
+ PoolVector<uint8_t> message = _make_pkt(p_type, 1, 0, (uint8_t *)&p_peer_id, 4);
+ p_peer->put_packet(&(message.read()[0]), message.size());
+}
+
+PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
+
+ PoolVector<uint8_t> out;
+ out.resize(PROTO_SIZE + p_data_size);
+
+ PoolVector<uint8_t>::Write w = out.write();
+ copymem(&w[0], &p_type, 1);
+ copymem(&w[1], &p_from, 4);
+ copymem(&w[5], &p_to, 4);
+ copymem(&w[PROTO_SIZE], p_data, p_data_size);
+
+ return out;
+}
+
+void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
+
+ // First of all, confirm the ID!
+ _send_sys(get_peer(p_peer_id), SYS_ID, p_peer_id);
+
+ // Then send the server peer (which will trigger connection_succeded in client)
+ _send_sys(get_peer(p_peer_id), SYS_ADD, 1);
+
+ for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
+ uint32_t id = E->key();
+ if (p_peer_id == id)
+ continue; // Skip the newwly added peer (already confirmed)
+
+ // Send new peer to others
+ _send_sys(get_peer(id), SYS_ADD, p_peer_id);
+ // Send others to new peer
+ _send_sys(get_peer(p_peer_id), SYS_ADD, id);
+ }
+}
+
+void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) {
+ for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
+ uint32_t id = E->key();
+ if (p_peer_id != id)
+ _send_sys(get_peer(id), SYS_DEL, p_peer_id);
+ }
+}
+
+void WebSocketMultiplayerPeer::_store_pkt(int32_t p_source, int32_t p_dest, const uint8_t *p_data, uint32_t p_data_size) {
+ Packet packet;
+ packet.data = (uint8_t *)memalloc(p_data_size);
+ packet.size = p_data_size;
+ packet.source = p_source;
+ packet.destination = p_dest;
+ copymem(packet.data, &p_data[PROTO_SIZE], p_data_size);
+ _incoming_packets.push_back(packet);
+ emit_signal("peer_packet", p_source);
+}
+
+Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size) {
+ if (p_to == 1) {
+
+ return OK; // Will not send to self
+
+ } else if (p_to == 0) {
+
+ for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
+ if (E->key() != p_from)
+ E->get()->put_packet(p_buffer, p_buffer_size);
+ }
+ return OK; // Sent to all but sender
+
+ } else if (p_to < 0) {
+
+ for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
+ if (E->key() != p_from && E->key() != -p_to)
+ E->get()->put_packet(p_buffer, p_buffer_size);
+ }
+ return OK; // Sent to all but sender and excluded
+
+ } else {
+
+ ERR_FAIL_COND_V(p_to == p_from, FAILED);
+
+ return get_peer(p_to)->put_packet(p_buffer, p_buffer_size); // Sending to specific peer
+ }
+}
+
+void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, uint32_t p_peer_id) {
+
+ ERR_FAIL_COND(!p_peer.is_valid());
+
+ const uint8_t *in_buffer;
+ int size = 0;
+ int data_size = 0;
+
+ Error err = p_peer->get_packet(&in_buffer, size);
+
+ ERR_FAIL_COND(err != OK);
+ ERR_FAIL_COND(size < PROTO_SIZE);
+
+ data_size = size - PROTO_SIZE;
+
+ uint8_t type = 0;
+ int32_t from = 0;
+ int32_t to = 0;
+ copymem(&type, in_buffer, 1);
+ copymem(&from, &in_buffer[1], 4);
+ copymem(&to, &in_buffer[5], 4);
+
+ if (is_server()) { // Server can resend
+
+ ERR_FAIL_COND(type != SYS_NONE); // Only server sends sys messages
+ ERR_FAIL_COND(from != p_peer_id); // Someone is cheating
+
+ _server_relay(from, to, in_buffer, size); // Relay if needed
+
+ if (to == 1) { // This is for the server
+
+ _store_pkt(from, to, in_buffer, data_size);
+
+ } else if (to == 0) {
+
+ // Broadcast, for us too
+ _store_pkt(from, to, in_buffer, data_size);
+
+ } else if (to < 0) {
+
+ // All but one, for us if not excluded
+ if (_peer_id != -p_peer_id)
+ _store_pkt(from, to, in_buffer, data_size);
+
+ } else {
+
+ // Send to specific peer
+ ERR_FAIL_COND(!_peer_map.has(to));
+ get_peer(to)->put_packet(in_buffer, size);
+ }
+
+ } else {
+
+ if (type == SYS_NONE) { // Payload message
+
+ _store_pkt(from, to, in_buffer, data_size);
+ return;
+ }
+
+ // System message
+ ERR_FAIL_COND(data_size < 4);
+ int id = 0;
+ copymem(&id, &in_buffer[PROTO_SIZE], 4);
+
+ switch (type) {
+
+ case SYS_ADD: // Add peer
+ _peer_map[id] = Ref<WebSocketPeer>();
+ emit_signal("peer_connected", id);
+ if (id == 1) // We just connected to the server
+ emit_signal("connection_succeeded");
+ break;
+
+ case SYS_DEL: // Remove peer
+ _peer_map.erase(id);
+ emit_signal("peer_disconnected", id);
+ break;
+ case SYS_ID: // Helo, server assigned ID
+ _peer_id = id;
+ break;
+ default:
+ ERR_EXPLAIN("Invalid multiplayer message");
+ ERR_FAIL();
+ break;
+ }
+ }
+}
diff --git a/modules/websocket/websocket_multiplayer.h b/modules/websocket/websocket_multiplayer.h
new file mode 100644
index 0000000000..e8e795e97f
--- /dev/null
+++ b/modules/websocket/websocket_multiplayer.h
@@ -0,0 +1,110 @@
+/*************************************************************************/
+/* websocket_multiplayer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef WEBSOCKET_MULTIPLAYER_PEER_H
+#define WEBSOCKET_MULTIPLAYER_PEER_H
+
+#include "core/error_list.h"
+#include "core/io/networked_multiplayer_peer.h"
+#include "core/list.h"
+#include "websocket_peer.h"
+
+class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer {
+
+ GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer);
+
+private:
+ PoolVector<uint8_t> _make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
+ void _store_pkt(int32_t p_source, int32_t p_dest, const uint8_t *p_data, uint32_t p_data_size);
+ Error _server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size);
+
+protected:
+ enum {
+ SYS_NONE = 0,
+ SYS_ADD = 1,
+ SYS_DEL = 2,
+ SYS_ID = 3,
+
+ PROTO_SIZE = 9,
+ SYS_PACKET_SIZE = 13,
+ MAX_PACKET_SIZE = 65536 - 14 // 5 websocket, 9 multiplayer
+ };
+
+ struct Packet {
+ int source;
+ int destination;
+ uint8_t *data;
+ uint32_t size;
+ };
+
+ List<Packet> _incoming_packets;
+ Map<int, Ref<WebSocketPeer> > _peer_map;
+ Packet _current_packet;
+
+ bool _is_multiplayer;
+ int _target_peer;
+ int _peer_id;
+ int _refusing;
+
+ static void _bind_methods();
+
+ void _send_add(int32_t p_peer_id);
+ void _send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id);
+ void _send_del(int32_t p_peer_id);
+ int _gen_unique_id() const;
+
+public:
+ /* NetworkedMultiplayerPeer */
+ void set_transfer_mode(TransferMode p_mode);
+ TransferMode get_transfer_mode() const;
+ void set_target_peer(int p_peer_id);
+ int get_packet_peer() const;
+ int get_unique_id() const;
+ virtual bool is_server() const = 0;
+ void set_refuse_new_connections(bool p_enable);
+ bool is_refusing_new_connections() const;
+ virtual ConnectionStatus get_connection_status() const = 0;
+
+ /* PacketPeer */
+ virtual int get_available_packet_count() const;
+ virtual int get_max_packet_size() const;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size);
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+
+ /* WebSocketPeer */
+ virtual Ref<WebSocketPeer> get_peer(int p_peer_id) const = 0;
+
+ void _process_multiplayer(Ref<WebSocketPeer> p_peer, uint32_t p_peer_id);
+ void _clear();
+
+ WebSocketMultiplayerPeer();
+ ~WebSocketMultiplayerPeer();
+};
+
+#endif // WEBSOCKET_MULTIPLAYER_PEER_H
diff --git a/modules/websocket/websocket_peer.cpp b/modules/websocket/websocket_peer.cpp
new file mode 100644
index 0000000000..a6fbb4481b
--- /dev/null
+++ b/modules/websocket/websocket_peer.cpp
@@ -0,0 +1,49 @@
+/*************************************************************************/
+/* websocket_peer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "websocket_peer.h"
+
+GDCINULL(WebSocketPeer);
+
+WebSocketPeer::WebSocketPeer() {
+}
+
+WebSocketPeer::~WebSocketPeer() {
+}
+
+void WebSocketPeer::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_write_mode"), &WebSocketPeer::get_write_mode);
+ ClassDB::bind_method(D_METHOD("set_write_mode", "mode"), &WebSocketPeer::set_write_mode);
+ ClassDB::bind_method(D_METHOD("is_connected_to_host"), &WebSocketPeer::is_connected_to_host);
+ ClassDB::bind_method(D_METHOD("was_string_packet"), &WebSocketPeer::was_string_packet);
+ ClassDB::bind_method(D_METHOD("close"), &WebSocketPeer::close);
+
+ BIND_ENUM_CONSTANT(WRITE_MODE_TEXT);
+ BIND_ENUM_CONSTANT(WRITE_MODE_BINARY);
+}
diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h
new file mode 100644
index 0000000000..f4d8ce3e38
--- /dev/null
+++ b/modules/websocket/websocket_peer.h
@@ -0,0 +1,73 @@
+/*************************************************************************/
+/* websocket_peer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef WEBSOCKETPEER_H
+#define WEBSOCKETPEER_H
+
+#include "core/error_list.h"
+#include "core/io/packet_peer.h"
+#include "core/ring_buffer.h"
+#include "websocket_macros.h"
+
+class WebSocketPeer : public PacketPeer {
+
+ GDCLASS(WebSocketPeer, PacketPeer);
+ GDCICLASS(WebSocketPeer);
+
+public:
+ enum WriteMode {
+ WRITE_MODE_TEXT,
+ WRITE_MODE_BINARY,
+ };
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_available_packet_count() const = 0;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) = 0;
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) = 0;
+ virtual int get_max_packet_size() const = 0;
+
+ virtual WriteMode get_write_mode() const = 0;
+ virtual void set_write_mode(WriteMode p_mode) = 0;
+
+ virtual void close() = 0;
+
+ virtual bool is_connected_to_host() const = 0;
+ virtual IP_Address get_connected_host() const = 0;
+ virtual uint16_t get_connected_port() const = 0;
+ virtual bool was_string_packet() const = 0;
+
+ WebSocketPeer();
+ ~WebSocketPeer();
+};
+
+VARIANT_ENUM_CAST(WebSocketPeer::WriteMode);
+#endif // WEBSOCKETPEER_H
diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp
new file mode 100644
index 0000000000..ba77019f55
--- /dev/null
+++ b/modules/websocket/websocket_server.cpp
@@ -0,0 +1,94 @@
+/*************************************************************************/
+/* websocket_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "websocket_server.h"
+
+GDCINULL(WebSocketServer);
+
+WebSocketServer::WebSocketServer() {
+ _peer_id = 1;
+}
+
+WebSocketServer::~WebSocketServer() {
+}
+
+void WebSocketServer::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("is_listening"), &WebSocketServer::is_listening);
+ ClassDB::bind_method(D_METHOD("listen", "port", "protocols", "gd_mp_api"), &WebSocketServer::listen, DEFVAL(PoolVector<String>()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("stop"), &WebSocketServer::stop);
+ ClassDB::bind_method(D_METHOD("has_peer", "id"), &WebSocketServer::has_peer);
+
+ ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol")));
+ ADD_SIGNAL(MethodInfo("data_received", PropertyInfo(Variant::INT, "id")));
+}
+
+NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
+ if (is_listening())
+ return CONNECTION_CONNECTED;
+
+ return CONNECTION_DISCONNECTED;
+};
+
+bool WebSocketServer::is_server() const {
+
+ return true;
+}
+
+void WebSocketServer::_on_peer_packet(int32_t p_peer_id) {
+
+ if (_is_multiplayer) {
+ _process_multiplayer(get_peer(p_peer_id), p_peer_id);
+ } else {
+ emit_signal("data_received", p_peer_id);
+ }
+}
+
+void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol) {
+
+ if (_is_multiplayer) {
+ // Send add to clients
+ _send_add(p_peer_id);
+ emit_signal("peer_connected", p_peer_id);
+ } else {
+ emit_signal("client_connected", p_peer_id, p_protocol);
+ }
+}
+
+void WebSocketServer::_on_disconnect(int32_t p_peer_id) {
+
+ if (_is_multiplayer) {
+ // Send delete to clients
+ _send_del(p_peer_id);
+ emit_signal("peer_disconnected", p_peer_id);
+ } else {
+ emit_signal("client_disconnected", p_peer_id);
+ }
+}
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
new file mode 100644
index 0000000000..db188811fd
--- /dev/null
+++ b/modules/websocket/websocket_server.h
@@ -0,0 +1,63 @@
+/*************************************************************************/
+/* websocket_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef WEBSOCKET_H
+#define WEBSOCKET_H
+
+#include "core/reference.h"
+#include "websocket_multiplayer.h"
+#include "websocket_peer.h"
+
+class WebSocketServer : public WebSocketMultiplayerPeer {
+
+ GDCLASS(WebSocketServer, WebSocketMultiplayerPeer);
+ GDCICLASS(WebSocketServer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual void poll() = 0;
+ virtual Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false) = 0;
+ virtual void stop() = 0;
+ virtual bool is_listening() const = 0;
+ virtual bool has_peer(int p_id) const = 0;
+ virtual Ref<WebSocketPeer> get_peer(int p_id) const = 0;
+ virtual bool is_server() const;
+ ConnectionStatus get_connection_status() const;
+
+ void _on_peer_packet(int32_t p_peer_id);
+ void _on_connect(int32_t p_peer_id, String p_protocol);
+ void _on_disconnect(int32_t p_peer_id);
+
+ WebSocketServer();
+ ~WebSocketServer();
+};
+
+#endif // WEBSOCKET_H