Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
module_wrap.h
Go to the documentation of this file.
1 #ifndef SRC_MODULE_WRAP_H_
2 #define SRC_MODULE_WRAP_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include <map>
7 #include <string>
8 #include <vector>
9 #include "node_url.h"
10 #include "base-object.h"
11 #include "base-object-inl.h"
12 
13 namespace node {
14 namespace loader {
15 
16 node::url::URL Resolve(std::string specifier, node::url::URL* base,
17  bool read_pkg_json = false);
18 
19 class ModuleWrap : public BaseObject {
20  public:
21  static const std::string EXTENSIONS[];
22  static void Initialize(v8::Local<v8::Object> target,
23  v8::Local<v8::Value> unused,
24  v8::Local<v8::Context> context);
25 
26  private:
27  ModuleWrap(node::Environment* env,
28  v8::Local<v8::Object> object,
29  v8::Local<v8::Module> module,
30  v8::Local<v8::String> url);
31  ~ModuleWrap();
32 
33  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
34  static void Link(const v8::FunctionCallbackInfo<v8::Value>& args);
35  static void Instantiate(const v8::FunctionCallbackInfo<v8::Value>& args);
36  static void Evaluate(const v8::FunctionCallbackInfo<v8::Value>& args);
37  static void GetUrl(v8::Local<v8::String> property,
38  const v8::PropertyCallbackInfo<v8::Value>& info);
39  static void Resolve(const v8::FunctionCallbackInfo<v8::Value>& args);
40  static v8::MaybeLocal<v8::Module> ResolveCallback(
41  v8::Local<v8::Context> context,
42  v8::Local<v8::String> specifier,
43  v8::Local<v8::Module> referrer);
44 
45  v8::Persistent<v8::Module> module_;
46  v8::Persistent<v8::String> url_;
47  bool linked_ = false;
48  std::map<std::string, v8::Persistent<v8::Promise>*> resolve_cache_;
49 
50  static std::map<int, std::vector<ModuleWrap*>*> module_map_;
51 };
52 
53 } // namespace loader
54 } // namespace node
55 
56 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
57 
58 #endif // SRC_MODULE_WRAP_H_
void Initialize(Local< Object > target, Local< Value > unused, Local< Context > context, void *priv)
Definition: node_http2.cc:1172
MaybeLocal< Object > New(Isolate *isolate, Local< String > string, enum encoding enc)
Definition: node_buffer.cc:241
StringPtr url_
URL Resolve(std::string specifier, URL *base, bool read_pkg_json)
Definition: module_wrap.cc:445