diff options
24 files changed, 157 insertions, 1118 deletions
diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 83dc84e041..0000000000 --- a/LICENSE.md +++ /dev/null @@ -1,28 +0,0 @@ - GODOT ENGINE - http://www.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. - -************************************************************************ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..0b5b0c341f --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +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. + +-- Godot Engine <https://godotengine.org> diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 1becf3accb..30d2377a04 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -77,7 +77,7 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) { if (p_addr->sa_family == AF_INET) { struct sockaddr_in *addr = (struct sockaddr_in *)p_addr; ip.set_ipv4((uint8_t *)&(addr->sin_addr)); - } else { + } else if (p_addr->sa_family == AF_INET6) { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr; ip.set_ipv6(addr6->sin6_addr.s6_addr); }; @@ -180,15 +180,16 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { SOCKADDR_IN *ipv4 = reinterpret_cast<SOCKADDR_IN *>(address->Address.lpSockaddr); ip.set_ipv4((uint8_t *)&(ipv4->sin_addr)); - } else { // ipv6 + r_addresses->push_back(ip); + + } else if (address->Address.lpSockaddr->sa_family == AF_INET6) { // ipv6 SOCKADDR_IN6 *ipv6 = reinterpret_cast<SOCKADDR_IN6 *>(address->Address.lpSockaddr); ip.set_ipv6(ipv6->sin6_addr.s6_addr); + r_addresses->push_back(ip); }; - r_addresses->push_back(ip); - address = address->Next; }; adapter = adapter->Next; @@ -205,6 +206,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { struct ifaddrs *ifAddrStruct = NULL; struct ifaddrs *ifa = NULL; + int family; getifaddrs(&ifAddrStruct); @@ -212,6 +214,11 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { if (!ifa->ifa_addr) continue; + family = ifa->ifa_addr->sa_family; + + if (family != AF_INET && family != AF_INET6) + continue; + IP_Address ip = _sockaddr2ip(ifa->ifa_addr); r_addresses->push_back(ip); } diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 8e54afcdba..5fa727a9b9 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -100,13 +100,21 @@ static size_t _set_listen_sockaddr(struct sockaddr_storage *p_addr, int p_port, }; }; -static int _socket_create(IP::Type p_type, int type, int protocol) { +static int _socket_create(IP::Type &p_type, int type, int protocol) { ERR_FAIL_COND_V(p_type > IP::TYPE_ANY || p_type < IP::TYPE_NONE, ERR_INVALID_PARAMETER); int family = p_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6; int sockfd = socket(family, type, protocol); + if (sockfd == -1 && p_type == IP::TYPE_ANY) { + // Careful here, changing the referenced parameter so the caller knows that we are using an IPv4 socket + // in place of a dual stack one, and further calls to _set_sock_addr will work as expected. + p_type = IP::TYPE_IPV4; + family = AF_INET; + sockfd = socket(family, type, protocol); + } + ERR_FAIL_COND_V(sockfd == -1, -1); if (family == AF_INET6) { diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 3774c8d4c3..cb1b958cca 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -210,7 +210,7 @@ EditorExportPreset::EditorExportPreset() { void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) { - String host = EditorSettings::get_singleton()->get("network/debug_host"); + String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) host = "localhost"; @@ -620,7 +620,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) { - String host = EditorSettings::get_singleton()->get("network/debug_host"); + String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) host = "localhost"; @@ -2108,7 +2108,7 @@ static int _get_pad(int p_alignment, int p_n) { void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) { - String host = EditorSettings::get_singleton()->get("network/debug_host"); + String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); if (p_flags&EXPORT_REMOTE_DEBUG_LOCALHOST) host="localhost"; diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index d36b8cece5..e0ebe985cd 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -41,6 +41,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li List<String> args; String resource_path = GlobalConfig::get_singleton()->get_resource_path(); + String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host"); if (resource_path != "") { args.push_back("-path"); @@ -49,7 +50,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li if (true) { args.push_back("-rdebug"); - args.push_back("localhost:" + String::num(GLOBAL_GET("network/debug/remote_port"))); + args.push_back(remote_host + ":" + String::num(GLOBAL_GET("network/debug/remote_port"))); } args.push_back("-epid"); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9fd76590a6..0a46acddb2 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -407,13 +407,12 @@ void EditorSettings::setup_network() { IP::get_singleton()->get_local_addresses(&local_ip); String lip; String hint; - String current = has("network/debug_host") ? get("network/debug_host") : ""; + String current = has("network/debug/remote_host") ? get("network/debug/remote_host") : ""; + int port = has("network/debug/remote_port") ? (int)get("network/debug/remote_port") : 6007; for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) { String ip = E->get(); - if (ip == "127.0.0.1") - continue; if (lip == "") lip = ip; @@ -424,8 +423,11 @@ void EditorSettings::setup_network() { hint += ip; } - set("network/debug_host", lip); - add_property_hint(PropertyInfo(Variant::STRING, "network/debug_host", PROPERTY_HINT_ENUM, hint)); + set("network/debug/remote_host", lip); + add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint)); + + set("network/debug/remote_port", port); + add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1")); } void EditorSettings::save() { diff --git a/main/main.cpp b/main/main.cpp index 33095e8599..ea7d8e075c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -588,8 +588,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ScriptDebuggerRemote *sdr = memnew(ScriptDebuggerRemote); uint16_t debug_port = GLOBAL_GET("network/debug/remote_port"); if (debug_host.find(":") != -1) { - debug_port = debug_host.get_slicec(':', 1).to_int(); - debug_host = debug_host.get_slicec(':', 0); + int sep_pos = debug_host.find_last(":"); + debug_port = debug_host.substr(sep_pos + 1, debug_host.length()).to_int(); + debug_host = debug_host.substr(0, sep_pos); } Error derr = sdr->connect_to_host(debug_host, debug_port); diff --git a/modules/gdnative/godot.cpp b/modules/gdnative/godot.cpp index 7477a28db6..bc53eb93f4 100644 --- a/modules/gdnative/godot.cpp +++ b/modules/gdnative/godot.cpp @@ -30,6 +30,7 @@ #include "godot.h" #include "class_db.h" +#include "error_macros.h" #include "gdnative.h" #include "global_config.h" #include "global_constants.h" @@ -115,6 +116,28 @@ void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_obj mb->ptrcall(o, p_args, p_ret); } +godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error) { + MethodBind *mb = (MethodBind *)p_method_bind; + Object *o = (Object *)p_instance; + const Variant **args = (const Variant **)p_args; + + godot_variant ret; + godot_variant_new_nil(&ret); + + Variant *ret_val = (Variant *)&ret; + + Variant::CallError r_error; + *ret_val = mb->call(o, args, p_arg_count, r_error); + + if (p_call_error) { + p_call_error->error = (godot_variant_call_error_error)r_error.error; + p_call_error->argument = r_error.argument; + p_call_error->expected = (godot_variant_type)r_error.expected; + } + + return ret; +} + // @Todo /* void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind) @@ -215,6 +238,18 @@ void GDAPI godot_free(void *p_ptr) { memfree(p_ptr); } +void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { + _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR); +} + +void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) { + _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING); +} + +void GDAPI godot_print(const godot_string *p_message) { + print_line(*(String *)p_message); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/godot.h b/modules/gdnative/godot.h index b05cafbe50..7214ce62df 100644 --- a/modules/gdnative/godot.h +++ b/modules/gdnative/godot.h @@ -228,7 +228,7 @@ typedef struct godot_method_bind { godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname); void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret); - +godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error); ////// Script API typedef struct godot_native_init_options { @@ -404,6 +404,11 @@ void GDAPI *godot_alloc(int p_bytes); void GDAPI *godot_realloc(void *p_ptr, int p_bytes); void GDAPI godot_free(void *p_ptr); +//print using Godot's error handler list +void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line); +void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line); +void GDAPI godot_print(const godot_string *p_message); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/godot/godot_variant.cpp b/modules/gdnative/godot/godot_variant.cpp index 2214f85056..e9fa4eb8c6 100644 --- a/modules/gdnative/godot/godot_variant.cpp +++ b/modules/gdnative/godot/godot_variant.cpp @@ -457,12 +457,22 @@ godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_varia return pba; } -godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount /*, godot_variant_call_error *r_error */) { +godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *p_error) { Variant *v = (Variant *)p_v; String *method = (String *)p_method; - Variant **args = (Variant **)p_args; + const Variant **args = (const Variant **)p_args; godot_variant res; - memnew_placement_custom((Variant *)&res, Variant, Variant(v->call(*method, args, p_argcount))); + godot_variant_new_nil(&res); + + Variant *ret_val = (Variant *)&res; + + Variant::CallError r_error; + *ret_val = v->call(StringName(*method), args, p_argcount, r_error); + if (p_error) { + p_error->error = (godot_variant_call_error_error)r_error.error; + p_error->argument = r_error.argument; + p_error->expected = (godot_variant_type)r_error.expected; + } return res; } diff --git a/modules/gdnative/godot/godot_variant.h b/modules/gdnative/godot/godot_variant.h index 6f98b32363..0a5771d2f6 100644 --- a/modules/gdnative/godot/godot_variant.h +++ b/modules/gdnative/godot/godot_variant.h @@ -45,13 +45,6 @@ typedef struct godot_variant { struct godot_transform2d; typedef struct godot_transform2d godot_transform2d; -#include "godot_array.h" -#include "godot_dictionary.h" -#include "godot_input_event.h" -#include "godot_node_path.h" -#include "godot_rid.h" -#include "godot_transform2d.h" - typedef enum godot_variant_type { GODOT_VARIANT_TYPE_NIL, @@ -93,6 +86,28 @@ typedef enum godot_variant_type { GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY, } godot_variant_type; +typedef enum godot_variant_call_error_error { + GODOT_CALL_ERROR_CALL_OK, + GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD, + GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT, + GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS, + GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS, + GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL, +} godot_variant_call_error_error; + +typedef struct godot_variant_call_error { + godot_variant_call_error_error error; + int argument; + godot_variant_type expected; +} godot_variant_call_error; + +#include "godot_array.h" +#include "godot_dictionary.h" +#include "godot_input_event.h" +#include "godot_node_path.h" +#include "godot_rid.h" +#include "godot_transform2d.h" + godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src); @@ -159,7 +174,7 @@ godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_v godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_v); godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_v); -godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount /*, godot_variant_call_error *r_error */); +godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *p_error); godot_bool GDAPI godot_variant_has_method(godot_variant *p_v, const godot_string *p_method); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 4667e541dd..5d404e2f7d 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -2395,7 +2395,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } break; - case GDParser::COMPLETION_PRELOAD: { + case GDParser::COMPLETION_RESOURCE_PATH: { if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options); diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index b02d7f713b..4ae62eb1d0 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -387,15 +387,21 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool _set_error("Expected '(' after 'preload'"); return NULL; } - completion_cursor = StringName(); - completion_type = COMPLETION_PRELOAD; - completion_class = current_class; - completion_function = current_function; - completion_line = tokenizer->get_token_line(); - completion_block = current_block; - completion_found = true; tokenizer->advance(); + if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + completion_cursor = StringName(); + completion_node = p_parent; + completion_type = COMPLETION_RESOURCE_PATH; + completion_class = current_class; + completion_function = current_function; + completion_line = tokenizer->get_token_line(); + completion_block = current_block; + completion_argument = 0; + completion_found = true; + tokenizer->advance(); + } + String path; bool found_constant = false; bool valid = false; @@ -467,10 +473,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool _set_error("Expected ')' after 'preload' path"); return NULL; } + tokenizer->advance(); ConstantNode *constant = alloc_node<ConstantNode>(); constant->value = res; - tokenizer->advance(); expr = constant; } else if (tokenizer->get_token() == GDTokenizer::TK_PR_YIELD) { diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h index 4f3ca0dc5f..7e7e19de1b 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gd_parser.h @@ -437,7 +437,7 @@ public: COMPLETION_PARENT_FUNCTION, COMPLETION_METHOD, COMPLETION_CALL_ARGUMENTS, - COMPLETION_PRELOAD, + COMPLETION_RESOURCE_PATH, COMPLETION_INDEX, COMPLETION_VIRTUAL_FUNC, COMPLETION_YIELD, diff --git a/modules/multiscript/SCsub b/modules/multiscript/SCsub deleted file mode 100644 index 0882406761..0000000000 --- a/modules/multiscript/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.modules_sources, "*.cpp") - -Export('env') diff --git a/modules/multiscript/config.py b/modules/multiscript/config.py deleted file mode 100644 index 5698a37295..0000000000 --- a/modules/multiscript/config.py +++ /dev/null @@ -1,8 +0,0 @@ - - -def can_build(platform): - return True - - -def configure(env): - pass diff --git a/modules/multiscript/multiscript.cpp b/modules/multiscript/multiscript.cpp deleted file mode 100644 index b2633b7207..0000000000 --- a/modules/multiscript/multiscript.cpp +++ /dev/null @@ -1,750 +0,0 @@ -/*************************************************************************/ -/* multiscript.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.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 "multiscript.h" - -bool MultiScriptInstance::set(const StringName &p_name, const Variant &p_value) { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - bool found = sarr[i]->set(p_name, p_value); - if (found) - return true; - } - - if (String(p_name).begins_with("script_")) { - bool valid; - owner->set(p_name, p_value, &valid); - return valid; - } - return false; -} - -bool MultiScriptInstance::get(const StringName &p_name, Variant &r_ret) const { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - bool found = sarr[i]->get(p_name, r_ret); - if (found) - return true; - } - if (String(p_name).begins_with("script_")) { - bool valid; - r_ret = owner->get(p_name, &valid); - return valid; - } - return false; -} -void MultiScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - Set<String> existing; - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - List<PropertyInfo> pl; - sarr[i]->get_property_list(&pl); - - for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) { - - if (existing.has(E->get().name)) - continue; - - p_properties->push_back(E->get()); - existing.insert(E->get().name); - } - } - - p_properties->push_back(PropertyInfo(Variant::NIL, "Scripts", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); - - for (int i = 0; i < owner->scripts.size(); i++) { - - p_properties->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + i), PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_EDITOR)); - } - - if (owner->scripts.size() < 25) { - - p_properties->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + (owner->scripts.size())), PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_EDITOR)); - } -} - -void MultiScriptInstance::get_method_list(List<MethodInfo> *p_list) const { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - Set<StringName> existing; - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - List<MethodInfo> ml; - sarr[i]->get_method_list(&ml); - - for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) { - - if (existing.has(E->get().name)) - continue; - - p_list->push_back(E->get()); - existing.insert(E->get().name); - } - } -} -bool MultiScriptInstance::has_method(const StringName &p_method) const { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - if (sarr[i]->has_method(p_method)) - return true; - } - - return false; -} - -Variant MultiScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - Variant r = sarr[i]->call(p_method, p_args, p_argcount, r_error); - if (r_error.error == Variant::CallError::CALL_OK) - return r; - else if (r_error.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) - return r; - } - - r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; - return Variant(); -} - -void MultiScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - sarr[i]->call_multilevel(p_method, p_args, p_argcount); - } -} -void MultiScriptInstance::notification(int p_notification) { - - // ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - ScriptInstance *instance = instances[i]; - - if (!instance) - continue; - - instance->notification(p_notification); - } -} - -Ref<Script> MultiScriptInstance::get_script() const { - - return owner; -} - -ScriptLanguage *MultiScriptInstance::get_language() { - - return MultiScriptLanguage::get_singleton(); -} - -MultiScriptInstance::~MultiScriptInstance() { - - owner->remove_instance(object); -} - -Variant::Type MultiScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { - bool valid = false; - Variant::Type type; - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - type = sarr[i]->get_property_type(p_name, &valid); - if (valid) { - *r_is_valid = valid; - return type; - } - } - *r_is_valid = false; - return Variant::NIL; -} - -ScriptInstance::RPCMode MultiScriptInstance::get_rpc_mode(const StringName &p_method) const { - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - if (sarr[i]->has_method(p_method)) - return sarr[i]->get_rpc_mode(p_method); - } - return RPC_MODE_DISABLED; -} - -ScriptInstance::RPCMode MultiScriptInstance::get_rset_mode(const StringName &p_variable) const { - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for (int i = 0; i < sc; i++) { - - if (!sarr[i]) - continue; - - List<PropertyInfo> properties; - sarr[i]->get_property_list(&properties); - - for (List<PropertyInfo>::Element *P = properties.front(); P; P = P->next()) { - if (P->get().name == p_variable) { - return sarr[i]->get_rset_mode(p_variable); - } - } - } - return RPC_MODE_DISABLED; -} - -/////////////////// - -bool MultiScript::is_tool() const { - - for (int i = 0; i < scripts.size(); i++) { - - if (scripts[i]->is_tool()) - return true; - } - - return false; -} - -bool MultiScript::_set(const StringName &p_name, const Variant &p_value) { - - _THREAD_SAFE_METHOD_ - - String s = String(p_name); - if (s.begins_with("script_")) { - - int idx = s[7]; - if (idx == 0) - return false; - idx -= 'a'; - - ERR_FAIL_COND_V(idx < 0, false); - - Ref<Script> s = p_value; - - if (idx < scripts.size()) { - - if (s.is_null()) - remove_script(idx); - else - set_script(idx, s); - } else if (idx == scripts.size()) { - if (s.is_null()) - return false; - add_script(s); - } else - return false; - - return true; - } - - return false; -} - -bool MultiScript::_get(const StringName &p_name, Variant &r_ret) const { - - _THREAD_SAFE_METHOD_ - - String s = String(p_name); - if (s.begins_with("script_")) { - - int idx = s[7]; - if (idx == 0) - return false; - idx -= 'a'; - - ERR_FAIL_COND_V(idx < 0, false); - - if (idx < scripts.size()) { - - r_ret = get_script(idx); - return true; - } else if (idx == scripts.size()) { - r_ret = Ref<Script>(); - return true; - } - } - - return false; -} -void MultiScript::_get_property_list(List<PropertyInfo> *p_list) const { - - _THREAD_SAFE_METHOD_ - - for (int i = 0; i < scripts.size(); i++) { - - p_list->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + i), PROPERTY_HINT_RESOURCE_TYPE, "Script")); - } - - if (scripts.size() < 25) { - - p_list->push_back(PropertyInfo(Variant::OBJECT, "script_" + String::chr('a' + (scripts.size())), PROPERTY_HINT_RESOURCE_TYPE, "Script")); - } -} - -void MultiScript::set_script(int p_idx, const Ref<Script> &p_script) { - - _THREAD_SAFE_METHOD_ - - ERR_FAIL_INDEX(p_idx, scripts.size()); - ERR_FAIL_COND(p_script.is_null()); - - scripts[p_idx] = p_script; - Ref<Script> s = p_script; - - for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) { - - MultiScriptInstance *msi = E->get(); - ScriptInstance *si = msi->instances[p_idx]; - if (si) { - msi->instances[p_idx] = NULL; - memdelete(si); - } - - if (p_script->can_instance()) - msi->instances[p_idx] = s->instance_create(msi->object); - } -} - -Ref<Script> MultiScript::get_script(int p_idx) const { - - _THREAD_SAFE_METHOD_ - - ERR_FAIL_INDEX_V(p_idx, scripts.size(), Ref<Script>()); - - return scripts[p_idx]; -} -void MultiScript::add_script(const Ref<Script> &p_script) { - - _THREAD_SAFE_METHOD_ - ERR_FAIL_COND(p_script.is_null()); - Multi *script_owner = memnew(Multi); - script_instances.push_back(script_owner); - scripts.push_back(p_script); - Ref<Script> s = p_script; - - for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) { - - MultiScriptInstance *msi = E->get(); - - if (p_script->can_instance()) { - script_owner->real_owner = msi->object; - msi->instances.push_back(s->instance_create(script_owner)); - } else { - msi->instances.push_back(NULL); - } - - msi->object->_change_notify(); - } - - _change_notify(); -} - -void MultiScript::remove_script(int p_idx) { - - _THREAD_SAFE_METHOD_ - - ERR_FAIL_INDEX(p_idx, scripts.size()); - - scripts.remove(p_idx); - script_instances.remove(p_idx); - - for (Map<Object *, MultiScriptInstance *>::Element *E = instances.front(); E; E = E->next()) { - - MultiScriptInstance *msi = E->get(); - ScriptInstance *si = msi->instances[p_idx]; - msi->instances.remove(p_idx); - if (si) { - memdelete(si); - } - - msi->object->_change_notify(); - } -} - -void MultiScript::remove_instance(Object *p_object) { - - _THREAD_SAFE_METHOD_ - instances.erase(p_object); -} - -bool MultiScript::can_instance() const { - - return true; -} - -StringName MultiScript::get_instance_base_type() const { - - return StringName(); -} -ScriptInstance *MultiScript::instance_create(Object *p_this) { - - _THREAD_SAFE_METHOD_ - MultiScriptInstance *msi = memnew(MultiScriptInstance); - msi->object = p_this; - msi->owner = this; - - for (int i = 0; i < scripts.size(); i++) { - - ScriptInstance *si; - - if (scripts[i]->can_instance()) { - script_instances[i]->real_owner = p_this; - si = scripts[i]->instance_create(script_instances[i]); - } else { - si = NULL; - } - - msi->instances.push_back(si); - } - - instances[p_this] = msi; - p_this->_change_notify(); - return msi; -} -bool MultiScript::instance_has(const Object *p_this) const { - - _THREAD_SAFE_METHOD_ - return instances.has((Object *)p_this); -} - -bool MultiScript::has_source_code() const { - - return false; -} -String MultiScript::get_source_code() const { - - return ""; -} -void MultiScript::set_source_code(const String &p_code) { -} -Error MultiScript::reload(bool p_keep_state) { - - for (int i = 0; i < scripts.size(); i++) - scripts[i]->reload(p_keep_state); - - return OK; -} - -String MultiScript::get_node_type() const { - - return ""; -} - -void MultiScript::_bind_methods() { -} - -ScriptLanguage *MultiScript::get_language() const { - - return MultiScriptLanguage::get_singleton(); -} - -/////////////// - -MultiScript::MultiScript() { -} - -MultiScript::~MultiScript() { - for (int i = 0; i < script_instances.size(); i++) { - memdelete(script_instances[i]); - } - - script_instances.resize(0); -} - -Ref<Script> MultiScript::get_base_script() const { - Ref<MultiScript> base_script; - return base_script; -} - -bool MultiScript::has_method(const StringName &p_method) const { - for (int i = 0; i < scripts.size(); i++) { - if (scripts[i]->has_method(p_method)) { - return true; - } - } - return false; -} - -MethodInfo MultiScript::get_method_info(const StringName &p_method) const { - for (int i = 0; i < scripts.size(); i++) { - if (scripts[i]->has_method(p_method)) { - return scripts[i]->get_method_info(p_method); - } - } - return MethodInfo(); -} - -bool MultiScript::has_script_signal(const StringName &p_signal) const { - for (int i = 0; i < scripts.size(); i++) { - if (scripts[i]->has_script_signal(p_signal)) { - return true; - } - } - return false; -} - -void MultiScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - for (int i = 0; i < scripts.size(); i++) { - scripts[i]->get_script_signal_list(r_signals); - } -} - -bool MultiScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { - for (int i = 0; i < scripts.size(); i++) { - - if (scripts[i]->get_property_default_value(p_property, r_value)) { - return true; - } - } - return false; -} - -void MultiScript::get_script_method_list(List<MethodInfo> *p_list) const { - for (int i = 0; i < scripts.size(); i++) { - scripts[i]->get_script_method_list(p_list); - } -} - -void MultiScript::get_script_property_list(List<PropertyInfo> *p_list) const { - for (int i = 0; i < scripts.size(); i++) { - scripts[i]->get_script_property_list(p_list); - } -} - -void MultiScript::update_exports() { - for (int i = 0; i < scripts.size(); i++) { - scripts[i]->update_exports(); - } -} - -MultiScriptLanguage *MultiScriptLanguage::singleton = NULL; - -MultiScriptLanguage *MultiScriptLanguage::get_singleton() { - return singleton; -} - -String MultiScriptLanguage::get_name() const { - return "MultiScript"; -} - -void MultiScriptLanguage::init() {} - -String MultiScriptLanguage::get_type() const { - return "MultiScript"; -} - -String MultiScriptLanguage::get_extension() const { - return ""; -} - -Error MultiScriptLanguage::execute_file(const String &p_path) { - return OK; -} - -void MultiScriptLanguage::finish() {} - -void MultiScriptLanguage::get_reserved_words(List<String> *p_words) const {} - -void MultiScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {} - -void MultiScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {} - -Ref<Script> MultiScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { - MultiScript *s = memnew(MultiScript); - s->base_class_name = p_base_class_name; - return Ref<MultiScript>(s); -} - -bool MultiScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_fn) const { - return true; -} - -Script *MultiScriptLanguage::create_script() const { - return memnew(MultiScript); -} - -bool MultiScriptLanguage::has_named_classes() const { - return false; -} - -int MultiScriptLanguage::find_function(const String &p_function, const String &p_code) const { - return -1; -} - -String MultiScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const { - return ""; -} - -String MultiScriptLanguage::debug_get_error() const { - return ""; -} - -int MultiScriptLanguage::debug_get_stack_level_count() const { - return 0; -} - -int MultiScriptLanguage::debug_get_stack_level_line(int p_level) const { - return 0; -} - -String MultiScriptLanguage::debug_get_stack_level_function(int p_level) const { - return ""; -} - -String MultiScriptLanguage::debug_get_stack_level_source(int p_level) const { - return ""; -} - -void MultiScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} - -void MultiScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} - -void MultiScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} - -String MultiScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { - return ""; -} - -void MultiScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {} - -void MultiScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {} - -MultiScriptLanguage::MultiScriptLanguage() { - singleton = this; -} - -MultiScriptLanguage::~MultiScriptLanguage() {} - -void MultiScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const { -} - -void MultiScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { -} - -void MultiScriptLanguage::reload_all_scripts() { -} - -void MultiScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { -} - -void MultiScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const { -} - -void MultiScriptLanguage::profiling_start() { -} - -void MultiScriptLanguage::profiling_stop() { -} - -int MultiScriptLanguage::profiling_get_accumulated_data(ScriptLanguage::ProfilingInfo *p_info_arr, int p_info_max) { - return 0; -} - -int MultiScriptLanguage::profiling_get_frame_data(ScriptLanguage::ProfilingInfo *p_info_arr, int p_info_max) { - return 0; -} - -void Multi::_bind_methods() { - // ClassDB::bind_method("call", &Multi::call); - // ClassDB::bind_method("call_multilevel", &Multi::call_multilevel); - // ClassDB::bind_method("call_multilevel_reversed", &Multi::call_multilevel_reversed); -} - -Variant Multi::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { - if (real_owner) - return real_owner->call(p_method, p_args, p_argcount, r_error); - return Variant(); -} - -void Multi::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { - if (real_owner) - real_owner->call_multilevel(p_method, p_args, p_argcount); -} - -void Multi::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { - if (real_owner) - real_owner->call_multilevel_reversed(p_method, p_args, p_argcount); -} diff --git a/modules/multiscript/multiscript.h b/modules/multiscript/multiscript.h deleted file mode 100644 index 7ec1d5402f..0000000000 --- a/modules/multiscript/multiscript.h +++ /dev/null @@ -1,200 +0,0 @@ -/*************************************************************************/ -/* multiscript.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.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 MULTISCRIPT_H -#define MULTISCRIPT_H - -#include "os/thread_safe.h" -#include "script_language.h" - -class MultiScript; - -class Multi : public Object { - GDCLASS(Multi, Object) - - friend class MultiScript; - - Object *real_owner; - -public: - static void _bind_methods(); - - virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error); - virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount); - virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount); -}; - -class MultiScriptInstance : public ScriptInstance { - friend class MultiScript; - mutable Vector<ScriptInstance *> instances; - Object *object; - mutable MultiScript *owner; - -public: - virtual bool set(const StringName &p_name, const Variant &p_value); - virtual bool get(const StringName &p_name, Variant &r_ret) const; - virtual void get_property_list(List<PropertyInfo> *p_properties) const; - - virtual void get_method_list(List<MethodInfo> *p_list) const; - virtual bool has_method(const StringName &p_method) const; - virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error); - virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount); - virtual void notification(int p_notification); - - virtual Ref<Script> get_script() const; - - virtual ScriptLanguage *get_language(); - virtual ~MultiScriptInstance(); - - // ScriptInstance interface -public: - Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const; - RPCMode get_rpc_mode(const StringName &p_method) const; - RPCMode get_rset_mode(const StringName &p_variable) const; -}; - -class MultiScript : public Script { - - _THREAD_SAFE_CLASS_ - friend class MultiScriptInstance; - friend class MultiScriptLanguage; - GDCLASS(MultiScript, Script) - - StringName base_class_name; - - Vector<Ref<Script> > scripts; - Vector<Multi *> script_instances; - - Map<Object *, MultiScriptInstance *> instances; - -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - static void _bind_methods(); - -public: - void remove_instance(Object *p_object); - virtual bool can_instance() const; - - virtual StringName get_instance_base_type() const; - virtual ScriptInstance *instance_create(Object *p_this); - virtual bool instance_has(const Object *p_this) const; - - virtual bool has_source_code() const; - virtual String get_source_code() const; - virtual void set_source_code(const String &p_code); - virtual Error reload(bool p_keep_state = false); - - virtual bool is_tool() const; - - virtual String get_node_type() const; - - void set_script(int p_idx, const Ref<Script> &p_script); - Ref<Script> get_script(int p_idx) const; - void remove_script(int p_idx); - void add_script(const Ref<Script> &p_script); - - virtual ScriptLanguage *get_language() const; - - MultiScript(); - ~MultiScript(); - - virtual Ref<Script> get_base_script() const; - virtual bool has_method(const StringName &p_method) const; - virtual MethodInfo get_method_info(const StringName &p_method) const; - virtual bool has_script_signal(const StringName &p_signal) const; - virtual void get_script_signal_list(List<MethodInfo> *r_signals) const; - virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const; - virtual void get_script_method_list(List<MethodInfo> *p_list) const; - virtual void get_script_property_list(List<PropertyInfo> *p_list) const; - virtual void update_exports(); -}; - -class MultiScriptLanguage : public ScriptLanguage { - - static MultiScriptLanguage *singleton; - -public: - static _FORCE_INLINE_ MultiScriptLanguage *get_singleton(); - virtual String get_name() const; - - /* LANGUAGE FUNCTIONS */ - virtual void init(); - virtual String get_type() const; - virtual String get_extension() const; - virtual Error execute_file(const String &p_path); - virtual void finish(); - - /* EDITOR FUNCTIONS */ - virtual void get_reserved_words(List<String> *p_words) const; - virtual void get_comment_delimiters(List<String> *p_delimiters) const; - virtual void get_string_delimiters(List<String> *p_delimiters) const; - virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_fn = NULL) const; - virtual Script *create_script() const; - virtual bool has_named_classes() const; - virtual int find_function(const String &p_function, const String &p_code) const; - virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; - - /* DEBUGGER FUNCTIONS */ - - virtual String debug_get_error() const; - virtual int debug_get_stack_level_count() const; - virtual int debug_get_stack_level_line(int p_level) const; - virtual String debug_get_stack_level_function(int p_level) const; - virtual String debug_get_stack_level_source(int p_level) const; - virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1); - virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1); - virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1); - virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1); - - /* LOADER FUNCTIONS */ - - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual void get_public_functions(List<MethodInfo> *p_functions) const; - - MultiScriptLanguage(); - virtual ~MultiScriptLanguage(); - - // ScriptLanguage interface -public: - void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const; - void add_global_constant(const StringName &p_variable, const Variant &p_value); - void reload_all_scripts(); - void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload); - void get_public_constants(List<Pair<String, Variant> > *p_constants) const; - void profiling_start(); - void profiling_stop(); - int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max); - int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max); -}; - -#endif // MULTISCRIPT_H diff --git a/modules/multiscript/register_types.cpp b/modules/multiscript/register_types.cpp deleted file mode 100644 index 8170a2d9c1..0000000000 --- a/modules/multiscript/register_types.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.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 "multiscript.h" - -#include "core/script_language.h" - -static MultiScriptLanguage *script_multi_script = NULL; - -void register_multiscript_types() { - script_multi_script = memnew(MultiScriptLanguage); - ScriptServer::register_language(script_multi_script); - ClassDB::register_class<MultiScript>(); - - // ClassDB::register_class<Multi>(); -} - -void unregister_multiscript_types() { - if (script_multi_script) { - ScriptServer::unregister_language(script_multi_script); - memdelete(script_multi_script); - } -} diff --git a/modules/multiscript/register_types.h b/modules/multiscript/register_types.h deleted file mode 100644 index b18d1adff2..0000000000 --- a/modules/multiscript/register_types.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.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. */ -/*************************************************************************/ -void register_multiscript_types(); -void unregister_multiscript_types(); diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index 8dfb006c00..e8de93067f 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.3.1' $$GRADLE_CLASSPATH$$ } } @@ -66,6 +66,7 @@ android { $$GRADLE_ASSET_DIRS$$ ] jniLibs.srcDirs = [ + 'libs' $$GRADLE_JNI_DIRS$$ ] } diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties index d57051703e..a11cc1b825 100644 --- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties +++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Fri May 12 08:50:03 KST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip +org.gradle.jvmargs=-Xmx1536M diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java index 627bf3eedd..e83faa2756 100644 --- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java +++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java @@ -569,10 +569,10 @@ public abstract class DownloaderService extends CustomIntentService implements I */ void pollNetworkState() { if (null == mConnectivityManager) { - mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + mConnectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); } if (null == mWifiManager) { - mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); + mWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); } if (mConnectivityManager == null) { Log.w(Constants.TAG, |