node-addon-api 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -4
- package/CHANGELOG.md +88 -30
- package/README.md +53 -7
- package/benchmark/README.md +47 -0
- package/benchmark/binding.gyp +25 -0
- package/benchmark/function_args.cc +153 -0
- package/benchmark/function_args.js +52 -0
- package/benchmark/index.js +34 -0
- package/benchmark/property_descriptor.cc +60 -0
- package/benchmark/property_descriptor.js +29 -0
- package/common.gypi +21 -0
- package/doc/async_worker.md +33 -4
- package/doc/{async_progress_worker.md → async_worker_variants.md} +115 -3
- package/doc/bigint.md +2 -1
- package/doc/class_property_descriptor.md +3 -3
- package/doc/creating_a_release.md +5 -5
- package/doc/env.md +14 -0
- package/doc/function.md +108 -1
- package/doc/object.md +40 -1
- package/doc/object_lifetime_management.md +1 -1
- package/doc/object_wrap.md +278 -2
- package/doc/property_descriptor.md +64 -9
- package/doc/setup.md +0 -1
- package/doc/string.md +1 -1
- package/doc/symbol.md +1 -1
- package/doc/value.md +1 -1
- package/except.gypi +16 -0
- package/index.js +5 -42
- package/napi-inl.h +727 -141
- package/napi.h +338 -83
- package/node_api.gyp +9 -0
- package/noexcept.gypi +16 -0
- package/{src/nothing.c → nothing.c} +0 -0
- package/package.json +33 -1
- package/tools/README.md +4 -4
- package/tools/conversion.js +0 -4
- package/external-napi/node_api.h +0 -7
- package/src/node_api.cc +0 -3655
- package/src/node_api.gyp +0 -21
- package/src/node_api.h +0 -588
- package/src/node_api_types.h +0 -115
- package/src/node_internals.cc +0 -142
- package/src/node_internals.h +0 -157
- package/src/util-inl.h +0 -38
- package/src/util.h +0 -7
package/src/node_api_types.h
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
#ifndef SRC_NODE_API_TYPES_H_
|
|
2
|
-
#define SRC_NODE_API_TYPES_H_
|
|
3
|
-
|
|
4
|
-
#include <stddef.h>
|
|
5
|
-
#include <stdint.h>
|
|
6
|
-
|
|
7
|
-
#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
|
|
8
|
-
typedef uint16_t char16_t;
|
|
9
|
-
#endif
|
|
10
|
-
|
|
11
|
-
// JSVM API types are all opaque pointers for ABI stability
|
|
12
|
-
// typedef undefined structs instead of void* for compile time type safety
|
|
13
|
-
typedef struct napi_env__ *napi_env;
|
|
14
|
-
typedef struct napi_value__ *napi_value;
|
|
15
|
-
typedef struct napi_ref__ *napi_ref;
|
|
16
|
-
typedef struct napi_handle_scope__ *napi_handle_scope;
|
|
17
|
-
typedef struct napi_escapable_handle_scope__ *napi_escapable_handle_scope;
|
|
18
|
-
typedef struct napi_callback_info__ *napi_callback_info;
|
|
19
|
-
typedef struct napi_async_context__ *napi_async_context;
|
|
20
|
-
typedef struct napi_async_work__ *napi_async_work;
|
|
21
|
-
typedef struct napi_deferred__ *napi_deferred;
|
|
22
|
-
|
|
23
|
-
typedef enum {
|
|
24
|
-
napi_default = 0,
|
|
25
|
-
napi_writable = 1 << 0,
|
|
26
|
-
napi_enumerable = 1 << 1,
|
|
27
|
-
napi_configurable = 1 << 2,
|
|
28
|
-
|
|
29
|
-
// Used with napi_define_class to distinguish static properties
|
|
30
|
-
// from instance properties. Ignored by napi_define_properties.
|
|
31
|
-
napi_static = 1 << 10,
|
|
32
|
-
} napi_property_attributes;
|
|
33
|
-
|
|
34
|
-
typedef enum {
|
|
35
|
-
// ES6 types (corresponds to typeof)
|
|
36
|
-
napi_undefined,
|
|
37
|
-
napi_null,
|
|
38
|
-
napi_boolean,
|
|
39
|
-
napi_number,
|
|
40
|
-
napi_string,
|
|
41
|
-
napi_symbol,
|
|
42
|
-
napi_object,
|
|
43
|
-
napi_function,
|
|
44
|
-
napi_external,
|
|
45
|
-
} napi_valuetype;
|
|
46
|
-
|
|
47
|
-
typedef enum {
|
|
48
|
-
napi_int8_array,
|
|
49
|
-
napi_uint8_array,
|
|
50
|
-
napi_uint8_clamped_array,
|
|
51
|
-
napi_int16_array,
|
|
52
|
-
napi_uint16_array,
|
|
53
|
-
napi_int32_array,
|
|
54
|
-
napi_uint32_array,
|
|
55
|
-
napi_float32_array,
|
|
56
|
-
napi_float64_array,
|
|
57
|
-
} napi_typedarray_type;
|
|
58
|
-
|
|
59
|
-
typedef enum {
|
|
60
|
-
napi_ok,
|
|
61
|
-
napi_invalid_arg,
|
|
62
|
-
napi_object_expected,
|
|
63
|
-
napi_string_expected,
|
|
64
|
-
napi_name_expected,
|
|
65
|
-
napi_function_expected,
|
|
66
|
-
napi_number_expected,
|
|
67
|
-
napi_boolean_expected,
|
|
68
|
-
napi_array_expected,
|
|
69
|
-
napi_generic_failure,
|
|
70
|
-
napi_pending_exception,
|
|
71
|
-
napi_cancelled,
|
|
72
|
-
napi_escape_called_twice,
|
|
73
|
-
napi_handle_scope_mismatch
|
|
74
|
-
} napi_status;
|
|
75
|
-
|
|
76
|
-
typedef napi_value (*napi_callback)(napi_env env,
|
|
77
|
-
napi_callback_info info);
|
|
78
|
-
typedef void (*napi_finalize)(napi_env env,
|
|
79
|
-
void* finalize_data,
|
|
80
|
-
void* finalize_hint);
|
|
81
|
-
typedef void (*napi_async_execute_callback)(napi_env env,
|
|
82
|
-
void* data);
|
|
83
|
-
typedef void (*napi_async_complete_callback)(napi_env env,
|
|
84
|
-
napi_status status,
|
|
85
|
-
void* data);
|
|
86
|
-
|
|
87
|
-
typedef struct {
|
|
88
|
-
// One of utf8name or name should be NULL.
|
|
89
|
-
const char* utf8name;
|
|
90
|
-
napi_value name;
|
|
91
|
-
|
|
92
|
-
napi_callback method;
|
|
93
|
-
napi_callback getter;
|
|
94
|
-
napi_callback setter;
|
|
95
|
-
napi_value value;
|
|
96
|
-
|
|
97
|
-
napi_property_attributes attributes;
|
|
98
|
-
void* data;
|
|
99
|
-
} napi_property_descriptor;
|
|
100
|
-
|
|
101
|
-
typedef struct {
|
|
102
|
-
const char* error_message;
|
|
103
|
-
void* engine_reserved;
|
|
104
|
-
uint32_t engine_error_code;
|
|
105
|
-
napi_status error_code;
|
|
106
|
-
} napi_extended_error_info;
|
|
107
|
-
|
|
108
|
-
typedef struct {
|
|
109
|
-
uint32_t major;
|
|
110
|
-
uint32_t minor;
|
|
111
|
-
uint32_t patch;
|
|
112
|
-
const char* release;
|
|
113
|
-
} napi_node_version;
|
|
114
|
-
|
|
115
|
-
#endif // SRC_NODE_API_TYPES_H_
|
package/src/node_internals.cc
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#include "node_internals.h"
|
|
2
|
-
#include <stdlib.h>
|
|
3
|
-
#include <cstdarg>
|
|
4
|
-
#include <vector>
|
|
5
|
-
#include "uv.h"
|
|
6
|
-
|
|
7
|
-
#if defined(_MSC_VER)
|
|
8
|
-
#define getpid GetCurrentProcessId
|
|
9
|
-
#else
|
|
10
|
-
#include <unistd.h> // getpid
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
|
-
#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6
|
|
14
|
-
CallbackScope::CallbackScope(void *work) {
|
|
15
|
-
}
|
|
16
|
-
#endif // NODE_MAJOR_VERSION < 8
|
|
17
|
-
|
|
18
|
-
namespace node {
|
|
19
|
-
|
|
20
|
-
#if NODE_MAJOR_VERSION < 8
|
|
21
|
-
|
|
22
|
-
async_context EmitAsyncInit(v8::Isolate* isolate,
|
|
23
|
-
v8::Local<v8::Object> resource,
|
|
24
|
-
v8::Local<v8::String> name,
|
|
25
|
-
async_id trigger_async_id) {
|
|
26
|
-
return async_context();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
void EmitAsyncDestroy(v8::Isolate* isolate,
|
|
30
|
-
async_context asyncContext) {
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
AsyncResource::AsyncResource(v8::Isolate* isolate,
|
|
34
|
-
v8::Local<v8::Object> object,
|
|
35
|
-
const char *name) {
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#endif // NODE_MAJOR_VERSION < 8
|
|
39
|
-
|
|
40
|
-
#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6
|
|
41
|
-
|
|
42
|
-
v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
|
|
43
|
-
v8::Local<v8::Object> recv,
|
|
44
|
-
v8::Local<v8::Function> callback,
|
|
45
|
-
int argc,
|
|
46
|
-
v8::Local<v8::Value>* argv,
|
|
47
|
-
async_context asyncContext) {
|
|
48
|
-
return node::MakeCallback(isolate, recv, callback, argc, argv);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#endif // NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6
|
|
52
|
-
|
|
53
|
-
static void PrintErrorString(const char* format, ...) {
|
|
54
|
-
va_list ap;
|
|
55
|
-
va_start(ap, format);
|
|
56
|
-
#ifdef _WIN32
|
|
57
|
-
HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
|
|
58
|
-
|
|
59
|
-
// Check if stderr is something other than a tty/console
|
|
60
|
-
if (stderr_handle == INVALID_HANDLE_VALUE ||
|
|
61
|
-
stderr_handle == nullptr ||
|
|
62
|
-
uv_guess_handle(_fileno(stderr)) != UV_TTY) {
|
|
63
|
-
vfprintf(stderr, format, ap);
|
|
64
|
-
va_end(ap);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Fill in any placeholders
|
|
69
|
-
int n = _vscprintf(format, ap);
|
|
70
|
-
std::vector<char> out(n + 1);
|
|
71
|
-
vsprintf(out.data(), format, ap);
|
|
72
|
-
|
|
73
|
-
// Get required wide buffer size
|
|
74
|
-
n = MultiByteToWideChar(CP_UTF8, 0, out.data(), -1, nullptr, 0);
|
|
75
|
-
|
|
76
|
-
std::vector<wchar_t> wbuf(n);
|
|
77
|
-
MultiByteToWideChar(CP_UTF8, 0, out.data(), -1, wbuf.data(), n);
|
|
78
|
-
|
|
79
|
-
// Don't include the null character in the output
|
|
80
|
-
CHECK_GT(n, 0);
|
|
81
|
-
WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr);
|
|
82
|
-
#else
|
|
83
|
-
vfprintf(stderr, format, ap);
|
|
84
|
-
#endif
|
|
85
|
-
va_end(ap);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
void DumpBacktrace(FILE* fp) {
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
NO_RETURN void Abort() {
|
|
92
|
-
DumpBacktrace(stderr);
|
|
93
|
-
fflush(stderr);
|
|
94
|
-
ABORT_NO_BACKTRACE();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
NO_RETURN void Assert(const char* const (*args)[4]) {
|
|
98
|
-
auto filename = (*args)[0];
|
|
99
|
-
auto linenum = (*args)[1];
|
|
100
|
-
auto message = (*args)[2];
|
|
101
|
-
auto function = (*args)[3];
|
|
102
|
-
|
|
103
|
-
char exepath[256];
|
|
104
|
-
size_t exepath_size = sizeof(exepath);
|
|
105
|
-
if (uv_exepath(exepath, &exepath_size))
|
|
106
|
-
snprintf(exepath, sizeof(exepath), "node");
|
|
107
|
-
|
|
108
|
-
char pid[12] = {0};
|
|
109
|
-
snprintf(pid, sizeof(pid), "[%u]", getpid());
|
|
110
|
-
|
|
111
|
-
fprintf(stderr, "%s%s: %s:%s:%s%s Assertion `%s' failed.\n",
|
|
112
|
-
exepath, pid, filename, linenum,
|
|
113
|
-
function, *function ? ":" : "", message);
|
|
114
|
-
fflush(stderr);
|
|
115
|
-
|
|
116
|
-
Abort();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static void OnFatalError(const char* location, const char* message) {
|
|
120
|
-
if (location) {
|
|
121
|
-
PrintErrorString("FATAL ERROR: %s %s\n", location, message);
|
|
122
|
-
} else {
|
|
123
|
-
PrintErrorString("FATAL ERROR: %s\n", message);
|
|
124
|
-
}
|
|
125
|
-
fflush(stderr);
|
|
126
|
-
ABORT();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
NO_RETURN void FatalError(const char* location, const char* message) {
|
|
130
|
-
OnFatalError(location, message);
|
|
131
|
-
// to suppress compiler warning
|
|
132
|
-
ABORT();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
} // namespace node
|
|
136
|
-
|
|
137
|
-
#if NODE_MAJOR_VERSION < 6
|
|
138
|
-
v8::Local<v8::Name> v8::Private::ForApi(v8::Isolate* isolate,
|
|
139
|
-
v8::Local<v8::String> key) {
|
|
140
|
-
return v8::Symbol::ForApi(isolate, key);
|
|
141
|
-
}
|
|
142
|
-
#endif // NODE_MAJOR_VERSION < 6
|
package/src/node_internals.h
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#ifndef SRC_NODE_INTERNALS_H_
|
|
2
|
-
#define SRC_NODE_INTERNALS_H_
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
// This is a stripped down shim to allow node_api.cc to build outside of the node source tree.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#include "node_version.h"
|
|
9
|
-
#include "util-inl.h"
|
|
10
|
-
#include <stdio.h>
|
|
11
|
-
#include <stdint.h>
|
|
12
|
-
#include "uv.h"
|
|
13
|
-
#include "node.h"
|
|
14
|
-
#include <string>
|
|
15
|
-
|
|
16
|
-
// Windows 8+ does not like abort() in Release mode
|
|
17
|
-
#ifdef _WIN32
|
|
18
|
-
#define ABORT_NO_BACKTRACE() raise(SIGABRT)
|
|
19
|
-
#else
|
|
20
|
-
#define ABORT_NO_BACKTRACE() abort()
|
|
21
|
-
#endif
|
|
22
|
-
|
|
23
|
-
#define ABORT() node::Abort()
|
|
24
|
-
|
|
25
|
-
#ifdef __GNUC__
|
|
26
|
-
#define LIKELY(expr) __builtin_expect(!!(expr), 1)
|
|
27
|
-
#define UNLIKELY(expr) __builtin_expect(!!(expr), 0)
|
|
28
|
-
#define PRETTY_FUNCTION_NAME __PRETTY_FUNCTION__
|
|
29
|
-
#else
|
|
30
|
-
#define LIKELY(expr) expr
|
|
31
|
-
#define UNLIKELY(expr) expr
|
|
32
|
-
#define PRETTY_FUNCTION_NAME ""
|
|
33
|
-
#endif
|
|
34
|
-
|
|
35
|
-
#define STRINGIFY_(x) #x
|
|
36
|
-
#define STRINGIFY(x) STRINGIFY_(x)
|
|
37
|
-
|
|
38
|
-
#define CHECK(expr) \
|
|
39
|
-
do { \
|
|
40
|
-
if (UNLIKELY(!(expr))) { \
|
|
41
|
-
static const char* const args[] = { __FILE__, STRINGIFY(__LINE__), \
|
|
42
|
-
#expr, PRETTY_FUNCTION_NAME }; \
|
|
43
|
-
node::Assert(&args); \
|
|
44
|
-
} \
|
|
45
|
-
} while (0)
|
|
46
|
-
|
|
47
|
-
#define CHECK_EQ(a, b) CHECK((a) == (b))
|
|
48
|
-
#define CHECK_GE(a, b) CHECK((a) >= (b))
|
|
49
|
-
#define CHECK_GT(a, b) CHECK((a) > (b))
|
|
50
|
-
#define CHECK_LE(a, b) CHECK((a) <= (b))
|
|
51
|
-
#define CHECK_LT(a, b) CHECK((a) < (b))
|
|
52
|
-
#define CHECK_NE(a, b) CHECK((a) != (b))
|
|
53
|
-
|
|
54
|
-
#ifdef __GNUC__
|
|
55
|
-
#define NO_RETURN __attribute__((noreturn))
|
|
56
|
-
#else
|
|
57
|
-
#define NO_RETURN
|
|
58
|
-
#endif
|
|
59
|
-
|
|
60
|
-
#ifndef NODE_RELEASE
|
|
61
|
-
#define NODE_RELEASE "node"
|
|
62
|
-
#endif
|
|
63
|
-
|
|
64
|
-
#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6
|
|
65
|
-
class CallbackScope {
|
|
66
|
-
public:
|
|
67
|
-
CallbackScope(void *work);
|
|
68
|
-
};
|
|
69
|
-
#endif // NODE_MAJOR_VERSION < 8
|
|
70
|
-
|
|
71
|
-
namespace node {
|
|
72
|
-
|
|
73
|
-
// Copied from Node.js' src/node_persistent.h
|
|
74
|
-
template <typename T>
|
|
75
|
-
struct ResetInDestructorPersistentTraits {
|
|
76
|
-
static const bool kResetInDestructor = true;
|
|
77
|
-
template <typename S, typename M>
|
|
78
|
-
// Disallow copy semantics by leaving this unimplemented.
|
|
79
|
-
inline static void Copy(
|
|
80
|
-
const v8::Persistent<S, M>&,
|
|
81
|
-
v8::Persistent<T, ResetInDestructorPersistentTraits<T>>*);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// v8::Persistent does not reset the object slot in its destructor. That is
|
|
85
|
-
// acknowledged as a flaw in the V8 API and expected to change in the future
|
|
86
|
-
// but for now node::Persistent is the easier and safer alternative.
|
|
87
|
-
template <typename T>
|
|
88
|
-
using Persistent = v8::Persistent<T, ResetInDestructorPersistentTraits<T>>;
|
|
89
|
-
|
|
90
|
-
#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 2
|
|
91
|
-
typedef int async_id;
|
|
92
|
-
|
|
93
|
-
typedef struct async_context {
|
|
94
|
-
node::async_id async_id;
|
|
95
|
-
node::async_id trigger_async_id;
|
|
96
|
-
} async_context;
|
|
97
|
-
#endif // NODE_MAJOR_VERSION < 8.2
|
|
98
|
-
|
|
99
|
-
#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6
|
|
100
|
-
NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
|
|
101
|
-
v8::Local<v8::Object> resource,
|
|
102
|
-
v8::Local<v8::String> name,
|
|
103
|
-
async_id trigger_async_id = -1);
|
|
104
|
-
|
|
105
|
-
NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
|
|
106
|
-
async_context asyncContext);
|
|
107
|
-
|
|
108
|
-
v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
|
|
109
|
-
v8::Local<v8::Object> recv,
|
|
110
|
-
v8::Local<v8::Function> callback,
|
|
111
|
-
int argc,
|
|
112
|
-
v8::Local<v8::Value>* argv,
|
|
113
|
-
async_context asyncContext);
|
|
114
|
-
|
|
115
|
-
#if NODE_MAJOR_VERSION < 8
|
|
116
|
-
class AsyncResource {
|
|
117
|
-
public:
|
|
118
|
-
AsyncResource(v8::Isolate* isolate,
|
|
119
|
-
v8::Local<v8::Object> object,
|
|
120
|
-
const char *name);
|
|
121
|
-
};
|
|
122
|
-
#endif // node version below 8
|
|
123
|
-
|
|
124
|
-
#endif // node version below 8.6
|
|
125
|
-
|
|
126
|
-
// The slightly odd function signature for Assert() is to ease
|
|
127
|
-
// instruction cache pressure in calls from ASSERT and CHECK.
|
|
128
|
-
NO_RETURN void Abort();
|
|
129
|
-
NO_RETURN void Assert(const char* const (*args)[4]);
|
|
130
|
-
void DumpBacktrace(FILE* fp);
|
|
131
|
-
|
|
132
|
-
template <typename T, size_t N>
|
|
133
|
-
constexpr size_t arraysize(const T(&)[N]) { return N; }
|
|
134
|
-
|
|
135
|
-
NO_RETURN void FatalError(const char* location, const char* message);
|
|
136
|
-
|
|
137
|
-
} // namespace node
|
|
138
|
-
|
|
139
|
-
#if NODE_MAJOR_VERSION < 8
|
|
140
|
-
#define NewTarget This
|
|
141
|
-
#endif // NODE_MAJOR_VERSION < 8
|
|
142
|
-
|
|
143
|
-
#if NODE_MAJOR_VERSION < 6
|
|
144
|
-
namespace v8 {
|
|
145
|
-
namespace Private {
|
|
146
|
-
v8::Local<v8::Name> ForApi(v8::Isolate* isolate, v8::Local<v8::String> key);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
#define GetPrivate(context, key) Get((context), (key))
|
|
150
|
-
#define SetPrivate(context, key, value) \
|
|
151
|
-
DefineOwnProperty((context), (key), (value), \
|
|
152
|
-
static_cast<v8::PropertyAttribute>(v8::DontEnum | \
|
|
153
|
-
v8::DontDelete | \
|
|
154
|
-
v8::ReadOnly))
|
|
155
|
-
#endif // NODE_MAJOR_VERSION < 6
|
|
156
|
-
|
|
157
|
-
#endif // SRC_NODE_INTERNALS_H_
|
package/src/util-inl.h
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#ifndef SRC_UTIL_INL_H_
|
|
2
|
-
#define SRC_UTIL_INL_H_
|
|
3
|
-
|
|
4
|
-
#include "util.h"
|
|
5
|
-
#include "v8.h"
|
|
6
|
-
|
|
7
|
-
namespace node {
|
|
8
|
-
|
|
9
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
10
|
-
const char* data,
|
|
11
|
-
int length) {
|
|
12
|
-
return v8::String::NewFromOneByte(isolate,
|
|
13
|
-
reinterpret_cast<const uint8_t*>(data),
|
|
14
|
-
v8::NewStringType::kNormal,
|
|
15
|
-
length).ToLocalChecked();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
19
|
-
const signed char* data,
|
|
20
|
-
int length) {
|
|
21
|
-
return v8::String::NewFromOneByte(isolate,
|
|
22
|
-
reinterpret_cast<const uint8_t*>(data),
|
|
23
|
-
v8::NewStringType::kNormal,
|
|
24
|
-
length).ToLocalChecked();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
|
|
28
|
-
const unsigned char* data,
|
|
29
|
-
int length) {
|
|
30
|
-
return v8::String::NewFromOneByte(isolate,
|
|
31
|
-
reinterpret_cast<const uint8_t*>(data),
|
|
32
|
-
v8::NewStringType::kNormal,
|
|
33
|
-
length).ToLocalChecked();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
} // namespace node
|
|
37
|
-
|
|
38
|
-
#endif // SRC_UTIL_INL_H_
|