Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: update uses of deprecated NewExternal
V8 String::NewExternal is deprecated in 4.9. Migrate string_bytes.cc to
the alternatives.
  • Loading branch information
ofrobots committed Feb 26, 2016
commit eb215ccb40265043d3a1f8d0cbc2232108241957
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