Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
napi: adding napi_run_script support for chakracore
Browse files Browse the repository at this point in the history
  • Loading branch information
MSLaguana committed Sep 15, 2017
1 parent 06d06cb commit 18d71ba
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/node_api_jsrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,32 @@ napi_status napi_adjust_external_memory(napi_env env,
return napi_ok;
}

JsValueRef runScriptSourceUrl = JS_INVALID_REFERENCE;

napi_status napi_run_script(napi_env env,
napi_value script,
napi_value* result) {
CHECK_ARG(script);
CHECK_ARG(result);
JsValueRef scriptVar = reinterpret_cast<JsValueRef>(script);

if (runScriptSourceUrl == JS_INVALID_REFERENCE) {
const char * napiScriptString = "NAPI run script";
CHECK_JSRT(JsCreateString(napiScriptString,
strlen(napiScriptString),
&runScriptSourceUrl));
}

CHECK_JSRT_EXPECTED(JsRun(scriptVar,
JS_SOURCE_CONTEXT_NONE,
runScriptSourceUrl,
JsParseScriptAttributeNone,
reinterpret_cast<JsValueRef*>(result)),
napi_string_expected);

return napi_ok;
}

namespace uvimpl {

napi_status ConvertUVErrorCode(int code) {
Expand Down

0 comments on commit 18d71ba

Please sign in to comment.