160 ((type *) _alloc(_##type()))
165#define cast(type, obj) \
166 ((type *) _cast(_##type(), (const ident) obj))
171#define classof(obj) \
172 ((Object *) obj)->clazz
177#define classnameof(obj) \
178 classof(obj)->def.name
183#define interfaceof(type, clazz) \
184 ((type##Interface *) (clazz)->interface)
189#define $(obj, method, ...) \
191 typeof(obj) _obj = obj; \
192 _obj->interface->method(_obj, ## __VA_ARGS__); \
198#define $$(type, method, ...) \
200 interfaceof(type, _##type())->method(__VA_ARGS__); \
206#define super(type, obj, method, ...) \
207 interfaceof(type, _Class()->def.superclass)->method(cast(type, obj), ## __VA_ARGS__)
OBJECTIVELY_EXPORT ident retain(ident obj)
Atomically increment the given Object's reference count.
OBJECTIVELY_EXPORT ident _cast(Class *clazz, const ident obj)
Perform a type-checking cast.
OBJECTIVELY_EXPORT size_t _pageSize
The page size, in bytes, of the target host.
OBJECTIVELY_EXPORT Class * _initialize(const ClassDef *clazz)
Initializes the given Class.
OBJECTIVELY_EXPORT ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
OBJECTIVELY_EXPORT ident _alloc(Class *clazz)
Instantiate a type through the given Class.
OBJECTIVELY_EXPORT Class * classForName(const char *name)
Helpers for at-most-once semantics.
void * ident
The identity type, similar to Objective-C id.
#define OBJECTIVELY_EXPORT
ClassDefs are passed to _initialize via an archetype to initialize a Class.
size_t instanceSize
The instance size (required).
size_t interfaceSize
The interface size (required).
ptrdiff_t interfaceOffset
The interface offset (required).
Class * superclass
The superclass (required). e.g. _Object().
void(* destroy)(Class *clazz)
The Class destructor (optional). This method is run for initialized Classes when your application exi...
const char * name
The Class name (required).
void(* initialize)(Class *clazz)
The Class initializer (optional).
The runtime representation of a Class.
ClassDef def
The Class definition.
Class * next
Provides chaining of initialized Classes.
ident interface
The interface of the Class.