@ 261103.1

251103.1 · 21b47f08b762b21b1d4d970940ab23f59f43249c

Adopt fixes from hermes-windows (#16)

reading declarations

Changes to src/ApiLoaders/. All files

src/ApiLoaders/HermesApi.cpp

@@ -3,6 +3,16 @@  #include "HermesApi.h" +// Define cross-platform pragma macros for suppressing offsetof warnings+#ifdef __clang__+#define HERMES_PRAGMA_PUSH_OFFSETOF \+  _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")+#define HERMES_PRAGMA_POP_OFFSETOF _Pragma("GCC diagnostic pop")+#else+#define HERMES_PRAGMA_PUSH_OFFSETOF __pragma(warning(push)) __pragma(warning(disable : 4117))+#define HERMES_PRAGMA_POP_OFFSETOF __pragma(warning(pop))+#endif+ namespace Microsoft::NodeApiJsi {  namespace {@@ -17,9 +27,11 @@ struct HermesApiNames { void loadInspectorFuncs() {   HermesApi *current = HermesApi::current(); #define HERMES_INSPECTOR_FUNC(func)                                                                                  \+  HERMES_PRAGMA_PUSH_OFFSETOF                                                                                        \   decltype(::func) *loaded_##func = reinterpret_cast<decltype(::func) *>(current->getFuncPtr(HermesApiNames::func)); \   size_t offset_##func = offsetof(HermesApi, func);                                                                  \-  *reinterpret_cast<decltype(::func) **>(reinterpret_cast<char *>(current) + offset_##func) = loaded_##func;+  *reinterpret_cast<decltype(::func) **>(reinterpret_cast<char *>(current) + offset_##func) = loaded_##func;         \+  HERMES_PRAGMA_POP_OFFSETOF #include "HermesApi.inc" } @@ -29,12 +41,16 @@ thread_local HermesApi *HermesApi::current_{};  HermesApi::HermesApi(IFuncResolver *funcResolver)     : JSRuntimeApi(funcResolver)-#define HERMES_FUNC(func) \-  , func(&ApiFuncResolver<HermesApi, decltype(::func) *, HermesApiNames::func, offsetof(HermesApi, func)>::stub)+#define HERMES_FUNC(func)                                                                                          \+  HERMES_PRAGMA_PUSH_OFFSETOF                                                                                      \+  ,                                                                                                                \+      func(&ApiFuncResolver<HermesApi, decltype(::func) *, HermesApiNames::func, offsetof(HermesApi, func)>::stub) \+          HERMES_PRAGMA_POP_OFFSETOF #define HERMES_INSPECTOR_FUNC(func)                                                                           \+  HERMES_PRAGMA_PUSH_OFFSETOF                                                                                 \   ,                                                                                                           \       func(&ApiFuncResolver<HermesApi, decltype(::func) *, HermesApiNames::func, offsetof(HermesApi, func)>:: \-               preloadStub<&loadInspectorFuncs>)+               preloadStub<&loadInspectorFuncs>) HERMES_PRAGMA_POP_OFFSETOF  #include "HermesApi.inc" {

src/ApiLoaders/HermesApi.inc

@@ -20,6 +20,8 @@ HERMES_FUNC(hermes_sampling_profiler_dump_to_file) HERMES_FUNC(hermes_config_enable_default_crash_handler) HERMES_FUNC(hermes_set_inspector) +HERMES_FUNC(hermes_get_inspector_vtable)+ HERMES_INSPECTOR_FUNC(hermes_create_local_connection) HERMES_INSPECTOR_FUNC(hermes_delete_local_connection) HERMES_INSPECTOR_FUNC(hermes_local_connection_send_message)