diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-14 21:01:30 +0100 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2008-02-14 21:01:30 +0100 |
commit | 0d873f963da9a18844bce8a11dda5ea907b06465 (patch) | |
tree | cb3e3a732e94142cc96ae9192a83ff39ddf5793e /Objective-C | |
parent | 308b848cc4e6630356d84fc43530739a72374130 (diff) |
Objective-C layer: Revamp the ObjectiveCLWrapperLink category.
darcs-hash:7e73acd87a97630ee76587a52e9bb3303940371f
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/NSObject-ObjectiveCLWrapperLink.h | 12 | ||||
-rw-r--r-- | Objective-C/NSObject-ObjectiveCLWrapperLink.m | 39 |
2 files changed, 16 insertions, 35 deletions
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 <Foundation/NSDictionary.h> +#import <Foundation/NSSet.h> #import <Foundation/NSObject.h> #import <Foundation/NSString.h> -#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) */ |