diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-10-12 02:43:25 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-10-12 02:43:25 +0000 |
commit | debfbfeefc5f8c9236c1de2de874df52eaf8c8c4 (patch) | |
tree | 1565198dee2ff7c323dd7ae7d47bcb976d011d43 /libobjc/objc/runtime.h | |
parent | 524660d2e3e96ac715623c052338c25a14938dfa (diff) | |
download | gcc-debfbfeefc5f8c9236c1de2de874df52eaf8c8c4.zip gcc-debfbfeefc5f8c9236c1de2de874df52eaf8c8c4.tar.gz gcc-debfbfeefc5f8c9236c1de2de874df52eaf8c8c4.tar.bz2 |
In libobjc/: 2010-10-12 Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/:
2010-10-12 Nicola Pero <nicola.pero@meta-innovation.com>
* Makefile.in (C_SOURCE_FILES): Added protocols.c.
* objc-private/protocols.h: New.
* protocols.c: New.
* init.c: Include objc-private/protocols.h.
(__objc_exec_class): Call __objc_protocols_init on startup.
(__objc_init_protocols): Call __objc_protocols_add_protocol.
* objc-private/runtime.h: Use (struct objc_method_list *) instead
of MethodList_t, and (struct objc_method *) instead of Method_t.
* objc/deprecated/struct_objc_class.h: Define
__objc_STRUCT_OBJC_CLASS_defined.
* objc-private/module-abi-8.h (struct
objc_method_description_list): New.
(struct objc_class): Only define if
__objc_STRUCT_OBJC_CLASS_defined is undefined.
* objc/runtime.h (class_getName): New.
(objc_getProtocol): New.
(objc_copyProtocolList): New.
(class_addProtocol): New.
(class_conformsToProtocol): New.
(class_copyProtocolList): New.
(protocol_conformsToProtocol): New.
(protocol_isEqual): New.
(protocol_getName): New.
(protocol_getMethodDescription): New.
(protocol_copyMethodDescriptionList): New.
(protocol_getProperty): New.
(protocol_copyPropertyList): New.
(protocol_copyProtocolList): New.
* class.c (class_getName): New.
* selector.c (sel_isEqual): New.
From-SVN: r165349
Diffstat (limited to 'libobjc/objc/runtime.h')
-rw-r--r-- | libobjc/objc/runtime.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index f3a19ec..b5ae87b 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -356,6 +356,138 @@ objc_EXPORT int objc_getClassList (Class *returnValue, int maxNumberOfClassesToR the documentation is unclear on what they are supposed to do, and the GNU Objective-C Runtime currently does not provide them. */ +/* Return the name of the class 'class_', or the string "nil" if the + class_ is Nil. */ +objc_EXPORT const char * class_getName (Class class_); + + +/** Implementation: the following functions are in protocols.c. */ + +/* Return the protocol with name 'name', or nil if it the protocol is + not known to the runtime. */ +objc_EXPORT Protocol *objc_getProtocol (const char *name); + +/* Return all the protocols known to the runtime. The return value of + the function is a pointer to an area, allocated with malloc(), that + contains all the protocols known to the runtime; the list is + terminated by NULL. You should free this area using free() once + you no longer need it. Optionally, if you pass a non-NULL + 'numberOfReturnedProtocols' pointer, the unsigned int that it + points to will be filled with the number of protocols returned. If + there are no protocols known to the runtime, NULL is returned. */ +objc_EXPORT Protocol **objc_copyProtocolList (unsigned int *numberOfReturnedProtocols); + +/* Add a protocol to a class, and return YES if it was done + succesfully, and NO if not. At the moment, NO should only happen + if class_ or protocol are nil, if the protocol is not a Protocol + object or if the class already conforms to the protocol. */ +objc_EXPORT BOOL class_addProtocol (Class class_, Protocol *protocol); + +/* Return YES if the class 'class_' conforms to Protocol 'protocol', + and NO if not. */ +objc_EXPORT BOOL class_conformsToProtocol (Class class_, Protocol *protocol); + +/* Return all the protocols that the class conforms to. The return + value of the function is a pointer to an area, allocated with + malloc(), that contains all the protocols formally adopted by the + class. It does not include protocols adopted by superclasses. The + list is terminated by NULL. Optionally, if you pass a non-NULL + 'numberOfReturnedProtocols' pointer, the unsigned int that it + points to will be filled with the number of protocols returned. */ +objc_EXPORT Protocol **class_copyProtocolList (Class class_, unsigned int *numberOfReturnedProtocols); + +/* Return YES if protocol 'protocol' conforms to protocol + 'anotherProtocol', and NO if not. Note that if one of the two + protocols is nil, it returns NO. */ +objc_EXPORT BOOL protocol_conformsToProtocol (Protocol *protocol, Protocol *anotherProtocol); + +/* Return YES if protocol 'protocol' is the same as protocol + 'anotherProtocol', and 'NO' if not. Note that it returns YES if + the two protocols are both nil. */ +objc_EXPORT BOOL protocol_isEqual (Protocol *protocol, Protocol *anotherProtocol); + +/* Return the name of protocol 'protocol'. If 'protocol' is nil or is + not a Protocol, return NULL. */ +objc_EXPORT const char *protocol_getName (Protocol *protocol); + +/* Return the method description for the method with selector + 'selector' in protocol 'protocol'; if 'requiredMethod' is YES, the + function searches the list of required methods; if NO, the list of + optional methods. If 'instanceMethod' is YES, the function search + for an instance method; if NO, for a class method. If there is no + matching method, an objc_method_description structure with both + name and types set to NULL is returned. This function will only + find methods that are directly declared in the protocol itself, not + in other protocols that this protocol adopts. + + Note that the traditional ABI does not store the list of optional + methods of a protocol in a compiled module, so the traditional ABI + will always return (NULL, NULL) when requiredMethod == NO. */ +objc_EXPORT struct objc_method_description protocol_getMethodDescription (Protocol *protocol, + SEL selector, + BOOL requiredMethod, + BOOL instanceMethod); + +/* Return the method descriptions of all the methods of the protocol. + The return value of the function is a pointer to an area, allocated + with malloc(), that contains all the method descriptions of the + methods of the protocol. It does not recursively include methods + of the protocols adopted by this protocol. The list is terminated + by a NULL objc_method_description (one with both fields set to + NULL). Optionally, if you pass a non-NULL + 'numberOfReturnedMethods' pointer, the unsigned int that it points + to will be filled with the number of properties returned. + + Note that the traditional ABI does not store the list of optional + methods of a protocol in a compiled module, so the traditional ABI + will always return an empty list if requiredMethod is set to + NO. */ +objc_EXPORT struct objc_method_description *protocol_copyMethodDescriptionList (Protocol *protocol, + BOOL requiredMethod, + BOOL instanceMethod, + unsigned int *numberOfReturnedMethods); + +/* Return the property with name 'propertyName' of the protocol + 'protocol'. If 'requiredProperty' is YES, the function searches + the list of required properties; if NO, the list of optional + properties. If 'instanceProperty' is YES, the function searches + the list of instance properties; if NO, the list of class + properties. At the moment, optional properties and class + properties are not part of the Objective-C language, so both + 'requiredProperty' and 'instanceProperty' should be set to YES. + This function returns NULL if the required property can not be + found. + + Note that the traditional ABI does not store the list of properties + of a protocol in a compiled module, so the traditional ABI will + always return NULL. */ +objc_EXPORT Property protocol_getProperty (Protocol *protocol, const char *propertyName, + BOOL requiredProperty, BOOL instanceProperty); + +/* Return all the properties of the protocol. The return value of the + function is a pointer to an area, allocated with malloc(), that + contains all the properties of the protocol. It does not + recursively include properties of the protocols adopted by this + protocol. The list is terminated by NULL. Optionally, if you pass + a non-NULL 'numberOfReturnedProperties' pointer, the unsigned int + that it points to will be filled with the number of properties + returned. + + Note that the traditional ABI does not store the list of properties + of a protocol in a compiled module, so the traditional ABI will + always return NULL and store 0 in numberOfReturnedProperties. */ +objc_EXPORT Property *protocol_copyPropertyList (Protocol *protocol, unsigned int *numberOfReturnedProperties); + +/* Return all the protocols that the protocol conforms to. The return + value of the function is a pointer to an area, allocated with + malloc(), that contains all the protocols formally adopted by the + protocol. It does not recursively include protocols adopted by the + protocols adopted by this protocol. The list is terminated by + NULL. Optionally, if you pass a non-NULL + 'numberOfReturnedProtocols' pointer, the unsigned int that it + points to will be filled with the number of protocols returned. */ +objc_EXPORT Protocol **protocol_copyProtocolList (Protocol *protocol, unsigned int *numberOfReturnedProtocols); + /* TODO: Add all the other functions in the API. */ |