From c7f8b22ba07c27ceb91307a178ee7520677018e1 Mon Sep 17 00:00:00 2001 From: Karroffel Date: Sun, 9 Apr 2017 21:07:53 +0200 Subject: renamed dlscript module to gdnative --- modules/dlscript/SCsub | 14 - modules/dlscript/api_generator.cpp | 412 --------- modules/dlscript/api_generator.h | 9 - modules/dlscript/config.py | 8 - modules/dlscript/dl_script.cpp | 1237 -------------------------- modules/dlscript/dl_script.h | 421 --------- modules/dlscript/godot.cpp | 213 ----- modules/dlscript/godot.h | 392 -------- modules/dlscript/godot/godot_array.cpp | 271 ------ modules/dlscript/godot/godot_array.h | 88 -- modules/dlscript/godot/godot_basis.cpp | 58 -- modules/dlscript/godot/godot_basis.h | 34 - modules/dlscript/godot/godot_color.cpp | 34 - modules/dlscript/godot/godot_color.h | 29 - modules/dlscript/godot/godot_dictionary.cpp | 109 --- modules/dlscript/godot/godot_dictionary.h | 51 -- modules/dlscript/godot/godot_image.cpp | 85 -- modules/dlscript/godot/godot_image.h | 95 -- modules/dlscript/godot/godot_input_event.cpp | 280 ------ modules/dlscript/godot/godot_input_event.h | 206 ----- modules/dlscript/godot/godot_node_path.cpp | 91 -- modules/dlscript/godot/godot_node_path.h | 39 - modules/dlscript/godot/godot_plane.cpp | 48 - modules/dlscript/godot/godot_plane.h | 37 - modules/dlscript/godot/godot_pool_arrays.cpp | 558 ------------ modules/dlscript/godot/godot_pool_arrays.h | 256 ------ modules/dlscript/godot/godot_quat.cpp | 77 -- modules/dlscript/godot/godot_quat.h | 33 - modules/dlscript/godot/godot_rect2.cpp | 48 - modules/dlscript/godot/godot_rect2.h | 31 - modules/dlscript/godot/godot_rect3.cpp | 48 - modules/dlscript/godot/godot_rect3.h | 31 - modules/dlscript/godot/godot_rid.cpp | 36 - modules/dlscript/godot/godot_rid.h | 28 - modules/dlscript/godot/godot_string.cpp | 83 -- modules/dlscript/godot/godot_string.h | 42 - modules/dlscript/godot/godot_transform.cpp | 42 - modules/dlscript/godot/godot_transform.h | 29 - modules/dlscript/godot/godot_transform2d.cpp | 59 -- modules/dlscript/godot/godot_transform2d.h | 48 - modules/dlscript/godot/godot_variant.cpp | 476 ---------- modules/dlscript/godot/godot_variant.h | 150 ---- modules/dlscript/godot/godot_vector2.cpp | 124 --- modules/dlscript/godot/godot_vector2.h | 78 -- modules/dlscript/godot/godot_vector3.cpp | 150 ---- modules/dlscript/godot/godot_vector3.h | 82 -- modules/dlscript/register_types.cpp | 70 -- modules/dlscript/register_types.h | 31 - 48 files changed, 6871 deletions(-) delete mode 100644 modules/dlscript/SCsub delete mode 100644 modules/dlscript/api_generator.cpp delete mode 100644 modules/dlscript/api_generator.h delete mode 100644 modules/dlscript/config.py delete mode 100644 modules/dlscript/dl_script.cpp delete mode 100644 modules/dlscript/dl_script.h delete mode 100644 modules/dlscript/godot.cpp delete mode 100644 modules/dlscript/godot.h delete mode 100644 modules/dlscript/godot/godot_array.cpp delete mode 100644 modules/dlscript/godot/godot_array.h delete mode 100644 modules/dlscript/godot/godot_basis.cpp delete mode 100644 modules/dlscript/godot/godot_basis.h delete mode 100644 modules/dlscript/godot/godot_color.cpp delete mode 100644 modules/dlscript/godot/godot_color.h delete mode 100644 modules/dlscript/godot/godot_dictionary.cpp delete mode 100644 modules/dlscript/godot/godot_dictionary.h delete mode 100644 modules/dlscript/godot/godot_image.cpp delete mode 100644 modules/dlscript/godot/godot_image.h delete mode 100644 modules/dlscript/godot/godot_input_event.cpp delete mode 100644 modules/dlscript/godot/godot_input_event.h delete mode 100644 modules/dlscript/godot/godot_node_path.cpp delete mode 100644 modules/dlscript/godot/godot_node_path.h delete mode 100644 modules/dlscript/godot/godot_plane.cpp delete mode 100644 modules/dlscript/godot/godot_plane.h delete mode 100644 modules/dlscript/godot/godot_pool_arrays.cpp delete mode 100644 modules/dlscript/godot/godot_pool_arrays.h delete mode 100644 modules/dlscript/godot/godot_quat.cpp delete mode 100644 modules/dlscript/godot/godot_quat.h delete mode 100644 modules/dlscript/godot/godot_rect2.cpp delete mode 100644 modules/dlscript/godot/godot_rect2.h delete mode 100644 modules/dlscript/godot/godot_rect3.cpp delete mode 100644 modules/dlscript/godot/godot_rect3.h delete mode 100644 modules/dlscript/godot/godot_rid.cpp delete mode 100644 modules/dlscript/godot/godot_rid.h delete mode 100644 modules/dlscript/godot/godot_string.cpp delete mode 100644 modules/dlscript/godot/godot_string.h delete mode 100644 modules/dlscript/godot/godot_transform.cpp delete mode 100644 modules/dlscript/godot/godot_transform.h delete mode 100644 modules/dlscript/godot/godot_transform2d.cpp delete mode 100644 modules/dlscript/godot/godot_transform2d.h delete mode 100644 modules/dlscript/godot/godot_variant.cpp delete mode 100644 modules/dlscript/godot/godot_variant.h delete mode 100644 modules/dlscript/godot/godot_vector2.cpp delete mode 100644 modules/dlscript/godot/godot_vector2.h delete mode 100644 modules/dlscript/godot/godot_vector3.cpp delete mode 100644 modules/dlscript/godot/godot_vector3.h delete mode 100644 modules/dlscript/register_types.cpp delete mode 100644 modules/dlscript/register_types.h (limited to 'modules/dlscript') diff --git a/modules/dlscript/SCsub b/modules/dlscript/SCsub deleted file mode 100644 index ac13319a1d..0000000000 --- a/modules/dlscript/SCsub +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.modules_sources, "*.cpp") -env.add_source_files(env.modules_sources, "godot/*.cpp") - -env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) - -if "platform" in env and env["platform"] == "x11": # there has to be a better solution? - env.Append(LINKFLAGS=["-rdynamic"]) -env.use_ptrcall = True - -Export('env') diff --git a/modules/dlscript/api_generator.cpp b/modules/dlscript/api_generator.cpp deleted file mode 100644 index 1de3f6d520..0000000000 --- a/modules/dlscript/api_generator.cpp +++ /dev/null @@ -1,412 +0,0 @@ -#include "api_generator.h" - -#ifdef TOOLS_ENABLED - -#include "class_db.h" -#include "core/global_config.h" -#include "core/global_constants.h" -#include "os/file_access.h" - -// helper stuff - -static Error save_file(const String &p_path, const List &p_content) { - - FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE); - - ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); - - for (const List::Element *e = p_content.front(); e != NULL; e = e->next()) { - file->store_string(e->get()); - } - - file->close(); - - return OK; -} - -// helper stuff end - -struct MethodAPI { - String method_name; - String return_type; - - List argument_types; - List argument_names; - - Map default_arguments; - - int argument_count; - bool has_varargs; - bool is_editor; - bool is_noscript; - bool is_const; - bool is_reverse; - bool is_virtual; - bool is_from_script; -}; - -struct PropertyAPI { - String name; - String getter; - String setter; - String type; -}; - -struct ConstantAPI { - String constant_name; - int constant_value; -}; - -struct SignalAPI { - String name; - List argument_types; - List argument_names; - Map default_arguments; -}; - -struct ClassAPI { - String class_name; - String super_class_name; - - ClassDB::APIType api_type; - - bool is_singleton; - bool is_instanciable; - // @Unclear - bool is_creatable; - // @Unclear - bool memory_own; - - List methods; - List properties; - List constants; - List signals_; -}; - -/* - * Reads the entire Godot API to a list - */ -List generate_c_api_classes() { - - List api; - - List classes; - ClassDB::get_class_list(&classes); - - // Register global constants as a fake GlobalConstants singleton class - { - ClassAPI global_constants_api; - global_constants_api.class_name = L"GlobalConstants"; - global_constants_api.api_type = ClassDB::API_CORE; - global_constants_api.is_singleton = true; - global_constants_api.is_instanciable = false; - const int constants_count = GlobalConstants::get_global_constant_count(); - for (int i = 0; i < constants_count; ++i) { - ConstantAPI constant_api; - constant_api.constant_name = GlobalConstants::get_global_constant_name(i); - constant_api.constant_value = GlobalConstants::get_global_constant_value(i); - global_constants_api.constants.push_back(constant_api); - } - api.push_back(global_constants_api); - } - - for (List::Element *e = classes.front(); e != NULL; e = e->next()) { - StringName class_name = e->get(); - - ClassAPI class_api; - class_api.api_type = ClassDB::get_api_type(e->get()); - class_api.class_name = class_name; - class_api.super_class_name = ClassDB::get_parent_class(class_name); - { - String name = class_name; - if (name.begins_with("_")) { - name.remove(0); - } - class_api.is_singleton = GlobalConfig::get_singleton()->has_singleton(name); - } - class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name); - - { - bool is_reference = false; - List inheriters; - ClassDB::get_inheriters_from_class("Reference", &inheriters); - is_reference = !!inheriters.find(class_name); - // @Unclear - class_api.memory_own = !class_api.is_singleton && is_reference; - } - - // constants - { - List constant; - ClassDB::get_integer_constant_list(class_name, &constant, true); - for (List::Element *c = constant.front(); c != NULL; c = c->next()) { - ConstantAPI constant_api; - constant_api.constant_name = c->get(); - constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get()); - - class_api.constants.push_back(constant_api); - } - } - - // signals - { - List signals_; - ClassDB::get_signal_list(class_name, &signals_, true); - - for (int i = 0; i < signals_.size(); i++) { - SignalAPI signal; - - MethodInfo method_info = signals_[i]; - signal.name = method_info.name; - - for (int j = 0; j < method_info.arguments.size(); j++) { - PropertyInfo argument = method_info.arguments[j]; - String type; - String name = argument.name; - - if (argument.name.find(":") != -1) { - type = argument.name.get_slice(":", 1); - name = argument.name.get_slice(":", 0); - } else if (argument.hint == PROPERTY_HINT_RESOURCE_TYPE) { - type = argument.hint_string; - } else if (argument.type == Variant::NIL) { - type = "Variant"; - } else { - type = Variant::get_type_name(argument.type); - } - - signal.argument_names.push_back(name); - signal.argument_types.push_back(type); - } - - Vector default_arguments = method_info.default_arguments; - - int default_start = signal.argument_names.size() - default_arguments.size(); - - for (int j = 0; j < default_arguments.size(); j++) { - signal.default_arguments[default_start + j] = default_arguments[j]; - } - - class_api.signals_.push_back(signal); - } - } - - //properties - { - List properties; - ClassDB::get_property_list(class_name, &properties, true); - - for (List::Element *p = properties.front(); p != NULL; p = p->next()) { - PropertyAPI property_api; - - property_api.name = p->get().name; - property_api.getter = ClassDB::get_property_getter(class_name, p->get().name); - property_api.setter = ClassDB::get_property_setter(class_name, p->get().name); - - if (p->get().name.find(":") != -1) { - property_api.type = p->get().name.get_slice(":", 1); - property_api.name = p->get().name.get_slice(":", 0); - } else if (p->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - property_api.type = p->get().hint_string; - } else if (p->get().type == Variant::NIL) { - property_api.type = "Variant"; - } else { - property_api.type = Variant::get_type_name(p->get().type); - } - - if (!property_api.setter.empty() || !property_api.getter.empty()) { - class_api.properties.push_back(property_api); - } - } - } - - //methods - { - List methods; - ClassDB::get_method_list(class_name, &methods, true); - - for (List::Element *m = methods.front(); m != NULL; m = m->next()) { - MethodAPI method_api; - MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name); - MethodInfo &method_info = m->get(); - - //method name - method_api.method_name = m->get().name; - //method return type - if (method_bind && method_bind->get_return_type() != StringName()) { - method_api.return_type = method_bind->get_return_type(); - } else if (method_api.method_name.find(":") != -1) { - method_api.return_type = method_api.method_name.get_slice(":", 1); - method_api.method_name = method_api.method_name.get_slice(":", 0); - } else if (m->get().return_val.type != Variant::NIL) { - method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type); - } else { - method_api.return_type = "void"; - } - - method_api.argument_count = method_info.arguments.size(); - method_api.has_varargs = method_bind && method_bind->is_vararg(); - - // Method flags - if (method_info.flags) { - const uint32_t flags = method_info.flags; - method_api.is_editor = flags & METHOD_FLAG_EDITOR; - method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT; - method_api.is_const = flags & METHOD_FLAG_CONST; - method_api.is_reverse = flags & METHOD_FLAG_REVERSE; - method_api.is_virtual = flags & METHOD_FLAG_VIRTUAL; - method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT; - } - - method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_'; - - // method argument name and type - - for (int i = 0; i < method_api.argument_count; i++) { - String arg_name; - String arg_type; - PropertyInfo arg_info = method_info.arguments[i]; - - arg_name = arg_info.name; - - if (arg_info.name.find(":") != -1) { - arg_type = arg_info.name.get_slice(":", 1); - arg_name = arg_info.name.get_slice(":", 0); - } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { - arg_type = arg_info.hint_string; - } else if (arg_info.type == Variant::NIL) { - arg_type = "Variant"; - } else { - arg_type = Variant::get_type_name(arg_info.type); - } - - method_api.argument_names.push_back(arg_name); - method_api.argument_types.push_back(arg_type); - - if (method_bind && method_bind->has_default_argument(i)) { - method_api.default_arguments[i] = method_bind->get_default_argument(i); - } - } - - class_api.methods.push_back(method_api); - } - } - - api.push_back(class_api); - } - - return api; -} - -/* - * Generates the JSON source from the API in p_api - */ -static List generate_c_api_json(const List &p_api) { - - // I'm sorry for the \t mess - - List source; - - source.push_back("[\n"); - - for (const List::Element *c = p_api.front(); c != NULL; c = c->next()) { - ClassAPI api = c->get(); - - source.push_back("\t{\n"); - - source.push_back("\t\t\"name\": \"" + api.class_name + "\",\n"); - source.push_back("\t\t\"base_class\": \"" + api.super_class_name + "\",\n"); - source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n"); - source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\"instanciable\": ") + (api.is_instanciable ? "true" : "false") + ",\n"); - // @Unclear - // source.push_back(String("\t\t\"createable\": ") + (api.is_creatable ? "true" : "false") + ",\n"); - - source.push_back("\t\t\"constants\": {\n"); - for (List::Element *e = api.constants.front(); e; e = e->next()) { - source.push_back("\t\t\t\"" + e->get().constant_name + "\": " + String::num_int64(e->get().constant_value) + (e->next() ? "," : "") + "\n"); - } - source.push_back("\t\t},\n"); - - source.push_back("\t\t\"properties\": [\n"); - for (List::Element *e = api.properties.front(); e; e = e->next()) { - source.push_back("\t\t\t{\n"); - source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); - source.push_back("\t\t\t\t\"type\": \"" + e->get().type + "\",\n"); - source.push_back("\t\t\t\t\"getter\": \"" + e->get().getter + "\",\n"); - source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\"\n"); - source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); - } - source.push_back("\t\t],\n"); - - source.push_back("\t\t\"signals\": [\n"); - for (List::Element *e = api.signals_.front(); e; e = e->next()) { - source.push_back("\t\t\t{\n"); - source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); - source.push_back("\t\t\t\t\"arguments\": [\n"); - for (int i = 0; i < e->get().argument_names.size(); i++) { - source.push_back("\t\t\t\t\t{\n"); - source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n"); - source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n"); - source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n"); - source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n"); - } - source.push_back("\t\t\t\t]\n"); - source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); - } - source.push_back("\t\t],\n"); - - source.push_back("\t\t\"methods\": [\n"); - for (List::Element *e = api.methods.front(); e; e = e->next()) { - source.push_back("\t\t\t{\n"); - source.push_back("\t\t\t\t\"name\": \"" + e->get().method_name + "\",\n"); - source.push_back("\t\t\t\t\"return_type\": \"" + e->get().return_type + "\",\n"); - source.push_back(String("\t\t\t\t\"is_editor\": ") + (e->get().is_editor ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"is_noscript\": ") + (e->get().is_noscript ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n"); - source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n"); - source.push_back("\t\t\t\t\"arguments\": [\n"); - for (int i = 0; i < e->get().argument_names.size(); i++) { - source.push_back("\t\t\t\t\t{\n"); - source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n"); - source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n"); - source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n"); - source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n"); - } - source.push_back("\t\t\t\t]\n"); - source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); - } - source.push_back("\t\t]\n"); - - source.push_back(String("\t}") + (c->next() ? "," : "") + "\n"); - } - - source.push_back("]"); - - return source; -} - -// - -#endif - -/* - * Saves the whole Godot API to a JSON file located at - * p_path - */ -Error generate_c_api(const String &p_path) { - -#ifndef TOOLS_ENABLED - return ERR_BUG; -#else - - List api = generate_c_api_classes(); - - List json_source = generate_c_api_json(api); - - return save_file(p_path, json_source); -#endif -} diff --git a/modules/dlscript/api_generator.h b/modules/dlscript/api_generator.h deleted file mode 100644 index 4a8354e9d6..0000000000 --- a/modules/dlscript/api_generator.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef API_GENERATOR_H -#define API_GENERATOR_H - -#include "core/ustring.h" -#include "typedefs.h" - -Error generate_c_api(const String &p_path); - -#endif // API_GENERATOR_H diff --git a/modules/dlscript/config.py b/modules/dlscript/config.py deleted file mode 100644 index 9f57b9bb74..0000000000 --- a/modules/dlscript/config.py +++ /dev/null @@ -1,8 +0,0 @@ - - -def can_build(platform): - return True - - -def configure(env): - env.use_ptrcall = True diff --git a/modules/dlscript/dl_script.cpp b/modules/dlscript/dl_script.cpp deleted file mode 100644 index fa082d7b94..0000000000 --- a/modules/dlscript/dl_script.cpp +++ /dev/null @@ -1,1237 +0,0 @@ -/*************************************************************************/ -/* dl_script.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 "dl_script.h" - -#include "global_config.h" -#include "global_constants.h" -#include "io/file_access_encrypted.h" -#include "os/file_access.h" -#include "os/os.h" - -#include "scene/main/scene_main_loop.h" -#include "scene/resources/scene_format_text.h" - -#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) -#include "api_generator.h" -#endif - -#ifdef TOOLS_ENABLED -#include "editor/editor_node.h" -#endif - -Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p_path) { - - if (DLScriptLanguage::get_singleton()->initialized_libraries.has(p_path)) { - p_native_lib = DLScriptLanguage::get_singleton()->initialized_libraries[p_path]; - return OK; - } - - NativeLibrary *lib = memnew(NativeLibrary); - lib->path = p_path; - - p_native_lib = lib; - - // Open the file - - Error error; - error = OS::get_singleton()->open_dynamic_library(p_path, lib->handle); - if (error) return error; - ERR_FAIL_COND_V(!lib->handle, ERR_BUG); - - // Get the method - - void *library_init; - error = OS::get_singleton()->get_dynamic_library_symbol_handle(lib->handle, DLScriptLanguage::get_init_symbol_name(), library_init); - if (error) return error; - ERR_FAIL_COND_V(!library_init, ERR_BUG); - - void (*library_init_fpointer)(godot_dlscript_init_options *) = (void (*)(godot_dlscript_init_options *))library_init; - - godot_dlscript_init_options options; - - options.in_editor = SceneTree::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); - */ - - library_init_fpointer(&options); // Catch errors? - - DLScriptLanguage::get_singleton()->initialized_libraries[p_path] = lib; - - return OK; -} - -Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) { - - if (!DLScriptLanguage::get_singleton()->initialized_libraries.has(p_native_lib->path)) { - OS::get_singleton()->close_dynamic_library(p_native_lib->handle); - p_native_lib->handle = 0; - return OK; - } - - Error error = OK; - void *library_terminate; - error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, DLScriptLanguage::get_terminate_symbol_name(), library_terminate); - if (error) - return OK; // no terminate? okay, not that important lol - - void (*library_terminate_pointer)(godot_dlscript_terminate_options *) = (void (*)(godot_dlscript_terminate_options *))library_terminate; - - godot_dlscript_terminate_options options; - options.in_editor = SceneTree::get_singleton()->is_editor_hint(); - - library_terminate_pointer(&options); - - DLScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); - - OS::get_singleton()->close_dynamic_library(p_native_lib->handle); - p_native_lib->handle = 0; - - return OK; -} - -// Script -#ifdef TOOLS_ENABLED - -void DLScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { - - List pinfo; - Map values; - - for (Map::Element *E = script_data->properties.front(); E; E = E->next()) { - PropertyInfo p = E->get().info; - p.name = String(E->key()); - pinfo.push_back(p); - values[p.name] = E->get().default_value; - } - - p_placeholder->update(pinfo, values); -} - -void DLScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { - - placeholders.erase(p_placeholder); -} - -#endif - -bool DLScript::can_instance() const { -#ifdef DLSCRIPT_EDITOR_FEATURES - return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled()); -#else - // allow defaultlibrary without editor features - if (!library.is_valid()) { - String path = GLOBAL_GET("dlscript/default_dllibrary"); - - RES lib = ResourceLoader::load(path); - - if (lib.is_valid() && lib->cast_to()) { - return true; - } - } - - return script_data; -#endif - //return script_data || (!tool && !ScriptServer::is_scripting_enabled()); - // change to true enable in editor stuff. -} - -Ref