Browse Source

src: update uses of deprecated NewExternal

V8 String::NewExternal is deprecated in 4.9. Migrate string_bytes.cc to
the alternatives.

PR-URL: https://github.com/nodejs/node/pull/5462
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
process-exit-stdio-flushing
Ali Ijaz Sheikh 9 years ago
committed by Ali Sheikh
parent
commit
492fbfbff8
  1. 19
      src/string_bytes.cc

19
src/string_bytes.cc

@ -77,7 +77,7 @@ class ExternString: public ResourceType {
ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate,
data,
length);
MaybeLocal<String> str = String::NewExternal(isolate, h_str);
MaybeLocal<String> 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<String> NewExternal(Isolate* isolate,
ExternString* h_str);
Isolate* isolate_;
const TypeName* data_;
size_t length_;
@ -105,6 +108,20 @@ typedef ExternString<String::ExternalStringResource,
uint16_t> ExternTwoByteString;
template <>
MaybeLocal<String> ExternOneByteString::NewExternal(
Isolate* isolate, ExternOneByteString* h_str) {
return String::NewExternalOneByte(isolate, h_str);
}
template <>
MaybeLocal<String> 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)

Loading…
Cancel
Save