summaryrefslogtreecommitdiff
path: root/Objective-C/NSObject-ObjectiveCLWrapperLink.m
blob: 5dac3a79731ca0ee5e5ee3c71a8655f2f8fa5e5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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) */