Skip to content

Commit dceba8c

Browse files
committed
fix for ios
1 parent bcba773 commit dceba8c

File tree

6 files changed

+217
-195
lines changed

6 files changed

+217
-195
lines changed

API/hermes/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ set(api_sources
88
hermes_napi.cpp
99
DebuggerAPI.cpp
1010
MurmurHash.cpp
11+
hermes_win.cpp
1112
)
1213

13-
if (WIN32)
14-
list(APPEND api_sources hermes_win.cpp)
15-
endif()
14+
# if (WIN32)
15+
# list(APPEND api_sources hermes_win.cpp)
16+
# endif()
1617

1718
file(GLOB api_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
1819
file(GLOB api_public_headers ${PROJECT_SOURCE_DIR}/public/hermes/Public/*.h)
1920

2021
add_hermes_library(hermesapi
2122
${api_sources}
22-
LINK_LIBS jsi hermesVMRuntime hermesNapi hermesinspector)
23+
LINK_LIBS jsi hermesVMRuntime hermesNapi)
2324
target_include_directories(hermesapi PUBLIC .. ${REACT_NATIVE_SOURCE}/ReactCommon)
2425

2526
add_hermes_library(hermesapiLean
@@ -70,7 +71,6 @@ target_link_libraries(libhermes
7071
PRIVATE
7172
jsi
7273
hermesNapi
73-
hermesinspector
7474
${LIBHERMES_VM_DEP}
7575
)
7676
target_link_options(libhermes PRIVATE ${HERMES_EXTRA_LINKER_FLAGS})

API/hermes/MurmurHash.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#pragma once
44

55
#include <stdint.h>
6+
#include <stddef.h>
67

78
// Computes the hash of key using MurmurHash3 algorithm, the value is planced in the "hash" output parameter
89
// The function returns whether or not key is comprised of only ASCII characters (<=127)

API/hermes/hermes_napi.cpp

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@
106106
} \
107107
} while (false)
108108

109+
#ifdef __APPLE__
110+
111+
// Crash if the condition is false.
112+
#define CRASH_IF_FALSE(condition) \
113+
do { \
114+
if (!(condition)) { \
115+
std::terminate(); \
116+
} \
117+
} while (false)
118+
119+
#else
120+
109121
// Crash if the condition is false.
110122
#define CRASH_IF_FALSE(condition) \
111123
do { \
@@ -116,6 +128,8 @@
116128
} \
117129
} while (false)
118130

131+
#endif
132+
119133
// Return error status with message.
120134
#define ERROR_STATUS(status, ...) \
121135
env.setLastNativeError( \
@@ -209,7 +223,12 @@ union HermesBuildVersionInfo {
209223
uint64_t version;
210224
};
211225

212-
constexpr HermesBuildVersionInfo HermesBuildVersion = {HERMES_FILE_VERSION_BIN};
226+
#ifdef __APPLE__
227+
#undef HERMES_FILE_VERSION_BIN
228+
#define HERMES_FILE_VERSION_BIN 0,0,0,0
229+
#endif
230+
231+
constexpr HermesBuildVersionInfo HermesBuildVersion = {{HERMES_FILE_VERSION_BIN}};
213232

214233
//=============================================================================
215234
// Forward declaration of all classes.
@@ -2218,7 +2237,7 @@ class NapiComplexReference : public NapiReference {
22182237
}
22192238
if (--refCount_ == 0) {
22202239
if (value_.isObject()) {
2221-
weakRoot_ = env.createWeakRoot(getObjectUnsafe(value_));
2240+
weakRoot_ = std::move(env.createWeakRoot(getObjectUnsafe(value_)));
22222241
} else {
22232242
weakRoot_ = vm::WeakRoot<vm::JSObject>{};
22242243
}
@@ -2297,7 +2316,7 @@ class NapiFinalizeCallbackHolder : public TBaseReference {
22972316
if (finalizeCallback_) {
22982317
napi_finalize finalizeCallback =
22992318
std::exchange(finalizeCallback_, nullptr);
2300-
env.callFinalizer(finalizeCallback, nativeData(), finalizeHint());
2319+
env.callFinalizer(finalizeCallback, this->nativeData(), this->finalizeHint());
23012320
}
23022321
return napi_ok;
23032322
}
@@ -2331,7 +2350,7 @@ class NapiFinalizingReference final : public TBaseReference {
23312350
: TBaseReference(std::forward<TArgs>(args)...) {}
23322351

23332352
void finalize(NapiEnvironment &env) noexcept override {
2334-
callFinalizeCallback(env);
2353+
this->callFinalizeCallback(env);
23352354
NapiReference::deleteReference(
23362355
env, this, NapiReference::ReasonToDelete::FinalizerCall);
23372356
}
@@ -3107,8 +3126,8 @@ NapiEnvironment::NapiEnvironment(
31073126
std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptCache,
31083127
const vm::RuntimeConfig &runtimeConfig) noexcept
31093128
: runtime_(runtime),
3110-
isInspectable_(isInspectable),
3111-
scriptCache_(std::move(scriptCache)) {
3129+
scriptCache_(std::move(scriptCache)),
3130+
isInspectable_(isInspectable) {
31123131
switch (runtimeConfig.getCompilationMode()) {
31133132
case vm::SmartCompilation:
31143133
compileFlags_.lazy = true;
@@ -6378,7 +6397,7 @@ napi_status NapiEnvironment::createPreparedScript(
63786397

63796398
if (scriptCache_) {
63806399
uint64_t hash{};
6381-
bool isAscii = murmurhash(buffer->data(), buffer->size(), /*ref*/ hash);
6400+
murmurhash(buffer->data(), buffer->size(), /*ref*/ hash);
63826401
facebook::jsi::JSRuntimeVersion_t runtimeVersion =
63836402
HermesBuildVersion.version;
63846403
scriptSignature = {std::string(sourceURL ? sourceURL : ""), hash};
@@ -6390,7 +6409,7 @@ napi_status NapiEnvironment::createPreparedScript(
63906409
cache = scriptCache_->tryGetPreparedScript(
63916410
scriptSignature, runtimeSignature, prepareTag);
63926411
bcErr = hbc::BCProviderFromBuffer::createBCProviderFromBuffer(
6393-
std::make_unique<JsiBuffer>(move(cache)));
6412+
std::make_unique<JsiBuffer>(std::move(cache)));
63946413
}
63956414

63966415
hbc::BCProviderFromSrc *bytecodeProviderFromSrc{};

0 commit comments

Comments
 (0)