From 0d873f963da9a18844bce8a11dda5ea907b06465 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Thu, 14 Feb 2008 21:01:30 +0100 Subject: Objective-C layer: Revamp the ObjectiveCLWrapperLink category. darcs-hash:7e73acd87a97630ee76587a52e9bb3303940371f --- Objective-C/NSObject-ObjectiveCLWrapperLink.h | 12 ++------- Objective-C/NSObject-ObjectiveCLWrapperLink.m | 39 ++++++++++----------------- 2 files changed, 16 insertions(+), 35 deletions(-) (limited to 'Objective-C') diff --git a/Objective-C/NSObject-ObjectiveCLWrapperLink.h b/Objective-C/NSObject-ObjectiveCLWrapperLink.h index 9bdf902..691c6fc 100644 --- a/Objective-C/NSObject-ObjectiveCLWrapperLink.h +++ b/Objective-C/NSObject-ObjectiveCLWrapperLink.h @@ -9,14 +9,6 @@ void objcl_shutdown_instance_wrappers (void); @interface NSObject (ObjectiveCLWrapperLink) --(const char *) __objectiveCLWrapperID; --(void) __setObjectiveCLWrapperID: (const char *)wrapper_id; --(void) __removeObjectiveCLWrapperID; - -/* Classes can't be wrapped at the moment. */ -/* -+(const char *) __objectiveCLWrapperID; -+(const char *) __setObjectiveCLWrapperID: (const char *)wrapper_id; -+(const char *) __removeObjectiveCLWrapperID; -*/ +-(BOOL) __objcl_isBackedByLispInstance; +-(void) __objcl_setBackedByLispInstance: (BOOL)backed_p; @end /* NSObject (ObjectiveCL) */ diff --git a/Objective-C/NSObject-ObjectiveCLWrapperLink.m b/Objective-C/NSObject-ObjectiveCLWrapperLink.m index 8677ef3..665d302 100644 --- a/Objective-C/NSObject-ObjectiveCLWrapperLink.m +++ b/Objective-C/NSObject-ObjectiveCLWrapperLink.m @@ -1,51 +1,40 @@ /* -*- mode: objc; coding: utf-8 -*- */ #import "NSObject-ObjectiveCLWrapperLink.h" -#import +#import #import #import -#ifndef NULL -#define NULL (void *)0 -#endif - -static NSMutableDictionary *instance_wrappers = NULL; +static NSMutableSet *lisp_backed_objects = nil; void objcl_initialise_instance_wrappers (void) { - if (!instance_wrappers) - instance_wrappers = [[NSMutableDictionary alloc] init]; + if (lisp_backed_objects == nil) + lisp_backed_objects = [[NSMutableSet alloc] init]; } void objcl_shutdown_instance_wrappers (void) { - if (instance_wrappers) + if (lisp_backed_objects != nil) { - [instance_wrappers release]; - instance_wrappers = NULL; + [lisp_backed_objects release]; + lisp_backed_objects = nil; } } @implementation NSObject (ObjectiveCLWrapperLink) --(const char *) __objectiveCLWrapperID -{ - NSString *string = [instance_wrappers objectForKey: self]; - if (string != nil) - return [string UTF8String]; - else - return NULL; -} - --(void) __setObjectiveCLWrapperID: (const char *)wrapper_id +-(BOOL) __objcl_isBackedByLispInstance { - [instance_wrappers setObject: [NSString stringWithUTF8String: wrapper_id] - forKey: self]; + return [lisp_backed_objects containsObject: self]; } --(void) __removeObjectiveCLWrapperID +-(void) __objcl_setBackedByLispInstance: (BOOL)backed_p { - [instance_wrappers removeObjectForKey: self]; + if (backed_p) + [lisp_backed_objects addObject: self]; + else + [lisp_backed_objects removeObject: self]; } @end /* NSObject (ObjectiveCL) */ -- cgit v1.2.3