Skip to content

Commit

Permalink
src: update uses of deprecated NewExternal
Browse files Browse the repository at this point in the history
V8 String::NewExternal is deprecated in 4.9. Migrate string_bytes.cc to
the alternatives.

PR-URL: nodejs#5462
Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
  • Loading branch information
ofrobots committed Mar 1, 2016
1 parent ea8ade9 commit 9e1c4e3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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_;
Expand All @@ -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)
Expand Down

0 comments on commit 9e1c4e3

Please sign in to comment.