-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
src: Use V8 function to get Module Namespace #16261
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,6 +207,14 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { | |
| args.GetReturnValue().Set(ret); | ||
| } | ||
|
|
||
| void ModuleWrap::Namespace(const FunctionCallbackInfo<Value>& args) { | ||
| auto iso = args.GetIsolate(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style nit:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| auto that = args.This(); | ||
| ModuleWrap* obj = Unwrap<ModuleWrap>(that); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| auto result = obj->module_.Get(iso)->GetModuleNamespace(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I believe I understand how the previous code enforced that invariant (by calling
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nothing except when it is called, can add a check and throw though.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made it throw after checking status |
||
| args.GetReturnValue().Set(result); | ||
| } | ||
|
|
||
| MaybeLocal<Module> ModuleWrap::ResolveCallback(Local<Context> context, | ||
| Local<String> specifier, | ||
| Local<Module> referrer) { | ||
|
|
@@ -516,6 +524,7 @@ void ModuleWrap::Initialize(Local<Object> target, | |
| env->SetProtoMethod(tpl, "link", Link); | ||
| env->SetProtoMethod(tpl, "instantiate", Instantiate); | ||
| env->SetProtoMethod(tpl, "evaluate", Evaluate); | ||
| env->SetProtoMethod(tpl, "namespace", Namespace); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it can throw if it isn't instantiated. |
||
|
|
||
| target->Set(FIXED_ONE_BYTE_STRING(isolate, "ModuleWrap"), tpl->GetFunction()); | ||
| env->SetMethod(target, "resolve", node::loader::ModuleWrap::Resolve); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could fit this on one line now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done