-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added `util.h` and `util-inl.h` for incoming changes to error helpers
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef SRC_UTIL_INL_H_ | ||
#define SRC_UTIL_INL_H_ | ||
|
||
#include "util.h" | ||
#include "v8.h" | ||
|
||
namespace node { | ||
|
||
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | ||
const char* data, | ||
int length) { | ||
return v8::String::NewFromOneByte(isolate, | ||
reinterpret_cast<const uint8_t*>(data), | ||
v8::NewStringType::kNormal, | ||
length).ToLocalChecked(); | ||
} | ||
|
||
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | ||
const signed char* data, | ||
int length) { | ||
return v8::String::NewFromOneByte(isolate, | ||
reinterpret_cast<const uint8_t*>(data), | ||
v8::NewStringType::kNormal, | ||
length).ToLocalChecked(); | ||
} | ||
|
||
inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | ||
const unsigned char* data, | ||
int length) { | ||
return v8::String::NewFromOneByte(isolate, | ||
reinterpret_cast<const uint8_t*>(data), | ||
v8::NewStringType::kNormal, | ||
length).ToLocalChecked(); | ||
} | ||
|
||
} // namespace node | ||
|
||
#endif // SRC_UTIL_INL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef SRC_UTIL_H_ | ||
#define SRC_UTIL_H_ | ||
|
||
#define FIXED_ONE_BYTE_STRING(isolate, string) \ | ||
(node::OneByteString((isolate), (string), sizeof(string) - 1)) | ||
|
||
#endif // SRC_UTIL_H_ |