diff options
Diffstat (limited to 'Objective-C/NSObject-ObjectiveCLWrapperLink.m')
-rw-r--r-- | Objective-C/NSObject-ObjectiveCLWrapperLink.m | 47 |
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) */ |