pluginscript_language.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*************************************************************************/
  2. /* pluginscript_language.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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/map.h"
  36. #include "core/script_language.h"
  37. #include "core/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 void get_comment_delimiters(List<String> *p_delimiters) const;
  65. virtual void get_string_delimiters(List<String> *p_delimiters) const;
  66. virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
  67. 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 = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const;
  68. virtual Script *create_script() const;
  69. virtual bool has_named_classes() const;
  70. virtual bool supports_builtin_mode() const;
  71. virtual bool can_inherit_from_file() { return true; }
  72. virtual int find_function(const String &p_function, const String &p_code) const;
  73. virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
  74. virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_force, String &r_call_hint);
  75. virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
  76. virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
  77. /* MULTITHREAD FUNCTIONS */
  78. //some VMs need to be notified of thread creation/exiting to allocate a stack
  79. // void thread_enter() {}
  80. // void thread_exit() {}
  81. /* DEBUGGER FUNCTIONS */
  82. virtual String debug_get_error() const;
  83. virtual int debug_get_stack_level_count() const;
  84. virtual int debug_get_stack_level_line(int p_level) const;
  85. virtual String debug_get_stack_level_function(int p_level) const;
  86. virtual String debug_get_stack_level_source(int p_level) const;
  87. 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);
  88. 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);
  89. virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  90. virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
  91. // virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
  92. virtual void reload_all_scripts();
  93. virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
  94. /* LOADER FUNCTIONS */
  95. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  96. virtual void get_public_functions(List<MethodInfo> *p_functions) const;
  97. virtual void get_public_constants(List<Pair<String, Variant> > *p_constants) const;
  98. virtual void profiling_start();
  99. virtual void profiling_stop();
  100. virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
  101. virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
  102. virtual void frame();
  103. void lock();
  104. void unlock();
  105. PluginScriptLanguage(const godot_pluginscript_language_desc *desc);
  106. virtual ~PluginScriptLanguage();
  107. };
  108. #endif // PLUGINSCRIPT_LANGUAGE_H