Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
node.h File Reference
#include "v8.h"
#include "node_version.h"
#include <assert.h>
#include <stdint.h>
#include <sys/types.h>
Include dependency graph for node.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  node_module
 
struct  async_context
 
class  AsyncResource
 

Namespaces

 node
 

Macros

#define NODE_EXTERN   /* nothing */
 
#define NODE_MAKE_VERSION(major, minor, patch)   ((major) * 0x1000 + (minor) * 0x100 + (patch))
 
#define NODE_CLANG_AT_LEAST(major, minor, patch)   (0)
 
#define NODE_GNUC_AT_LEAST(major, minor, patch)   (0)
 
#define NODE_DEPRECATED(message, declarator)   declarator
 
#define NODE_UNIXTIME_V8(t)
 
#define NODE_V8_UNIXTIME(v)   (static_cast<double>((v)->NumberValue())/1000.0);
 
#define NODE_DEFINE_CONSTANT(target, constant)
 
#define NODE_DEFINE_HIDDEN_CONSTANT(target, constant)
 
#define NODE_SET_METHOD   node::NODE_SET_METHOD
 
#define NODE_SET_PROTOTYPE_METHOD   node::NODE_SET_PROTOTYPE_METHOD
 
#define NM_F_BUILTIN   0x01
 
#define NM_F_LINKED   0x02
 
#define NODE_MODULE_EXPORT   __attribute__((visibility("default")))
 
#define NODE_CTOR_PREFIX   static
 
#define NODE_C_CTOR(fn)
 
#define NODE_MODULE_X(modname, regfunc, priv, flags)
 
#define NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, priv, flags)
 
#define NODE_MODULE(modname, regfunc)   NODE_MODULE_X(modname, regfunc, NULL, 0)
 
#define NODE_MODULE_CONTEXT_AWARE(modname, regfunc)   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
 
#define NODE_MODULE_CONTEXT_AWARE_BUILTIN(modname, regfunc)   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, NM_F_BUILTIN) \
 
#define NODE_MODULE_DECL   /* nothing */
 
#define EmitAsyncInit   EmitAsyncInit__New
 

Typedefs

typedef void(* addon_register_func) (v8::Local< v8::Object > exports, v8::Local< v8::Value > module, void *priv)
 
typedef void(* addon_context_register_func) (v8::Local< v8::Object > exports, v8::Local< v8::Value > module, v8::Local< v8::Context > context, void *priv)
 
typedef void(* promise_hook_func) (v8::PromiseHookType type, v8::Local< v8::Promise > promise, v8::Local< v8::Value > parent, void *arg)
 
typedef double async_id
 
typedef async_id async_uid
 

Enumerations

enum  encoding {
  ASCII, UTF8, BASE64, UCS2,
  BINARY, HEX, BUFFER, LATIN1 = BINARY
}
 

Functions

NODE_EXTERN v8::Local< v8::Value > ErrnoException (v8::Isolate *isolate, int errorno, const char *syscall=NULL, const char *message=NULL, const char *path=NULL)
 
NODE_EXTERN v8::Local< v8::Value > UVException (v8::Isolate *isolate, int errorno, const char *syscall=NULL, const char *message=NULL, const char *path=NULL)
 
NODE_EXTERN v8::Local< v8::Value > UVException (v8::Isolate *isolate, int errorno, const char *syscall, const char *message, const char *path, const char *dest)
 
 NODE_DEPRECATED ("Use ErrnoException(isolate, ...)", inline v8::Local< v8::Value > ErrnoException(int errorno, const char *syscall=NULL, const char *message=NULL, const char *path=NULL) { return ErrnoException(v8::Isolate::GetCurrent(), errorno, syscall, message, path);}) inline v8
 
NODE_EXTERN v8::Local< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, const char *method, int argc, v8::Local< v8::Value > *argv)
 
NODE_EXTERN v8::Local< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::String > symbol, int argc, v8::Local< v8::Value > *argv)
 
NODE_EXTERN v8::Local< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::Function > callback, int argc, v8::Local< v8::Value > *argv)
 
NODE_EXTERN int Start (int argc, char *argv[])
 
void Init (int *argc, const char **argv, int *exec_argc, const char ***exec_argv)
 
