gd_mono_method.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*************************************************************************/
  2. /* gd_mono_method.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 GD_MONO_METHOD_H
  31. #define GD_MONO_METHOD_H
  32. #include "gd_mono.h"
  33. #include "gd_mono_header.h"
  34. #include "i_mono_class_member.h"
  35. class GDMonoMethod : public IMonoClassMember {
  36. StringName name;
  37. uint16_t params_count;
  38. unsigned int params_buffer_size = 0;
  39. ManagedType return_type;
  40. Vector<ManagedType> param_types;
  41. bool method_info_fetched = false;
  42. MethodInfo method_info;
  43. bool attrs_fetched = false;
  44. MonoCustomAttrInfo *attributes = nullptr;
  45. void _update_signature();
  46. void _update_signature(MonoMethodSignature *p_method_sig);
  47. friend class GDMonoClass;
  48. MonoMethod *mono_method;
  49. public:
  50. virtual GDMonoClass *get_enclosing_class() const final;
  51. virtual MemberType get_member_type() const final { return MEMBER_TYPE_METHOD; }
  52. virtual StringName get_name() const final { return name; }
  53. virtual bool is_static() final;
  54. virtual Visibility get_visibility() final;
  55. virtual bool has_attribute(GDMonoClass *p_attr_class) final;
  56. virtual MonoObject *get_attribute(GDMonoClass *p_attr_class) final;
  57. void fetch_attributes();
  58. _FORCE_INLINE_ MonoMethod *get_mono_ptr() const { return mono_method; }
  59. _FORCE_INLINE_ uint16_t get_parameters_count() const { return params_count; }
  60. _FORCE_INLINE_ ManagedType get_return_type() const { return return_type; }
  61. MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = nullptr) const;
  62. MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = nullptr) const;
  63. MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr) const;
  64. String get_full_name(bool p_signature = false) const;
  65. String get_full_name_no_class() const;
  66. String get_ret_type_full_name() const;
  67. String get_signature_desc(bool p_namespaces = false) const;
  68. void get_parameter_names(Vector<StringName> &names) const;
  69. void get_parameter_types(Vector<ManagedType> &types) const;
  70. const MethodInfo &get_method_info();
  71. GDMonoMethod(StringName p_name, MonoMethod *p_method);
  72. ~GDMonoMethod();
  73. };
  74. #endif // GD_MONO_METHOD_H