summaryrefslogtreecommitdiff
path: root/src/node_union_bytes.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-03 00:49:12 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-12-11 06:40:09 +0800
commit44a5fe145759a2fa43247da2f40a55df23572944 (patch)
tree74c346b396e14f5da4fbc85d4a48bd974b2a3432 /src/node_union_bytes.h
parent9fb4fa8ded0504f63c89ed969640e5a2df8d0d59 (diff)
downloadandroid-node-v8-44a5fe145759a2fa43247da2f40a55df23572944.tar.gz
android-node-v8-44a5fe145759a2fa43247da2f40a55df23572944.tar.bz2
android-node-v8-44a5fe145759a2fa43247da2f40a55df23572944.zip
process: specialize building and storage of process.config
Instead of treating config.gypi as a JavaScript file, specialize the processing in js2c and make the serialized result a real JSON string (with 'true' and 'false' converted to boolean values) so we don't have to use a custom deserializer during bootstrap. In addition, store the JSON string separately in NativeModuleLoader, and keep it separate from the map of the builtin source code, so we don't have to put it onto `NativeModule._source` and delete it later, though we still preserve it in `process.binding('natives')`, which we don't use anymore. This patch also makes the map of builtin source code and the config.gypi string available through side-effect-free getters in C++. PR-URL: https://github.com/nodejs/node/pull/24816 Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'src/node_union_bytes.h')
-rw-r--r--src/node_union_bytes.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node_union_bytes.h b/src/node_union_bytes.h
index 128bb11ed0..66d8509bea 100644
--- a/src/node_union_bytes.h
+++ b/src/node_union_bytes.h
@@ -55,21 +55,31 @@ class UnionBytes {
: is_one_byte_(false), two_bytes_(data), length_(length) {}
UnionBytes(const uint8_t* data, size_t length)
: is_one_byte_(true), one_bytes_(data), length_(length) {}
+
+ UnionBytes(const UnionBytes&) = default;
+ UnionBytes& operator=(const UnionBytes&) = default;
+ UnionBytes(UnionBytes&&) = default;
+ UnionBytes& operator=(UnionBytes&&) = default;
+
bool is_one_byte() const { return is_one_byte_; }
const uint16_t* two_bytes_data() const {
CHECK(!is_one_byte_);
+ CHECK_NE(two_bytes_, nullptr);
return two_bytes_;
}
const uint8_t* one_bytes_data() const {
CHECK(is_one_byte_);
+ CHECK_NE(one_bytes_, nullptr);
return one_bytes_;
}
v8::Local<v8::String> ToStringChecked(v8::Isolate* isolate) const {
if (is_one_byte_) {
+ CHECK_NE(one_bytes_, nullptr);
NonOwningExternalOneByteResource* source =
new NonOwningExternalOneByteResource(one_bytes_, length_);
return v8::String::NewExternalOneByte(isolate, source).ToLocalChecked();
} else {
+ CHECK_NE(two_bytes_, nullptr);
NonOwningExternalTwoByteResource* source =
new NonOwningExternalTwoByteResource(two_bytes_, length_);
return v8::String::NewExternalTwoByte(isolate, source).ToLocalChecked();