MethodBridge.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "../CommonDef.h"
  3. #include "InterpreterDefs.h"
  4. namespace hybridclr
  5. {
  6. namespace interpreter
  7. {
  8. union StackObject;
  9. typedef void (*Managed2NativeCallMethod)(const MethodInfo* method, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret);
  10. typedef void (*NativeClassCtor0)(Il2CppObject* obj, const MethodInfo* method);
  11. struct Managed2NativeMethodInfo
  12. {
  13. const char* signature;
  14. Managed2NativeCallMethod method;
  15. };
  16. struct Native2ManagedMethodInfo
  17. {
  18. const char* signature;
  19. Il2CppMethodPointer method;
  20. };
  21. struct NativeAdjustThunkMethodInfo
  22. {
  23. const char* signature;
  24. Il2CppMethodPointer method;
  25. };
  26. struct FullName2Signature
  27. {
  28. const char* fullName;
  29. const char* signature;
  30. };
  31. extern Managed2NativeMethodInfo g_managed2nativeStub[];
  32. extern Native2ManagedMethodInfo g_native2managedStub[];
  33. extern NativeAdjustThunkMethodInfo g_adjustThunkStub[];
  34. extern FullName2Signature g_fullName2SignatureStub[];
  35. void ConvertInvokeArgs(StackObject* resultArgs, const MethodInfo* method, MethodArgDesc* argDescs, void** args);
  36. bool ComputeSignature(const MethodInfo* method, bool call, char* sigBuf, size_t bufferSize);
  37. bool ComputeSignature(const Il2CppMethodDefinition* method, bool call, char* sigBuf, size_t bufferSize);
  38. bool ComputeSignature(const Il2CppType* ret, const Il2CppType* params, uint32_t paramCount, bool instanceCall, char* sigBuf, size_t bufferSize);
  39. template<typename T> uint64_t N2MAsUint64ValueOrAddress(T& value)
  40. {
  41. return sizeof(T) <= 8 ? *(uint64_t*)&value : (uint64_t)&value;
  42. }
  43. template<typename T> T& M2NFromValueOrAddress(void* value)
  44. {
  45. //return sizeof(T) <= 8 ? *(T*)value : **(T**)value;
  46. return *(T*)value;
  47. }
  48. }
  49. }