Fix incorrect invocation of JSClassCreate

Reviewed By: kathryngray

Differential Revision: D5465118

fbshipit-source-id: 16e1a1af52fb1ef41fa02e380223e9e90c0611ba
This commit is contained in:
Pieter De Baets 2017-07-24 04:49:37 -07:00 коммит произвёл Facebook Github Bot
Родитель db3df3400a
Коммит 543cd217f6
2 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -31,9 +31,11 @@ JSValueRef functionCaller(
JSClassRef createFuncClass(JSContextRef ctx) {
JSClassDefinition definition = kJSClassDefinitionEmpty;
definition.attributes |= kJSClassAttributeNoAutomaticPrototype;
// Need to duplicate the two different finalizer blocks, since there's no way
// for it to capture this static information.
if (isCustomJSCPtr(ctx)) {
const bool isCustomJSC = isCustomJSCPtr(ctx);
if (isCustomJSC) {
definition.finalize = [](JSObjectRef object) {
auto* function = static_cast<JSFunction*>(JSC_JSObjectGetPrivate(true, object));
delete function;
@ -46,7 +48,7 @@ JSClassRef createFuncClass(JSContextRef ctx) {
}
definition.callAsFunction = exceptionWrapMethod<&functionCaller>();
return JSC_JSClassCreate(ctx, &definition);
return JSC_JSClassCreate(isCustomJSC, &definition);
}
JSObjectRef makeFunction(

Просмотреть файл

@ -31,10 +31,12 @@
// Use for methods were access to a JSContextRef is impractical. The first bool param
// will be dropped before the JSC method is invoked.
#define __jsc_bool_wrapper(method, useCustomJSC, ...) \
(useCustomJSC ? \
facebook::react::customJSCWrapper() : \
facebook::react::systemJSCWrapper() \
#define __jsc_ensure_bool(field) \
static_assert(std::is_same<typename std::decay<decltype(field)>::type, bool>::value, "useCustomJSC must be bool");
#define __jsc_bool_wrapper(method, useCustomJSC, ...) \
([]{ __jsc_ensure_bool(useCustomJSC) }, useCustomJSC ? \
facebook::react::customJSCWrapper() : \
facebook::react::systemJSCWrapper() \
)->method(__VA_ARGS__)
// Used for wrapping properties