summaryrefslogtreecommitdiff
path: root/modules/gdnative/pluginscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative/pluginscript')
-rw-r--r--modules/gdnative/pluginscript/SCsub6
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.cpp140
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.h82
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp459
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h138
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp114
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h62
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp510
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h146
-rw-r--r--modules/gdnative/pluginscript/register_types.cpp121
-rw-r--r--modules/gdnative/pluginscript/register_types.h37
11 files changed, 0 insertions, 1815 deletions
diff --git a/modules/gdnative/pluginscript/SCsub b/modules/gdnative/pluginscript/SCsub
deleted file mode 100644
index 0b2db3b504..0000000000
--- a/modules/gdnative/pluginscript/SCsub
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-
-Import("env")
-Import("env_gdnative")
-
-env_gdnative.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp
deleted file mode 100644
index 9236aceb3e..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_instance.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*************************************************************************/
-/* pluginscript_instance.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 "pluginscript_instance.h"
-
-// Godot imports
-#include "core/os/os.h"
-#include "core/variant/variant.h"
-
-// PluginScript imports
-#include "pluginscript_language.h"
-#include "pluginscript_script.h"
-
-bool PluginScriptInstance::set(const StringName &p_name, const Variant &p_value) {
- return _desc->set_prop(_data, (const godot_string_name *)&p_name, (const godot_variant *)&p_value);
-}
-
-bool PluginScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
- return _desc->get_prop(_data, (const godot_string_name *)&p_name, (godot_variant *)&r_ret);
-}
-
-Ref<Script> PluginScriptInstance::get_script() const {
- return _script;
-}
-
-ScriptLanguage *PluginScriptInstance::get_language() {
- return _script->get_language();
-}
-
-Variant::Type PluginScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
- if (!_script->has_property(p_name)) {
- if (r_is_valid) {
- *r_is_valid = false;
- }
- return Variant::NIL;
- }
- if (r_is_valid) {
- *r_is_valid = true;
- }
- return _script->get_property_info(p_name).type;
-}
-
-void PluginScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
- _script->get_script_property_list(p_properties);
-}
-
-void PluginScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
- _script->get_script_method_list(p_list);
-}
-
-bool PluginScriptInstance::has_method(const StringName &p_method) const {
- return _script->has_method(p_method);
-}
-
-Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- // TODO: optimize when calling a Godot method from Godot to avoid param conversion ?
- 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;
- godot_variant_destroy(&ret);
- return var_ret;
-}
-
-void PluginScriptInstance::notification(int p_notification) {
- _desc->notification(_data, p_notification);
-}
-
-String PluginScriptInstance::to_string(bool *r_valid) {
- godot_string ret = _desc->to_string(_data, r_valid);
- String str_ret = *(String *)&ret;
- godot_string_destroy(&ret);
- return str_ret;
-}
-
-const Vector<Multiplayer::RPCConfig> PluginScriptInstance::get_rpc_methods() const {
- return _script->get_rpc_methods();
-}
-
-void PluginScriptInstance::refcount_incremented() {
- if (_desc->refcount_decremented) {
- _desc->refcount_incremented(_data);
- }
-}
-
-bool PluginScriptInstance::refcount_decremented() {
- // Return true if it can die
- if (_desc->refcount_decremented) {
- return _desc->refcount_decremented(_data);
- }
- return true;
-}
-
-PluginScriptInstance::PluginScriptInstance() {
-}
-
-bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) {
- _owner = p_owner;
- _owner_variant = Variant(p_owner);
- _script = Ref<PluginScript>(p_script);
- _desc = &p_script->_desc->instance_desc;
- _data = _desc->init(p_script->_data, (godot_object *)p_owner);
- ERR_FAIL_COND_V(_data == nullptr, false);
- p_owner->set_script_instance(this);
- return true;
-}
-
-PluginScriptInstance::~PluginScriptInstance() {
- _desc->finish(_data);
- _script->_language->lock();
- _script->_instances.erase(_owner);
- _script->_language->unlock();
-}
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h
deleted file mode 100644
index 09b051c008..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_instance.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*************************************************************************/
-/* pluginscript_instance.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_INSTANCE_H
-#define PLUGINSCRIPT_INSTANCE_H
-
-// Godot imports
-#include "core/object/script_language.h"
-
-// PluginScript imports
-#include <pluginscript/godot_pluginscript.h>
-
-class PluginScript;
-
-class PluginScriptInstance : public ScriptInstance {
- friend class PluginScript;
-
-private:
- Ref<PluginScript> _script;
- Object *_owner = nullptr;
- Variant _owner_variant;
- godot_pluginscript_instance_data *_data = nullptr;
- const godot_pluginscript_instance_desc *_desc = nullptr;
-
-public:
- _FORCE_INLINE_ Object *get_owner() { return _owner; }
-
- 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 Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) 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, Callable::CallError &r_error);
-
- virtual void notification(int p_notification);
- virtual String to_string(bool *r_valid);
-
- virtual Ref<Script> get_script() const;
-
- virtual ScriptLanguage *get_language();
-
- virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const;
-
- virtual void refcount_incremented();
- virtual bool refcount_decremented();
-
- PluginScriptInstance();
- bool init(PluginScript *p_script, Object *p_owner);
- virtual ~PluginScriptInstance();
-};
-
-#endif // PLUGINSCRIPT_INSTANCE_H
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
deleted file mode 100644
index 0e068dec3a..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ /dev/null
@@ -1,459 +0,0 @@
-/*************************************************************************/
-/* pluginscript_language.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 imports
-#include "core/config/project_settings.h"
-#include "core/io/file_access.h"
-#include "core/os/os.h"
-// PluginScript imports
-#include "pluginscript_language.h"
-#include "pluginscript_script.h"
-
-String PluginScriptLanguage::get_name() const {
- return String(_desc.name);
-}
-
-void PluginScriptLanguage::init() {
- _data = _desc.init();
-}
-
-String PluginScriptLanguage::get_type() const {
- // 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 {
- return String(_desc.extension);
-}
-
-Error PluginScriptLanguage::execute_file(const String &p_path) {
- // TODO: pretty sure this method is totally deprecated and should be removed...
- return OK;
-}
-
-void PluginScriptLanguage::finish() {
- _desc.finish(_data);
-}
-
-/* EDITOR FUNCTIONS */
-
-void PluginScriptLanguage::get_reserved_words(List<String> *p_words) const {
- if (_desc.reserved_words) {
- const char **w = _desc.reserved_words;
- while (*w) {
- p_words->push_back(*w);
- w++;
- }
- }
-}
-
-bool PluginScriptLanguage::is_control_flow_keyword(String p_keyword) const {
- return false;
-}
-
-void PluginScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
- if (_desc.comment_delimiters) {
- const char **w = _desc.comment_delimiters;
- while (*w) {
- p_delimiters->push_back(*w);
- w++;
- }
- }
-}
-
-void PluginScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
- if (_desc.string_delimiters) {
- const char **w = _desc.string_delimiters;
- while (*w) {
- p_delimiters->push_back(*w);
- w++;
- }
- }
-}
-
-Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
- Script *ns = create_script();
- Ref<Script> script = Ref<Script>(ns);
- 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;
-}
-
-bool PluginScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
- PackedStringArray functions;
- Array errors;
- if (_desc.validate) {
- bool ret = _desc.validate(
- _data,
- (godot_string *)&p_script,
- (godot_string *)&p_path,
- (godot_packed_string_array *)&functions,
- (godot_array *)&errors);
- for (int i = 0; i < functions.size(); i++) {
- r_functions->push_back(functions[i]);
- }
- if (r_errors) {
- for (int i = 0; i < errors.size(); i++) {
- Dictionary error = errors[i];
- ScriptLanguage::ScriptError e;
- e.line = error["line"];
- e.column = error["column"];
- e.message = error["message"];
- r_errors->push_back(e);
- }
- }
- return ret;
- }
- return true;
-}
-
-Script *PluginScriptLanguage::create_script() const {
- PluginScript *script = memnew(PluginScript());
- // I'm hurting kittens doing this I guess...
- script->init(const_cast<PluginScriptLanguage *>(this));
- return script;
-}
-
-bool PluginScriptLanguage::has_named_classes() const {
- return _desc.has_named_classes;
-}
-
-bool PluginScriptLanguage::supports_builtin_mode() const {
- return _desc.supports_builtin_mode;
-}
-
-bool PluginScriptLanguage::can_inherit_from_file() const {
- return _desc.can_inherit_from_file;
-}
-
-int PluginScriptLanguage::find_function(const String &p_function, const String &p_code) const {
- if (_desc.find_function) {
- return _desc.find_function(_data, (godot_string *)&p_function, (godot_string *)&p_code);
- }
- return -1;
-}
-
-String PluginScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
- if (_desc.make_function) {
- godot_string tmp = _desc.make_function(_data, (godot_string *)&p_class, (godot_string *)&p_name, (godot_packed_string_array *)&p_args);
- String ret = *(String *)&tmp;
- godot_string_destroy(&tmp);
- return ret;
- }
- return String();
-}
-
-Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) {
- if (_desc.complete_code) {
- Array options;
- godot_error tmp = _desc.complete_code(
- _data,
- (godot_string *)&p_code,
- (godot_string *)&p_path,
- (godot_object *)p_owner,
- (godot_array *)&options,
- &r_force,
- (godot_string *)&r_call_hint);
- for (int i = 0; i < options.size(); i++) {
- ScriptCodeCompletionOption option(options[i], ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
- r_options->push_back(option);
- }
- return (Error)tmp;
- }
- return ERR_UNAVAILABLE;
-}
-
-void PluginScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
- if (_desc.auto_indent_code) {
- _desc.auto_indent_code(_data, (godot_string *)&p_code, p_from_line, p_to_line);
- }
- return;
-}
-
-void PluginScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
- _desc.add_global_constant(_data, (godot_string_name *)&p_variable, (godot_variant *)&p_value);
-}
-
-/* LOADER FUNCTIONS */
-
-void PluginScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
- for (int i = 0; _desc.recognized_extensions[i]; ++i) {
- p_extensions->push_back(String(_desc.recognized_extensions[i]));
- }
-}
-
-void PluginScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
- // TODO: provide this statically in `godot_pluginscript_language_desc` ?
- if (_desc.get_public_functions) {
- Array functions;
- _desc.get_public_functions(_data, (godot_array *)&functions);
- for (int i = 0; i < functions.size(); i++) {
- MethodInfo mi = MethodInfo::from_dict(functions[i]);
- p_functions->push_back(mi);
- }
- }
-}
-
-void PluginScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
- // TODO: provide this statically in `godot_pluginscript_language_desc` ?
- if (_desc.get_public_constants) {
- Dictionary constants;
- _desc.get_public_constants(_data, (godot_dictionary *)&constants);
- for (const Variant *key = constants.next(); key; key = constants.next(key)) {
- Variant value = constants[*key];
- p_constants->push_back(Pair<String, Variant>(*key, value));
- }
- }
-}
-
-void PluginScriptLanguage::profiling_start() {
-#ifdef DEBUG_ENABLED
- if (_desc.profiling_start) {
- lock();
- _desc.profiling_start(_data);
- unlock();
- }
-#endif
-}
-
-void PluginScriptLanguage::profiling_stop() {
-#ifdef DEBUG_ENABLED
- if (_desc.profiling_stop) {
- lock();
- _desc.profiling_stop(_data);
- unlock();
- }
-#endif
-}
-
-int PluginScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
- int info_count = 0;
-#ifdef DEBUG_ENABLED
- if (_desc.profiling_get_accumulated_data) {
- godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc(
- sizeof(godot_pluginscript_profiling_data) * p_info_max);
- info_count = _desc.profiling_get_accumulated_data(_data, info, p_info_max);
- for (int i = 0; i < info_count; ++i) {
- p_info_arr[i].signature = *(StringName *)&info[i].signature;
- p_info_arr[i].call_count = info[i].call_count;
- p_info_arr[i].total_time = info[i].total_time;
- p_info_arr[i].self_time = info[i].self_time;
- godot_string_name_destroy(&info[i].signature);
- }
- }
-#endif
- return info_count;
-}
-
-int PluginScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
- int info_count = 0;
-#ifdef DEBUG_ENABLED
- if (_desc.profiling_get_frame_data) {
- godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc(
- sizeof(godot_pluginscript_profiling_data) * p_info_max);
- info_count = _desc.profiling_get_frame_data(_data, info, p_info_max);
- for (int i = 0; i < info_count; ++i) {
- p_info_arr[i].signature = *(StringName *)&info[i].signature;
- p_info_arr[i].call_count = info[i].call_count;
- p_info_arr[i].total_time = info[i].total_time;
- p_info_arr[i].self_time = info[i].self_time;
- godot_string_name_destroy(&info[i].signature);
- }
- }
-#endif
- return info_count;
-}
-
-void PluginScriptLanguage::frame() {
-#ifdef DEBUG_ENABLED
- if (_desc.profiling_frame) {
- _desc.profiling_frame(_data);
- }
-#endif
-}
-
-/* DEBUGGER FUNCTIONS */
-
-String PluginScriptLanguage::debug_get_error() const {
- if (_desc.debug_get_error) {
- godot_string tmp = _desc.debug_get_error(_data);
- String ret = *(String *)&tmp;
- godot_string_destroy(&tmp);
- return ret;
- }
- return String("Nothing");
-}
-
-int PluginScriptLanguage::debug_get_stack_level_count() const {
- if (_desc.debug_get_stack_level_count) {
- return _desc.debug_get_stack_level_count(_data);
- }
- return 1;
-}
-
-int PluginScriptLanguage::debug_get_stack_level_line(int p_level) const {
- if (_desc.debug_get_stack_level_line) {
- return _desc.debug_get_stack_level_line(_data, p_level);
- }
- return 1;
-}
-
-String PluginScriptLanguage::debug_get_stack_level_function(int p_level) const {
- if (_desc.debug_get_stack_level_function) {
- godot_string tmp = _desc.debug_get_stack_level_function(_data, p_level);
- String ret = *(String *)&tmp;
- godot_string_destroy(&tmp);
- return ret;
- }
- return String("Nothing");
-}
-
-String PluginScriptLanguage::debug_get_stack_level_source(int p_level) const {
- if (_desc.debug_get_stack_level_source) {
- godot_string tmp = _desc.debug_get_stack_level_source(_data, p_level);
- String ret = *(String *)&tmp;
- godot_string_destroy(&tmp);
- return ret;
- }
- return String("Nothing");
-}
-
-void PluginScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_desc.debug_get_stack_level_locals) {
- PackedStringArray locals;
- Array values;
- _desc.debug_get_stack_level_locals(_data, p_level, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
- for (int i = 0; i < locals.size(); i++) {
- p_locals->push_back(locals[i]);
- }
- for (int i = 0; i < values.size(); i++) {
- p_values->push_back(values[i]);
- }
- }
-}
-
-void PluginScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_desc.debug_get_stack_level_members) {
- PackedStringArray members;
- Array values;
- _desc.debug_get_stack_level_members(_data, p_level, (godot_packed_string_array *)&members, (godot_array *)&values, p_max_subitems, p_max_depth);
- for (int i = 0; i < members.size(); i++) {
- p_members->push_back(members[i]);
- }
- for (int i = 0; i < values.size(); i++) {
- p_values->push_back(values[i]);
- }
- }
-}
-
-void PluginScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_desc.debug_get_globals) {
- PackedStringArray locals;
- Array values;
- _desc.debug_get_globals(_data, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
- for (int i = 0; i < locals.size(); i++) {
- p_locals->push_back(locals[i]);
- }
- for (int i = 0; i < values.size(); i++) {
- p_values->push_back(values[i]);
- }
- }
-}
-
-String PluginScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
- if (_desc.debug_parse_stack_level_expression) {
- godot_string tmp = _desc.debug_parse_stack_level_expression(_data, p_level, (godot_string *)&p_expression, p_max_subitems, p_max_depth);
- String ret = *(String *)&tmp;
- godot_string_destroy(&tmp);
- return ret;
- }
- return String("Nothing");
-}
-
-void PluginScriptLanguage::reload_all_scripts() {
- // TODO
-}
-
-void PluginScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
-#ifdef DEBUG_ENABLED
- lock();
- // TODO
- unlock();
-#endif
-}
-
-bool PluginScriptLanguage::handles_global_class_type(const String &p_type) const {
- return p_type == "PluginScript";
-}
-
-String PluginScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
- if (!p_path.is_empty()) {
- Ref<PluginScript> script = ResourceLoader::load(p_path, "PluginScript");
- if (script.is_valid()) {
- if (r_base_type) {
- *r_base_type = script->get_instance_base_type();
- }
- if (r_icon_path) {
- *r_icon_path = script->get_script_class_icon_path();
- }
- return script->get_script_class_name();
- }
- if (r_base_type) {
- *r_base_type = String();
- }
- if (r_icon_path) {
- *r_icon_path = String();
- }
- }
- return String();
-}
-
-void PluginScriptLanguage::lock() {
- _lock.lock();
-}
-
-void PluginScriptLanguage::unlock() {
- _lock.unlock();
-}
-
-PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) :
- _desc(*desc) {
- _resource_loader = Ref<ResourceFormatLoaderPluginScript>(memnew(ResourceFormatLoaderPluginScript(this)));
- _resource_saver = Ref<ResourceFormatSaverPluginScript>(memnew(ResourceFormatSaverPluginScript(this)));
-}
-
-PluginScriptLanguage::~PluginScriptLanguage() {
-}
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
deleted file mode 100644
index 6039f807a8..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*************************************************************************/
-/* pluginscript_language.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_LANGUAGE_H
-#define PLUGINSCRIPT_LANGUAGE_H
-
-// Godot imports
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
-#include "core/object/script_language.h"
-#include "core/templates/map.h"
-#include "core/templates/self_list.h"
-// PluginScript imports
-#include "pluginscript_loader.h"
-#include <pluginscript/godot_pluginscript.h>
-
-class PluginScript;
-class PluginScriptInstance;
-
-class PluginScriptLanguage : public ScriptLanguage {
- friend class PluginScript;
- friend class PluginScriptInstance;
-
- Ref<ResourceFormatLoaderPluginScript> _resource_loader;
- Ref<ResourceFormatSaverPluginScript> _resource_saver;
- const godot_pluginscript_language_desc _desc;
- godot_pluginscript_language_data *_data;
-
- Mutex _lock;
- SelfList<PluginScript>::List _script_list;
-
-public:
- virtual String get_name() const;
-
- _FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; }
- _FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; }
-
- /* 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 bool is_control_flow_keyword(String p_keyword) 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, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
- virtual Script *create_script() const;
- virtual bool has_named_classes() const;
- virtual bool supports_builtin_mode() const;
- virtual bool can_inherit_from_file() 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 PackedStringArray &p_args) const;
- virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint);
- virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
- virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
-
- /* MULTITHREAD FUNCTIONS */
-
- //some VMs need to be notified of thread creation/exiting to allocate a stack
- // void thread_enter() {}
- // void thread_exit() {}
-
- /* 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);
-
- // virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
-
- virtual void reload_all_scripts();
- virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
-
- /* LOADER FUNCTIONS */
-
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual void get_public_functions(List<MethodInfo> *p_functions) const;
- virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
-
- virtual void profiling_start();
- 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);
-
- virtual void frame();
-
- /* GLOBAL CLASSES */
-
- virtual bool handles_global_class_type(const String &p_type) const;
- virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
-
- void lock();
- void unlock();
-
- PluginScriptLanguage(const godot_pluginscript_language_desc *desc);
- virtual ~PluginScriptLanguage();
-};
-
-#endif // PLUGINSCRIPT_LANGUAGE_H
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp
deleted file mode 100644
index a151d551dc..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*************************************************************************/
-/* pluginscript_loader.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 imports
-#include "core/io/file_access.h"
-// Pythonscript imports
-#include "pluginscript_language.h"
-#include "pluginscript_loader.h"
-#include "pluginscript_script.h"
-
-ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptLanguage *language) {
- _language = language;
-}
-
-RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
- if (r_error) {
- *r_error = ERR_FILE_CANT_OPEN;
- }
-
- PluginScript *script = memnew(PluginScript);
- script->init(_language);
-
- Ref<PluginScript> scriptres(script);
-
- Error err = script->load_source_code(p_path);
- ERR_FAIL_COND_V(err != OK, RES());
-
- script->set_path(p_original_path);
-
- script->reload();
-
- if (r_error) {
- *r_error = OK;
- }
-
- return scriptres;
-}
-
-void ResourceFormatLoaderPluginScript::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back(_language->get_extension());
-}
-
-bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const {
- return p_type == "Script" || p_type == _language->get_type();
-}
-
-String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const {
- String el = p_path.get_extension().to_lower();
- if (el == _language->get_extension()) {
- return _language->get_type();
- }
- return "";
-}
-
-ResourceFormatSaverPluginScript::ResourceFormatSaverPluginScript(PluginScriptLanguage *language) {
- _language = language;
-}
-
-Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- Ref<PluginScript> sqscr = p_resource;
- ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
-
- String source = sqscr->get_source_code();
-
- Error err;
- FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
- ERR_FAIL_COND_V(err, err);
-
- file->store_string(source);
- if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
- memdelete(file);
- return ERR_CANT_CREATE;
- }
- file->close();
- memdelete(file);
- return OK;
-}
-
-void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (Object::cast_to<PluginScript>(*p_resource)) {
- p_extensions->push_back(_language->get_extension());
- }
-}
-
-bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const {
- return Object::cast_to<PluginScript>(*p_resource) != nullptr;
-}
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
deleted file mode 100644
index bcce742aea..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*************************************************************************/
-/* pluginscript_loader.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 PYTHONSCRIPT_PY_LOADER_H
-#define PYTHONSCRIPT_PY_LOADER_H
-
-// Godot imports
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
-#include "core/object/script_language.h"
-
-class PluginScriptLanguage;
-
-class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
- PluginScriptLanguage *_language;
-
-public:
- ResourceFormatLoaderPluginScript(PluginScriptLanguage *language);
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
- 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;
-};
-
-class ResourceFormatSaverPluginScript : public ResourceFormatSaver {
- PluginScriptLanguage *_language;
-
-public:
- ResourceFormatSaverPluginScript(PluginScriptLanguage *language);
- virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
- virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
- virtual bool recognize(const RES &p_resource) const;
-};
-
-#endif // PYTHONSCRIPT_PY_LOADER_H
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
deleted file mode 100644
index ec3c9eb4ff..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ /dev/null
@@ -1,510 +0,0 @@
-/*************************************************************************/
-/* pluginscript_script.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 imports
-#include "core/io/file_access.h"
-// PluginScript imports
-#include "pluginscript_instance.h"
-#include "pluginscript_script.h"
-
-#include <stdint.h>
-
-#ifdef DEBUG_ENABLED
-#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
-#define ASSERT_SCRIPT_VALID() \
- { \
- ERR_FAIL_COND_MSG(!can_instantiate(), __ASSERT_SCRIPT_REASON); \
- }
-#define ASSERT_SCRIPT_VALID_V(ret) \
- { \
- ERR_FAIL_COND_V_MSG(!can_instantiate(), ret, __ASSERT_SCRIPT_REASON); \
- }
-#else
-#define ASSERT_SCRIPT_VALID()
-#define ASSERT_SCRIPT_VALID_V(ret)
-#endif
-
-void PluginScript::_bind_methods() {
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &PluginScript::_new, MethodInfo("new"));
-}
-
-PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) {
- r_error.error = Callable::CallError::CALL_OK;
-
- // Create instance
- PluginScriptInstance *instance = memnew(PluginScriptInstance());
-
- if (instance->init(this, p_owner)) {
- _language->lock();
- _instances.insert(instance->get_owner());
- _language->unlock();
- } else {
- r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
- memdelete(instance);
- ERR_FAIL_V(nullptr);
- }
-
- // Construct
- // TODO: Support arguments in the constructor?
- // There is currently no way to get the constructor function name of the script.
- // instance->call("__init__", p_args, p_argcount, r_error);
- if (p_argcount > 0) {
- WARN_PRINT("PluginScript doesn't support arguments in the constructor");
- }
-
- return instance;
-}
-
-Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- r_error.error = Callable::CallError::CALL_OK;
-
- if (!_valid) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
- }
-
- REF ref;
- Object *owner = nullptr;
-
- if (get_instance_base_type() == StringName()) {
- owner = memnew(RefCounted);
- } else {
- owner = ClassDB::instantiate(get_instance_base_type());
- }
-
- if (!owner) {
- r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
- return Variant();
- }
-
- RefCounted *r = Object::cast_to<RefCounted>(owner);
- if (r) {
- ref = REF(r);
- }
-
- PluginScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r_error);
-
- if (!instance) {
- if (ref.is_null()) {
- memdelete(owner); //no owner, sorry
- }
- return Variant();
- }
-
- if (ref.is_valid()) {
- return ref;
- } else {
- return owner;
- }
-}
-
-#ifdef TOOLS_ENABLED
-
-void PluginScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
- placeholders.erase(p_placeholder);
-}
-
-#endif
-
-bool PluginScript::can_instantiate() const {
- bool can = _valid || (!_tool && !ScriptServer::is_scripting_enabled());
- return can;
-}
-
-bool PluginScript::inherits_script(const Ref<Script> &p_script) const {
- Ref<PluginScript> ps = p_script;
- if (ps.is_null()) {
- return false;
- }
-
- const PluginScript *s = this;
-
- while (s) {
- if (s == p_script.ptr()) {
- return true;
- }
- s = Object::cast_to<PluginScript>(s->_ref_base_parent.ptr());
- }
-
- return false;
-}
-
-Ref<Script> PluginScript::get_base_script() const {
- if (_ref_base_parent.is_valid()) {
- return Ref<PluginScript>(_ref_base_parent);
- } else {
- return Ref<Script>();
- }
-}
-
-StringName PluginScript::get_instance_base_type() const {
- if (_native_parent) {
- return _native_parent;
- }
- if (_ref_base_parent.is_valid()) {
- return _ref_base_parent->get_instance_base_type();
- }
- return StringName();
-}
-
-void PluginScript::update_exports() {
-#ifdef TOOLS_ENABLED
- ASSERT_SCRIPT_VALID();
- if (placeholders.size()) {
- //update placeholders if any
- Map<StringName, Variant> propdefvalues;
- List<PropertyInfo> propinfos;
-
- get_script_property_list(&propinfos);
- for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
- E->get()->update(propinfos, _properties_default_values);
- }
- }
-#endif
-}
-
-// TODO: rename p_this "p_owner" ?
-ScriptInstance *PluginScript::instance_create(Object *p_this) {
- ASSERT_SCRIPT_VALID_V(nullptr);
- // TODO check script validity ?
- if (!_tool && !ScriptServer::is_scripting_enabled()) {
-#ifdef TOOLS_ENABLED
- // Instance a fake script for editing the values
- PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(get_language(), Ref<Script>(this), p_this));
- placeholders.insert(si);
- update_exports();
- return si;
-#else
- return nullptr;
-#endif
- }
-
- 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 instantiated in object of type: '" + p_this->get_class() + "'";
- // TODO: implement PluginscriptLanguage::debug_break_parse
- // if (EngineDebugger::is_active()) {
- // _language->debug_break_parse(get_path(), 0, msg);
- // }
- ERR_FAIL_V_MSG(nullptr, msg);
- }
- }
-
- Callable::CallError unchecked_error;
- return _create_instance(nullptr, 0, p_this, unchecked_error);
-}
-
-bool PluginScript::instance_has(const Object *p_this) const {
- ERR_FAIL_COND_V(!_language, false);
-
- _language->lock();
- bool hasit = _instances.has((Object *)p_this);
- _language->unlock();
- return hasit;
-}
-
-bool PluginScript::has_source_code() const {
- return !_source.is_empty();
-}
-
-String PluginScript::get_source_code() const {
- return _source;
-}
-
-void PluginScript::set_source_code(const String &p_code) {
- if (_source == p_code) {
- return;
- }
- _source = p_code;
-}
-
-Error PluginScript::reload(bool p_keep_state) {
- ERR_FAIL_COND_V(!_language, ERR_UNCONFIGURED);
-
- _language->lock();
- ERR_FAIL_COND_V(!p_keep_state && _instances.size(), ERR_ALREADY_IN_USE);
- _language->unlock();
-
- _valid = false;
- String basedir = _path;
-
- if (basedir.is_empty()) {
- basedir = get_path();
- }
-
- if (!basedir.is_empty()) {
- basedir = basedir.get_base_dir();
- }
-
- if (_data) {
- _desc->finish(_data);
- }
-
- Error err;
- godot_pluginscript_script_manifest manifest = _desc->init(
- _language->_data,
- (godot_string *)&_path,
- (godot_string *)&_source,
- (godot_error *)&err);
-// Manifest's attributes must be explicitly freed
-#define FREE_SCRIPT_MANIFEST(manifest) \
- { \
- godot_string_name_destroy(&manifest.name); \
- godot_string_name_destroy(&manifest.base); \
- godot_dictionary_destroy(&manifest.member_lines); \
- godot_array_destroy(&manifest.methods); \
- godot_array_destroy(&manifest.signals); \
- godot_array_destroy(&manifest.properties); \
- }
-
- if (err) {
- FREE_SCRIPT_MANIFEST(manifest);
- // 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;
- FREE_SCRIPT_MANIFEST(manifest);
- ERR_FAIL_V_MSG(ERR_PARSE_ERROR, _path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'.");
- }
- }
- }
-
- _valid = true;
- // Use the manifest to configure this script object
- _data = manifest.data;
- _name = *(StringName *)&manifest.name;
- _tool = manifest.is_tool;
- _icon_path = *(String *)&manifest.icon_path;
-
- Dictionary *members = (Dictionary *)&manifest.member_lines;
- for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) {
- _member_lines[*key] = (*members)[*key];
- }
- Array *methods = (Array *)&manifest.methods;
- _rpc_methods.clear();
- if (_ref_base_parent.is_valid()) {
- /// XXX TODO Should this be _rpc_methods.append_array(...)
- _rpc_methods = _ref_base_parent->get_rpc_methods();
- }
- for (int i = 0; i < methods->size(); ++i) {
- Dictionary v = (*methods)[i];
- MethodInfo mi = MethodInfo::from_dict(v);
- _methods_info[mi.name] = mi;
- // rpc_mode is passed as an optional field and is not part of MethodInfo
- Variant var = v["rpc_mode"];
- if (var != Variant()) {
- Multiplayer::RPCConfig nd;
- nd.name = mi.name;
- nd.rpc_mode = Multiplayer::RPCMode(int(var));
- // TODO Transfer Channel
- if (_rpc_methods.find(nd) == -1) {
- _rpc_methods.push_back(nd);
- }
- }
- }
-
- // Sort so we are 100% that they are always the same.
- _rpc_methods.sort_custom<Multiplayer::SortRPCConfig>();
-
- Array *signals = (Array *)&manifest.signals;
- for (int i = 0; i < signals->size(); ++i) {
- Variant v = (*signals)[i];
- MethodInfo mi = MethodInfo::from_dict(v);
- _signals_info[mi.name] = mi;
- }
- Array *properties = (Array *)&manifest.properties;
- for (int i = 0; i < properties->size(); ++i) {
- Dictionary v = (*properties)[i];
- PropertyInfo pi = PropertyInfo::from_dict(v);
- _properties_info[pi.name] = pi;
- _properties_default_values[pi.name] = v["default_value"];
- }
-
- FREE_SCRIPT_MANIFEST(manifest);
- return OK;
-#undef FREE_SCRIPT_MANIFEST
-}
-
-void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const {
- ASSERT_SCRIPT_VALID();
- for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) {
- r_methods->push_back(e->get());
- }
-}
-
-void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const {
- ASSERT_SCRIPT_VALID();
- for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) {
- r_properties->push_back(e->get());
- }
-}
-
-bool PluginScript::has_method(const StringName &p_method) const {
- ASSERT_SCRIPT_VALID_V(false);
- return _methods_info.has(p_method);
-}
-
-MethodInfo PluginScript::get_method_info(const StringName &p_method) const {
- ASSERT_SCRIPT_VALID_V(MethodInfo());
- const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method);
- if (e != nullptr) {
- return e->get();
- } else {
- return MethodInfo();
- }
-}
-
-bool PluginScript::has_property(const StringName &p_method) const {
- ASSERT_SCRIPT_VALID_V(false);
- return _properties_info.has(p_method);
-}
-
-PropertyInfo PluginScript::get_property_info(const StringName &p_property) const {
- ASSERT_SCRIPT_VALID_V(PropertyInfo());
- const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property);
- if (e != nullptr) {
- return e->get();
- } else {
- return PropertyInfo();
- }
-}
-
-bool PluginScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
- ASSERT_SCRIPT_VALID_V(false);
-#ifdef TOOLS_ENABLED
- const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property);
- if (e != nullptr) {
- r_value = e->get();
- return true;
- } else {
- return false;
- }
-#endif
- return false;
-}
-
-ScriptLanguage *PluginScript::get_language() const {
- return _language;
-}
-
-Error PluginScript::load_source_code(const String &p_path) {
- Vector<uint8_t> sourcef;
- Error err;
- FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'.");
-
- uint64_t len = f->get_length();
- sourcef.resize(len + 1);
- uint8_t *w = sourcef.ptrw();
- uint64_t r = f->get_buffer(w, len);
- f->close();
- memdelete(f);
- ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
- w[len] = 0;
-
- String s;
- if (s.parse_utf8((const char *)w)) {
- ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
- }
-
- _source = s;
-#ifdef TOOLS_ENABLED
-// source_changed_cache=true;
-#endif
- _path = p_path;
- return OK;
-}
-
-bool PluginScript::has_script_signal(const StringName &p_signal) const {
- ASSERT_SCRIPT_VALID_V(false);
- return _signals_info.has(p_signal);
-}
-
-void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
- ASSERT_SCRIPT_VALID();
- for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) {
- r_signals->push_back(e->get());
- }
-}
-
-int PluginScript::get_member_line(const StringName &p_member) const {
-#ifdef TOOLS_ENABLED
- if (_member_lines.has(p_member)) {
- return _member_lines[p_member];
- }
-#endif
- return -1;
-}
-
-const Vector<Multiplayer::RPCConfig> PluginScript::get_rpc_methods() const {
- return _rpc_methods;
-}
-
-PluginScript::PluginScript() :
- _script_list(this) {
-}
-
-void PluginScript::init(PluginScriptLanguage *language) {
- _desc = &language->_desc.script_desc;
- _language = language;
-
-#ifdef DEBUG_ENABLED
- _language->lock();
- _language->_script_list.add(&_script_list);
- _language->unlock();
-#endif
-}
-
-PluginScript::~PluginScript() {
- if (_desc && _data) {
- _desc->finish(_data);
- }
-
-#ifdef DEBUG_ENABLED
- if (_language) {
- _language->lock();
- _language->_script_list.remove(&_script_list);
- _language->unlock();
- }
-#endif
-}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
deleted file mode 100644
index 73c486f6d9..0000000000
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************************************/
-/* pluginscript_script.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_SCRIPT_H
-#define PLUGINSCRIPT_SCRIPT_H
-
-// Godot imports
-
-#include "core/doc_data.h"
-#include "core/object/script_language.h"
-// PluginScript imports
-#include "pluginscript_language.h"
-#include <pluginscript/godot_pluginscript.h>
-
-class PluginScript : public Script {
- GDCLASS(PluginScript, Script);
-
- friend class PluginScriptInstance;
- friend class PluginScriptLanguage;
-
-private:
- godot_pluginscript_script_data *_data = nullptr;
- const godot_pluginscript_script_desc *_desc = nullptr;
- PluginScriptLanguage *_language = nullptr;
- bool _tool = false;
- bool _valid = false;
-
- Ref<Script> _ref_base_parent;
- StringName _native_parent;
- SelfList<PluginScript> _script_list;
-
- Map<StringName, int> _member_lines;
- Map<StringName, Variant> _properties_default_values;
- Map<StringName, PropertyInfo> _properties_info;
- Map<StringName, MethodInfo> _signals_info;
- Map<StringName, MethodInfo> _methods_info;
- Vector<Multiplayer::RPCConfig> _rpc_methods;
-
- Set<Object *> _instances;
- //exported members
- String _source;
- String _path;
- StringName _name;
- String _icon_path;
-
-protected:
- static void _bind_methods();
-
- bool inherits_script(const Ref<Script> &p_script) const override;
-
- PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error);
- Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
-
-#ifdef TOOLS_ENABLED
- Set<PlaceHolderScriptInstance *> placeholders;
- //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
- virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
-#endif
-public:
- String get_script_class_name() const {
- return _name;
- }
-
- String get_script_class_icon_path() const {
- return _icon_path;
- }
-
- virtual bool can_instantiate() const override;
-
- virtual Ref<Script> get_base_script() const override; //for script inheritance
-
- virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so
- virtual ScriptInstance *instance_create(Object *p_this) override;
- virtual bool instance_has(const Object *p_this) const override;
-
- virtual bool has_source_code() const override;
- virtual String get_source_code() const override;
- virtual void set_source_code(const String &p_code) override;
- virtual Error reload(bool p_keep_state = false) override;
- // TODO: load_source_code only allow utf-8 file, should handle bytecode as well ?
- virtual Error load_source_code(const String &p_path);
-
-#ifdef TOOLS_ENABLED
- virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
- static Vector<DocData::ClassDoc> docs;
- return docs;
- }
-#endif // TOOLS_ENABLED
-
- virtual bool has_method(const StringName &p_method) const override;
- virtual MethodInfo get_method_info(const StringName &p_method) const override;
-
- bool has_property(const StringName &p_method) const;
- PropertyInfo get_property_info(const StringName &p_property) const;
-
- bool is_tool() const override { return _tool; }
- bool is_valid() const override { return true; }
-
- virtual ScriptLanguage *get_language() const override;
-
- virtual bool has_script_signal(const StringName &p_signal) const override;
- virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override;
-
- virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
-
- virtual void update_exports() override;
- virtual void get_script_method_list(List<MethodInfo> *r_methods) const override;
- virtual void get_script_property_list(List<PropertyInfo> *r_properties) const override;
-
- virtual int get_member_line(const StringName &p_member) const override;
-
- virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
-
- PluginScript();
- void init(PluginScriptLanguage *language);
- virtual ~PluginScript();
-};
-
-#endif // PLUGINSCRIPT_SCRIPT_H
diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp
deleted file mode 100644
index 39c8124c17..0000000000
--- a/modules/gdnative/pluginscript/register_types.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************/
-/* register_types.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 "core/config/project_settings.h"
-#include "core/io/dir_access.h"
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
-#include "core/os/os.h"
-#include "scene/main/scene_tree.h"
-
-#include "pluginscript_language.h"
-#include "pluginscript_script.h"
-#include <pluginscript/godot_pluginscript.h>
-
-static List<PluginScriptLanguage *> pluginscript_languages;
-
-static Error _check_language_desc(const godot_pluginscript_language_desc *desc) {
- ERR_FAIL_COND_V(!desc->name, ERR_BUG);
- ERR_FAIL_COND_V(!desc->type, ERR_BUG);
- ERR_FAIL_COND_V(!desc->extension, ERR_BUG);
- ERR_FAIL_COND_V(!desc->recognized_extensions || !desc->recognized_extensions[0], ERR_BUG);
- ERR_FAIL_COND_V(!desc->init, ERR_BUG);
- ERR_FAIL_COND_V(!desc->finish, ERR_BUG);
-
- // desc->reserved_words is not mandatory
- // desc->comment_delimiters is not mandatory
- // desc->string_delimiters is not mandatory
-
- // desc->get_template_source_code is not mandatory
- // desc->validate is not mandatory
-
- // desc->get_template_source_code is not mandatory
- // desc->validate is not mandatory
- // desc->find_function is not mandatory
- // desc->make_function is not mandatory
- // desc->complete_code is not mandatory
- // desc->auto_indent_code is not mandatory
- ERR_FAIL_COND_V(!desc->add_global_constant, ERR_BUG);
- // desc->debug_get_error is not mandatory
- // desc->debug_get_stack_level_count is not mandatory
- // desc->debug_get_stack_level_line is not mandatory
- // desc->debug_get_stack_level_function is not mandatory
- // desc->debug_get_stack_level_source is not mandatory
- // desc->debug_get_stack_level_locals is not mandatory
- // desc->debug_get_stack_level_members is not mandatory
- // desc->debug_get_globals is not mandatory
- // desc->debug_parse_stack_level_expression is not mandatory
- // desc->profiling_start is not mandatory
- // desc->profiling_stop is not mandatory
- // desc->profiling_get_accumulated_data is not mandatory
- // desc->profiling_get_frame_data is not mandatory
- // desc->profiling_frame is not mandatory
-
- ERR_FAIL_COND_V(!desc->script_desc.init, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.finish, ERR_BUG);
-
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.init, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.finish, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.set_prop, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.get_prop, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.call_method, ERR_BUG);
- ERR_FAIL_COND_V(!desc->script_desc.instance_desc.notification, ERR_BUG);
- // desc->script_desc.instance_desc.refcount_incremented is not mandatory
- // desc->script_desc.instance_desc.refcount_decremented is not mandatory
- return OK;
-}
-
-void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc) {
- Error ret = _check_language_desc(language_desc);
- if (ret) {
- ERR_FAIL();
- }
- PluginScriptLanguage *language = memnew(PluginScriptLanguage(language_desc));
- ScriptServer::register_language(language);
- ResourceLoader::add_resource_format_loader(language->get_resource_loader());
- ResourceSaver::add_resource_format_saver(language->get_resource_saver());
- pluginscript_languages.push_back(language);
-}
-
-void register_pluginscript_types() {
- GDREGISTER_CLASS(PluginScript);
-}
-
-void unregister_pluginscript_types() {
- for (List<PluginScriptLanguage *>::Element *e = pluginscript_languages.front(); e; e = e->next()) {
- PluginScriptLanguage *language = e->get();
- ScriptServer::unregister_language(language);
- ResourceLoader::remove_resource_format_loader(language->get_resource_loader());
- ResourceSaver::remove_resource_format_saver(language->get_resource_saver());
- memdelete(language);
- }
-}
diff --git a/modules/gdnative/pluginscript/register_types.h b/modules/gdnative/pluginscript/register_types.h
deleted file mode 100644
index 49e7357a98..0000000000
--- a/modules/gdnative/pluginscript/register_types.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*************************************************************************/
-/* register_types.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 PLUGINSCRIPT_REGISTER_TYPES_H
-#define PLUGINSCRIPT_REGISTER_TYPES_H
-
-void register_pluginscript_types();
-void unregister_pluginscript_types();
-
-#endif // PLUGINSCRIPT_REGISTER_TYPES_H