Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: refactor contextify #8909

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,13 @@ class ContextifyContext {
int length = names->Length();
for (int i = 0; i < length; i++) {
Local<String> key = names->Get(i)->ToString(env()->isolate());
auto maybe_has = sandbox_obj->HasOwnProperty(context, key);
Maybe<bool> has = sandbox_obj->HasOwnProperty(context, key);

// Check for pending exceptions
if (!maybe_has.IsJust())
break;

bool has = maybe_has.FromJust();
if (has.IsNothing())
return;

if (!has) {
if (!has.FromJust()) {
// Could also do this like so:
//
// PropertyAttribute att = global->GetPropertyAttributes(key_v);
Expand Down Expand Up @@ -316,7 +314,7 @@ class ContextifyContext {
}
Local<Object> sandbox = args[0].As<Object>();

auto result =
Maybe<bool> result =
sandbox->HasPrivate(env->context(),
env->contextify_context_private_symbol());
args.GetReturnValue().Set(result.FromJust());
Expand All @@ -332,7 +330,7 @@ class ContextifyContext {
static ContextifyContext* ContextFromContextifiedSandbox(
Environment* env,
const Local<Object>& sandbox) {
auto maybe_value =
MaybeLocal<Value> maybe_value =
sandbox->GetPrivate(env->context(),
env->contextify_context_private_symbol());
Local<Value> context_external_v;
Expand Down Expand Up @@ -506,8 +504,8 @@ class ContextifyScript : public BaseObject {
}

ScriptCompiler::CachedData* cached_data = nullptr;
if (!cached_data_buf.IsEmpty()) {
Local<Uint8Array> ui8 = cached_data_buf.ToLocalChecked();
Local<Uint8Array> ui8;
if (cached_data_buf.ToLocal(&ui8)) {
ArrayBuffer::Contents contents = ui8->Buffer()->GetContents();
cached_data = new ScriptCompiler::CachedData(
static_cast<uint8_t*>(contents.Data()) + ui8->ByteOffset(),
Expand Down Expand Up @@ -655,7 +653,7 @@ class ContextifyScript : public BaseObject {

AppendExceptionLine(env, exception, try_catch.Message(), CONTEXTIFY_ERROR);
Local<Value> stack = err_obj->Get(env->stack_string());
auto maybe_value =
MaybeLocal<Value> maybe_value =
err_obj->GetPrivate(
env->context(),
env->arrow_message_private_symbol());
Expand Down