Skip to content

Commit

Permalink
fix(hermes): resolve build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Jan 23, 2025
1 parent 434fe2b commit 53834bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
34 changes: 8 additions & 26 deletions driver/js/src/js_driver_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#pragma clang diagnostic ignored "-Wsign-conversion"
#include "hermes/hermes.h"
#pragma clang diagnostic pop
#endif
#endif /* JS_HERMES */

namespace hippy {
inline namespace driver {
Expand Down Expand Up @@ -553,8 +553,8 @@ void JsDriverUtils::DestroyInstance(std::shared_ptr<Engine>&& engine,
// the scope and engine into the scope_destroy_callback, which will be released
// when the callback is executed, ensuring no other tasks can be added to the
// task runner.
#if defined(JS_V8) && defined(ENABLE_INSPECTOR) && !defined(V8_WITHOUT_INSPECTOR)
auto scope_destroy_callback = [engine = std::move(engine), scope = std::move(scope), is_reload, callback] {
#if defined(JS_V8) && defined(ENABLE_INSPECTOR) && !defined(V8_WITHOUT_INSPECTOR)
auto v8_vm = std::static_pointer_cast<V8VM>(engine->GetVM());
if (v8_vm->IsDebug()) {
auto inspector_client = v8_vm->GetInspectorClient();
Expand All @@ -567,15 +567,13 @@ void JsDriverUtils::DestroyInstance(std::shared_ptr<Engine>&& engine,
}
FOOTSTONE_LOG(INFO) << "js destroy end";
callback(true);
};
#else
auto scope_destroy_callback = [engine = std::move(engine), scope = std::move(scope), callback] {
(void)is_reload;
scope->WillExit();
FOOTSTONE_LOG(INFO) << "js destroy end";
callback(true);
};
#endif
};
runner->PostTask(std::move(scope_destroy_callback));
FOOTSTONE_DLOG(INFO) << "destroy, group = " << group;
}
Expand Down Expand Up @@ -713,8 +711,8 @@ void JsDriverUtils::CallNative(hippy::napi::CallbackInfo& info, const std::funct
}

std::string buffer_data;
#ifdef JS_V8
if (info[3] && context->IsObject(info[3])) {
#ifdef JS_V8
auto engine = scope->GetEngine().lock();
FOOTSTONE_DCHECK(engine);
if (!engine) {
Expand Down Expand Up @@ -742,28 +740,12 @@ void JsDriverUtils::CallNative(hippy::napi::CallbackInfo& info, const std::funct
FOOTSTONE_DLOG(INFO) << "CallJava json = " << json;
buffer_data = StringViewUtils::ToStdString(
StringViewUtils::ConvertEncoding(json, string_view::Encoding::Utf8).utf8_value());
#ifdef JS_V8
}
#elif JS_JSH
}
}
#elif defined(JS_HERMES)
if (info[3] && context->IsObject(info[3])) {
string_view json;
auto flag = context->GetValueJson(info[3], &json);
FOOTSTONE_DCHECK(flag);
FOOTSTONE_DLOG(INFO) << "CallJava json = " << json;
buffer_data =
StringViewUtils::ToStdString(StringViewUtils::ConvertEncoding(json, string_view::Encoding::Utf8).utf8_value());
}
#else
if (info[3] && context->IsObject(info[3])) {
} else {
string_view json;
auto flag = context->GetValueJson(info[3], &json);
FOOTSTONE_DCHECK(flag);
FOOTSTONE_DLOG(INFO) << "CallJava json = " << json;
buffer_data =
StringViewUtils::ToStdString(StringViewUtils::ConvertEncoding(json, string_view::Encoding::Utf8).utf8_value());
}
#endif
}

int32_t transfer_type = 0;
if (info[4]) {
Expand Down
10 changes: 5 additions & 5 deletions driver/js/src/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@
#include "driver/vm/v8/memory_module.h"
#include "driver/napi/v8/v8_ctx.h"
#include "driver/vm/v8/v8_vm.h"
#endif
#endif /* JS_V8 */

#ifdef JS_HERMES
#include "driver/vm/hermes/hermes_vm.h"
#include "driver/napi/hermes/hermes_ctx.h"
#endif
#endif /* JS_HERMES */

#elif JS_JSH
#ifdef JS_JSH
#include "driver/napi/jsh/jsh_ctx.h"
#include "driver/vm/jsh/jsh_vm.h"
#endif
#endif /* JS_JSH */

#ifdef ENABLE_INSPECTOR
#include "devtools/devtools_data_source.h"
#endif
#endif /* ENABLE_INSPECTOR */

using string_view = footstone::stringview::string_view;
using StringViewUtils = footstone::stringview::StringViewUtils;
Expand Down

0 comments on commit 53834bd

Please sign in to comment.