NODE_EXTERN IsolateData * CreateIsolateData (v8::Isolate *isolate, struct uv_loop_s *loop)
 
void FreeIsolateData (IsolateData *isolate_data)
 
NODE_EXTERN Environment * CreateEnvironment (IsolateData *isolate_data, v8::Local< v8::Context > context, int argc, const char *const *argv, int exec_argc, const char *const *exec_argv)
 
void LoadEnvironment (Environment *env)
 
void FreeEnvironment (Environment *env)
 
void EmitBeforeExit (Environment *env)
 
int EmitExit (Environment *env)
 
void RunAtExit (Environment *env)
 
void NODE_SET_METHOD (v8::Local< v8::Template > recv, const char *name, v8::FunctionCallback callback)
 
void NODE_SET_METHOD (v8::Local< v8::Object > recv, const char *name, v8::FunctionCallback callback)
 
void NODE_SET_PROTOTYPE_METHOD (v8::Local< v8::FunctionTemplate > recv, const char *name, v8::FunctionCallback callback)
 
NODE_EXTERN enum encoding ParseEncoding (v8::Isolate *isolate, v8::Local< v8::Value > encoding_v, enum encoding default_encoding=LATIN1)
 
struct node_module * get_builtin_module (const char *name)
 
struct node_module * get_linked_module (const char *name)
 
void node_module_register (void *m)
 
void AtExit (void(*cb)(void *arg), void *arg)
 
void AtExit (Environment *env, void(*cb)(void *arg), void *arg)
 
void AddPromiseHook (v8::Isolate *isolate, promise_hook_func fn, void *arg)
 
NODE_EXTERN async_id AsyncHooksGetExecutionAsyncId (v8::Isolate *isolate)
 
NODE_EXTERN NODE_DEPRECATED ("Use AsyncHooksGetExecutionAsyncId(isolate)", async_id AsyncHooksGetCurrentId(v8::Isolate *isolate))
 
NODE_EXTERN async_id AsyncHooksGetTriggerAsyncId (v8::Isolate *isolate)
 
NODE_EXTERN NODE_DEPRECATED ("Use AsyncHooksGetTriggerAsyncId(isolate)", async_id AsyncHooksGetTriggerId(v8::Isolate *isolate))
 
NODE_EXTERN async_uid EmitAsyncInit (v8::Isolate *isolate, v8::Local< v8::Object > resource, const char *name, async_id trigger_async_id)
 
NODE_EXTERN void EmitAsyncDestroy (v8::Isolate *isolate, async_context asyncContext)
 
NODE_EXTERN v8::MaybeLocal< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::Function > callback, int argc, v8::Local< v8::Value > *argv, async_context asyncContext)
 
NODE_EXTERN v8::MaybeLocal< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, const char *method, int argc, v8::Local< v8::Value > *argv, async_context asyncContext)
 
NODE_EXTERN v8::MaybeLocal< v8::Value > MakeCallback (v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::String > symbol, int argc, v8::Local< v8::Value > *argv, async_context asyncContext)
 
NODE_EXTERN NODE_DEPRECATED ("Use MakeCallback(..., async_context asyncContext) instead", v8::MaybeLocal< v8::Value > MakeCallback(v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::Function > callback, int argc, v8::Local< v8::Value > *argv, async_id asyncId, async_id triggerAsyncId))
 
NODE_EXTERN NODE_DEPRECATED ("Use MakeCallback(..., async_context asyncContext) instead", v8::MaybeLocal< v8::Value > MakeCallback(v8::Isolate *isolate, v8::Local< v8::Object > recv, const char *method, int argc, v8::Local< v8::Value > *argv, async_id asyncId, async_id triggerAsyncId))
 
NODE_EXTERN NODE_DEPRECATED ("Use MakeCallback(..., async_context asyncContext) instead", v8::MaybeLocal< v8::Value > MakeCallback(v8::Isolate *isolate, v8::Local< v8::Object > recv, v8::Local< v8::String > symbol, int argc, v8::Local< v8::Value > *argv, async_id asyncId, async_id triggerAsyncId))
 

Variables

