diff --git a/src/string_bytes.cc b/src/string_bytes.cc index d9ca6e565e..a2e4fe388a 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -77,7 +77,7 @@ class ExternString: public ResourceType { ExternString* h_str = new ExternString(isolate, data, length); - MaybeLocal str = String::NewExternal(isolate, h_str); + MaybeLocal str = NewExternal(isolate, h_str); isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); if (str.IsEmpty()) { @@ -93,6 +93,9 @@ class ExternString: public ResourceType { private: ExternString(Isolate* isolate, const TypeName* data, size_t length) : isolate_(isolate), data_(data), length_(length) { } + static MaybeLocal NewExternal(Isolate* isolate, + ExternString* h_str); + Isolate* isolate_; const TypeName* data_; size_t length_; @@ -105,6 +108,20 @@ typedef ExternString ExternTwoByteString; +template <> +MaybeLocal ExternOneByteString::NewExternal( + Isolate* isolate, ExternOneByteString* h_str) { + return String::NewExternalOneByte(isolate, h_str); +} + + +template <> +MaybeLocal ExternTwoByteString::NewExternal( + Isolate* isolate, ExternTwoByteString* h_str) { + return String::NewExternalTwoByte(isolate, h_str); +} + + //// Base 64 //// #define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)