New doc system done for core
[io.git] / libs / iovm / source / IoTag.c
blob8537e11aea682221d0ea5c28156a984398ea770f
2 //metadoc Tag copyright Steve Dekorte 2002
3 //metadoc Tag license BSD revised
5 #define IOTAG_C 1
6 #include "IoTag.h"
7 #undef IOTAG_C
9 #include "IoObject.h"
10 #include "IoState.h"
11 #include <string.h>
13 IoTag *IoTag_new(void)
15 IoTag *self = (IoTag *)io_calloc(1, sizeof(IoTag));
16 #ifdef IOMESSAGE_INLINE_PERFORM
17 self->performFunc = NULL;
18 #else
19 self->performFunc = (IoTagPerformFunc *)IoObject_perform;
20 #endif
22 self->referenceCount = 1;
23 //self->recyclableInstances = Stack_new();
24 //self->maxRecyclableInstances = 10000;
25 return self;
28 IoTag *IoTag_newWithName_(const char *name)
30 IoTag *self = IoTag_new();
31 IoTag_name_(self, name);
32 return self;
35 void IoTag_free(IoTag *self)
37 //printf("io_free tag %p\n", (void *)self);
38 //printf("%s\n", self->name ? self->name : "NULL");
39 if (--self->referenceCount > 0) {
40 return;
43 if (self->tagCleanupFunc)
45 (self->tagCleanupFunc)(self);
48 if (self->name)
50 io_free(self->name);
51 self->name = NULL;
54 //Stack_free(self->recyclableInstances);
55 io_free(self);
58 int IoTag_reference(IoTag *self)
60 return ++self->referenceCount;
63 void IoTag_name_(IoTag *self, const char *name)
65 self->name = strcpy((char *)io_realloc(self->name, strlen(name)+1), name);
68 const char *IoTag_name(IoTag *self)
70 return self->name;
73 void IoTag_mark(IoTag *self)
76 if (Stack_count(self->recyclableInstances))
78 Stack_do_(self->recyclableInstances, (StackDoCallback *)IoObject_shouldMark);