#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "Object.h"
Go to the source code of this file.
◆ _Class
◆ _Object()
Definition at line 136 of file Object.c.
136 {
139
142 .name = "Object",
143 .instanceSize =
sizeof(
Object),
144 .interfaceOffset = offsetof(
Object, interface),
145 .interfaceSize = sizeof(ObjectInterface),
147 });
148 });
149
150 return clazz;
151}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
static void initialize(Class *clazz)
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
Object is the root Class of The Objectively Class hierarchy.
◆ copy()
Definition at line 39 of file Object.c.
39 {
40
43
45 object->referenceCount = 1;
46
47 return object;
48}
void * ident
The identity type, similar to Objective-C id.
size_t instanceSize
The instance size (required).
ClassDef def
The Class definition.
Class * clazz
Every instance of Object begins with a pointer to its Class.
◆ dealloc()
static void dealloc |
( |
Object * |
self | ) |
|
|
static |
Definition at line 54 of file Object.c.
54 {
55
56 free(self);
57}
◆ description()
Definition at line 63 of file Object.c.
63 {
64
66}
#define alloc(type)
Allocate and initialize and instance of type.
const char * name
The Class name (required).
◆ hash()
static int hash |
( |
const Object * |
self | ) |
|
|
static |
Definition at line 72 of file Object.c.
72 {
73
74 uintptr_t addr = (uintptr_t) self;
75
76 return (int) ((13 * addr) ^ (addr >> 15));
77}
◆ init()
Definition at line 83 of file Object.c.
83 {
84
85 return self;
86}
◆ initialize()
static void initialize |
( |
Class * |
clazz | ) |
|
|
static |
- See also
- Class::initialize(Class *)
Definition at line 121 of file Object.c.
121 {
122
130}
ident interface
The interface of the Class.
Condition * init(Condition *self)
Initializes this Condition.
Object * copy(const Object *self)
Creates a shallow copy of this Object.
_Bool isKindOfClass(const Object *self, const Class *clazz)
Tests for Class hierarchy membership.
String * description(const Object *self)
_Bool isEqual(const Object *self, const Object *other)
Tests equality of the other Object.
int hash(const Object *self)
void dealloc(Object *self)
Frees all resources held by this Object.
◆ isEqual()
static _Bool isEqual |
( |
const Object * |
self, |
|
|
const Object * |
other |
|
) |
| |
|
static |
Definition at line 92 of file Object.c.
92 {
93
94 return self == other;
95}
◆ isKindOfClass()
static _Bool isKindOfClass |
( |
const Object * |
self, |
|
|
const Class * |
clazz |
|
) |
| |
|
static |
Definition at line 101 of file Object.c.
101 {
102
103 assert(clazz);
104
106 while (c) {
107 if (memcmp(c, clazz, sizeof(*c)) == 0) {
108 return true;
109 }
111 }
112
113 return false;
114}
Class * superclass
The superclass (required). e.g. _Object().