Skip to content

Commit 3a41c66

Browse files
committed
jones-ndb: Adapt SetAccessor() in NdbTypeEncoders to newer V8 API
The DEFINE_JS_ACCESSOR macro in js_wrapper_macros.h should now use the Maybe<bool> version of v8::Object::SetAccessor()
1 parent cbe61e9 commit 3a41c66

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,22 @@
8080
#define DEFINE_JS_FUNCTION(TARGET, NAME, FN) \
8181
TARGET->Set(NEW_SYMBOL(NAME), NEW_FN_TEMPLATE(FN)->GetFunction())
8282

83-
#define DEFINE_JS_ACCESSOR(TARGET, property, getter) \
84-
(TARGET)->SetAccessor(NEW_SYMBOL(property), getter)
8583

8684
/* Some compatibility */
8785
#if NODE_MAJOR_VERSION > 3
86+
#define V8_PROPERTY_NAME_T Local<Name>
87+
#define DEFINE_JS_ACCESSOR(isolate, TARGET, property, getter) \
88+
(TARGET)->SetAccessor((target)->CreationContext(), \
89+
SYMBOL(isolate, property), \
90+
getter).IsJust()
8891
#define SET_PROPERTY(target, symbol, value, flags) \
8992
(target)->DefineOwnProperty((target)->CreationContext(), \
9093
symbol, value, static_cast<v8::PropertyAttribute>\
9194
(flags)).IsJust()
9295
#else
96+
#define V8_PROPERTY_NAME_T Local<String>
97+
#define DEFINE_JS_ACCESSOR(isolate, TARGET, property, getter) \
98+
(TARGET)->SetAccessor(SYMBOL(isolate, property), getter)
9399
#define SET_RO_PROPERTY(target, symbol, value, flags) \
94100
(target)->ForceSet(symbol, value, static_cast<v8::PropertyAttribute>(flags));
95101
#endif

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

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -225,27 +225,27 @@ struct encoder_stats_t {
225225

226226
/* Exports to JavaScript
227227
*/
228-
void GET_read_strings_externalized(Local<String>, const AccessorInfo & info) {
228+
void GET_read_strings_externalized(V8_PROPERTY_NAME_T, const AccessorInfo & info) {
229229
info.GetReturnValue().Set(stats.read_strings_externalized);
230230
}
231231

232-
void GET_read_strings_created(Local<String>, const AccessorInfo & info) {
232+
void GET_read_strings_created(V8_PROPERTY_NAME_T, const AccessorInfo & info) {
233233
info.GetReturnValue().Set(stats.read_strings_created);
234234
}
235235

236-
void GET_read_strings_recoded(Local<String>, const AccessorInfo & info) {
236+
void GET_read_strings_recoded(V8_PROPERTY_NAME_T, const AccessorInfo & info) {
237237
info.GetReturnValue().Set(stats.read_strings_recoded);
238238
}
239239

240-
void GET_externalized_text_writes(Local<String>, const AccessorInfo & info){
240+
void GET_externalized_text_writes(V8_PROPERTY_NAME_T, const AccessorInfo & info){
241241
info.GetReturnValue().Set(stats.externalized_text_writes);
242242
}
243243

244-
void GET_direct_writes(Local<String>, const AccessorInfo & info) {
244+
void GET_direct_writes(V8_PROPERTY_NAME_T, const AccessorInfo & info) {
245245
info.GetReturnValue().Set(stats.direct_writes);
246246
}
247247

248-
void GET_recode_writes(Local<String>, const AccessorInfo & info) {
248+
void GET_recode_writes(V8_PROPERTY_NAME_T, const AccessorInfo & info) {
249249
info.GetReturnValue().Set(stats.recode_writes);
250250
}
251251

@@ -280,13 +280,16 @@ void NdbTypeEncoders_initOnLoad(Handle<Object> target) {
280280

281281
Local<Object> s = Object::New(isolate);
282282
target->Set(NEW_SYMBOL("encoder_stats"), s);
283-
DEFINE_JS_ACCESSOR(s, "read_strings_externalized",
283+
DEFINE_JS_ACCESSOR(isolate, s, "read_strings_externalized",
284284
GET_read_strings_externalized);
285-
DEFINE_JS_ACCESSOR(s, "read_strings_created", GET_read_strings_created);
286-
DEFINE_JS_ACCESSOR(s, "read_strings_recoded", GET_read_strings_recoded);
287-
DEFINE_JS_ACCESSOR(s, "externalized_text_writes", GET_externalized_text_writes);
288-
DEFINE_JS_ACCESSOR(s, "direct_writes", GET_direct_writes);
289-
DEFINE_JS_ACCESSOR(s, "recode_writes", GET_recode_writes);
285+
DEFINE_JS_ACCESSOR(isolate, s, "read_strings_created",
286+
GET_read_strings_created);
287+
DEFINE_JS_ACCESSOR(isolate, s, "read_strings_recoded",
288+
GET_read_strings_recoded);
289+
DEFINE_JS_ACCESSOR(isolate, s, "externalized_text_writes",
290+
GET_externalized_text_writes);
291+
DEFINE_JS_ACCESSOR(isolate, s, "direct_writes", GET_direct_writes);
292+
DEFINE_JS_ACCESSOR(isolate, s, "recode_writes", GET_recode_writes);
290293
}
291294

292295

0 commit comments

Comments
 (0)