RCW.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #include "il2cpp-object-internals.h"
  4. struct Il2CppComObject;
  5. struct Il2CppGuid;
  6. struct Il2CppIUnknown;
  7. namespace il2cpp
  8. {
  9. namespace vm
  10. {
  11. class LIBIL2CPP_CODEGEN_API RCW
  12. {
  13. public:
  14. static void Register(Il2CppComObject* rcw);
  15. static Il2CppObject* GetOrCreateFromIUnknown(Il2CppIUnknown* unknown, Il2CppClass* fallbackClass);
  16. static Il2CppObject* GetOrCreateFromIInspectable(Il2CppIInspectable* inspectable, Il2CppClass* fallbackClass);
  17. static Il2CppObject* GetOrCreateForSealedClass(Il2CppIUnknown* unknown, Il2CppClass* objectClass);
  18. static void Cleanup(Il2CppComObject* rcw);
  19. template<bool throwOnError>
  20. inline static Il2CppIUnknown* QueryInterface(Il2CppComObject* rcw, const Il2CppGuid& iid)
  21. {
  22. IL2CPP_ASSERT(rcw);
  23. IL2CPP_ASSERT(rcw->identity);
  24. Il2CppIUnknown* result;
  25. const il2cpp_hresult_t hr = rcw->identity->QueryInterface(iid, reinterpret_cast<void**>(&result));
  26. if (IL2CPP_HR_FAILED(hr))
  27. {
  28. if (throwOnError)
  29. Exception::Raise(hr, true);
  30. return NULL;
  31. }
  32. IL2CPP_ASSERT(result);
  33. return result;
  34. }
  35. };
  36. } /* namespace vm */
  37. } /* namespace il2cpp */