summaryrefslogtreecommitdiff
path: root/Objective-C/NSObject-ObjectiveCLWrapperLink.m
blob: 8677ef33d9109434f96d12467f9c48774a058dde (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
48
49
50
51
/* -*- mode: objc; coding: utf-8 -*- */

#import "NSObject-ObjectiveCLWrapperLink.h"
#import <Foundation/NSDictionary.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>

#ifndef NULL
#define NULL (void *)0
#endif

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) */