Skip to content

Commit

Permalink
Add SetEnv plumbing
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdy committed Jul 25, 2024
1 parent a224282 commit fe67039
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/asherah.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Asherah : public Napi::Addon<Asherah> {
&Asherah::SetSafetyPaddingOverhead),
InstanceMethod("get_setup_status", &Asherah::GetSetupStatus),
InstanceMethod("set_log_hook", &Asherah::SetLogHook),
InstanceMethod("setenv", &Asherah::SetEnv),
});
}

Expand Down Expand Up @@ -409,6 +410,22 @@ class Asherah : public Napi::Addon<Asherah> {
}
}

void SetEnv(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
try {
NapiUtils::RequireParameterCount(info, 1);
CobhanBufferNapi env_json(env, info[0]);
GoInt32 Result = ::SetEnv(env_json);
} catch (Napi::Error &e) {
e.ThrowAsJavaScriptException();
return;
} catch (const std::exception &e) {
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
return;
}
}

void SetMaxStackAllocItemSize(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Expand Down

0 comments on commit fe67039

Please sign in to comment.