BsScriptScriptCode.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsScriptResource.h"
  4. #include "BsScriptObject.h"
  5. #include "BsScriptCode.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Interop class between C++ & CLR for ScriptCode.
  10. */
  11. class BS_SCR_BE_EXPORT ScriptScriptCode : public ScriptObject <ScriptScriptCode, ScriptResourceBase>
  12. {
  13. public:
  14. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "ScriptCode")
  15. /**
  16. * @copydoc ScriptResourceBase::getNativeHandle
  17. */
  18. HResource getNativeHandle() const override { return mScriptCode; }
  19. /**
  20. * @copydoc ScriptResourceBase::setNativeHandle
  21. */
  22. void setNativeHandle(const HResource& resource) override;
  23. /**
  24. * @brief Returns the native internal script code resource.
  25. */
  26. HScriptCode getScriptCodeHandle() const { return mScriptCode; }
  27. private:
  28. friend class ScriptResourceManager;
  29. typedef std::pair<WString, WString> FullTypeName;
  30. ScriptScriptCode(MonoObject* instance, const HScriptCode& scriptCode);
  31. /**
  32. * @copydoc ScriptObjectBase::_onManagedInstanceDeleted
  33. */
  34. void _onManagedInstanceDeleted() override;
  35. /**
  36. * @brief Parses the provided C# code and finds a list of all classes
  37. * and their namespaces. Nested classes are ignored.
  38. */
  39. static Vector<FullTypeName> parseTypes(const WString& code);
  40. HScriptCode mScriptCode;
  41. /************************************************************************/
  42. /* CLR HOOKS */
  43. /************************************************************************/
  44. static void internal_createInstance(MonoObject* instance, MonoString* text);
  45. static MonoString* internal_getText(ScriptScriptCode* thisPtr);
  46. static void internal_setText(ScriptScriptCode* thisPtr, MonoString* text);
  47. static MonoArray* internal_getTypes(ScriptScriptCode* thisPtr);
  48. };
  49. }