pluginscript_language.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*************************************************************************/
  2. /* pluginscript_language.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef PLUGINSCRIPT_LANGUAGE_H
  31. #define PLUGINSCRIPT_LANGUAGE_H
  32. // Godot imports
  33. #include "core/io/resource_loader.h"
  34. #include "core/io/resource_saver.h"
  35. #include "core/object/script_language.h"
  36. #include "core/templates/map.h"
  37. #include "core/templates/self_list.h"
  38. // PluginScript imports
  39. #include "pluginscript_loader.h"
  40. #include <pluginscript/godot_pluginscript.h>
  41. class PluginScript;
  42. class PluginScriptInstance;
  43. class PluginScriptLanguage : public ScriptLanguage {
  44. friend class PluginScript;
  45. friend class PluginScriptInstance;
  46. Ref<ResourceFormatLoaderPluginScript> _resource_loader;
  47. Ref<ResourceFormatSaverPluginScript> _resource_saver;
  48. const godot_pluginscript_language_desc _desc;
  49. godot_pluginscript_language_data *_data;
  50. Mutex _lock;
  51. SelfList<PluginScript>::List _script_list;
  52. public:
  53. virtual String get_name() const;
  54. _FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; }
  55. _FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; }
  56. /* LANGUAGE FUNCTIONS */
  57. virtual void init();
  58. virtual String get_type() const;
  59. virtual String get_extension() const;
  60. virtual Error execute_file(const String &p_path);
  61. virtual void finish();
  62. /* EDITOR FUNCTIONS */
  63. virtual void get_reserved_words(List<String> *p_words) const;
  64. virtual bool is_control_flow_keyword(String p_keyword) const;
  65. virtual void get_comment_delimiters(List<String> *p_delimiters) const;
  66. virtual void get_string_delimiters(List<String> *p_delimiters) const;
  67. virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
  68. 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;
  69. virtual Script *create_script() const;
  70. virtual bool has_named_classes() const;
  71. virtual bool supports_builtin_mode() const;
  72. virtual bool can_inherit_from_file() const;
  73. virtual int find_function(const String &p_function, const String &p_code) const;
  74. virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
  75. 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);
  76. virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
  77. virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
  78. /* MULTITHREAD FUNCTIONS */
  79. //some VMs need to be notified of thread creation/exiting to allocate a stack
  80. // void thread_enter() {}
  81. // void thread_exit() {}
  82. /* DEBUGGER FUNCTIONS */
  83. virtual String debug_get_error() const;
  84. virtual int debug_get_stack_level_count() const;
  85. virtual int debug_get_stack_level_line(int p_level) const;
  86. virtual String debug_get_stack_level_function(int p_level) const;
  87. virtual String debug_get_stack_level_source(int p_level) const;
  88. 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);
  89. 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);
  90. virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  91. virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
  92. // virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
  93. virtual void reload_all_scripts();
  94. virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
  95. /* LOADER FUNCTIONS */
  96. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  97. virtual void get_public_functions(List<MethodInfo> *p_functions) const;
  98. virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
  99. virtual void profiling_start();
  100. virtual void profiling_stop();
  101. virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
  102. virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
  103. virtual void frame();
  104. /* GLOBAL CLASSES */
  105. virtual bool handles_global_class_type(const String &p_type) const;
  106. virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
  107. void lock();
  108. void unlock();
  109. PluginScriptLanguage(const godot_pluginscript_language_desc *desc);
  110. virtual ~PluginScriptLanguage();
  111. };
  112. #endif // PLUGINSCRIPT_LANGUAGE_H