Skip to content

Commit fce8e68

Browse files
authored
Merge pull request #34 from NativeScript/v8-update
hermes: support loading bytecode
2 parents c75eb73 + 3eb8261 commit fce8e68

File tree

14 files changed

+10
-1
lines changed

14 files changed

+10
-1
lines changed

test-app/runtime/src/main/cpp/napi/hermes/include_shermes/hermes/hermes_node_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// #include "hermes/VM/RuntimeModule.h"
1717
#include "js_native_api.h"
1818

19+
NAPI_EXTERN napi_status NAPI_CDECL napi_run_bytecode(napi_env env, void* data, size_t size, const char* source_url, napi_value *result);
20+
1921
namespace hermes::node_api {
2022

2123
class NodeApiEnvironment;

test-app/runtime/src/main/cpp/napi/hermes/jsr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "jsr.h"
22
#include "js_runtime.h"
3+
#include "File.h"
34

45
using namespace facebook::jsi;
56
std::unordered_map<napi_env, JSR *> JSR::env_to_jsr_cache;
@@ -131,7 +132,13 @@ napi_status js_cache_script(napi_env env, const char *source, const char *file)
131132

132133
napi_status js_run_cached_script(napi_env env, const char *file, napi_value script, void *cache,
133134
napi_value *result) {
134-
return napi_ok;
135+
int length = 0;
136+
auto data = tns::File::ReadBinary(file, length);
137+
if (!data) {
138+
return napi_cannot_run_js;
139+
}
140+
141+
return napi_run_bytecode(env, data, length, file, result);
135142
}
136143

137144
napi_status js_get_runtime_version(napi_env env, napi_value *version) {
173 KB
Binary file not shown.
1.52 KB
Binary file not shown.
184 Bytes
Binary file not shown.
117 KB
Binary file not shown.
Binary file not shown.
184 Bytes
Binary file not shown.
163 KB
Binary file not shown.
1.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)