Added some documentation.

main
theraven 15 years ago
parent dda2e03871
commit e0d80861b5

@ -26,31 +26,52 @@
# undef objc_lookUpClass # undef objc_lookUpClass
#endif #endif
/**
* Opaque type for Objective-C instance variable metadata.
*/
typedef struct objc_ivar* Ivar; typedef struct objc_ivar* Ivar;
// Don't redefine these types if the old GNU header was included first. // Don't redefine these types if the old GCC header was included first.
#ifndef __objc_INCLUDE_GNU #ifndef __objc_INCLUDE_GNU
// Define the macro so that including the old GNU header does nothing. // Define the macro so that including the old GCC header does nothing.
# define __objc_INCLUDE_GNU # define __objc_INCLUDE_GNU
# define __objc_api_INCLUDE_GNU # define __objc_api_INCLUDE_GNU
/**
* Opaque type used for selectors.
*/
#if !defined(__clang__) && !defined(__OBJC_RUNTIME_INTERNAL__) #if !defined(__clang__) && !defined(__OBJC_RUNTIME_INTERNAL__)
typedef const struct objc_selector *SEL; typedef const struct objc_selector *SEL;
#else #else
typedef struct objc_selector *SEL; typedef struct objc_selector *SEL;
#endif #endif
/**
* Opaque type for Objective-C classes.
*/
typedef struct objc_class *Class; typedef struct objc_class *Class;
/**
* Type for Objective-C objects.
*/
typedef struct objc_object typedef struct objc_object
{ {
/**
* Pointer to this object's class. Accessing this directly is STRONGLY
* discouraged. You are recommended to use object_getClass() instead.
*/
Class isa; Class isa;
} *id; } *id;
/**
* Structure used for calling superclass methods.
*/
struct objc_super struct objc_super
{ {
/** The receiver of the message. */
id receiver; id receiver;
/** The class containing the method to call. */
# if !defined(__cplusplus) && !__OBJC2__ # if !defined(__cplusplus) && !__OBJC2__
Class class; Class class;
# else # else
@ -58,9 +79,21 @@ struct objc_super
# endif # endif
}; };
/**
* Instance Method Pointer type. Note: Since the calling convention for
* variadic functions sometimes differs from the calling convention for
* non-variadic functions, you must cast an IMP to the correct type before
* calling.
*/
typedef id (*IMP)(id, SEL, ...); typedef id (*IMP)(id, SEL, ...);
/**
* Opaque type for Objective-C method metadata.
*/
typedef struct objc_method *Method; typedef struct objc_method *Method;
/**
* Objective-C boolean type.
*/
# ifdef STRICT_APPLE_COMPATIBILITY # ifdef STRICT_APPLE_COMPATIBILITY
typedef signed char BOOL; typedef signed char BOOL;
# else # else
@ -77,14 +110,24 @@ typedef unsigned char BOOL;
#endif // __objc_INCLUDE_GNU #endif // __objc_INCLUDE_GNU
struct objc_property; /**
* Opaque type for Objective-C property metadata.
*/
typedef struct objc_property* objc_property_t; typedef struct objc_property* objc_property_t;
/**
* Opaque type for Objective-C protocols. Note that, although protocols are
* objects, sending messages to them is deprecated in Objective-C 2 and may not
* work in the future.
*/
#ifdef __OBJC__ #ifdef __OBJC__
@class Protocol; @class Protocol;
#else #else
typedef struct objc_protocol Protocol; typedef struct objc_protocol Protocol;
#endif #endif
/**
* Objective-C method description.
*/
struct objc_method_description struct objc_method_description
{ {
/** /**
@ -123,19 +166,40 @@ struct objc_method_description
#include "slot.h" #include "slot.h"
/**
* Adds an instance variable to the named class. The class must not have been
* registered by the runtime. The alignment must be the base-2 logarithm of
* the alignment requirement and the types should be an Objective-C type encoding.
*/
BOOL class_addIvar(Class cls, BOOL class_addIvar(Class cls,
const char *name, const char *name,
size_t size, size_t size,
uint8_t alignment, uint8_t alignment,
const char *types); const char *types);
/**
* Adds a method to the class.
*/
BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types); BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types);
/**
* Adds a protocol to the class.
*/
BOOL class_addProtocol(Class cls, Protocol *protocol); BOOL class_addProtocol(Class cls, Protocol *protocol);
/**
* Tests for protocol conformance. Note: Currently, protocols with the same
* name are regarded as equivalent, even if they have different methods. This
* behaviour will change in a future version.
*/
BOOL class_conformsToProtocol(Class cls, Protocol *protocol); BOOL class_conformsToProtocol(Class cls, Protocol *protocol);
Ivar * class_copyIvarList(Class cls, unsigned int *outCount); /**
* Copies the instance variable list for this class. The integer pointed to by
* the outCount argument is set to the number of instance variables returned.
* The caller is responsible for freeing the returned buffer.
*/
Ivar* class_copyIvarList(Class cls, unsigned int *outCount);
Method * class_copyMethodList(Class cls, unsigned int *outCount); Method * class_copyMethodList(Class cls, unsigned int *outCount);
@ -153,7 +217,8 @@ Method class_getInstanceMethod(Class aClass, SEL aSelector);
size_t class_getInstanceSize(Class cls); size_t class_getInstanceSize(Class cls);
/** Look up the named instance variable in the class (and its superclasses) /**
* Look up the named instance variable in the class (and its superclasses)
* returning a pointer to the instance variable definition or a null * returning a pointer to the instance variable definition or a null
* pointer if no instance variable of that name was found. * pointer if no instance variable of that name was found.
*/ */
@ -283,6 +348,16 @@ const char *sel_getName(SEL sel);
SEL sel_getUid(const char *selName); SEL sel_getUid(const char *selName);
/**
* Returns whether two selectors are equal. For the purpose of comparison,
* selectors with the same name and type are regarded as equal. Selectors with
* the same name and different types are regarded as different. If one
* selector is typed and the other is untyped, but the names are the same, then
* they are regarded as equal. This means that sel_isEqual(a, b) and
* sel_isEqual(a, c) does not imply sel_isEqual(b, c) - if a is untyped but
* both b and c are typed selectors with different types, then then the first
* two will return YES, but the third case will return NO.
*/
BOOL sel_isEqual(SEL sel1, SEL sel2); BOOL sel_isEqual(SEL sel1, SEL sel2);
SEL sel_registerName(const char *selName); SEL sel_registerName(const char *selName);
@ -321,7 +396,6 @@ extern struct objc_slot *objc_msg_lookup_sender(id *receiver, SEL selector, id s
* All of the functions in this section are deprecated and should not be used * All of the functions in this section are deprecated and should not be used
* in new code. * in new code.
*/ */
__attribute__((deprecated)) __attribute__((deprecated))
void *objc_malloc(size_t size); void *objc_malloc(size_t size);

Loading…
Cancel
Save