summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Objective-C/NSObject-ObjectiveCLWrapperLink.h4
-rw-r--r--Objective-C/NSObject-ObjectiveCLWrapperLink.m30
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) */