1 module objc.runtime; 2 3 version(D_ObjectiveC){ 4 public import core.attribute: optional, selector; 5 } 6 7 struct Block(RetT, Args...){ 8 void* isa; 9 int flags; 10 int reserved; 11 RetT function(void*, Args) invoke; 12 } 13 14 struct objc_ivar; 15 alias Ivar = objc_ivar*; 16 17 struct objc_selector; 18 alias SEL = objc_selector*; 19 20 struct objc_class; 21 alias Class = objc_class*; 22 23 struct objc_object; 24 alias id = objc_object*; //alias id = NSObject; 25 26 struct objc_super{ 27 id reciever; 28 Class super_class; 29 } 30 31 alias IMP = id function(id, SEL, ...); 32 struct objc_method; 33 alias Method = objc_method*; 34 35 struct objc_method_description{ 36 SEL name; 37 char* types; 38 } 39 40 alias objc_property_t = void*; 41 42 version(D_ObjectiveC){ 43 extern(Objective-C) class Protocol; 44 }else{ 45 struct objc_protocol; 46 alias Protocol = objc_protocol*; 47 } 48 49 enum nil = cast(id)null; 50 51 enum Nil = cast(Class)null; 52 53 extern(C) nothrow @nogc{ 54 bool class_addIvar(Class cls, const(char)* name, size_t size, ubyte alignment, const(char)* types); 55 bool class_addMethod(Class cls, SEL name, IMP imp, const(char)* types); 56 bool class_addProtocol(Class cls, Protocol* protocol); 57 bool class_conformsToProtocol(Class cls, Protocol* protocol); 58 Ivar* class_copyIvarList(Class cls, uint* outCount); 59 Method* class_copyMethodList(Class cls, uint* outCount); 60 objc_property_t* class_copyPropertyList(Class cls, uint* outCount); 61 Protocol** class_copyProtocolList(Class cls, uint* outCount); 62 id class_createInstance(Class cls, size_t extraBytes); 63 Method class_getClassMethod(Class aClass, SEL aSelector); 64 Ivar class_getClassVariable(Class cls, const(char)* name); 65 Method class_getInstanceMethod(Class aClass, SEL aSelector); 66 size_t class_getInstanceSize(Class cls); 67 Ivar class_getInstanceVariable(Class cls, const(char)* name); 68 const(char)* class_getIvarLayout(Class cls); 69 IMP class_getMethodImplementation(Class cls, SEL name); 70 IMP class_getMethodImplementation_stret(Class cls, SEL name); 71 const(char)* class_getName(Class cls); 72 objc_property_t class_getProperty(Class cls, const(char)* name); 73 Class class_getSuperclass(Class cls); 74 int class_getVersion(Class theClass); 75 const(char)* class_getWeakIvarLayout(Class cls); 76 bool class_isMetaClass(Class cls); 77 IMP class_replaceMethod(Class cls, SEL name, IMP imp, const(char)* types); 78 bool class_respondsToSelector(Class cls, SEL sel); 79 void class_setIvarLayout(Class cls, const(char)* layout); 80 void class_setVersion(Class theClass, int version_); 81 void class_setWeakIvarLayout(Class cls, const(char)* layout); 82 const(char)* ivar_getName(Ivar ivar); 83 ptrdiff_t ivar_getOffset(Ivar ivar); 84 const(char)* ivar_getTypeEncoding(Ivar ivar); 85 char* method_copyArgumentType(Method method, uint index); 86 char* method_copyReturnType(Method method); 87 void method_exchangeImplementations(Method m1, Method m2); 88 void method_getArgumentType(Method method, uint index, char* dst, size_t dst_len); 89 IMP method_getImplementation(Method method); 90 SEL method_getName(Method method); 91 uint method_getNumberOfArguments(Method method); 92 void method_getReturnType(Method method, char* dst, size_t dst_len); 93 const(char)* method_getTypeEncoding(Method method); 94 IMP method_setImplementation(Method method, IMP imp); 95 Class objc_allocateClassPair(Class superclass, const(char)* name, size_t extraBytes); 96 Class objc_allocateMetaClass(Class superclass, size_t extraBytes); 97 void objc_disposeClassPair(Class cls); 98 id objc_getClass(const(char)* name); 99 int objc_getClassList(Class* buffer, int bufferLen); 100 id objc_getMetaClass(const(char)* name); 101 id objc_getRequiredClass(const(char)* name); 102 id objc_lookUpClass(const(char)* name); 103 Class objc_allocateClassPair(Class superclass, const(char)* name, size_t extraBytes); 104 Protocol* objc_getProtocol(const(char)* name); 105 void objc_registerClassPair(Class cls); 106 void* object_getIndexedIvars(id obj); 107 id object_dispose(id obj); 108 Class object_getClass(id obj); 109 Class object_setClass(id obj, Class cls); 110 const(char)* object_getClassName(id obj); 111 Protocol** objc_copyProtocolList(uint* count); 112 bool protocol_conformsToProtocol(Protocol* p, Protocol* other); 113 objc_method_description* protocol_copyMethodDescriptionList(Protocol* p, bool isRequiredMethod, bool isInstanceMethod, uint* count); 114 objc_property_t* protocol_copyPropertyList(Protocol* p, uint* count); 115 Protocol** protocol_copyProtocolList(Protocol* p, uint* count); 116 objc_method_description protocol_getMethodDescription(Protocol* p, SEL aSel, bool isRequiredMethod, bool isInstanceMethod); 117 const(char)* protocol_getName(Protocol* p); 118 objc_property_t protocol_getProperty(Protocol* p, const(char)* name, bool isRequiredProperty, bool isInstanceProperty); 119 bool protocol_isEqual(Protocol* p, Protocol* other); 120 void objc_msgSend(Class theReceiver, SEL theSelector, ...); 121 void objc_msgSendSuper(objc_super* super_, SEL op, ...); 122 const(char)* sel_getName(SEL sel); 123 SEL sel_getUid(const(char)* selName); 124 bool sel_isEqual(SEL sel1, SEL sel2); 125 SEL sel_registerName(const(char)* selName); 126 }