Reuse and clean up JSC class ref bindings

Reviewed By: fkgozali

Differential Revision: D7893634

fbshipit-source-id: de11cb93f9f7e7c935af2da4616671043438363b
This commit is contained in:
Sebastian Markbage 2018-05-15 14:28:30 -07:00 committed by Facebook Github Bot
parent 4a2c560768
commit 6c58035ae6
1 changed files with 7 additions and 0 deletions

View File

@ -33,10 +33,15 @@ typedef struct FabricJSCUIManager {
: wrapperObjectClassRef(classRef)
, useCustomJSC(customJSC) {
fabricUiManager = make_global(module);
JSC_JSClassRetain(useCustomJSC, wrapperObjectClassRef);
}
global_ref<jobject> fabricUiManager;
JSClassRef wrapperObjectClassRef;
bool useCustomJSC;
~FabricJSCUIManager() {
JSC_JSClassRelease(useCustomJSC, wrapperObjectClassRef);
}
} FabricJSCUIManager;
jobject makePlainGlobalRef(jobject object) {
@ -283,6 +288,8 @@ void FabricJSCBinding::installFabric(jlong jsContextNativePointer,
addFabricMethod(context, fabricModule, classRef, module, "appendChildToSet", appendChildToSet);
addFabricMethod(context, fabricModule, classRef, module, "completeRoot", completeRoot);
JSC_JSClassRelease(useCustomJSC, classRef);
JSObjectRef globalObject = JSC_JSContextGetGlobalObject(context);
JSStringRef globalName = JSC_JSStringCreateWithUTF8CString(context, "nativeFabricUIManager");
JSC_JSObjectSetProperty(context, globalObject, globalName, module, kJSPropertyAttributeNone, NULL);