WindowsRuntime.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "il2cpp-vm-support.h"
  3. #include "os/WindowsRuntime.h"
  4. #include "vm/Exception.h"
  5. #include "utils/StringView.h"
  6. struct Il2CppIActivationFactory;
  7. namespace il2cpp
  8. {
  9. namespace vm
  10. {
  11. class LIBIL2CPP_CODEGEN_API WindowsRuntime
  12. {
  13. public:
  14. static Il2CppIActivationFactory* GetActivationFactory(const utils::StringView<Il2CppNativeChar>& runtimeClassName);
  15. static inline void CreateHStringReference(const utils::StringView<Il2CppNativeChar>& str, Il2CppHStringHeader* header, Il2CppHString* hstring)
  16. {
  17. il2cpp_hresult_t hr = os::WindowsRuntime::CreateHStringReference(str, header, hstring);
  18. IL2CPP_VM_RAISE_IF_FAILED(hr, false);
  19. }
  20. static inline Il2CppHString CreateHString(Il2CppString* str)
  21. {
  22. Il2CppHString result;
  23. il2cpp_hresult_t hr = os::WindowsRuntime::CreateHString(utils::StringView<Il2CppChar>(str->chars, str->length), &result);
  24. IL2CPP_VM_RAISE_IF_FAILED(hr, false);
  25. return result;
  26. }
  27. static inline void DeleteHString(Il2CppHString hstring)
  28. {
  29. il2cpp_hresult_t hr = os::WindowsRuntime::DeleteHString(hstring);
  30. IL2CPP_VM_RAISE_IF_FAILED(hr, false);
  31. }
  32. static inline Il2CppString* HStringToManagedString(Il2CppHString hstring)
  33. {
  34. return os::WindowsRuntime::HStringToManagedString(hstring);
  35. }
  36. };
  37. }
  38. }