From 54e3490b89ee1cc882d7c308ea65f023d374e482 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 9 Jun 2012 18:46:44 -0700 Subject: [PATCH 1/1] Use JSGlobalContextRef for context_; retain/release. --- ObjectiveC/Library.mm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index 377af6d..e7ed92d 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -567,7 +567,7 @@ NSObject *NSCFType$cy$toJSON(id self, SEL sel, NSString *key) { /* Bridge: CYJSObject {{{ */ @interface CYJSObject : NSMutableDictionary { JSObjectRef object_; - JSContextRef context_; + JSGlobalContextRef context_; } - (id) initWithJSObject:(JSObjectRef)object inContext:(JSContextRef)context; @@ -585,7 +585,7 @@ NSObject *NSCFType$cy$toJSON(id self, SEL sel, NSString *key) { /* Bridge: CYJSArray {{{ */ @interface CYJSArray : NSMutableArray { JSObjectRef object_; - JSContextRef context_; + JSGlobalContextRef context_; } - (id) initWithJSObject:(JSObjectRef)object inContext:(JSContextRef)context; @@ -1173,14 +1173,14 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry { if ((self = [super init]) != nil) { object_ = object; context_ = CYGetJSContext(context); - //XXX:JSGlobalContextRetain(context_); + JSGlobalContextRetain(context_); JSValueProtect(context_, object_); } return self; } CYObjectiveCatch } - (void) dealloc { CYObjectiveTry { JSValueUnprotect(context_, object_); - //XXX:JSGlobalContextRelease(context_); + JSGlobalContextRelease(context_); [super dealloc]; } CYObjectiveCatch } @@ -1251,14 +1251,14 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry { if ((self = [super init]) != nil) { object_ = object; context_ = CYGetJSContext(context); - //XXX:JSGlobalContextRetain(context_); + JSGlobalContextRetain(context_); JSValueProtect(context_, object_); } return self; } CYObjectiveCatch } - (void) dealloc { CYObjectiveTry { JSValueUnprotect(context_, object_); - //XXX:JSGlobalContextRelease(context_); + JSGlobalContextRelease(context_); [super dealloc]; } CYObjectiveCatch } @@ -1325,7 +1325,7 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry { // XXX: inherit from or replace with CYJSObject @interface CYInternal : NSObject { - JSContextRef context_; + JSGlobalContextRef context_; JSObjectRef object_; } @@ -1335,14 +1335,14 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry { - (void) dealloc { JSValueUnprotect(context_, object_); - //XXX:JSGlobalContextRelease(context_); + JSGlobalContextRelease(context_); [super dealloc]; } - (id) initInContext:(JSContextRef)context { if ((self = [super init]) != nil) { context_ = CYGetJSContext(context); - //XXX:JSGlobalContextRetain(context_); + JSGlobalContextRetain(context_); } return self; } -- 2.45.2