BsMonoProperty.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "BsMonoPrerequisites.h"
  3. #include <mono/jit/jit.h>
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Encapsulates information about a single Mono (i.e. managed) property
  8. * belonging to some managed class. This object also allows you to set
  9. * or retrieve values to/from specific instances containing the property.
  10. */
  11. class BS_MONO_EXPORT MonoProperty
  12. {
  13. public:
  14. /**
  15. * @brief Returns a boxed value contained in the property in the specified instance.
  16. *
  17. * @param instance Object instance to access the property on. Can be null for static properties.
  18. *
  19. * @returns A boxed value of the property.
  20. */
  21. MonoObject* get(MonoObject* instance) const;
  22. /**
  23. * @brief Sets a value of the property in the specified instance.
  24. *
  25. * @param instance Object instance to access the property on. Can be null for static properties.
  26. * @param value Value to set on the property. For value type it should be a pointer to the
  27. * value and for reference type it should be a pointer to MonoObject.
  28. */
  29. void set(MonoObject* instance, void* value) const;
  30. /**
  31. * @brief Returns a boxed value contained in the property in the specified instance. Used for properties
  32. * with indexers.
  33. *
  34. * @param instance Object instance to access the property on. Can be null for static properties.
  35. * @param index Index of the value to retrieve.
  36. *
  37. * @returns A boxed value of the property.
  38. */
  39. MonoObject* getIndexed(MonoObject* instance, UINT32 index) const;
  40. /**
  41. * @brief Sets a value of the property in the specified instance. Used for properties
  42. * with indexers.
  43. *
  44. * @param instance Object instance to access the property on. Can be null for static properties.
  45. * @param index Index of the value to set.
  46. * @param value Value to set on the property. For value type it should be a pointer to the
  47. * value and for reference type it should be a pointer to MonoObject.
  48. */
  49. void setIndexed(MonoObject* instance, UINT32 index, void* value) const;
  50. /**
  51. * @brief Returns the data type the property holds.
  52. */
  53. MonoClass* getReturnType();
  54. private:
  55. friend class MonoClass;
  56. MonoProperty(::MonoProperty* monoProp);
  57. ::MonoProperty* mProperty;
  58. ::MonoMethod* mGetMethod;
  59. ::MonoMethod* mSetMethod;
  60. MonoClass* mGetReturnType;
  61. };
  62. }