pluginscript_instance.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*************************************************************************/
  2. /* pluginscript_instance.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_INSTANCE_H
  31. #define PLUGINSCRIPT_INSTANCE_H
  32. // Godot imports
  33. #include "core/object/script_language.h"
  34. // PluginScript imports
  35. #include <pluginscript/godot_pluginscript.h>
  36. class PluginScript;
  37. class PluginScriptInstance : public ScriptInstance {
  38. friend class PluginScript;
  39. private:
  40. Ref<PluginScript> _script;
  41. Object *_owner = nullptr;
  42. Variant _owner_variant;
  43. godot_pluginscript_instance_data *_data = nullptr;
  44. const godot_pluginscript_instance_desc *_desc = nullptr;
  45. public:
  46. _FORCE_INLINE_ Object *get_owner() { return _owner; }
  47. virtual bool set(const StringName &p_name, const Variant &p_value);
  48. virtual bool get(const StringName &p_name, Variant &r_ret) const;
  49. virtual void get_property_list(List<PropertyInfo> *p_properties) const;
  50. virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
  51. virtual void get_method_list(List<MethodInfo> *p_list) const;
  52. virtual bool has_method(const StringName &p_method) const;
  53. virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  54. virtual void notification(int p_notification);
  55. virtual Ref<Script> get_script() const;
  56. virtual ScriptLanguage *get_language();
  57. void set_path(const String &p_path);
  58. virtual Vector<ScriptNetData> get_rpc_methods() const;
  59. virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
  60. virtual StringName get_rpc_method(uint16_t p_id) const;
  61. virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(uint16_t p_id) const;
  62. virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
  63. virtual Vector<ScriptNetData> get_rset_properties() const;
  64. virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
  65. virtual StringName get_rset_property(uint16_t p_id) const;
  66. virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(uint16_t p_id) const;
  67. virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
  68. virtual void refcount_incremented();
  69. virtual bool refcount_decremented();
  70. PluginScriptInstance();
  71. bool init(PluginScript *p_script, Object *p_owner);
  72. virtual ~PluginScriptInstance();
  73. };
  74. #endif // PLUGINSCRIPT_INSTANCE_H