Class ObjCRuntime
Due to the nature of the objc_msgSend*
functions, they are not directly exposed in this binding. Advanced users with good understanding of the
complexity involved with using these functions, may access them via the getLibrary()
method:
SharedLibrary objc = ObjCRuntime.getLibrary();
long objc_msgSend = objc.getFunctionAddress("objc_msgSend");
// example usage
long NSThread = objc_getClass("NSThread");
long currentThread = invokePPP(NSThread, sel_getUid("currentThread"), objc_msgSend);
The safe way to use objc_msgSend in C code is to cast it to an appropriate function pointer. This is exactly what the JNI
class does. If a particular function signature is not available, LibFFI
may be used to invoke it.
The functions not exposed are:
- objc_msgSend
- objc_msgSend_stret
- objc_msgSendSuper
- objc_msgSendSuper_stret
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Contains the function pointers loaded from the objcSharedLibrary
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final char
Types.static final long
Nil value.static final byte
Boolean values.static final int
Policies related to associative references.static final int
Policies related to associative references.static final int
Policies related to associative references.static final int
Policies related to associative references.static final int
Policies related to associative references.static final byte
Boolean values. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
class_addIvar
(long cls, CharSequence name, long size, byte alignment, CharSequence types) Adds a new instance variable to a class.static boolean
class_addIvar
(long cls, ByteBuffer name, long size, byte alignment, ByteBuffer types) Adds a new instance variable to a class.static boolean
class_addMethod
(long cls, long name, long imp, CharSequence types) Adds a new method to a class with a given name and implementation.static boolean
class_addMethod
(long cls, long name, long imp, ByteBuffer types) Adds a new method to a class with a given name and implementation.static boolean
class_addProperty
(long cls, CharSequence name, ObjCPropertyAttribute.Buffer attributes) Adds a property to a class.static boolean
class_addProperty
(long cls, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes) Adds a property to a class.static boolean
class_addProtocol
(long cls, long protocol) Adds a protocol to a class.static boolean
class_conformsToProtocol
(long cls, long protocol) Returns a Boolean value that indicates whether a class conforms to a given protocol.static org.lwjgl.PointerBuffer
class_copyIvarList
(long cls) Describes the instance variables declared by a class.static org.lwjgl.PointerBuffer
class_copyMethodList
(long cls) Describes the instance methods implemented by a class.static org.lwjgl.PointerBuffer
class_copyPropertyList
(long cls) Describes the properties declared by a class.static org.lwjgl.PointerBuffer
class_copyProtocolList
(long cls) Describes the protocols adopted by a class.static long
class_createInstance
(long cls, long extraBytes) Creates an instance of a class, allocating memory for the class in the default malloc memory zone.static long
class_getClassMethod
(long cls, long name) Returns a pointer to the data structure describing a given class method for a given class.static long
class_getClassVariable
(long cls, CharSequence name) Returns the Ivar for a specified class variable of a given class.static long
class_getClassVariable
(long cls, ByteBuffer name) Returns the Ivar for a specified class variable of a given class.static String
class_getImageName
(long cls) Returns the name of the dynamic library a class originated from.static long
class_getInstanceMethod
(long cls, long name) Returns a specified instance method for a given class.static long
class_getInstanceSize
(long cls) Returns the size of instances of a class.static long
class_getInstanceVariable
(long cls, CharSequence name) Returns the Ivar for a specified instance variable of a given class.static long
class_getInstanceVariable
(long cls, ByteBuffer name) Returns the Ivar for a specified instance variable of a given class.static String
class_getIvarLayout
(long cls) Returns a description of the Ivar layout for a given class.static long
class_getMethodImplementation
(long cls, long name) Returns the function pointer that would be called if a particular message were sent to an instance of a class.static String
class_getName
(long cls) Returns the name of a class.static long
class_getProperty
(long cls, CharSequence name) Returns a property with a given name of a given class.static long
class_getProperty
(long cls, ByteBuffer name) Returns a property with a given name of a given class.static long
class_getSuperclass
(long cls) Returns the superclass of a class.static int
class_getVersion
(long cls) Returns the version number of a class definition.static String
class_getWeakIvarLayout
(long cls) Returns a description of the layout of weak Ivars for a given class.static boolean
class_isMetaClass
(long cls) Returns a Boolean value that indicates whether a class object is a metaclass.static long
class_replaceMethod
(long cls, long name, long imp, CharSequence types) Replaces the implementation of a method for a given class.static long
class_replaceMethod
(long cls, long name, long imp, ByteBuffer types) Replaces the implementation of a method for a given class.static void
class_replaceProperty
(long cls, CharSequence name, ObjCPropertyAttribute.Buffer attributes) Replaces a property of a class.static void
class_replaceProperty
(long cls, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes) Replaces a property of a class.static boolean
class_respondsToSelector
(long cls, long name) Returns a Boolean value that indicates whether instances of a class respond to a particular selector.static void
class_setIvarLayout
(long cls, CharSequence layout) Sets the Ivar layout for a given class.static void
class_setIvarLayout
(long cls, ByteBuffer layout) Sets the Ivar layout for a given class.static void
class_setVersion
(long cls, int version) Sets the version number of a class definition.static void
class_setWeakIvarLayout
(long cls, CharSequence layout) Sets the layout for weak Ivars for a given class.static void
class_setWeakIvarLayout
(long cls, ByteBuffer layout) Sets the layout for weak Ivars for a given class.static org.lwjgl.system.SharedLibrary
Returns the objcSharedLibrary
.static long
imp_getBlock
(long anImp) Returns the block associated with an IMP that was created usingimp_implementationWithBlock(long)
.static long
imp_implementationWithBlock
(long block) Creates a pointer to a function that calls the specified block when the method is called.static boolean
imp_removeBlock
(long anImp) Disassociates a block from an IMP that was created usingimp_implementationWithBlock(long)
, and releases the copy of the block that was created.static String
ivar_getName
(long v) Returns the name of an instance variable.static long
ivar_getOffset
(long v) Returns the offset of an instance variable.static String
ivar_getTypeEncoding
(long v) Returns the type string of an instance variable.static String
method_copyArgumentType
(long m, int index) Returns a string describing a single parameter type of a method.static String
method_copyReturnType
(long m) Returns a string describing a method's return type.static void
method_exchangeImplementations
(long m1, long m2) Exchanges the implementations of two methods.static String
method_getArgumentType
(long m, int index, long dst_len) Returns by reference a string describing a single parameter type of a method.static void
method_getArgumentType
(long m, int index, ByteBuffer dst) Returns by reference a string describing a single parameter type of a method.static long
method_getImplementation
(long m) Returns the implementation of a method.static long
method_getName
(long m) Returns the name of a method.static int
method_getNumberOfArguments
(long m) Returns the number of arguments accepted by a method.static String
method_getReturnType
(long m, long dst_len) Returns by reference a string describing a method's return type.static void
method_getReturnType
(long m, ByteBuffer dst) Returns by reference a string describing a method's return type.static String
method_getTypeEncoding
(long m) Returns a string describing a method's parameter and return types.static long
method_setImplementation
(long m, long imp) Sets the implementation of a method.static boolean
nclass_addIvar
(long cls, long name, long size, byte alignment, long types) Unsafe version of:class_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer)
static boolean
nclass_addMethod
(long cls, long name, long imp, long types) Unsafe version of:class_addMethod(long, long, long, java.nio.ByteBuffer)
static boolean
nclass_addProperty
(long cls, long name, long attributes, int attributeCount) static long
nclass_copyIvarList
(long cls, long outCount) Unsafe version of:class_copyIvarList(long)
static long
nclass_copyMethodList
(long cls, long outCount) Unsafe version of:class_copyMethodList(long)
static long
nclass_copyPropertyList
(long cls, long outCount) Unsafe version of:class_copyPropertyList(long)
static long
nclass_copyProtocolList
(long cls, long outCount) Unsafe version of:class_copyProtocolList(long)
static long
nclass_getClassVariable
(long cls, long name) Unsafe version of:class_getClassVariable(long, java.nio.ByteBuffer)
static long
nclass_getImageName
(long cls) Unsafe version of:class_getImageName(long)
static long
nclass_getInstanceVariable
(long cls, long name) Unsafe version of:class_getInstanceVariable(long, java.nio.ByteBuffer)
static long
nclass_getIvarLayout
(long cls) Unsafe version of:class_getIvarLayout(long)
static long
nclass_getName
(long cls) Unsafe version of:class_getName(long)
static long
nclass_getProperty
(long cls, long name) Unsafe version of:class_getProperty(long, java.nio.ByteBuffer)
static long
nclass_getWeakIvarLayout
(long cls) Unsafe version of:class_getWeakIvarLayout(long)
static long
nclass_replaceMethod
(long cls, long name, long imp, long types) Unsafe version of:class_replaceMethod(long, long, long, java.nio.ByteBuffer)
static void
nclass_replaceProperty
(long cls, long name, long attributes, int attributeCount) static void
nclass_setIvarLayout
(long cls, long layout) Unsafe version of:class_setIvarLayout(long, java.nio.ByteBuffer)
static void
nclass_setWeakIvarLayout
(long cls, long layout) Unsafe version of:class_setWeakIvarLayout(long, java.nio.ByteBuffer)
static long
nivar_getName
(long v) Unsafe version of:ivar_getName(long)
static long
nivar_getTypeEncoding
(long v) Unsafe version of:ivar_getTypeEncoding(long)
static long
nmethod_copyArgumentType
(long m, int index) Unsafe version of:method_copyArgumentType(long, int)
static long
nmethod_copyReturnType
(long m) Unsafe version of:method_copyReturnType(long)
static void
nmethod_getArgumentType
(long m, int index, long dst, long dst_len) Unsafe version of:method_getArgumentType(long, int, java.nio.ByteBuffer)
static void
nmethod_getReturnType
(long m, long dst, long dst_len) Unsafe version of:method_getReturnType(long, java.nio.ByteBuffer)
static long
nmethod_getTypeEncoding
(long m) Unsafe version of:method_getTypeEncoding(long)
static long
nobjc_allocateClassPair
(long superclass, long name, long extraBytes) Unsafe version of:objc_allocateClassPair(long, java.nio.ByteBuffer, long)
static long
nobjc_allocateProtocol
(long name) Unsafe version of:objc_allocateProtocol(java.nio.ByteBuffer)
static long
nobjc_constructInstance
(long cls, long bytes) Unsafe version of:objc_constructInstance(long, java.nio.ByteBuffer)
static long
nobjc_copyClassList
(long outCount) Unsafe version of:objc_copyClassList()
static long
nobjc_copyClassNamesForImage
(long image, long outCount) Unsafe version of:objc_copyClassNamesForImage(java.nio.ByteBuffer)
static long
nobjc_copyImageNames
(long outCount) Unsafe version of:objc_copyImageNames()
static long
nobjc_copyProtocolList
(long outCount) Unsafe version of:objc_copyProtocolList()
static long
nobjc_getClass
(long name) Unsafe version of:objc_getClass(java.nio.ByteBuffer)
static int
nobjc_getClassList
(long buffer, int bufferCount) Unsafe version of:objc_getClassList(org.lwjgl.PointerBuffer)
static long
nobjc_getMetaClass
(long name) Unsafe version of:objc_getMetaClass(java.nio.ByteBuffer)
static long
nobjc_getProtocol
(long name) Unsafe version of:objc_getProtocol(java.nio.ByteBuffer)
static long
nobjc_getRequiredClass
(long name) Unsafe version of:objc_getRequiredClass(java.nio.ByteBuffer)
static long
nobjc_loadWeak
(long location) Unsafe version of:objc_loadWeak(org.lwjgl.PointerBuffer)
static long
nobjc_lookUpClass
(long name) Unsafe version of:objc_lookUpClass(java.nio.ByteBuffer)
static void
nobjc_setEnumerationMutationHandler
(long handler) static long
nobjc_storeWeak
(long location, long obj) Unsafe version of:objc_storeWeak(org.lwjgl.PointerBuffer, long)
static long
nobject_getClassName
(long obj) Unsafe version of:object_getClassName(long)
static long
nobject_getInstanceVariable
(long obj, long name, long outValue) static long
nobject_setInstanceVariable
(long obj, long name, long value) Unsafe version of:object_setInstanceVariable(long, java.nio.ByteBuffer, java.nio.ByteBuffer)
static long
nproperty_copyAttributeList
(long property, long outCount) Unsafe version of:property_copyAttributeList(long)
static long
nproperty_copyAttributeValue
(long property, long attributeName) Unsafe version of:property_copyAttributeValue(long, java.nio.ByteBuffer)
static long
nproperty_getAttributes
(long property) Unsafe version of:property_getAttributes(long)
static long
nproperty_getName
(long property) Unsafe version of:property_getName(long)
static void
nprotocol_addMethodDescription
(long proto, long name, long types, boolean isRequiredMethod, boolean isInstanceMethod) static void
nprotocol_addProperty
(long proto, long name, long attributes, int attributeCount, boolean isRequiredProperty, boolean isInstanceProperty) static long
nprotocol_copyMethodDescriptionList
(long p, boolean isRequiredMethod, boolean isInstanceMethod, long outCount) Unsafe version of:protocol_copyMethodDescriptionList(long, boolean, boolean)
static long
nprotocol_copyPropertyList
(long proto, long outCount) Unsafe version of:protocol_copyPropertyList(long)
static long
nprotocol_copyProtocolList
(long proto, long outCount) Unsafe version of:protocol_copyProtocolList(long)
static void
nprotocol_getMethodDescription
(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, long __result) static void
nprotocol_getMethodDescription
(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, long __functionAddress, long __result) static long
nprotocol_getName
(long p) Unsafe version of:protocol_getName(long)
static long
nprotocol_getProperty
(long proto, long name, boolean isRequiredProperty, boolean isInstanceProperty) Unsafe version of:protocol_getProperty(long, java.nio.ByteBuffer, boolean, boolean)
static long
nsel_getName
(long sel) Unsafe version of:sel_getName(long)
static long
nsel_getUid
(long str) Unsafe version of:sel_getUid(java.nio.ByteBuffer)
static long
nsel_registerName
(long str) Unsafe version of:sel_registerName(java.nio.ByteBuffer)
static long
objc_allocateClassPair
(long superclass, CharSequence name, long extraBytes) Creates a new class and metaclass.static long
objc_allocateClassPair
(long superclass, ByteBuffer name, long extraBytes) Creates a new class and metaclass.static long
Creates a new protocol instance.static long
Creates a new protocol instance.static long
objc_constructInstance
(long cls, ByteBuffer bytes) Creates an instance of a class at the specified location.static org.lwjgl.PointerBuffer
Creates and returns a list of pointers to all registered class definitions.static org.lwjgl.PointerBuffer
Returns the names of all the classes within a specified library or framework.static org.lwjgl.PointerBuffer
Returns the names of all the classes within a specified library or framework.static org.lwjgl.PointerBuffer
Returns the names of all the loaded Objective-C frameworks and dynamic libraries.static org.lwjgl.PointerBuffer
Returns an array of all the protocols known to the runtime.static long
objc_destructInstance
(long obj) Destroys an instance of a class without freeing memory and removes any of its associated references.static void
objc_disposeClassPair
(long cls) Destroys a class and its associated metaclass.static void
objc_enumerationMutation
(long obj) Inserted by the compiler when a mutation is detected during a foreach iteration.static long
objc_getAssociatedObject
(long object, long key) Returns the value associated with a given object for a given key.static long
objc_getClass
(CharSequence name) Returns the class definition of a specified class.static long
objc_getClass
(ByteBuffer name) Returns the class definition of a specified class.static int
objc_getClassList
(org.lwjgl.PointerBuffer buffer) Obtains the list of registered class definitions.static long
Returns the metaclass definition of a specified class.static long
objc_getMetaClass
(ByteBuffer name) Returns the metaclass definition of a specified class.static long
objc_getProtocol
(CharSequence name) Returns a specified protocol.static long
objc_getProtocol
(ByteBuffer name) Returns a specified protocol.static long
Returns the class definition of a specified class.static long
Returns the class definition of a specified class.static long
objc_loadWeak
(org.lwjgl.PointerBuffer location) Loads the object referenced by a weak pointer and returns it.static long
objc_lookUpClass
(CharSequence name) Returns the class definition of a specified class.static long
objc_lookUpClass
(ByteBuffer name) Returns the class definition of a specified class.static void
objc_registerClassPair
(long cls) Registers a class that was allocated usingobjc_allocateClassPair(long, java.nio.ByteBuffer, long)
.static void
objc_registerProtocol
(long proto) Registers a newly created protocol with the Objective-C runtime.static void
objc_removeAssociatedObjects
(long object) Removes all associations for a given object.static void
objc_setAssociatedObject
(long object, long key, long value, long policy) Sets an associated value for a given object using a given key and association policy.static void
Sets the current mutation handler.static long
objc_storeWeak
(org.lwjgl.PointerBuffer location, long obj) Stores a new value in a__weak
variable.static long
object_copy
(long obj, long size) Returns a copy of a given object.static long
object_dispose
(long obj) Frees the memory occupied by a given object.static long
object_getClass
(long obj) Returns the class of an object.static String
object_getClassName
(long obj) Returns the class name of a given object.static long
object_getIndexedIvars
(long obj) This function returns a pointer to any extra bytes allocated with the instance (as specified byclass_createInstance(long, long)
with extraBytes>0).static long
object_getInstanceVariable
(long obj, CharSequence name, org.lwjgl.PointerBuffer outValue) Obtains the value of an instance variable of a class instance.static long
object_getInstanceVariable
(long obj, ByteBuffer name, org.lwjgl.PointerBuffer outValue) Obtains the value of an instance variable of a class instance.static long
object_getIvar
(long obj, long ivar) Reads the value of an instance variable in an object.static long
object_setClass
(long obj, long cls) Sets the class of an object.static long
object_setInstanceVariable
(long obj, CharSequence name, ByteBuffer value) Changes the value of an instance variable of a class instance.static long
object_setInstanceVariable
(long obj, ByteBuffer name, ByteBuffer value) Changes the value of an instance variable of a class instance.static void
object_setIvar
(long obj, long ivar, long value) Sets the value of an instance variable in an object.static ObjCPropertyAttribute.Buffer
property_copyAttributeList
(long property) Returns an array of property attributes for a given property.static String
property_copyAttributeValue
(long property, CharSequence attributeName) Returns the value of a property attribute given the attribute name.static String
property_copyAttributeValue
(long property, ByteBuffer attributeName) Returns the value of a property attribute given the attribute name.static String
property_getAttributes
(long property) Returns the attribute string of a property.static String
property_getName
(long property) Returns the name of a property.static void
protocol_addMethodDescription
(long proto, long name, CharSequence types, boolean isRequiredMethod, boolean isInstanceMethod) Adds a method to a protocol.static void
protocol_addMethodDescription
(long proto, long name, ByteBuffer types, boolean isRequiredMethod, boolean isInstanceMethod) Adds a method to a protocol.static void
protocol_addProperty
(long proto, CharSequence name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty) Adds a property to a protocol that is under construction.static void
protocol_addProperty
(long proto, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty) Adds a property to a protocol that is under construction.static void
protocol_addProtocol
(long proto, long addition) Adds a registered protocol to another protocol that is under construction.static boolean
protocol_conformsToProtocol
(long proto, long other) Returns a Boolean value that indicates whether one protocol conforms to another protocol.static ObjCMethodDescription.Buffer
protocol_copyMethodDescriptionList
(long p, boolean isRequiredMethod, boolean isInstanceMethod) Returns an array of method descriptions of methods meeting a given specification for a given protocol.static org.lwjgl.PointerBuffer
protocol_copyPropertyList
(long proto) Returns an array of the properties declared by a protocol.static org.lwjgl.PointerBuffer
protocol_copyProtocolList
(long proto) eturns an array of the protocols adopted by a protocol.static ObjCMethodDescription
protocol_getMethodDescription
(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, ObjCMethodDescription __result) Returns a method description structure for a specified method of a given protocol.static String
protocol_getName
(long p) Returns a the name of a protocol.static long
protocol_getProperty
(long proto, CharSequence name, boolean isRequiredProperty, boolean isInstanceProperty) Returns the specified property of a given protocol.static long
protocol_getProperty
(long proto, ByteBuffer name, boolean isRequiredProperty, boolean isInstanceProperty) Returns the specified property of a given protocol.static boolean
protocol_isEqual
(long proto, long other) Returns a Boolean value that indicates whether two protocols are equal.static String
sel_getName
(long sel) Returns the name of the method specified by a given selector.static long
sel_getUid
(CharSequence str) Registers a method name with the Objective-C runtime system.static long
sel_getUid
(ByteBuffer str) Registers a method name with the Objective-C runtime system.static boolean
sel_isEqual
(long lhs, long rhs) Returns a Boolean value that indicates whether two selectors are equal.static long
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.static long
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.
-
Field Details
-
nil
public static final long nilNil value.- See Also:
-
YES
public static final byte YESBoolean values.- See Also:
-
NO
public static final byte NOBoolean values.- See Also:
-
_C_ID
public static final char _C_IDTypes.- See Also:
-
_C_CLASS
public static final char _C_CLASSTypes.- See Also:
-
_C_SEL
public static final char _C_SELTypes.- See Also:
-
_C_CHR
public static final char _C_CHRTypes.- See Also:
-
_C_UCHR
public static final char _C_UCHRTypes.- See Also:
-
_C_SHT
public static final char _C_SHTTypes.- See Also:
-
_C_USHT
public static final char _C_USHTTypes.- See Also:
-
_C_INT
public static final char _C_INTTypes.- See Also:
-
_C_UINT
public static final char _C_UINTTypes.- See Also:
-
_C_LNG
public static final char _C_LNGTypes.- See Also:
-
_C_ULNG
public static final char _C_ULNGTypes.- See Also:
-
_C_LNG_LNG
public static final char _C_LNG_LNGTypes.- See Also:
-
_C_ULNG_LNG
public static final char _C_ULNG_LNGTypes.- See Also:
-
_C_FLT
public static final char _C_FLTTypes.- See Also:
-
_C_DBL
public static final char _C_DBLTypes.- See Also:
-
_C_BFLD
public static final char _C_BFLDTypes.- See Also:
-
_C_BOOL
public static final char _C_BOOLTypes.- See Also:
-
_C_VOID
public static final char _C_VOIDTypes.- See Also:
-
_C_UNDEF
public static final char _C_UNDEFTypes.- See Also:
-
_C_PTR
public static final char _C_PTRTypes.- See Also:
-
_C_CHARPTR
public static final char _C_CHARPTRTypes.- See Also:
-
_C_ATOM
public static final char _C_ATOMTypes.- See Also:
-
_C_ARY_B
public static final char _C_ARY_BTypes.- See Also:
-
_C_ARY_E
public static final char _C_ARY_ETypes.- See Also:
-
_C_UNION_B
public static final char _C_UNION_BTypes.- See Also:
-
_C_UNION_E
public static final char _C_UNION_ETypes.- See Also:
-
_C_STRUCT_B
public static final char _C_STRUCT_BTypes.- See Also:
-
_C_STRUCT_E
public static final char _C_STRUCT_ETypes.- See Also:
-
_C_VECTOR
public static final char _C_VECTORTypes.- See Also:
-
_C_CONST
public static final char _C_CONSTTypes.- See Also:
-
OBJC_ASSOCIATION_ASSIGN
public static final int OBJC_ASSOCIATION_ASSIGNPolicies related to associative references.- See Also:
-
OBJC_ASSOCIATION_RETAIN_NONATOMIC
public static final int OBJC_ASSOCIATION_RETAIN_NONATOMICPolicies related to associative references.- See Also:
-
OBJC_ASSOCIATION_COPY_NONATOMIC
public static final int OBJC_ASSOCIATION_COPY_NONATOMICPolicies related to associative references.- See Also:
-
OBJC_ASSOCIATION_RETAIN
public static final int OBJC_ASSOCIATION_RETAINPolicies related to associative references.- See Also:
-
OBJC_ASSOCIATION_COPY
public static final int OBJC_ASSOCIATION_COPYPolicies related to associative references.- See Also:
-
-
Method Details
-
getLibrary
public static org.lwjgl.system.SharedLibrary getLibrary()Returns the objcSharedLibrary
. -
object_copy
public static long object_copy(long obj, long size) Returns a copy of a given object.- Parameters:
obj
- an Objective-C objectsize
- the size of the objectobj
- Returns:
- a copy of obj
-
object_dispose
public static long object_dispose(long obj) Frees the memory occupied by a given object.- Parameters:
obj
- an Objective-C object- Returns:
nil
-
object_getClass
public static long object_getClass(long obj) Returns the class of an object.- Parameters:
obj
- an Objective-C object- Returns:
- the class object of which object is an instance, or Nil if
obj
isnil
-
object_setClass
public static long object_setClass(long obj, long cls) Sets the class of an object.- Parameters:
obj
- the object to modifycls
- a class object- Returns:
- the previous value of object's class, or Nil if
obj
isnil
-
nobject_getClassName
public static long nobject_getClassName(long obj) Unsafe version of:object_getClassName(long)
-
object_getClassName
Returns the class name of a given object.- Parameters:
obj
- an Objective-C object- Returns:
- the name of the class of which
obj
is an instance
-
object_getIndexedIvars
public static long object_getIndexedIvars(long obj) This function returns a pointer to any extra bytes allocated with the instance (as specified byclass_createInstance(long, long)
with extraBytes>0). This memory follows the object's ordinary ivars, but may not be adjacent to the last ivar.The returned pointer is guaranteed to be pointer-size aligned, even if the area following the object's last ivar is less aligned than that. Alignment greater than pointer-size is never guaranteed, even if the area following the object's last ivar is more aligned than that.
In a garbage-collected environment, the memory is scanned conservatively.
- Parameters:
obj
- an Objective-C object- Returns:
- a pointer to any extra bytes allocated with
obj
. Ifobj
was not allocated with any extra bytes, then dereferencing the returned pointer is undefined.
-
object_getIvar
public static long object_getIvar(long obj, long ivar) Reads the value of an instance variable in an object. -
object_setIvar
public static void object_setIvar(long obj, long ivar, long value) Sets the value of an instance variable in an object.object_setIvar is faster than
object_setInstanceVariable(long, java.nio.ByteBuffer, java.nio.ByteBuffer)
if the Ivar for the instance variable is already known.- Parameters:
obj
- the object containing the instance variable whose value you want to setivar
- the Ivar describing the instance variable whose value you want to setvalue
- the new value for the instance variable
-
nobject_setInstanceVariable
public static long nobject_setInstanceVariable(long obj, long name, long value) Unsafe version of:object_setInstanceVariable(long, java.nio.ByteBuffer, java.nio.ByteBuffer)
-
object_setInstanceVariable
Changes the value of an instance variable of a class instance.- Parameters:
obj
- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to modifyname
- a C string. Pass the name of the instance variable whose value you wish to modifyvalue
- the new value for the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
object_setInstanceVariable
Changes the value of an instance variable of a class instance.- Parameters:
obj
- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to modifyname
- a C string. Pass the name of the instance variable whose value you wish to modifyvalue
- the new value for the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
nobject_getInstanceVariable
public static long nobject_getInstanceVariable(long obj, long name, long outValue) -
object_getInstanceVariable
public static long object_getInstanceVariable(long obj, ByteBuffer name, org.lwjgl.PointerBuffer outValue) Obtains the value of an instance variable of a class instance.- Parameters:
obj
- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to obtainname
- a C string. Pass the name of the instance variable whose value you wish to obtainoutValue
- on return, contains a pointer to the value of the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
object_getInstanceVariable
public static long object_getInstanceVariable(long obj, CharSequence name, org.lwjgl.PointerBuffer outValue) Obtains the value of an instance variable of a class instance.- Parameters:
obj
- a pointer to an instance of a class. Pass the object containing the instance variable whose value you wish to obtainname
- a C string. Pass the name of the instance variable whose value you wish to obtainoutValue
- on return, contains a pointer to the value of the instance variable- Returns:
- a pointer to the Ivar data structure that defines the type and name of the instance variable specified by name
-
nobjc_getClass
public static long nobjc_getClass(long name) Unsafe version of:objc_getClass(java.nio.ByteBuffer)
-
objc_getClass
Returns the class definition of a specified class.objc_getClass is different from
objc_lookUpClass(java.nio.ByteBuffer)
in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass does not call the class handler callback.- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class, or
nil
if the class is not registered with the Objective-C runtime
-
objc_getClass
Returns the class definition of a specified class.objc_getClass is different from
objc_lookUpClass(java.nio.ByteBuffer)
in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass does not call the class handler callback.- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class, or
nil
if the class is not registered with the Objective-C runtime
-
nobjc_getMetaClass
public static long nobjc_getMetaClass(long name) Unsafe version of:objc_getMetaClass(java.nio.ByteBuffer)
-
objc_getMetaClass
Returns the metaclass definition of a specified class.If the definition for the named class is not registered, this function calls the class handler callback and then checks a second time to see if the class is registered. However, every class definition must have a valid metaclass definition, and so the metaclass definition is always returned, whether it’s valid or not.
- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the metaclass of the named class, or
nil
if the class is not registered with the Objective-C runtime
-
objc_getMetaClass
Returns the metaclass definition of a specified class.If the definition for the named class is not registered, this function calls the class handler callback and then checks a second time to see if the class is registered. However, every class definition must have a valid metaclass definition, and so the metaclass definition is always returned, whether it’s valid or not.
- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the metaclass of the named class, or
nil
if the class is not registered with the Objective-C runtime
-
nobjc_lookUpClass
public static long nobjc_lookUpClass(long name) Unsafe version of:objc_lookUpClass(java.nio.ByteBuffer)
-
objc_lookUpClass
Returns the class definition of a specified class.objc_getClass(java.nio.ByteBuffer)
is different from this function in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. This function does not call the class handler callback.- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class, or
nil
if the class is not registered with the Objective-C runtime
-
objc_lookUpClass
Returns the class definition of a specified class.objc_getClass(java.nio.ByteBuffer)
is different from this function in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. This function does not call the class handler callback.- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class, or
nil
if the class is not registered with the Objective-C runtime
-
nobjc_getRequiredClass
public static long nobjc_getRequiredClass(long name) Unsafe version of:objc_getRequiredClass(java.nio.ByteBuffer)
-
objc_getRequiredClass
Returns the class definition of a specified class.This function is the same as
objc_getClass(java.nio.ByteBuffer)
, but kills the process if the class is not found.This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class
-
objc_getRequiredClass
Returns the class definition of a specified class.This function is the same as
objc_getClass(java.nio.ByteBuffer)
, but kills the process if the class is not found.This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
- Parameters:
name
- the name of the class to look up- Returns:
- the Class object for the named class
-
nobjc_getClassList
public static int nobjc_getClassList(long buffer, int bufferCount) Unsafe version of:objc_getClassList(org.lwjgl.PointerBuffer)
- Parameters:
bufferCount
- the number of pointers for which you have allocated space in buffer. On return, this function fills in only this number of elements. If this number is less than the number of registered classes, this function returns an arbitrary subset of the registered classes.
-
objc_getClassList
public static int objc_getClassList(@Nullable org.lwjgl.PointerBuffer buffer) Obtains the list of registered class definitions.The Objective-C runtime library automatically registers all the classes defined in your source code. You can create class definitions at runtime and register them with the
objc_allocateClassPair(long, java.nio.ByteBuffer, long)
andobjc_registerClassPair(long)
functions.Special Considerations
You cannot assume that class objects you get from this function are classes that inherit from NSObject, so you cannot safely call any methods on such classes without detecting that the method is implemented first.
- Parameters:
buffer
- an array of Class values. On output, each Class value points to one class definition, up to eitherbufferCount
or the total number of registered classes, whichever is less. You can passNULL
to obtain the total number of registered class definitions without actually retrieving any class definitions.- Returns:
- an integer value indicating the total number of registered classes
-
nobjc_copyClassList
public static long nobjc_copyClassList(long outCount) Unsafe version of:objc_copyClassList()
- Parameters:
outCount
- an integer pointer used to store the number of classes returned by this function in the list. This parameter may benil
-
objc_copyClassList
@Nullable public static org.lwjgl.PointerBuffer objc_copyClassList()Creates and returns a list of pointers to all registered class definitions.- Returns:
- a
nil
terminated array of classes. You must free the array with free()
-
nclass_getName
public static long nclass_getName(long cls) Unsafe version of:class_getName(long)
-
class_getName
Returns the name of a class.- Parameters:
cls
- a class object- Returns:
- the name of the class, or the empty string if cls is Nil
-
class_isMetaClass
public static boolean class_isMetaClass(long cls) Returns a Boolean value that indicates whether a class object is a metaclass. -
class_getSuperclass
public static long class_getSuperclass(long cls) Returns the superclass of a class.- Parameters:
cls
- a class object- Returns:
- the superclass of the class, or Nil if cls is a root class, or Nil if cls is Nil
-
class_getVersion
public static int class_getVersion(long cls) Returns the version number of a class definition.You can use the version number of the class definition to provide versioning of the interface that your class represents to other classes. This is especially useful for object serialization (that is, archiving of the object in a flattened form), where it is important to recognize changes to the layout of the instance variables in different class-definition versions.
Classes derived from the Foundation framework NSObject class can obtain the class-definition version number using the getVersion class method, which is implemented using the class_getVersion function.
- Parameters:
cls
- a pointer to an Class data structure. Pass the class definition for which you wish to obtain the version- Returns:
- an integer indicating the version number of the class definition
-
class_setVersion
public static void class_setVersion(long cls, int version) Sets the version number of a class definition.You can use the version number of the class definition to provide versioning of the interface that your class represents to other classes. This is especially useful for object serialization (that is, archiving of the object in a flattened form), where it is important to recognize changes to the layout of the instance variables in different class-definition versions.
Classes derived from the Foundation framework NSObject class can set the class-definition version number using the setVersion: class method, which is implemented using the class_setVersion function.
- Parameters:
cls
- a pointer to an Class data structure. Pass the class definition for which you wish to set the versionversion
- the new version number of the class definition
-
class_getInstanceSize
public static long class_getInstanceSize(long cls) Returns the size of instances of a class.- Parameters:
cls
- a class object- Returns:
- the size in bytes of instances of the class
cls
, or 0 ifcls
is Nil
-
nclass_getInstanceVariable
public static long nclass_getInstanceVariable(long cls, long name) Unsafe version of:class_getInstanceVariable(long, java.nio.ByteBuffer)
-
class_getInstanceVariable
Returns the Ivar for a specified instance variable of a given class.- Parameters:
cls
- the class whose instance variable you wish to obtainname
- the name of the instance variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the instance variable specified by name
-
class_getInstanceVariable
Returns the Ivar for a specified instance variable of a given class.- Parameters:
cls
- the class whose instance variable you wish to obtainname
- the name of the instance variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the instance variable specified by name
-
nclass_getClassVariable
public static long nclass_getClassVariable(long cls, long name) Unsafe version of:class_getClassVariable(long, java.nio.ByteBuffer)
-
class_getClassVariable
Returns the Ivar for a specified class variable of a given class.- Parameters:
cls
- the class definition whose class variable you wish to obtainname
- the name of the class variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the class variable specified by name
-
class_getClassVariable
Returns the Ivar for a specified class variable of a given class.- Parameters:
cls
- the class definition whose class variable you wish to obtainname
- the name of the class variable definition to obtain- Returns:
- a pointer to an Ivar data structure containing information about the class variable specified by name
-
nclass_copyIvarList
public static long nclass_copyIvarList(long cls, long outCount) Unsafe version of:class_copyIvarList(long)
- Parameters:
outCount
- on return, contains the length of the returned array. IfoutCount
isNULL
, the length is not returned
-
class_copyIvarList
@Nullable public static org.lwjgl.PointerBuffer class_copyIvarList(long cls) Describes the instance variables declared by a class.- Parameters:
cls
- the class to inspect- Returns:
- an array of pointers of type Ivar describing the instance variables declared by the class. Any instance variables declared by superclasses are not
included. The array contains
*outCount
pointers followed by aNULL
terminator. You must free the array with free().If the class declares no instance variables, or
cls
is Nil,NULL
is returned and*outCount
is 0.
-
class_getInstanceMethod
public static long class_getInstanceMethod(long cls, long name) Returns a specified instance method for a given class.Note that this function searches superclasses for implementations, whereas
class_copyMethodList(long)
does not.- Parameters:
cls
- the class you want to inspectname
- the selector of the method you want to retrieve- Returns:
- the method that corresponds to the implementation of the selector specified by aSelector for the class specified by
cls
, orNULL
if the specified class or its superclasses do not contain an instance method with the specified selector.
-
class_getClassMethod
public static long class_getClassMethod(long cls, long name) Returns a pointer to the data structure describing a given class method for a given class.Note that this function searches superclasses for implementations, whereas
class_copyMethodList(long)
does not.- Parameters:
cls
- a pointer to a class definition. Pass the class that contains the method you want to retrievename
- a pointer of type SEL. Pass the selector of the method you want to retrieve- Returns:
- a pointer to the Method data structure that corresponds to the implementation of the selector specified by
name
for the class specified bycls
, orNULL
if the specified class or its superclasses do not contain a class method with the specified selector.
-
class_getMethodImplementation
public static long class_getMethodImplementation(long cls, long name) Returns the function pointer that would be called if a particular message were sent to an instance of a class.class_getMethodImplementation may be faster than
method_getImplementation(class_getInstanceMethod(cls, name))
.The function pointer returned may be a function internal to the runtime instead of an actual method implementation. For example, if instances of the class do not respond to the selector, the function pointer returned will be part of the runtime's message forwarding machinery.
- Parameters:
cls
- the class you want to inspectname
- a selector- Returns:
- the function pointer that would be called if
[object name]
were called with an instance of the class, orNULL
ifcls
is Nil
-
class_respondsToSelector
public static boolean class_respondsToSelector(long cls, long name) Returns a Boolean value that indicates whether instances of a class respond to a particular selector.You should usually use NSObject's respondsToSelector: or instancesRespondToSelector: methods instead of this function.
-
nclass_copyMethodList
public static long nclass_copyMethodList(long cls, long outCount) Unsafe version of:class_copyMethodList(long)
- Parameters:
outCount
- on return, contains the length of the returned array. IfoutCount
isNULL
, the length is not returned
-
class_copyMethodList
@Nullable public static org.lwjgl.PointerBuffer class_copyMethodList(long cls) Describes the instance methods implemented by a class.- Parameters:
cls
- the class you want to inspect- Returns:
- an array of pointers of type Method describing the instance methods implemented by the class—any instance methods implemented by superclasses are not
included. The array contains
*outCount
pointers followed by aNULL
terminator. You must free the array with free().If
cls
implements no instance methods, orcls
is Nil, returnsNULL
and*outCount
is 0.
-
class_conformsToProtocol
public static boolean class_conformsToProtocol(long cls, long protocol) Returns a Boolean value that indicates whether a class conforms to a given protocol.You should usually use NSObject's conformsToProtocol: method instead of this function.
-
nclass_copyProtocolList
public static long nclass_copyProtocolList(long cls, long outCount) Unsafe version of:class_copyProtocolList(long)
- Parameters:
outCount
- on return, contains the length of the returned array. IfoutCount
isNULL
, the length is not returned
-
class_copyProtocolList
@Nullable public static org.lwjgl.PointerBuffer class_copyProtocolList(long cls) Describes the protocols adopted by a class.- Parameters:
cls
- the class you want to inspect- Returns:
- an array of pointers of type Protocol* describing the protocols adopted by the class. Any protocols adopted by superclasses or other protocols are not
included. The array contains
*outCount
pointers followed by aNULL
terminator. You must free the array with free().If
cls
adopts no protocols, orcls
is Nil, returnsNULL
and*outCount
is 0.
-
nclass_getProperty
public static long nclass_getProperty(long cls, long name) Unsafe version of:class_getProperty(long, java.nio.ByteBuffer)
-
class_getProperty
Returns a property with a given name of a given class.- Parameters:
cls
- the class you want to inspectname
- a C string. Pass the name of the instance variable whose value you wish to modify.- Returns:
- a pointer of type
objc_property_t
describing the property, orNULL
if the class does not declare a property with that name, orNULL
ifcls
is Nil.
-
class_getProperty
Returns a property with a given name of a given class.- Parameters:
cls
- the class you want to inspectname
- a C string. Pass the name of the instance variable whose value you wish to modify.- Returns:
- a pointer of type
objc_property_t
describing the property, orNULL
if the class does not declare a property with that name, orNULL
ifcls
is Nil.
-
nclass_copyPropertyList
public static long nclass_copyPropertyList(long cls, long outCount) Unsafe version of:class_copyPropertyList(long)
- Parameters:
outCount
- on return, contains the length of the returned array. IfoutCount
isNULL
, the length is not returned
-
class_copyPropertyList
@Nullable public static org.lwjgl.PointerBuffer class_copyPropertyList(long cls) Describes the properties declared by a class.- Parameters:
cls
- the class you want to inspect- Returns:
- an array of pointers of type
objc_property_t
describing the properties declared by the class. Any properties declared by superclasses are not included. The array contains*outCount
pointers followed by aNULL
terminator. You must free the array with free().If
cls
declares no properties, orcls
is Nil, returnsNULL
and*outCount
is 0.
-
nclass_getIvarLayout
public static long nclass_getIvarLayout(long cls) Unsafe version of:class_getIvarLayout(long)
-
class_getIvarLayout
Returns a description of the Ivar layout for a given class.- Parameters:
cls
- the class to inspect- Returns:
- a description of the Ivar layout for
cls
-
nclass_getWeakIvarLayout
public static long nclass_getWeakIvarLayout(long cls) Unsafe version of:class_getWeakIvarLayout(long)
-
class_getWeakIvarLayout
Returns a description of the layout of weak Ivars for a given class.- Parameters:
cls
- the class to inspect- Returns:
- a description of the layout of the weak Ivars for
cls
-
nclass_addMethod
public static boolean nclass_addMethod(long cls, long name, long imp, long types) Unsafe version of:class_addMethod(long, long, long, java.nio.ByteBuffer)
-
class_addMethod
Adds a new method to a class with a given name and implementation.Discussion
class_addMethod will add an override of a superclass's implementation, but will not replace an existing implementation in this class. To change an existing implementation, use
method_setImplementation(long, long)
.An Objective-C method is simply a C function that takes at least two arguments –
self
and_cmd
. For example, given the following function:void myMethodIMP(id self, SEL _cmd) { // implementation .... }
you can dynamically add it to a class as a method (called
resolveThisMethodDynamically
) like this:class_addMethod([self class], @selector(resolveThisMethodDynamically), (IMP) myMethodIMP, "v@:");
- Parameters:
cls
- the class to which to add a methodname
- a selector that specifies the name of the method being addedimp
- a function which is the implementation of the new method. The function must take at least two arguments –self
and_cmd
.types
- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –self
and_cmd
, the second and third characters must be “@:” (the first character is the return type).- Returns:
YES
if the method was added successfully, otherwiseNO
(for example, the class already contains a method implementation with that name)
-
class_addMethod
Adds a new method to a class with a given name and implementation.Discussion
class_addMethod will add an override of a superclass's implementation, but will not replace an existing implementation in this class. To change an existing implementation, use
method_setImplementation(long, long)
.An Objective-C method is simply a C function that takes at least two arguments –
self
and_cmd
. For example, given the following function:void myMethodIMP(id self, SEL _cmd) { // implementation .... }
you can dynamically add it to a class as a method (called
resolveThisMethodDynamically
) like this:class_addMethod([self class], @selector(resolveThisMethodDynamically), (IMP) myMethodIMP, "v@:");
- Parameters:
cls
- the class to which to add a methodname
- a selector that specifies the name of the method being addedimp
- a function which is the implementation of the new method. The function must take at least two arguments –self
and_cmd
.types
- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –self
and_cmd
, the second and third characters must be “@:” (the first character is the return type).- Returns:
YES
if the method was added successfully, otherwiseNO
(for example, the class already contains a method implementation with that name)
-
nclass_replaceMethod
public static long nclass_replaceMethod(long cls, long name, long imp, long types) Unsafe version of:class_replaceMethod(long, long, long, java.nio.ByteBuffer)
-
class_replaceMethod
Replaces the implementation of a method for a given class.Discussion
This function behaves in two different ways:
- If the method identified by name does not yet exist, it is added as if class_addMethod were called. The type encoding specified by types is used as given.
- If the method identified by name does exist, its IMP is replaced as if method_setImplementation were called. The type encoding specified by types is ignored.
- Parameters:
cls
- the class you want to modifyname
- a selector that identifies the method whose implementation you want to replaceimp
- the new implementation for the method identified byname
for the class identified bycls
types
- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –self
and_cmd
, the second and third characters must be “@:” (the first character is the return type).- Returns:
- the previous implementation of the method identified by
name
for the class identified bycls
-
class_replaceMethod
Replaces the implementation of a method for a given class.Discussion
This function behaves in two different ways:
- If the method identified by name does not yet exist, it is added as if class_addMethod were called. The type encoding specified by types is used as given.
- If the method identified by name does exist, its IMP is replaced as if method_setImplementation were called. The type encoding specified by types is ignored.
- Parameters:
cls
- the class you want to modifyname
- a selector that identifies the method whose implementation you want to replaceimp
- the new implementation for the method identified byname
for the class identified bycls
types
- an array of characters that describe the types of the arguments to the method. For possible values, see Objective-C Runtime Programming Guide > Type Encodings in Objective-C Runtime Programming Guide. Since the function must take at least two arguments –self
and_cmd
, the second and third characters must be “@:” (the first character is the return type).- Returns:
- the previous implementation of the method identified by
name
for the class identified bycls
-
nclass_addIvar
public static boolean nclass_addIvar(long cls, long name, long size, byte alignment, long types) Unsafe version of:class_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer)
-
class_addIvar
public static boolean class_addIvar(long cls, ByteBuffer name, long size, byte alignment, ByteBuffer types) Adds a new instance variable to a class.This function may only be called after
objc_allocateClassPair(long, java.nio.ByteBuffer, long)
and beforeobjc_registerClassPair(long)
. Adding an instance variable to an existing class is not supported.The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
The instance variable's minimum alignment in bytes is
1<<align
. The minimum alignment of an instance variable depends on the ivar's type and the machine architecture. For variables of any pointer type, passlog2(sizeof(pointer_type))
. -
class_addIvar
public static boolean class_addIvar(long cls, CharSequence name, long size, byte alignment, CharSequence types) Adds a new instance variable to a class.This function may only be called after
objc_allocateClassPair(long, java.nio.ByteBuffer, long)
and beforeobjc_registerClassPair(long)
. Adding an instance variable to an existing class is not supported.The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
The instance variable's minimum alignment in bytes is
1<<align
. The minimum alignment of an instance variable depends on the ivar's type and the machine architecture. For variables of any pointer type, passlog2(sizeof(pointer_type))
. -
class_addProtocol
public static boolean class_addProtocol(long cls, long protocol) Adds a protocol to a class. -
nclass_addProperty
public static boolean nclass_addProperty(long cls, long name, long attributes, int attributeCount) Unsafe version of:class_addProperty(long, java.nio.ByteBuffer, org.lwjgl.system.macosx.ObjCPropertyAttribute.Buffer)
- Parameters:
attributeCount
- the number of attributes inattributes
-
class_addProperty
public static boolean class_addProperty(long cls, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes) Adds a property to a class. -
class_addProperty
public static boolean class_addProperty(long cls, CharSequence name, ObjCPropertyAttribute.Buffer attributes) Adds a property to a class. -
nclass_replaceProperty
public static void nclass_replaceProperty(long cls, long name, long attributes, int attributeCount) Unsafe version of:class_replaceProperty(long, java.nio.ByteBuffer, org.lwjgl.system.macosx.ObjCPropertyAttribute.Buffer)
- Parameters:
attributeCount
- the number of attributes inattributes
-
class_replaceProperty
public static void class_replaceProperty(long cls, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes) Replaces a property of a class.- Parameters:
cls
- the class to modifyname
- the name of the propertyattributes
- an array of property attributes
-
class_replaceProperty
public static void class_replaceProperty(long cls, CharSequence name, ObjCPropertyAttribute.Buffer attributes) Replaces a property of a class.- Parameters:
cls
- the class to modifyname
- the name of the propertyattributes
- an array of property attributes
-
nclass_setIvarLayout
public static void nclass_setIvarLayout(long cls, long layout) Unsafe version of:class_setIvarLayout(long, java.nio.ByteBuffer)
-
class_setIvarLayout
Sets the Ivar layout for a given class.- Parameters:
cls
- the class to modifylayout
- the layout of the Ivars forcls
-
class_setIvarLayout
Sets the Ivar layout for a given class.- Parameters:
cls
- the class to modifylayout
- the layout of the Ivars forcls
-
nclass_setWeakIvarLayout
public static void nclass_setWeakIvarLayout(long cls, long layout) Unsafe version of:class_setWeakIvarLayout(long, java.nio.ByteBuffer)
-
class_setWeakIvarLayout
Sets the layout for weak Ivars for a given class.- Parameters:
cls
- the class to modifylayout
- the layout of the weak Ivars forcls
-
class_setWeakIvarLayout
Sets the layout for weak Ivars for a given class.- Parameters:
cls
- the class to modifylayout
- the layout of the weak Ivars forcls
-
class_createInstance
public static long class_createInstance(long cls, long extraBytes) Creates an instance of a class, allocating memory for the class in the default malloc memory zone.- Parameters:
cls
- the class that you want to allocate an instance ofextraBytes
- an integer indicating the number of extra bytes to allocate. The additional bytes can be used to store additional instance variables beyond those defined in the class definition.- Returns:
- an instance of the class
cls
-
nobjc_constructInstance
public static long nobjc_constructInstance(long cls, long bytes) Unsafe version of:objc_constructInstance(long, java.nio.ByteBuffer)
-
objc_constructInstance
Creates an instance of a class at the specified location.- Parameters:
cls
- the class that you want to allocate an instance ofbytes
- the location at which to allocate an instance of thecls
class.bytes
must point to at leastclass_getInstanceSize(cls)
bytes of well-aligned, zero-filled memory.- Returns:
- an instance of the class
cls
atbytes
, if successful; otherwisenil
(for example, ifcls
orbytes
are themselvesnil
)
-
objc_destructInstance
public static long objc_destructInstance(long obj) Destroys an instance of a class without freeing memory and removes any of its associated references.This method does nothing if obj is
nil
.Important
The garbage collector does not call this function. As a result, if you edit this function, you should also edit finalize. That said, Core Foundation and other clients do call this function under garbage collection.
- Parameters:
obj
- the instance to destroy
-
nobjc_allocateClassPair
public static long nobjc_allocateClassPair(long superclass, long name, long extraBytes) Unsafe version of:objc_allocateClassPair(long, java.nio.ByteBuffer, long)
-
objc_allocateClassPair
Creates a new class and metaclass.You can get a pointer to the new metaclass by calling
object_getClass(newClass)
.To create a new class, start by calling objc_allocateClassPair. Then set the class's attributes with functions like
class_addMethod(long, long, long, java.nio.ByteBuffer)
andclass_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer)
. When you are done building the class, callobjc_registerClassPair(long)
. The new class is now ready for use.Instance methods and instance variables should be added to the class itself. Class methods should be added to the metaclass.
- Parameters:
superclass
- the class to use as the new class's superclass, or Nil to create a new root classname
- the string to use as the new class's name. The string will be copied.extraBytes
- the number of bytes to allocate for indexed ivars at the end of the class and metaclass objects. This should usually be 0.- Returns:
- the new class, or Nil if the class could not be created (for example, the desired name is already in use)
-
objc_allocateClassPair
Creates a new class and metaclass.You can get a pointer to the new metaclass by calling
object_getClass(newClass)
.To create a new class, start by calling objc_allocateClassPair. Then set the class's attributes with functions like
class_addMethod(long, long, long, java.nio.ByteBuffer)
andclass_addIvar(long, java.nio.ByteBuffer, long, byte, java.nio.ByteBuffer)
. When you are done building the class, callobjc_registerClassPair(long)
. The new class is now ready for use.Instance methods and instance variables should be added to the class itself. Class methods should be added to the metaclass.
- Parameters:
superclass
- the class to use as the new class's superclass, or Nil to create a new root classname
- the string to use as the new class's name. The string will be copied.extraBytes
- the number of bytes to allocate for indexed ivars at the end of the class and metaclass objects. This should usually be 0.- Returns:
- the new class, or Nil if the class could not be created (for example, the desired name is already in use)
-
objc_registerClassPair
public static void objc_registerClassPair(long cls) Registers a class that was allocated usingobjc_allocateClassPair(long, java.nio.ByteBuffer, long)
.- Parameters:
cls
- the class you want to register
-
objc_disposeClassPair
public static void objc_disposeClassPair(long cls) Destroys a class and its associated metaclass.Do not call this function if instances of the
cls
class or any subclass exist.- Parameters:
cls
- the class to be destroyed. This class must have been allocated usingobjc_allocateClassPair(long, java.nio.ByteBuffer, long)
.
-
method_getName
public static long method_getName(long m) Returns the name of a method.To get the method name as a C string, call
sel_getName(method_getName(method))
.- Parameters:
m
- the method to inspect- Returns:
- a pointer of type SEL
-
method_getImplementation
public static long method_getImplementation(long m) Returns the implementation of a method.- Parameters:
m
- the method to inspect- Returns:
- a function pointer of type IMP
-
nmethod_getTypeEncoding
public static long nmethod_getTypeEncoding(long m) Unsafe version of:method_getTypeEncoding(long)
-
method_getTypeEncoding
Returns a string describing a method's parameter and return types.- Parameters:
m
- the method to inspect- Returns:
- a C string. The string may be
NULL
-
method_getNumberOfArguments
public static int method_getNumberOfArguments(long m) Returns the number of arguments accepted by a method.- Parameters:
m
- a pointer to a Method data structure. Pass the method in question.- Returns:
- an integer containing the number of arguments accepted by the given method
-
nmethod_copyReturnType
public static long nmethod_copyReturnType(long m) Unsafe version of:method_copyReturnType(long)
-
method_copyReturnType
Returns a string describing a method's return type.- Parameters:
m
- the method to inspect- Returns:
- a C string describing the return type. You must free the string with free().
-
nmethod_copyArgumentType
public static long nmethod_copyArgumentType(long m, int index) Unsafe version of:method_copyArgumentType(long, int)
-
method_copyArgumentType
Returns a string describing a single parameter type of a method.- Parameters:
m
- the method to inspectindex
- the index of the parameter to inspect- Returns:
- a C string describing the type of the parameter at index
index
, orNULL
if method has no parameter indexindex
. You must free the string with free().
-
nmethod_getReturnType
public static void nmethod_getReturnType(long m, long dst, long dst_len) Unsafe version of:method_getReturnType(long, java.nio.ByteBuffer)
- Parameters:
dst_len
- the maximum number of characters that can be stored indst
-
method_getReturnType
Returns by reference a string describing a method's return type.The method's return type string is copied to
dst
.dst
is filled as ifstrncpy(dst, parameter_type, dst_len)
were called.- Parameters:
m
- the method to inspectdst
- the reference string to store the description
-
method_getReturnType
Returns by reference a string describing a method's return type.The method's return type string is copied to
dst
.dst
is filled as ifstrncpy(dst, parameter_type, dst_len)
were called.- Parameters:
m
- the method to inspectdst_len
- the maximum number of characters that can be stored indst
-
nmethod_getArgumentType
public static void nmethod_getArgumentType(long m, int index, long dst, long dst_len) Unsafe version of:method_getArgumentType(long, int, java.nio.ByteBuffer)
- Parameters:
dst_len
- the maximum number of characters that can be stored indst
-
method_getArgumentType
Returns by reference a string describing a single parameter type of a method.The parameter type string is copied to
dst
.dst
is filled as ifstrncpy(dst, parameter_type, dst_len)
were called. If the method contains no parameter with that index,dst
is filled as ifstrncpy(dst, "", dst_len)
were called.- Parameters:
m
- the method you want to inquire aboutindex
- the index of the parameter you want to inquire aboutdst
- the reference string to store the description
-
method_getArgumentType
Returns by reference a string describing a single parameter type of a method.The parameter type string is copied to
dst
.dst
is filled as ifstrncpy(dst, parameter_type, dst_len)
were called. If the method contains no parameter with that index,dst
is filled as ifstrncpy(dst, "", dst_len)
were called.- Parameters:
m
- the method you want to inquire aboutindex
- the index of the parameter you want to inquire aboutdst_len
- the maximum number of characters that can be stored indst
-
method_setImplementation
public static long method_setImplementation(long m, long imp) Sets the implementation of a method.- Parameters:
m
- the method for which to set an implementationimp
- the implemention to set to this method- Returns:
- the previous implementation of the method
-
method_exchangeImplementations
public static void method_exchangeImplementations(long m1, long m2) Exchanges the implementations of two methods.- Parameters:
m1
- the method to exchange with second methodm2
- the method to exchange with first method
-
nivar_getName
public static long nivar_getName(long v) Unsafe version of:ivar_getName(long)
-
ivar_getName
Returns the name of an instance variable.- Parameters:
v
- the instance variable- Returns:
- a C string containing the instance variable's name
-
nivar_getTypeEncoding
public static long nivar_getTypeEncoding(long v) Unsafe version of:ivar_getTypeEncoding(long)
-
ivar_getTypeEncoding
Returns the type string of an instance variable.- Parameters:
v
- the instance variable- Returns:
- a C string containing the instance variable's type encoding
-
ivar_getOffset
public static long ivar_getOffset(long v) Returns the offset of an instance variable.For instance variables of type
id
or other object types, callobject_getIvar(long, long)
andobject_setIvar(long, long, long)
instead of using this offset to access the instance variable data directly.- Parameters:
v
- the instance variable- Returns:
- the offset of
v
-
nproperty_getName
public static long nproperty_getName(long property) Unsafe version of:property_getName(long)
-
property_getName
Returns the name of a property.- Parameters:
property
- the property you want to inquire about- Returns:
- a C string containing the property's name
-
nproperty_getAttributes
public static long nproperty_getAttributes(long property) Unsafe version of:property_getAttributes(long)
-
property_getAttributes
Returns the attribute string of a property.- Parameters:
property
- a property- Returns:
- a C string containing the property's attributes
-
nproperty_copyAttributeList
public static long nproperty_copyAttributeList(long property, long outCount) Unsafe version of:property_copyAttributeList(long)
- Parameters:
outCount
- the number of attributes returned in the array
-
property_copyAttributeList
Returns an array of property attributes for a given property.- Parameters:
property
- the property whose attributes you want to copy- Returns:
- an array of property attributes. You must free the array with free().
-
nproperty_copyAttributeValue
public static long nproperty_copyAttributeValue(long property, long attributeName) Unsafe version of:property_copyAttributeValue(long, java.nio.ByteBuffer)
-
property_copyAttributeValue
Returns the value of a property attribute given the attribute name.- Parameters:
property
- the property whose value you are interested inattributeName
- a C string representing the name of the attribute- Returns:
- The value string of the
attributeName
attribute, if one exists inproperty
; otherwise,nil
. You must free the returned value string with free().
-
property_copyAttributeValue
@Nullable public static String property_copyAttributeValue(long property, CharSequence attributeName) Returns the value of a property attribute given the attribute name.- Parameters:
property
- the property whose value you are interested inattributeName
- a C string representing the name of the attribute- Returns:
- The value string of the
attributeName
attribute, if one exists inproperty
; otherwise,nil
. You must free the returned value string with free().
-
nobjc_getProtocol
public static long nobjc_getProtocol(long name) Unsafe version of:objc_getProtocol(java.nio.ByteBuffer)
-
objc_getProtocol
Returns a specified protocol.This function acquires the runtime lock.
- Parameters:
name
- the name of a protocol- Returns:
- the protocol named
name
{, orNULL
if no protocol named name could be found
-
objc_getProtocol
Returns a specified protocol.This function acquires the runtime lock.
- Parameters:
name
- the name of a protocol- Returns:
- the protocol named
name
{, orNULL
if no protocol named name could be found
-
nobjc_copyProtocolList
public static long nobjc_copyProtocolList(long outCount) Unsafe version of:objc_copyProtocolList()
- Parameters:
outCount
- upon return, contains the number of protocols in the returned array
-
objc_copyProtocolList
@Nullable public static org.lwjgl.PointerBuffer objc_copyProtocolList()Returns an array of all the protocols known to the runtime.- Returns:
- a C array of all the protocols known to the runtime. The array contains
*outCount
pointers followed by aNULL
terminator. You must free the list with free().
-
protocol_conformsToProtocol
public static boolean protocol_conformsToProtocol(long proto, long other) Returns a Boolean value that indicates whether one protocol conforms to another protocol.Discussion
One protocol can incorporate other protocols using the same syntax that classes use to adopt a protocol:
@protocol ProtocolName < protocol list >
All the protocols listed between angle brackets are considered part of the
ProtocolName
protocol. -
protocol_isEqual
public static boolean protocol_isEqual(long proto, long other) Returns a Boolean value that indicates whether two protocols are equal. -
nprotocol_getName
public static long nprotocol_getName(long p) Unsafe version of:protocol_getName(long)
-
protocol_getName
Returns a the name of a protocol.- Parameters:
p
- a protocol- Returns:
- the name of the protocol
p
as a C string
-
nprotocol_getMethodDescription
public static void nprotocol_getMethodDescription(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, long __functionAddress, long __result) -
nprotocol_getMethodDescription
public static void nprotocol_getMethodDescription(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, long __result) -
protocol_getMethodDescription
public static ObjCMethodDescription protocol_getMethodDescription(long p, long aSel, boolean isRequiredMethod, boolean isInstanceMethod, ObjCMethodDescription __result) Returns a method description structure for a specified method of a given protocol.- Parameters:
p
- a protocolaSel
- a selectorisRequiredMethod
- a Boolean value that indicates whetheraSel
is a required methodisInstanceMethod
- a Boolean value that indicates whetheraSel
is a instance method__result
- an objc_method_description structure that describes the method specified byaSel
,isRequiredMethod
, andisInstanceMethod
for the protocolp
.If the protocol does not contain the specified method, returns an objc_method_description structure with the value
{NULL, NULL}
.
-
nprotocol_copyMethodDescriptionList
public static long nprotocol_copyMethodDescriptionList(long p, boolean isRequiredMethod, boolean isInstanceMethod, long outCount) Unsafe version of:protocol_copyMethodDescriptionList(long, boolean, boolean)
- Parameters:
outCount
- upon return, contains the number of method description structures in the returned array
-
protocol_copyMethodDescriptionList
@Nullable public static ObjCMethodDescription.Buffer protocol_copyMethodDescriptionList(long p, boolean isRequiredMethod, boolean isInstanceMethod) Returns an array of method descriptions of methods meeting a given specification for a given protocol.Methods in other protocols adopted by this protocol are not included.
- Parameters:
p
- a protocolisRequiredMethod
- a Boolean value that indicates whether returned methods should be required methods (passYES
to specify required methods)isInstanceMethod
- a Boolean value that indicates whether returned methods should be instance methods (passYES
to specify instance methods)- Returns:
- a C array of objc_method_description structures containing the names and types of
p
's methods specified byisRequiredMethod
andisInstanceMethod
. The array contains*outCount
pointers followed by aNULL
terminator. You must free the list with free().If the protocol declares no methods that meet the specification,
NULL
is returned and*outCount
is 0.
-
nprotocol_getProperty
public static long nprotocol_getProperty(long proto, long name, boolean isRequiredProperty, boolean isInstanceProperty) Unsafe version of:protocol_getProperty(long, java.nio.ByteBuffer, boolean, boolean)
-
protocol_getProperty
public static long protocol_getProperty(long proto, ByteBuffer name, boolean isRequiredProperty, boolean isInstanceProperty) Returns the specified property of a given protocol.- Parameters:
proto
- a protocolname
- the name of a propertyisRequiredProperty
- a Boolean value that indicates whethername
is a required propertyisInstanceProperty
- a Boolean value that indicates whethername
is a instance property- Returns:
- the property specified by
name
,isRequiredProperty
, andisInstanceProperty
forproto
, orNULL
if none ofproto
's properties meets the specification
-
protocol_getProperty
public static long protocol_getProperty(long proto, CharSequence name, boolean isRequiredProperty, boolean isInstanceProperty) Returns the specified property of a given protocol.- Parameters:
proto
- a protocolname
- the name of a propertyisRequiredProperty
- a Boolean value that indicates whethername
is a required propertyisInstanceProperty
- a Boolean value that indicates whethername
is a instance property- Returns:
- the property specified by
name
,isRequiredProperty
, andisInstanceProperty
forproto
, orNULL
if none ofproto
's properties meets the specification
-
nprotocol_copyPropertyList
public static long nprotocol_copyPropertyList(long proto, long outCount) Unsafe version of:protocol_copyPropertyList(long)
- Parameters:
outCount
- upon return, contains the number of elements in the returned array
-
protocol_copyPropertyList
@Nullable public static org.lwjgl.PointerBuffer protocol_copyPropertyList(long proto) Returns an array of the properties declared by a protocol.- Parameters:
proto
- a protocol- Returns:
- a C array of pointers of type objc_property_t describing the properties declared by
proto
. Any properties declared by other protocols adopted by this protocol are not included. The array contains*outCount
pointers followed by aNULL
terminator. You must free the array with free().If the protocol declares no properties,
NULL
is returned and*outCount
is 0.
-
nprotocol_copyProtocolList
public static long nprotocol_copyProtocolList(long proto, long outCount) Unsafe version of:protocol_copyProtocolList(long)
- Parameters:
outCount
- upon return, contains the number of elements in the returned array
-
protocol_copyProtocolList
@Nullable public static org.lwjgl.PointerBuffer protocol_copyProtocolList(long proto) eturns an array of the protocols adopted by a protocol.- Parameters:
proto
- a protocol- Returns:
- a C array of protocols adopted by
proto
. The array contains*outCount
pointers followed by aNULL
terminator. You must free the array with free().If the protocol declares no properties,
NULL
is returned and*outCount
is 0.
-
nobjc_allocateProtocol
public static long nobjc_allocateProtocol(long name) Unsafe version of:objc_allocateProtocol(java.nio.ByteBuffer)
-
objc_allocateProtocol
Creates a new protocol instance.You must register the returned protocol instance with the
objc_registerProtocol(long)
function before you can use it.There is no dispose method associated with this function.
- Parameters:
name
- the name of the protocol you want to create- Returns:
- a new protocol instance or
nil
if a protocol with the same name asname
already exists
-
objc_allocateProtocol
Creates a new protocol instance.You must register the returned protocol instance with the
objc_registerProtocol(long)
function before you can use it.There is no dispose method associated with this function.
- Parameters:
name
- the name of the protocol you want to create- Returns:
- a new protocol instance or
nil
if a protocol with the same name asname
already exists
-
objc_registerProtocol
public static void objc_registerProtocol(long proto) Registers a newly created protocol with the Objective-C runtime.When you create a new protocol using the
objc_allocateProtocol(java.nio.ByteBuffer)
, you then register it with the Objective-C runtime by calling this function. After a protocol is successfully registered, it is immutable and ready to use.- Parameters:
proto
- the protocol you want to register with the Objective-C runtime
-
nprotocol_addMethodDescription
public static void nprotocol_addMethodDescription(long proto, long name, long types, boolean isRequiredMethod, boolean isInstanceMethod) -
protocol_addMethodDescription
public static void protocol_addMethodDescription(long proto, long name, ByteBuffer types, boolean isRequiredMethod, boolean isInstanceMethod) Adds a method to a protocol.To add a method to a protocol using this function, the protocol must be under construction. That is, you must add any methods to proto before you register it with the Objective-C runtime (via the
objc_registerProtocol(long)
function).- Parameters:
proto
- the protocol you want to add a method toname
- the name of the method you want to addtypes
- a C string representing the signature of the method you want to addisRequiredMethod
- a Boolean indicating whether the method is a required method of theproto
protocol. IfYES
, the method is a required method; ifNO
, the method is an optional method.isInstanceMethod
- a Boolean indicating whether the method is an instance method. IfYES
, the method is an instance method; ifNO
, the method is a class method.
-
protocol_addMethodDescription
public static void protocol_addMethodDescription(long proto, long name, CharSequence types, boolean isRequiredMethod, boolean isInstanceMethod) Adds a method to a protocol.To add a method to a protocol using this function, the protocol must be under construction. That is, you must add any methods to proto before you register it with the Objective-C runtime (via the
objc_registerProtocol(long)
function).- Parameters:
proto
- the protocol you want to add a method toname
- the name of the method you want to addtypes
- a C string representing the signature of the method you want to addisRequiredMethod
- a Boolean indicating whether the method is a required method of theproto
protocol. IfYES
, the method is a required method; ifNO
, the method is an optional method.isInstanceMethod
- a Boolean indicating whether the method is an instance method. IfYES
, the method is an instance method; ifNO
, the method is a class method.
-
protocol_addProtocol
public static void protocol_addProtocol(long proto, long addition) Adds a registered protocol to another protocol that is under construction.The protocol you want to add to (
proto
) must be under construction – allocated but not yet registered with the Objective-C runtime. The protocol you want to add (addition
) must be registered already.- Parameters:
proto
- the protocol you want to add the registered protocol toaddition
- the registered protocol you want to add toproto
-
nprotocol_addProperty
public static void nprotocol_addProperty(long proto, long name, long attributes, int attributeCount, boolean isRequiredProperty, boolean isInstanceProperty) Unsafe version of:protocol_addProperty(long, java.nio.ByteBuffer, org.lwjgl.system.macosx.ObjCPropertyAttribute.Buffer, boolean, boolean)
- Parameters:
attributeCount
- the number of properties inattributes
-
protocol_addProperty
public static void protocol_addProperty(long proto, ByteBuffer name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty) Adds a property to a protocol that is under construction.The protocol you want to add the property to must be under construction – allocated but not yet registered with the Objective-C runtime (via the
objc_registerProtocol(long)
function).- Parameters:
proto
- the protocol you want to add a property toname
- the name of the property you want to add.attributes
- an array of property attributesisRequiredProperty
- a Boolean indicating whether the property's accessor methods are required methods of theproto
protocol. IfYES
, the property's accessor methods are required methods; ifNO
, the property's accessor methods are optional methods.isInstanceProperty
- a Boolean indicating whether the property's accessor methods are instance methods. IfYES
, the property's accessor methods are instance methods.YES
is the only value allowed for a property. As a result, if you set this value toNO
, the property will not be added to the protocol.
-
protocol_addProperty
public static void protocol_addProperty(long proto, CharSequence name, ObjCPropertyAttribute.Buffer attributes, boolean isRequiredProperty, boolean isInstanceProperty) Adds a property to a protocol that is under construction.The protocol you want to add the property to must be under construction – allocated but not yet registered with the Objective-C runtime (via the
objc_registerProtocol(long)
function).- Parameters:
proto
- the protocol you want to add a property toname
- the name of the property you want to add.attributes
- an array of property attributesisRequiredProperty
- a Boolean indicating whether the property's accessor methods are required methods of theproto
protocol. IfYES
, the property's accessor methods are required methods; ifNO
, the property's accessor methods are optional methods.isInstanceProperty
- a Boolean indicating whether the property's accessor methods are instance methods. IfYES
, the property's accessor methods are instance methods.YES
is the only value allowed for a property. As a result, if you set this value toNO
, the property will not be added to the protocol.
-
nobjc_copyImageNames
public static long nobjc_copyImageNames(long outCount) Unsafe version of:objc_copyImageNames()
- Parameters:
outCount
- the number of names in the returned array
-
objc_copyImageNames
@Nullable public static org.lwjgl.PointerBuffer objc_copyImageNames()Returns the names of all the loaded Objective-C frameworks and dynamic libraries.- Returns:
- an array of C strings representing the names of all the loaded Objective-C frameworks and dynamic libraries
-
nclass_getImageName
public static long nclass_getImageName(long cls) Unsafe version of:class_getImageName(long)
-
class_getImageName
Returns the name of the dynamic library a class originated from.- Parameters:
cls
- the class you are inquiring about- Returns:
- a C string representing the name of the library containing the
cls
class.
-
nobjc_copyClassNamesForImage
public static long nobjc_copyClassNamesForImage(long image, long outCount) Unsafe version of:objc_copyClassNamesForImage(java.nio.ByteBuffer)
- Parameters:
outCount
- the number of names in the returned array
-
objc_copyClassNamesForImage
Returns the names of all the classes within a specified library or framework.- Parameters:
image
- the library or framework you are inquiring about- Returns:
- an array of C strings representing all of the class names within the specified library or framework
-
objc_copyClassNamesForImage
Returns the names of all the classes within a specified library or framework.- Parameters:
image
- the library or framework you are inquiring about- Returns:
- an array of C strings representing all of the class names within the specified library or framework
-
nsel_getName
public static long nsel_getName(long sel) Unsafe version of:sel_getName(long)
-
sel_getName
Returns the name of the method specified by a given selector.- Parameters:
sel
- a pointer of type SEL. Pass the selector whose name you wish to determine.- Returns:
- a C string indicating the name of the selector
-
nsel_getUid
public static long nsel_getUid(long str) Unsafe version of:sel_getUid(java.nio.ByteBuffer)
-
sel_getUid
Registers a method name with the Objective-C runtime system.The implementation of this method is identical to the implementation of
sel_registerName(java.nio.ByteBuffer)
.- Parameters:
str
- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_getUid
Registers a method name with the Objective-C runtime system.The implementation of this method is identical to the implementation of
sel_registerName(java.nio.ByteBuffer)
.- Parameters:
str
- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
nsel_registerName
public static long nsel_registerName(long str) Unsafe version of:sel_registerName(java.nio.ByteBuffer)
-
sel_registerName
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.You must register a method name with the Objective-C runtime system to obtain the method’s selector before you can add the method to a class definition. If the method name has already been registered, this function simply returns the selector.
- Parameters:
str
- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_registerName
Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.You must register a method name with the Objective-C runtime system to obtain the method’s selector before you can add the method to a class definition. If the method name has already been registered, this function simply returns the selector.
- Parameters:
str
- a pointer to a C string. Pass the name of the method you wish to register- Returns:
- a pointer of type SEL specifying the selector for the named method
-
sel_isEqual
public static boolean sel_isEqual(long lhs, long rhs) Returns a Boolean value that indicates whether two selectors are equal.sel_isEqual is equivalent to
==
. -
objc_enumerationMutation
public static void objc_enumerationMutation(long obj) Inserted by the compiler when a mutation is detected during a foreach iteration.The compiler inserts this function when it detects that an object is mutated during a foreach iteration. The function is called when a mutation occurs, and the enumeration mutation handler is enacted if it is set up (via the
objc_setEnumerationMutationHandler(org.lwjgl.system.macosx.EnumerationMutationHandlerI)
function). If the handler is not set up, a fatal error occurs.- Parameters:
obj
- the object being mutated
-
nobjc_setEnumerationMutationHandler
public static void nobjc_setEnumerationMutationHandler(long handler) -
objc_setEnumerationMutationHandler
Sets the current mutation handler.- Parameters:
handler
- a function pointer to the new mutation handler
-
imp_implementationWithBlock
public static long imp_implementationWithBlock(long block) Creates a pointer to a function that calls the specified block when the method is called.- Parameters:
block
- the block that implements this method. The signature ofblock
should bemethod_return_type ^(id self, self, method_args …)
. The selector of the method is not available toblock
.block
is copied withBlock_copy()
.- Returns:
- the IMP that calls
block
. You must dispose of the returned IMP using the function.
-
imp_getBlock
public static long imp_getBlock(long anImp) Returns the block associated with an IMP that was created usingimp_implementationWithBlock(long)
.- Parameters:
anImp
- the IMP that calls this block- Returns:
- the block called by
anImp
-
imp_removeBlock
public static boolean imp_removeBlock(long anImp) Disassociates a block from an IMP that was created usingimp_implementationWithBlock(long)
, and releases the copy of the block that was created.- Parameters:
anImp
- an IMP that was created using theimp_implementationWithBlock(long)
function.- Returns:
YES
if the block was released successfully; otherwise,NO
(for example, the function returnsNO
if the block was not used to createanImp
previously).
-
nobjc_loadWeak
public static long nobjc_loadWeak(long location) Unsafe version of:objc_loadWeak(org.lwjgl.PointerBuffer)
-
objc_loadWeak
public static long objc_loadWeak(@Nullable org.lwjgl.PointerBuffer location) Loads the object referenced by a weak pointer and returns it.This function loads the object referenced by a weak pointer and returns it after retaining and autoreleasing the object. As a result, the object stays alive long enough for the caller to use it. This function is typically used anywhere a
__weak
variable is used in an expression. -
nobjc_storeWeak
public static long nobjc_storeWeak(long location, long obj) Unsafe version of:objc_storeWeak(org.lwjgl.PointerBuffer, long)
-
objc_storeWeak
public static long objc_storeWeak(org.lwjgl.PointerBuffer location, long obj) Stores a new value in a__weak
variable.This function is typically used anywhere a
__weak
variable is the target of an assignment.- Parameters:
location
- the address of the weak pointerobj
- the new object you want the weak pointer to now point to- Returns:
- the value stored in location (that is,
obj
)
-
objc_setAssociatedObject
public static void objc_setAssociatedObject(long object, long key, long value, long policy) Sets an associated value for a given object using a given key and association policy.- Parameters:
object
- the source object for the associationkey
- the key for the associationvalue
- the value to associate with the keykey
forobject
. Passnil
to clear an existing association.policy
- the policy for the association. One of:OBJC_ASSOCIATION_ASSIGN
OBJC_ASSOCIATION_RETAIN_NONATOMIC
OBJC_ASSOCIATION_COPY_NONATOMIC
OBJC_ASSOCIATION_RETAIN
OBJC_ASSOCIATION_COPY
-
objc_getAssociatedObject
public static long objc_getAssociatedObject(long object, long key) Returns the value associated with a given object for a given key.- Parameters:
object
- the source object for the associationkey
- the key for the association- Returns:
- the value associated with the key
key
forobject
.
-
objc_removeAssociatedObjects
public static void objc_removeAssociatedObjects(long object) Removes all associations for a given object.The main purpose of this function is to make it easy to return an object to a "pristine state". You should not use this function for general removal of associations from objects, since it also removes associations that other clients may have added to the object. Typically you should use
objc_setAssociatedObject(long, long, long, long)
with anil
value to clear an association.- Parameters:
object
- an object that maintains associated objects
-