Skip to content

Commit 4011c96

Browse files
committed
Add new node shims
* Added `util.h` and `util-inl.h` for incoming changes to error helpers
1 parent 4686a4a commit 4011c96

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/node_internals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// This is a stripped down shim to allow node_api.cc to build outside of the node source tree.
66
//
77

8+
#include "util-inl.h"
89
#include <stdio.h>
910

1011
// Windows 8+ does not like abort() in Release mode

src/util-inl.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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_

src/util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef SRC_UTIL_H_
2+
#define SRC_UTIL_H_
3+
4+
#define FIXED_ONE_BYTE_STRING(isolate, string) \
5+
(node::OneByteString((isolate), (string), sizeof(string) - 1))
6+
7+
#endif // SRC_UTIL_H_

0 commit comments

Comments
 (0)