Fix incorrect invocation of JSClassCreate
Reviewed By: kathryngray Differential Revision: D5465118 fbshipit-source-id: 16e1a1af52fb1ef41fa02e380223e9e90c0611ba
This commit is contained in:
Родитель
db3df3400a
Коммит
543cd217f6
|
@ -31,9 +31,11 @@ JSValueRef functionCaller(
|
||||||
JSClassRef createFuncClass(JSContextRef ctx) {
|
JSClassRef createFuncClass(JSContextRef ctx) {
|
||||||
JSClassDefinition definition = kJSClassDefinitionEmpty;
|
JSClassDefinition definition = kJSClassDefinitionEmpty;
|
||||||
definition.attributes |= kJSClassAttributeNoAutomaticPrototype;
|
definition.attributes |= kJSClassAttributeNoAutomaticPrototype;
|
||||||
|
|
||||||
// Need to duplicate the two different finalizer blocks, since there's no way
|
// Need to duplicate the two different finalizer blocks, since there's no way
|
||||||
// for it to capture this static information.
|
// for it to capture this static information.
|
||||||
if (isCustomJSCPtr(ctx)) {
|
const bool isCustomJSC = isCustomJSCPtr(ctx);
|
||||||
|
if (isCustomJSC) {
|
||||||
definition.finalize = [](JSObjectRef object) {
|
definition.finalize = [](JSObjectRef object) {
|
||||||
auto* function = static_cast<JSFunction*>(JSC_JSObjectGetPrivate(true, object));
|
auto* function = static_cast<JSFunction*>(JSC_JSObjectGetPrivate(true, object));
|
||||||
delete function;
|
delete function;
|
||||||
|
@ -46,7 +48,7 @@ JSClassRef createFuncClass(JSContextRef ctx) {
|
||||||
}
|
}
|
||||||
definition.callAsFunction = exceptionWrapMethod<&functionCaller>();
|
definition.callAsFunction = exceptionWrapMethod<&functionCaller>();
|
||||||
|
|
||||||
return JSC_JSClassCreate(ctx, &definition);
|
return JSC_JSClassCreate(isCustomJSC, &definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObjectRef makeFunction(
|
JSObjectRef makeFunction(
|
||||||
|
|
|
@ -31,10 +31,12 @@
|
||||||
|
|
||||||
// Use for methods were access to a JSContextRef is impractical. The first bool param
|
// Use for methods were access to a JSContextRef is impractical. The first bool param
|
||||||
// will be dropped before the JSC method is invoked.
|
// will be dropped before the JSC method is invoked.
|
||||||
#define __jsc_bool_wrapper(method, useCustomJSC, ...) \
|
#define __jsc_ensure_bool(field) \
|
||||||
(useCustomJSC ? \
|
static_assert(std::is_same<typename std::decay<decltype(field)>::type, bool>::value, "useCustomJSC must be bool");
|
||||||
facebook::react::customJSCWrapper() : \
|
#define __jsc_bool_wrapper(method, useCustomJSC, ...) \
|
||||||
facebook::react::systemJSCWrapper() \
|
([]{ __jsc_ensure_bool(useCustomJSC) }, useCustomJSC ? \
|
||||||
|
facebook::react::customJSCWrapper() : \
|
||||||
|
facebook::react::systemJSCWrapper() \
|
||||||
)->method(__VA_ARGS__)
|
)->method(__VA_ARGS__)
|
||||||
|
|
||||||
// Used for wrapping properties
|
// Used for wrapping properties
|
||||||
|
|
Загрузка…
Ссылка в новой задаче