summaryrefslogtreecommitdiff
path: root/Objective-C/NSObject-ObjectiveCLWrapperLink.m
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-02-10 14:46:54 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-02-10 14:46:54 +0100
commit3170b6d37b051f42fe0b28ba2dfa54344e1c85e6 (patch)
tree630d20e53eb35af86c4274e0ebccb35d492155d1 /Objective-C/NSObject-ObjectiveCLWrapperLink.m
parent7d44a3313c9be065f962975b362d29684bcd3418 (diff)
Add NSObject category ObjectiveCLWrapperLink.
darcs-hash:0a90de7a76127351a989662a577b5688fe39654c
Diffstat (limited to 'Objective-C/NSObject-ObjectiveCLWrapperLink.m')
-rw-r--r--Objective-C/NSObject-ObjectiveCLWrapperLink.m47
1 files changed, 47 insertions, 0 deletions
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 <Foundation/NSDictionary.h>
+#import <Foundation/NSObject.h>
+#import <Foundation/NSString.h>
+
+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) */