1/*
2 * Copyright (c) 2006-2008, The RubyCocoa Project.
3 * Copyright (c) 2001-2006, FUJIMOTO Hisakuni.
4 * All Rights Reserved.
5 *
6 * RubyCocoa is free software, covered under either the Ruby's license or the
7 * LGPL. See the COPYRIGHT file for more information.
8 */
9
10#import <objc/objc-class.h>
11
12#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
13
14#define objc_registerClassPair(klass) (objc_addClass(klass))
15
16#define class_createInstance(klass, extra_bytes) (class_createInstanceFromZone(klass, extra_bytes, NSDefaultMallocZone()))
17#define class_getName(klass) (((struct objc_class *)(klass))->name)
18#define class_getSuperclass(klass) (((struct objc_class *)(klass))->super_class)
19#define class_isMetaClass(klass) (((struct objc_class *)(klass))->info & CLS_META)
20#define class_addMethod(klass, name, imp, types) \
21  do { \
22    struct objc_method_list* mlp; \
23    mlp = NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct objc_method_list)); \
24    mlp->obsolete = NULL; \
25    mlp->method_list[0].method_name = (SEL)(name);	\
26    mlp->method_list[0].method_types = types; \
27    mlp->method_list[0].method_imp = imp;   \
28    mlp->method_count = 1; \
29    class_addMethods(klass, mlp);		\
30  } \
31  while (0)
32#define class_respondsToSelector(klass, sel) ((class_getClassMethod(klass, sel) ?: class_getInstanceMethod(klass, sel)) != NULL)
33#define class_conformsToProtocol(klass, prot) [(Class)klass conformsToProtocol:prot]
34
35#define method_getName(method) (((Method)(method))->method_name)
36#define method_getImplementation(method) (((Method)(method))->method_imp)
37#define method_setImplementation(method, imp) (((Method)(method))->method_imp = imp)
38#define method_getTypeEncoding(method) (((Method)(method))->method_types)
39
40#define object_getClass(obj) (((struct objc_class *)(obj))->isa)
41
42#endif
43