BsScriptSerializableProperty.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "BsScriptObject.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Interop class between C++ & CLR for SerializableProperty (not implemented as its
  10. * own class, but instead implemented directly in the inerop object). Serializable property
  11. * wraps all types of serializable entries, whether they're object fields, array entries, dictionary
  12. * entries, etc. and offers a simple interface to access them.
  13. */
  14. class BS_SCR_BE_EXPORT ScriptSerializableProperty : public ScriptObject<ScriptSerializableProperty>
  15. {
  16. public:
  17. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "SerializableProperty")
  18. /**
  19. * @brief Creates a new managed serializable property object for the specified type.
  20. *
  21. * @param typeInfo Data about the type the property references.
  22. */
  23. static ScriptSerializableProperty* create(const ManagedSerializableTypeInfoPtr& typeInfo);
  24. /**
  25. * @brief Returns the data about the type the property is referencing.
  26. */
  27. ManagedSerializableTypeInfoPtr getTypeInfo() const { return mTypeInfo; }
  28. ~ScriptSerializableProperty() {}
  29. private:
  30. ScriptSerializableProperty(MonoObject* instance, const ManagedSerializableTypeInfoPtr& typeInfo);
  31. ManagedSerializableTypeInfoPtr mTypeInfo;
  32. /************************************************************************/
  33. /* CLR HOOKS */
  34. /************************************************************************/
  35. static void internal_CreateInstance(MonoObject* instance, MonoReflectionType* reflType);
  36. static MonoObject* internal_createObject(ScriptSerializableProperty* nativeInstance);
  37. static MonoObject* internal_createArray(ScriptSerializableProperty* nativeInstance);
  38. static MonoObject* internal_createList(ScriptSerializableProperty* nativeInstance);
  39. static MonoObject* internal_createDictionary(ScriptSerializableProperty* nativeInstance);
  40. static MonoObject* internal_createManagedObjectInstance(ScriptSerializableProperty* nativeInstance);
  41. static MonoObject* internal_createManagedArrayInstance(ScriptSerializableProperty* nativeInstance, MonoArray* sizes);
  42. static MonoObject* internal_createManagedListInstance(ScriptSerializableProperty* nativeInstance, int size);
  43. static MonoObject* internal_createManagedDictionaryInstance(ScriptSerializableProperty* nativeInstance);
  44. };
  45. }