NODE_DEPRECATED("Use ParseEncoding(isolate, ...)", inline enum encoding ParseEncoding(v8::Local< v8::Value > encoding_v, enum encoding default_encoding=LATIN1) { return ParseEncoding(v8::Isolate::GetCurrent(), encoding_v, default_encoding);}) NODE_EXTERN void FatalException(v8 NODE_DEPRECATED("Use FatalException(isolate, ...)", inline void FatalException(const v8::TryCatch &try_catch) { return FatalException(v8::Isolate::GetCurrent(), try_catch);}) NODE_EXTERN v8 NODE_EXTERN v8::Local< v8::Value > Encode (v8::Isolate *isolate, const uint16_t *buf, size_t len)
 
NODE_DEPRECATED("Use Encode(isolate, ...)", inline v8::Local< v8::Value > Encode(const void *buf, size_t len, enum encoding encoding=LATIN1) { v8::Isolate *isolate=v8::Isolate::GetCurrent();if(encoding==UCS2) { assert(reinterpret_cast< uintptr_t >(buf) % sizeof(uint16_t)==0 &&"UCS2 buffer must be aligned on two-byte boundary.");const uint16_t *that=static_cast< const uint16_t * >(buf);return Encode(isolate, that, len/sizeof(*that));} return Encode(isolate, static_cast< const char * >(buf), len, encoding);}) NODE_EXTERN ssize_t DecodeBytes(v8 NODE_DEPRECATED("Use DecodeBytes(isolate, ...)", inline ssize_t DecodeBytes(v8::Local< v8::Value > val, enum encoding encoding=LATIN1) { return DecodeBytes(v8::Isolate::GetCurrent(), val, encoding);}) NODE_EXTERN ssize_t DecodeWrite(v8 NODE_DEPRECATED ("Use DecodeWrite(isolate, ...)", inline ssize_t DecodeWrite(char *buf, size_t buflen, v8::Local< v8::Value > val, enum encoding encoding=LATIN1) { return DecodeWrite(v8::Isolate::GetCurrent(), buf, buflen, val, encoding);}) const char *signo_string(int errorno)
 

Macro Definition Documentation

◆ EmitAsyncInit

#define EmitAsyncInit   EmitAsyncInit__New

Definition at line 584 of file node.h.

Referenced by node::EmitAsyncInit(), and node::LoadAsyncWrapperInfo().

◆ NM_F_BUILTIN

#define NM_F_BUILTIN   0x01

Definition at line 428 of file node.h.

Referenced by node::get_builtin_module(), and node::node_module_register().

◆ NM_F_LINKED

#define NM_F_LINKED   0x02

Definition at line 429 of file node.h.

Referenced by node::get_linked_module().

◆ NODE_C_CTOR

#define NODE_C_CTOR (   fn)
Value:
NODE_CTOR_PREFIX void fn(void) __attribute__((constructor)); \
NODE_CTOR_PREFIX void fn(void)
#define NODE_CTOR_PREFIX
Definition: node.h:457

Definition at line 468 of file node.h.

◆ NODE_CLANG_AT_LEAST

#define NODE_CLANG_AT_LEAST (   major,
  minor,
  patch 
)    (0)

Definition at line 74 of file node.h.

◆ NODE_CTOR_PREFIX

#define NODE_CTOR_PREFIX   static

Definition at line 457 of file node.h.

◆ NODE_DEFINE_CONSTANT

#define NODE_DEFINE_CONSTANT (   target,
  constant 
)
Value:
do { \
v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
(target)->DefineOwnProperty(context, \
constant_name, \
constant_value, \
constant_attributes).FromJust(); \
} \
while (0)
MaybeLocal< Object > New(Isolate *isolate, Local< String > string, enum encoding enc)
Definition: node_buffer.cc:241

Definition at line 239 of file node.h.

Referenced by node::DefineConstants(), node::performance::Init(), and node::http2::Initialize().

◆ NODE_DEFINE_HIDDEN_CONSTANT

#define NODE_DEFINE_HIDDEN_CONSTANT (   target,
  constant 
)
Value:
do { \
v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant, \
v8::NewStringType::kInternalized) \
.ToLocalChecked(); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
v8::DontDelete | \
v8::DontEnum); \
(target)->DefineOwnProperty(context, \
constant_name, \
constant_value, \
constant_attributes).FromJust(); \
} \
while (0)
MaybeLocal< Object > New(Isolate *isolate, Local< String > string, enum encoding enc)
Definition: node_buffer.cc:241

