diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-14 21:42:48 +0100 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-14 21:42:48 +0100 |
commit | b2c371b10aff7125ae5cbfd83ba643e77b1bfb87 (patch) | |
tree | c9b8f4ef33ca754e1a155429d64d19fd33c0231a | |
parent | b3b8aeba34e58c0fd720018222d54e15ef2d5b9a (diff) |
Objective-C layer: Track Lisp backing status by class instead of by instance.
darcs-hash:0094d958feb2fd5e1715f953f6a67249850f095c
-rw-r--r-- | Objective-C/NSObject-ObjectiveCLWrapperLink.h | 4 | ||||
-rw-r--r-- | Objective-C/NSObject-ObjectiveCLWrapperLink.m | 30 |
2 files changed, 21 insertions, 13 deletions
diff --git a/Objective-C/NSObject-ObjectiveCLWrapperLink.h b/Objective-C/NSObject-ObjectiveCLWrapperLink.h index 691c6fc..4c4cc4c 100644 --- a/Objective-C/NSObject-ObjectiveCLWrapperLink.h +++ b/Objective-C/NSObject-ObjectiveCLWrapperLink.h @@ -9,6 +9,6 @@ void objcl_shutdown_instance_wrappers (void); @interface NSObject (ObjectiveCLWrapperLink) --(BOOL) __objcl_isBackedByLispInstance; --(void) __objcl_setBackedByLispInstance: (BOOL)backed_p; ++(BOOL) __objcl_isBackedByLispClass; ++(void) __objcl_setBackedByLispClass: (BOOL)backed_p; @end /* NSObject (ObjectiveCL) */ diff --git a/Objective-C/NSObject-ObjectiveCLWrapperLink.m b/Objective-C/NSObject-ObjectiveCLWrapperLink.m index 665d302..8d34a19 100644 --- a/Objective-C/NSObject-ObjectiveCLWrapperLink.m +++ b/Objective-C/NSObject-ObjectiveCLWrapperLink.m @@ -5,36 +5,44 @@ #import <Foundation/NSObject.h> #import <Foundation/NSString.h> -static NSMutableSet *lisp_backed_objects = nil; +/* A class is considered Lisp-backed if some of its methods are + implemented as Lisp callbacks. This is true if and only if + @selector(retain) and @selector(release) are overridden by + Objective-CL. In this case, the corresponding Lisp objects are + stored in a regular hash table instead of a weak one, as they may + hold data (like CLOS slots) that we can't do without as long as the + Objective-C instance is referenced from anywhere (where `anywhere' + includes both the Lisp and Objective-C worlds). */ +static NSMutableSet *lisp_backed_classes = nil; void objcl_initialise_instance_wrappers (void) { - if (lisp_backed_objects == nil) - lisp_backed_objects = [[NSMutableSet alloc] init]; + if (lisp_backed_classes == nil) + lisp_backed_classes = [[NSMutableSet alloc] init]; } void objcl_shutdown_instance_wrappers (void) { - if (lisp_backed_objects != nil) + if (lisp_backed_classes != nil) { - [lisp_backed_objects release]; - lisp_backed_objects = nil; + [lisp_backed_classes release]; + lisp_backed_classes = nil; } } @implementation NSObject (ObjectiveCLWrapperLink) --(BOOL) __objcl_isBackedByLispInstance ++(BOOL) __objcl_isBackedByLispClass { - return [lisp_backed_objects containsObject: self]; + return [lisp_backed_classes containsObject: self]; } --(void) __objcl_setBackedByLispInstance: (BOOL)backed_p ++(void) __objcl_setBackedByLispClass: (BOOL)backed_p { if (backed_p) - [lisp_backed_objects addObject: self]; + [lisp_backed_classes addObject: self]; else - [lisp_backed_objects removeObject: self]; + [lisp_backed_classes removeObject: self]; } @end /* NSObject (ObjectiveCL) */ |