Skip to content

Commit 530f14c

Browse files
committed
Merge ../working/mysql-js
Conflicts: jones-ndb/impl/src/common/async_common.cpp
2 parents 378d940 + e0ace18 commit 530f14c

File tree

7 files changed

+33
-20
lines changed

7 files changed

+33
-20
lines changed

jones-ndb/impl/include/common/JsWrapper.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ using v8::PropertyCallbackInfo;
4141
using v8::WeakCallbackData;
4242

4343
/* A Persistent<T> can be cast to a Local<T>. See:
44-
https://groups.google.com/forum/#!msg/v8-users/6kSAbnUb-rQ/9G5RmCpsDIMJ
44+
https://groups.google.com/forum/#!msg/v8-users/6kSAbnUb-rQ/9G5RmCpsDIMJ.
45+
At some point this can be replaced by persisent.Get(isolate)
4546
*/
4647
template<class T>
4748
inline Local<T> ToLocal(Persistent<T>* p_) {
@@ -53,6 +54,16 @@ inline Local<T> ToLocal(const Persistent<T>* p_) {
5354
return *reinterpret_cast<const Local<T>*>(p_);
5455
}
5556

57+
/* Some compatibility */
58+
#if NODE_MAJOR_VERSION > 3
59+
#define BUFFER_HANDLE v8::MaybeLocal
60+
#define LOCAL_BUFFER(B) B.ToLocalChecked()
61+
#define IsExternalAscii IsExternalOneByte
62+
#else
63+
#define BUFFER_HANDLE v8::Local
64+
#define LOCAL_BUFFER(B) B
65+
#endif
66+
5667
/* Signature of a V8 function wrapper
5768
*/
5869
typedef FunctionCallbackInfo<Value> Arguments;

jones-ndb/impl/include/ndb/BlobHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BlobReadHandler : public BlobHandler {
4949
BlobReadHandler(int columnId, int fieldNumber);
5050
void prepare(const NdbOperation *);
5151
int runActiveHook(NdbBlob *);
52-
v8::Local<v8::Object> getResultBuffer();
52+
v8::Local<v8::Object> getResultBuffer(v8::Isolate *);
5353
};
5454

5555

jones-ndb/impl/src/ndb/BlobHandler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "adapter_global.h"
2828
#include "unified_debug.h"
2929
#include "BlobHandler.h"
30+
#include "JsWrapper.h"
3031

3132

3233
// BlobHandler constructor
@@ -81,10 +82,10 @@ int BlobReadHandler::runActiveHook(NdbBlob *b) {
8182
return 0;
8283
}
8384

84-
v8::Local<v8::Object> BlobReadHandler::getResultBuffer() {
85+
v8::Local<v8::Object> BlobReadHandler::getResultBuffer(v8::Isolate * iso) {
8586
v8::Local<v8::Object> buffer;
8687
if(content) {
87-
buffer = node::Buffer::New(content, length, freeBufferContentsFromJs, 0);
88+
buffer = LOCAL_BUFFER(node::Buffer::New(iso, content, length, freeBufferContentsFromJs, 0));
8889
/* Content belongs to someone else now; clear it for the next user */
8990
content = 0;
9091
length = 0;

jones-ndb/impl/src/ndb/DBDictionaryImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ Local<Value> getDefaultValue(v8::Isolate *isolate, const NdbDictionary::Column *
805805

806806
const void* dictDefaultBuff = col->getDefaultValue(& defaultLen);
807807
if(defaultLen) {
808-
v = node::Buffer::New((char *) dictDefaultBuff, defaultLen);
808+
v = LOCAL_BUFFER(node::Buffer::New(isolate, (char *) dictDefaultBuff, defaultLen));
809809
}
810810
return v;
811811
}

jones-ndb/impl/src/ndb/KeyOperation.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,17 @@ int KeyOperation::createBlobWriteHandles(Handle<Object> blobsArray,
152152

153153
void KeyOperation::readBlobResults(const Arguments & args) {
154154
DEBUG_MARKER(UDEB_DEBUG);
155-
EscapableHandleScope scope(args.GetIsolate());
155+
v8::Isolate * isolate = args.GetIsolate();
156+
EscapableHandleScope scope(isolate);
156157

157158
args.GetReturnValue().SetUndefined();
158159
if(isBlobReadOperation()) {
159-
Local<Object> results = Array::New(args.GetIsolate());
160+
Local<Object> results = Array::New(isolate);
160161
BlobReadHandler * readHandler = static_cast<BlobReadHandler *>(blobHandler);
161162
while(readHandler) {
162-
Local<Value> buffer = readHandler->getResultBuffer();
163+
Local<Value> buffer = readHandler->getResultBuffer(isolate);
163164
if(buffer.IsEmpty()) {
164-
buffer = Null(args.GetIsolate());
165+
buffer = Null(isolate);
165166
}
166167
results->ToObject()->Set(readHandler->getFieldNumber(), buffer);
167168
readHandler = static_cast<BlobReadHandler *>(readHandler->getNext());

jones-ndb/impl/src/ndb/NdbTypeEncoders.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ Local<Value> fpWriter(const NdbDictionary::Column * col,
731731

732732
Local<Value> BinaryReader(const NdbDictionary::Column *col,
733733
char *buffer, size_t offset) {
734-
return node::Buffer::New(isolate, buffer + offset, col->getLength());
734+
return LOCAL_BUFFER(node::Buffer::New(isolate, buffer + offset, col->getLength()));
735735
}
736736

737737
Local<Value> BinaryWriter(const NdbDictionary::Column * col,
@@ -755,7 +755,7 @@ Local<Value> varbinaryReader(const NdbDictionary::Column *col,
755755
char *buffer, size_t offset) {
756756
LOAD_ALIGNED_DATA(LENGTHTYPE, length, buffer+offset);
757757
char * data = buffer+offset+sizeof(length);
758-
return node::Buffer::New(isolate, data, length);
758+
return LOCAL_BUFFER(node::Buffer::New(isolate, data, length));
759759
}
760760

761761
template<typename LENGTHTYPE>
@@ -804,7 +804,7 @@ inline bool stringIsAscii(const unsigned char *str, size_t len) {
804804
return true;
805805
}
806806

807-
class ExternalizedAsciiString : public String::ExternalAsciiStringResource {
807+
class ExternalizedAsciiString : public String::ExternalOneByteStringResource {
808808
public:
809809
char * buffer;
810810
size_t len;
@@ -990,7 +990,7 @@ Local<Object> getBufferForText(const NdbDictionary::Column *col,
990990
{
991991
DEBUG_PRINT("getBufferForText: fully externalized");
992992
stats.externalized_text_writes++;
993-
return node::Buffer::New(isolate, str);
993+
return LOCAL_BUFFER(node::Buffer::New(isolate, str));
994994
}
995995

996996
length = str->Length();
@@ -1000,17 +1000,17 @@ Local<Object> getBufferForText(const NdbDictionary::Column *col,
10001000

10011001
if(csinfo->isAscii || (valueIsAscii && ! csinfo->isMultibyte)) {
10021002
stats.direct_writes++;
1003-
buffer = node::Buffer::New(isolate, length);
1003+
buffer = LOCAL_BUFFER(node::Buffer::New(isolate, length));
10041004
data = node::Buffer::Data(buffer);
10051005
str->WriteOneByte((uint8_t*) data, 0, length);
10061006
} else if(csinfo->isUtf16le) {
10071007
stats.direct_writes++;
1008-
buffer = node::Buffer::New(isolate, length * 2);
1008+
buffer = LOCAL_BUFFER(node::Buffer::New(isolate, length * 2));
10091009
uint16_t * mbdata = (uint16_t*) node::Buffer::Data(buffer);
10101010
str->Write(mbdata, 0, length);
10111011
} else if(csinfo->isUtf8) {
10121012
stats.direct_writes++;
1013-
buffer = node::Buffer::New(isolate, utf8Length);
1013+
buffer = LOCAL_BUFFER(node::Buffer::New(isolate, utf8Length));
10141014
data = node::Buffer::Data(buffer);
10151015
str->WriteUtf8(data, utf8Length);
10161016
} else {
@@ -1022,7 +1022,7 @@ Local<Object> getBufferForText(const NdbDictionary::Column *col,
10221022
data = (char *) malloc(buflen);
10231023
size_t result_len = recodeFromUtf8(recode_buffer, utf8Length,
10241024
data, buflen, col->getCharsetNumber());
1025-
buffer = node::Buffer::New(isolate, data, result_len, freeBufferContentsFromJs, 0);
1025+
buffer = LOCAL_BUFFER(node::Buffer::New(isolate, data, result_len, freeBufferContentsFromJs, 0));
10261026
delete[] recode_buffer;
10271027
}
10281028

jones-ndb/impl/src/ndb/QueryOperation_wrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ void queryGetResult(const Arguments & args) {
288288
if(header) {
289289
if(header->data) {
290290
wrapper->Set(GET_KEY(K_data),
291-
node::Buffer::New(header->data,
292-
op->getResultRowSize(header->depth),
293-
doNotFreeQueryResultAtGC, 0));
291+
LOCAL_BUFFER(node::Buffer::New(isolate, header->data,
292+
op->getResultRowSize(header->depth),
293+
doNotFreeQueryResultAtGC, 0)));
294294
} else {
295295
wrapper->Set(GET_KEY(K_data), Null(isolate));
296296
}

0 commit comments

Comments
 (0)