2017-10-08 21:47:38 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* pluginscript_language.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2018-01-04 23:50:27 +00:00
|
|
|
/* https://godotengine.org */
|
2017-10-08 21:47:38 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-10-08 21:47:38 +00:00
|
|
|
/* */
|
|
|
|
/* 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"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/object/script_language.h"
|
|
|
|
#include "core/templates/map.h"
|
|
|
|
#include "core/templates/self_list.h"
|
2017-10-08 21:47:38 +00:00
|
|
|
// 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;
|
|
|
|
|
2018-06-11 00:59:53 +00:00
|
|
|
Ref<ResourceFormatLoaderPluginScript> _resource_loader;
|
|
|
|
Ref<ResourceFormatSaverPluginScript> _resource_saver;
|
2017-10-08 21:47:38 +00:00
|
|
|
const godot_pluginscript_language_desc _desc;
|
|
|
|
godot_pluginscript_language_data *_data;
|
|
|
|
|
2020-02-26 10:28:13 +00:00
|
|
|
Mutex _lock;
|
2017-10-08 21:47:38 +00:00
|
|
|
SelfList<PluginScript>::List _script_list;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String get_name() const;
|
|
|
|
|
2018-06-11 00:59:53 +00:00
|
|
|
_FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; }
|
|
|
|
_FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; }
|
2017-10-08 21:47:38 +00:00
|
|
|
|
|
|
|
/* LANGUAGE FUNCTIONS */
|
|
|
|
virtual void init();
|
|
|
|
virtual String get_type() const;
|
|
|
|
virtual String get_extension() const;
|
|
|
|
virtual Error execute_file(const String &p_path);
|
|
|
|
virtual void finish();
|
|
|
|
|
|
|
|
/* EDITOR FUNCTIONS */
|
|
|
|
virtual void get_reserved_words(List<String> *p_words) const;
|
|
|
|
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
|
|
|
|
virtual void get_string_delimiters(List<String> *p_delimiters) const;
|
|
|
|
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
|
2020-04-01 23:20:12 +00:00
|
|
|
virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
|
2017-10-08 21:47:38 +00:00
|
|
|
virtual Script *create_script() const;
|
|
|
|
virtual bool has_named_classes() const;
|
2017-10-23 23:54:47 +00:00
|
|
|
virtual bool supports_builtin_mode() const;
|
2020-12-08 12:06:15 +00:00
|
|
|
virtual bool can_inherit_from_file() const;
|
2017-10-08 21:47:38 +00:00
|
|
|
virtual int find_function(const String &p_function, const String &p_code) const;
|
2020-02-17 21:06:54 +00:00
|
|
|
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
|
2019-06-13 09:17:20 +00:00
|
|
|
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);
|
2017-10-08 21:47:38 +00:00
|
|
|
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;
|
2020-03-17 06:33:00 +00:00
|
|
|
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
|
2017-10-08 21:47:38 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2020-12-07 14:08:59 +00:00
|
|
|
/* 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;
|
|
|
|
|
2017-10-08 21:47:38 +00:00
|
|
|
void lock();
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
PluginScriptLanguage(const godot_pluginscript_language_desc *desc);
|
|
|
|
virtual ~PluginScriptLanguage();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLUGINSCRIPT_LANGUAGE_H
|