CmScriptClass.h 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include <mono/jit/jit.h>
  4. namespace CamelotFramework
  5. {
  6. class CM_EXPORT ScriptClass
  7. {
  8. struct MethodId
  9. {
  10. struct Hash
  11. {
  12. inline size_t operator()(const MethodId& v) const;
  13. };
  14. struct Equals
  15. {
  16. inline bool operator()(const MethodId &a, const MethodId &b) const;
  17. };
  18. MethodId(const String& name, UINT32 numParams);
  19. String name;
  20. UINT32 numParams;
  21. };
  22. public:
  23. ~ScriptClass();
  24. ScriptMethod& getMethod(const String& name, UINT32 numParams = 0);
  25. MonoObject* invokeMethod(const String& name, ScriptObject* instance = nullptr, void** params = nullptr, UINT32 numParams = 0);
  26. void addInternalCall(const String& name, const void* method);
  27. private:
  28. friend class ScriptAssembly;
  29. ScriptClass(const String& fullName, MonoClass* monoClass);
  30. MonoClass* mClass;
  31. String mFullName;
  32. UnorderedMap<MethodId, ScriptMethod*, MethodId::Hash, MethodId::Equals>::type mMethods;
  33. };
  34. }