gd_mono_method.h 3.9 KB

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