BsMonoProperty.h 2.6 KB

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