Permalink
Browse files

Fix incorrect invocation of JSClassCreate

Reviewed By: kathryngray

Differential Revision: D5465118

fbshipit-source-id: 16e1a1af52fb1ef41fa02e380223e9e90c0611ba
  • Loading branch information...
javache authored and facebook-github-bot committed Jul 24, 2017
1 parent db3df34 commit 543cd217f633003b3cf1f388ffdbb31116f664a4
Showing with 10 additions and 6 deletions.
  1. +4 −2 ReactCommon/jschelpers/JSCHelpers.cpp
  2. +6 −4 ReactCommon/jschelpers/JavaScriptCore.h
@@ -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

0 comments on commit 543cd21

Please sign in to comment.