summaryrefslogtreecommitdiff
path: root/Objective-C/NSObject-ObjectiveCLWrapperLink.m
blob: 665d302855340bc1b1656a6c01a35b7e8b6dbe2a (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
/* -*- mode: objc; coding: utf-8 -*- */

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

static NSMutableSet *lisp_backed_objects = nil;

void
objcl_initialise_instance_wrappers (void)
{
  if (lisp_backed_objects == nil)
    lisp_backed_objects = [[NSMutableSet alloc] init];
}

void
objcl_shutdown_instance_wrappers (void)
{
  if (lisp_backed_objects != nil)
    {
      [lisp_backed_objects release];
      lisp_backed_objects = nil;
    }
}

@implementation NSObject (ObjectiveCLWrapperLink)
-(BOOL) __objcl_isBackedByLispInstance
{
  return [lisp_backed_objects containsObject: self];
}

-(void) __objcl_setBackedByLispInstance: (BOOL)backed_p
{
  if (backed_p)
    [lisp_backed_objects addObject: self];
  else
    [lisp_backed_objects removeObject: self];
}
@end /* NSObject (ObjectiveCL) */