From 3170b6d37b051f42fe0b28ba2dfa54344e1c85e6 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 10 Feb 2008 14:46:54 +0100 Subject: Add NSObject category ObjectiveCLWrapperLink. darcs-hash:0a90de7a76127351a989662a577b5688fe39654c --- Objective-C/NSObject-ObjectiveCLWrapperLink.m | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Objective-C/NSObject-ObjectiveCLWrapperLink.m (limited to 'Objective-C/NSObject-ObjectiveCLWrapperLink.m') diff --git a/Objective-C/NSObject-ObjectiveCLWrapperLink.m b/Objective-C/NSObject-ObjectiveCLWrapperLink.m new file mode 100644 index 0000000..5dac3a7 --- /dev/null +++ b/Objective-C/NSObject-ObjectiveCLWrapperLink.m @@ -0,0 +1,47 @@ +/* -*- mode: objc; coding: utf-8 -*- */ + +#import "NSObject-ObjectiveCLWrapperLink.h" +#import +#import +#import + +static NSMutableDictionary *instance_wrappers = NULL; + +void +objcl_initialise_instance_wrappers (void) +{ + if (!instance_wrappers) + instance_wrappers = [[NSMutableDictionary alloc] init]; +} + +void +objcl_shutdown_instance_wrappers (void) +{ + if (instance_wrappers) + { + [instance_wrappers release]; + instance_wrappers = NULL; + } +} + +@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 +{ + [instance_wrappers setObject: [NSString stringWithUTF8String: wrapper_id] + forKey: self]; +} + +-(void) __removeObjectiveCLWrapperID +{ + [instance_wrappers removeObjectForKey: self]; +} +@end /* NSObject (ObjectiveCL) */ -- cgit v1.2.3