Definition at line 256 of file node.h.

Referenced by node::http2::Initialize().

◆ NODE_DEPRECATED

#define NODE_DEPRECATED (   message,
  declarator 
)    declarator

Definition at line 92 of file node.h.

◆ NODE_EXTERN

#define NODE_EXTERN   /* nothing */

Definition at line 32 of file node.h.

Referenced by node::NODE_DEPRECATED().

◆ NODE_GNUC_AT_LEAST

#define NODE_GNUC_AT_LEAST (   major,
  minor,
  patch 
)    (0)

Definition at line 82 of file node.h.

◆ NODE_MAKE_VERSION

#define NODE_MAKE_VERSION (   major,
  minor,
  patch 
)    ((major) * 0x1000 + (minor) * 0x100 + (patch))

Definition at line 66 of file node.h.

◆ NODE_MODULE

#define NODE_MODULE (   modname,
  regfunc 
)    NODE_MODULE_X(modname, regfunc, NULL, 0)

Definition at line 511 of file node.h.

◆ NODE_MODULE_CONTEXT_AWARE

#define NODE_MODULE_CONTEXT_AWARE (   modname,
  regfunc 
)    NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)

Definition at line 514 of file node.h.

◆ NODE_MODULE_CONTEXT_AWARE_BUILTIN

#define NODE_MODULE_CONTEXT_AWARE_BUILTIN (   modname,
  regfunc 
)    NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, NM_F_BUILTIN) \

Definition at line 517 of file node.h.

◆ NODE_MODULE_CONTEXT_AWARE_X

#define NODE_MODULE_CONTEXT_AWARE_X (   modname,
  regfunc,
  priv,
  flags 
)
Value:
extern "C" { \
static node::node_module _module = \
{ \
NODE_MODULE_VERSION, \
flags, \
NULL, \
__FILE__, \
NULL, \
NODE_STRINGIFY(modname), \
priv, \
NULL \
}; \
NODE_C_CTOR(_register_ ## modname) { \
node_module_register(&_module); \
} \
}
void(* addon_context_register_func)(v8::Local< v8::Object > exports, v8::Local< v8::Value > module, v8::Local< v8::Context > context, void *priv)
Definition: node.h:422

Definition at line 492 of file node.h.

◆ NODE_MODULE_DECL

#define NODE_MODULE_DECL   /* nothing */

Definition at line 523 of file node.h.

◆ NODE_MODULE_EXPORT

#define NODE_MODULE_EXPORT   __attribute__((visibility("default")))

Definition at line 451 of file node.h.

◆ NODE_MODULE_X

#define NODE_MODULE_X (   modname,
  regfunc,
  priv,
  flags 
)
Value:
extern "C" { \
static node::node_module _module = \
{ \
NODE_MODULE_VERSION, \
flags, \
NULL, \
__FILE__, \
NULL, \
NODE_STRINGIFY(modname), \
priv, \
NULL \
}; \
NODE_C_CTOR(_register_ ## modname) { \
node_module_register(&_module); \
} \
}
void(* addon_register_func)(v8::Local< v8::Object > exports, v8::Local< v8::Value > module, void *priv)
Definition: node.h:417

Definition at line 473 of file node.h.

◆ NODE_SET_METHOD

#define NODE_SET_METHOD   node::NODE_SET_METHOD

Definition at line 303 of file node.h.

◆ NODE_SET_PROTOTYPE_METHOD

#define NODE_SET_PROTOTYPE_METHOD   node::NODE_SET_PROTOTYPE_METHOD

Definition at line 319 of file node.h.

◆ NODE_UNIXTIME_V8

#define NODE_UNIXTIME_V8 (   t)
Value:
v8::Date::New(v8::Isolate::GetCurrent(), \
1000 * static_cast<double>(t))
dtrace t
Definition: v8ustack.d:582
MaybeLocal< Object > New(Isolate *isolate, Local< String > string, enum encoding enc)
Definition: node_buffer.cc:241

Definition at line 235 of file node.h.

◆ NODE_V8_UNIXTIME

#define NODE_V8_UNIXTIME (   v)    (static_cast<double>((v)->NumberValue())/1000.0);

Definition at line 237 of file node.h.