COM.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "il2cpp-config.h"
  2. #include "il2cpp-object-internals.h"
  3. #include "os/COM.h"
  4. #include "WindowsHeaders.h"
  5. #if !IL2CPP_USE_GENERIC_COM
  6. namespace il2cpp
  7. {
  8. namespace os
  9. {
  10. il2cpp_hresult_t COM::CreateInstance(const Il2CppGuid& clsid, Il2CppIUnknown** object)
  11. {
  12. return ::CoCreateInstance(reinterpret_cast<REFCLSID>(clsid), NULL, CLSCTX_ALL, __uuidof(IUnknown), reinterpret_cast<LPVOID*>(object));
  13. }
  14. il2cpp_hresult_t COM::CreateFreeThreadedMarshaler(Il2CppIUnknown* outer, Il2CppIUnknown** marshal)
  15. {
  16. return ::CoCreateFreeThreadedMarshaler(reinterpret_cast<LPUNKNOWN>(outer), reinterpret_cast<LPUNKNOWN*>(marshal));
  17. }
  18. }
  19. }
  20. #endif
  21. #if !IL2CPP_USE_GENERIC_COM_SAFEARRAYS
  22. namespace il2cpp
  23. {
  24. namespace os
  25. {
  26. // variant
  27. void COM::VariantInit(Il2CppVariant* variant)
  28. {
  29. ::VariantInit(reinterpret_cast<VARIANTARG*>(variant));
  30. }
  31. il2cpp_hresult_t COM::VariantClear(Il2CppVariant* variant)
  32. {
  33. return ::VariantClear(reinterpret_cast<VARIANTARG*>(variant));
  34. }
  35. // safe array
  36. Il2CppSafeArray* COM::SafeArrayCreate(uint16_t type, uint32_t dimension_count, Il2CppSafeArrayBound* bounds)
  37. {
  38. return reinterpret_cast<Il2CppSafeArray*>(::SafeArrayCreate(type, dimension_count, reinterpret_cast<SAFEARRAYBOUND*>(bounds)));
  39. }
  40. il2cpp_hresult_t COM::SafeArrayDestroy(Il2CppSafeArray* safeArray)
  41. {
  42. return ::SafeArrayDestroy(reinterpret_cast<SAFEARRAY*>(safeArray));
  43. }
  44. il2cpp_hresult_t COM::SafeArrayAccessData(Il2CppSafeArray* safeArray, void** data)
  45. {
  46. return ::SafeArrayAccessData(reinterpret_cast<SAFEARRAY*>(safeArray), data);
  47. }
  48. il2cpp_hresult_t COM::SafeArrayUnaccessData(Il2CppSafeArray* safeArray)
  49. {
  50. return ::SafeArrayUnaccessData(reinterpret_cast<SAFEARRAY*>(safeArray));
  51. }
  52. il2cpp_hresult_t COM::SafeArrayGetVartype(Il2CppSafeArray* safeArray, uint16_t* type)
  53. {
  54. return ::SafeArrayGetVartype(reinterpret_cast<SAFEARRAY*>(safeArray), type);
  55. }
  56. uint32_t COM::SafeArrayGetDim(Il2CppSafeArray* safeArray)
  57. {
  58. return ::SafeArrayGetDim(reinterpret_cast<SAFEARRAY*>(safeArray));
  59. }
  60. il2cpp_hresult_t COM::SafeArrayGetLBound(Il2CppSafeArray* safeArray, uint32_t dimention, int32_t* bound)
  61. {
  62. return ::SafeArrayGetLBound(reinterpret_cast<SAFEARRAY*>(safeArray), dimention, reinterpret_cast<LONG*>(bound));
  63. }
  64. il2cpp_hresult_t COM::SafeArrayGetUBound(Il2CppSafeArray* safeArray, uint32_t dimention, int32_t* bound)
  65. {
  66. return ::SafeArrayGetUBound(reinterpret_cast<SAFEARRAY*>(safeArray), dimention, reinterpret_cast<LONG*>(bound));
  67. }
  68. }
  69. }
  70. #endif