pluginscript_script.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*************************************************************************/
  2. /* pluginscript_script.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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_SCRIPT_H
  31. #define PLUGINSCRIPT_SCRIPT_H
  32. // Godot imports
  33. #include "core/script_language.h"
  34. // PluginScript imports
  35. #include "pluginscript_language.h"
  36. #include <pluginscript/godot_pluginscript.h>
  37. class PyInstance;
  38. class PluginScript : public Script {
  39. GDCLASS(PluginScript, Script);
  40. friend class PluginScriptInstance;
  41. friend class PluginScriptLanguage;
  42. private:
  43. godot_pluginscript_script_data *_data;
  44. const godot_pluginscript_script_desc *_desc;
  45. PluginScriptLanguage *_language;
  46. bool _tool;
  47. bool _valid;
  48. Ref<PluginScript> _ref_base_parent;
  49. StringName _native_parent;
  50. SelfList<PluginScript> _script_list;
  51. Map<StringName, int> _member_lines;
  52. Map<StringName, Variant> _properties_default_values;
  53. Map<StringName, PropertyInfo> _properties_info;
  54. Map<StringName, MethodInfo> _signals_info;
  55. Map<StringName, MethodInfo> _methods_info;
  56. Map<StringName, ScriptInstance::RPCMode> _variables_rset_mode;
  57. Map<StringName, ScriptInstance::RPCMode> _methods_rpc_mode;
  58. Set<Object *> _instances;
  59. //exported members
  60. String _source;
  61. String _path;
  62. StringName _name;
  63. protected:
  64. static void _bind_methods();
  65. #ifdef TOOLS_ENABLED
  66. Set<PlaceHolderScriptInstance *> placeholders;
  67. //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
  68. virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
  69. #endif
  70. public:
  71. virtual bool can_instance() const;
  72. virtual Ref<Script> get_base_script() const; //for script inheritance
  73. virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
  74. virtual ScriptInstance *instance_create(Object *p_this);
  75. virtual bool instance_has(const Object *p_this) const;
  76. virtual bool has_source_code() const;
  77. virtual String get_source_code() const;
  78. virtual void set_source_code(const String &p_code);
  79. virtual Error reload(bool p_keep_state = false);
  80. // TODO: load_source_code only allow utf-8 file, should handle bytecode as well ?
  81. virtual Error load_source_code(const String &p_path);
  82. virtual bool has_method(const StringName &p_method) const;
  83. virtual MethodInfo get_method_info(const StringName &p_method) const;
  84. bool has_property(const StringName &p_method) const;
  85. PropertyInfo get_property_info(const StringName &p_property) const;
  86. bool is_tool() const { return _tool; }
  87. virtual String get_node_type() const;
  88. virtual ScriptLanguage *get_language() const;
  89. virtual bool has_script_signal(const StringName &p_signal) const;
  90. virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
  91. virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
  92. virtual void update_exports();
  93. virtual void get_script_method_list(List<MethodInfo> *r_methods) const;
  94. virtual void get_script_property_list(List<PropertyInfo> *r_propertieslist) const;
  95. virtual int get_member_line(const StringName &p_member) const;
  96. ScriptInstance::RPCMode get_rpc_mode(const StringName &p_method) const;
  97. ScriptInstance::RPCMode get_rset_mode(const StringName &p_variable) const;
  98. PluginScript();
  99. void init(PluginScriptLanguage *language);
  100. virtual ~PluginScript();
  101. };
  102. #endif // PLUGINSCRIPT_SCRIPT_H