Add initial barebones headers and wrappers

This commit is contained in:
Joey Yakimowich-Payne 2022-11-27 16:16:26 -07:00
commit 3a021c543c
8 changed files with 2891 additions and 0 deletions

186
src/headers/message.h Normal file
View file

@ -0,0 +1,186 @@
/*
* Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/// Specifies the superclass of an instance.
struct objc_super {
/// Specifies an instance of a class.
__unsafe_unretained _Nonnull id receiver;
/// Specifies the particular superclass of the instance to message.
/* For compatibility with old objc-runtime.h header */
__unsafe_unretained _Nonnull Class super_class;
/* super_class is the first class to search */
};
/* Basic Messaging Primitives
*
* On some architectures, use objc_msgSend_stret for some struct return types.
* On some architectures, use objc_msgSend_fpret for some float return types.
* On some architectures, use objc_msgSend_fp2ret for some float return types.
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*/
/**
* Sends a message with a simple return value to an instance of a class.
*
* @param self A pointer to the instance of the class that is to receive the message.
* @param op The selector of the method that handles the message.
* @param ...
* A variable argument list containing the arguments to the method.
*
* @return The return value of the method.
*
* @note When it encounters a method call, the compiler generates a call to one of the
* functions \c objc_msgSend, \c objc_msgSend_stret, \c objc_msgSendSuper, or \c objc_msgSendSuper_stret.
* Messages sent to an objects superclass (using the \c super keyword) are sent using \c objc_msgSendSuper;
* other messages are sent using \c objc_msgSend. Methods that have data structures as return values
* are sent using \c objc_msgSendSuper_stret and \c objc_msgSend_stret.
*/
OBJC_EXPORT id _Nullable
objc_msgSend(id _Nullable self, SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Sends a message with a simple return value to the superclass of an instance of a class.
*
* @param super A pointer to an \c objc_super data structure. Pass values identifying the
* context the message was sent to, including the instance of the class that is to receive the
* message and the superclass at which to start searching for the method implementation.
* @param op A pointer of type SEL. Pass the selector of the method that will handle the message.
* @param ...
* A variable argument list containing the arguments to the method.
*
* @return The return value of the method identified by \e op.
*
* @see objc_msgSend
*/
OBJC_EXPORT id _Nullable
objc_msgSendSuper(struct objc_super * _Nonnull super, SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/* Struct-returning Messaging Primitives
*
* Use these functions to call methods that return structs on the stack.
* On some architectures, some structures are returned in registers.
* Consult your local function call ABI documentation for details.
*
* These functions must be cast to an appropriate function pointer type
* before being called.
* Sends a message with a data-structure return value to an instance of a class.
*
* @see objc_msgSend
*/
OBJC_EXPORT void
objc_msgSend_stret(id _Nullable self, SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
OBJC_ARM64_UNAVAILABLE;
/**
* Sends a message with a data-structure return value to the superclass of an instance of a class.
*
* @see objc_msgSendSuper
*/
OBJC_EXPORT void
objc_msgSendSuper_stret(struct objc_super * _Nonnull super,
SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
OBJC_ARM64_UNAVAILABLE;
/* Floating-point-returning Messaging Primitives
*
* Use these functions to call methods that return floating-point values
* on the stack.
* Consult your local function call ABI documentation for details.
*
* arm: objc_msgSend_fpret not used
* i386: objc_msgSend_fpret used for `float`, `double`, `long double`.
* x86-64: objc_msgSend_fpret used for `long double`.
*
* arm: objc_msgSend_fp2ret not used
* i386: objc_msgSend_fp2ret not used
* x86-64: objc_msgSend_fp2ret used for `_Complex long double`.
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*/
/**
* Sends a message with a floating-point return value to an instance of a class.
*
* @see objc_msgSend
*/
OBJC_EXPORT long double
objc_msgSend_fpret(id _Nullable self, SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
objc_msgSend_fp2ret(id _Nullable self, SEL _Nonnull op, ...)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
/* Direct Method Invocation Primitives
* Use these functions to call the implementation of a given Method.
* This is faster than calling method_getImplementation() and method_getName().
*
* The receiver must not be nil.
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*/
OBJC_EXPORT id _Nullable
method_invoke(id _Nullable receiver, Method _Nonnull m, ...)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
method_invoke_stret(id _Nullable receiver, Method _Nonnull m, ...)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0)
OBJC_ARM64_UNAVAILABLE;
/* Message Forwarding Primitives
* Use these functions to forward a message as if the receiver did not
* respond to it.
*
* The receiver must not be nil.
*
* class_getMethodImplementation() may return (IMP)_objc_msgForward.
* class_getMethodImplementation_stret() may return (IMP)_objc_msgForward_stret
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*
* Before Mac OS X 10.6, _objc_msgForward must not be called directly
* but may be compared to other IMP values.
*/
OBJC_EXPORT id _Nullable
_objc_msgForward(id _Nonnull receiver, SEL _Nonnull sel, ...)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
_objc_msgForward_stret(id _Nonnull receiver, SEL _Nonnull sel, ...)
OBJC_AVAILABLE(10.6, 3.0, 9.0, 1.0, 2.0)
OBJC_ARM64_UNAVAILABLE;

26
src/headers/objc.c2nim Normal file
View file

@ -0,0 +1,26 @@
#nep1
#skipinclude
#skipcomments
#cdecl
#dynlib libobjc
#def __Nullable
#def _Nullable
#def _Nonnull
#def OBJC_ISA_AVAILABILITY
#def OBJC_TYPES_DEFINED 0
#def OBJC_OLD_DISPATCH_PROTOTYPES 0
#def OBJC_EXPORT
#def OBJC_AVAILABLE(a,b,c,d,e)
#assumeifistrue
#assumendef __OBJC__
#def OBJC_ARC_UNAVAILABLE
#def OBJC_ARM64_UNAVAILABLE
#def __unsafe_unretained
#def OBJC_RETURNS_RETAINED
#def OBJC_ENUM(_type, _name) _type _name; enum
#def __OSX_DEPRECATED(a, b, c)
#def __IOS_DEPRECATED(a, b, c)
#def __TVOS_DEPRECATED(a, b, c)
#def __WATCHOS_DEPRECATED(a, b, c)
#def OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(a, b, c)
#mangle "'_C_'{.*}" "C_$1"

228
src/headers/objc.h Normal file
View file

@ -0,0 +1,228 @@
/*
* Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* objc.h
* Copyright 1988-1996, NeXT Software, Inc.
*/
#include <sys/types.h> // for __DARWIN_NULL
#include <Availability.h>
#include <objc/objc-api.h>
#include <stdbool.h>
/// An opaque type that represents an Objective-C class.
typedef struct objc_class *Class;
/// Represents an instance of a class.
struct objc_object {
Class _Nonnull isa OBJC_ISA_AVAILABILITY;
};
/// A pointer to an instance of a class.
typedef struct objc_object *id;
/// An opaque type that represents a method selector.
typedef struct objc_selector *SEL;
/// A pointer to the function of a method implementation.
typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...);
/// Type to represent a boolean value.
#if defined(__OBJC_BOOL_IS_BOOL)
// Honor __OBJC_BOOL_IS_BOOL when available.
# if __OBJC_BOOL_IS_BOOL
# define OBJC_BOOL_IS_BOOL 1
# else
# define OBJC_BOOL_IS_BOOL 0
# endif
#else
// __OBJC_BOOL_IS_BOOL not set.
# if TARGET_OS_OSX || TARGET_OS_MACCATALYST || ((TARGET_OS_IOS || 0) && !__LP64__ && !__ARM_ARCH_7K)
# define OBJC_BOOL_IS_BOOL 0
# else
# define OBJC_BOOL_IS_BOOL 1
# endif
#endif
#if OBJC_BOOL_IS_BOOL
typedef bool BOOL;
#else
# define OBJC_BOOL_IS_CHAR 1
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#endif
#define OBJC_BOOL_DEFINED
#if __has_feature(objc_bool)
#define YES __objc_yes
#define NO __objc_no
#else
#define YES ((BOOL)1)
#define NO ((BOOL)0)
#endif
#ifndef Nil
# if __has_feature(cxx_nullptr)
# define Nil nullptr
# else
# define Nil __DARWIN_NULL
# endif
#endif
#ifndef nil
# if __has_feature(cxx_nullptr)
# define nil nullptr
# else
# define nil __DARWIN_NULL
# endif
#endif
#ifndef __strong
# if !__has_feature(objc_arc)
# define __strong /* empty */
# endif
#endif
#ifndef __unsafe_unretained
# if !__has_feature(objc_arc)
# define __unsafe_unretained /* empty */
# endif
#endif
#ifndef __autoreleasing
# if !__has_feature(objc_arc)
# define __autoreleasing /* empty */
# endif
#endif
/**
* Returns the name of the method specified by a given selector.
*
* @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine.
*
* @return A C string indicating the name of the selector.
*/
OBJC_EXPORT const char * _Nonnull sel_getName(SEL _Nonnull sel)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Registers a method with the Objective-C runtime system, maps the method
* name to a selector, and returns the selector value.
*
* @param str A pointer to a C string. Pass the name of the method you wish to register.
*
* @return A pointer of type SEL specifying the selector for the named method.
*
* @note You must register a method name with the Objective-C runtime system to obtain the
* methods 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.
*/
OBJC_EXPORT SEL _Nonnull sel_registerName(const char * _Nonnull str)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Returns the class name of a given object.
*
* @param obj An Objective-C object.
*
* @return The name of the class of which \e obj is an instance.
*/
OBJC_EXPORT const char * _Nonnull object_getClassName(id _Nullable obj)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Returns a pointer to any extra bytes allocated with an instance given object.
*
* @param obj An Objective-C object.
*
* @return A pointer to any extra bytes allocated with \e obj. If \e obj was
* not allocated with any extra bytes, then dereferencing the returned pointer is undefined.
*
* @note This function returns a pointer to any extra bytes allocated with the instance
* (as specified by \c class_createInstance with extraBytes>0). This memory follows the
* object's ordinary ivars, but may not be adjacent to the last ivar.
* @note 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.
* @note In a garbage-collected environment, the memory is scanned conservatively.
*/
OBJC_EXPORT void * _Nullable object_getIndexedIvars(id _Nullable obj)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Identifies a selector as being valid or invalid.
*
* @param sel The selector you want to identify.
*
* @return YES if selector is valid and has a function implementation, NO otherwise.
*
* @warning On some platforms, an invalid reference (to invalid memory addresses) can cause
* a crash.
*/
OBJC_EXPORT BOOL sel_isMapped(SEL _Nonnull sel)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Registers a method name with the Objective-C runtime system.
*
* @param str A pointer to a C string. Pass the name of the method you wish to register.
*
* @return A pointer of type SEL specifying the selector for the named method.
*
* @note The implementation of this method is identical to the implementation of \c sel_registerName.
* @note Prior to OS X version 10.0, this method tried to find the selector mapped to the given name
* and returned \c NULL if the selector was not found. This was changed for safety, because it was
* observed that many of the callers of this function did not check the return value for \c NULL.
*/
OBJC_EXPORT SEL _Nonnull sel_getUid(const char * _Nonnull str)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
typedef const void* objc_objectptr_t;
// Obsolete ARC conversions.
OBJC_EXPORT id _Nullable objc_retainedObject(objc_objectptr_t _Nullable obj);
OBJC_EXPORT id _Nullable objc_unretainedObject(objc_objectptr_t _Nullable obj);
OBJC_EXPORT objc_objectptr_t _Nullable objc_unretainedPointer(id _Nullable obj);
// The following declarations are provided here for source compatibility.
typedef long arith_t;
typedef unsigned long uarith_t;
# define ARITH_SHIFT 32
typedef char *STR;
#define ISSELECTOR(sel) sel_isMapped(sel)
#define SELNAME(sel) sel_getName(sel)
#define SELUID(str) sel_getUid(str)
#define NAMEOF(obj) object_getClassName(obj)
#define IV(obj) object_getIndexedIvars(obj)

1906
src/headers/runtime.h Normal file

File diff suppressed because it is too large Load diff

7
src/libobjc/all.nim Normal file
View file

@ -0,0 +1,7 @@
import objc
import message
import runtime
export objc
export message
export runtime

38
src/libobjc/message.nim Normal file
View file

@ -0,0 +1,38 @@
import objc
import runtime
type
ObjcSuper* {.bycopy.} = object
receiver*: Id
superClass*: Class
proc objcMsgSend*(self: Id; op: Sel): Id {.varargs, cdecl, importc: "objc_msgSend",
dynlib: libobjc.}
proc objcMsgSendSuper*(super: ptr ObjcSuper; op: Sel): Id {.varargs, cdecl,
importc: "objc_msgSendSuper", dynlib: libobjc.}
proc objcMsgSendStret*(self: Id; op: Sel) {.varargs, cdecl,
importc: "objc_msgSend_stret",
dynlib: libobjc.}
proc objcMsgSendSuperStret*(super: ptr ObjcSuper; op: Sel) {.varargs, cdecl,
importc: "objc_msgSendSuper_stret", dynlib: libobjc.}
proc objcMsgSendFpret*(self: Id; op: Sel): clongdouble {.varargs, cdecl,
importc: "objc_msgSend_fpret", dynlib: libobjc.}
proc objcMsgSendFp2ret*(self: Id; op: Sel) {.varargs, cdecl,
importc: "objc_msgSend_fp2ret",
dynlib: libobjc.}
proc methodInvoke*(receiver: Id; m: Method): Id {.varargs, cdecl,
importc: "method_invoke", dynlib: libobjc.}
proc methodInvokeStret*(receiver: Id; m: Method) {.varargs, cdecl,
importc: "method_invoke_stret", dynlib: libobjc.}
proc objcMsgForward*(receiver: Id; sel: Sel): Id {.varargs, cdecl,
importc: "_objc_msgForward", dynlib: libobjc.}
proc objcMsgForwardStret*(receiver: Id; sel: Sel) {.varargs, cdecl,
importc: "_objc_msgForward_stret", dynlib: libobjc.}

69
src/libobjc/objc.nim Normal file
View file

@ -0,0 +1,69 @@
const libobjc* = "libobjc.dylib"
type
Class* = distinct pointer
ObjcObject* {.bycopy.} = object
isa*: Class
Id* = ptr ObjcObject
Sel* = distinct pointer
Imp* = proc (a1: Id; a2: Sel): Id {.cdecl, varargs.}
Bool* = bool
const
OBJC_BOOL_IS_BOOL* = 1
Nil* = nil
`nil`* = nil
strong* = true
unsafeUnretained* = true
autoreleasing* = true
proc selGetName*(sel: Sel): cstring {.cdecl, importc: "sel_getName", dynlib: libobjc.}
proc selRegisterName*(str: cstring): Sel {.cdecl, importc: "sel_registerName",
dynlib: libobjc.}
proc objectGetClassName*(obj: Id): cstring {.cdecl, importc: "object_getClassName",
dynlib: libobjc.}
proc objectGetIndexedIvars*(obj: Id): pointer {.cdecl,
importc: "object_getIndexedIvars", dynlib: libobjc.}
proc selIsMapped*(sel: Sel): Bool {.cdecl, importc: "sel_isMapped", dynlib: libobjc.}
proc selGetUid*(str: cstring): Sel {.cdecl, importc: "sel_getUid", dynlib: libobjc.}
type
ObjcObjectPtrT* = distinct pointer
proc objcRetainedObject*(obj: ObjcObjectPtrT): Id {.cdecl,
importc: "objc_retainedObject", dynlib: libobjc.}
proc objcUnRetainedObject*(obj: ObjcObjectPtrT): Id {.cdecl,
importc: "objc_unretainedObject", dynlib: libobjc.}
proc objcUnRetainedPointer*(obj: Id): ObjcObjectPtrT {.cdecl,
importc: "objc_unretainedPointer", dynlib: libobjc.}
type
ArithT* = clong
UarithT* = culong
const
ARITH_SHIFT* = 32
type
Str* = cstring
template isselector*(sel: untyped): untyped =
selIsMapped(sel)
template selname*(sel: untyped): untyped =
selGetName(sel)
template seluid*(str: untyped): untyped =
selGetUid(str)
template nameof*(obj: untyped): untyped =
objectGetClassName(obj)
template iv*(obj: untyped): untyped =
objectGetIndexedIvars(obj)

431
src/libobjc/runtime.nim Normal file
View file

@ -0,0 +1,431 @@
import objc
type
Method* = distinct pointer
Ivar* = distinct pointer
Category* = distinct pointer
ObjcPropertyT* = distinct pointer
Protocol* = ObjcObject
ObjcMethodDescription* {.bycopy.} = object
name*: Sel
types*: cstring
ObjcPropertyAttributeT* {.bycopy.} = object
name*: cstring
value*: cstring
ObjcAssociationPolicy* = ptr uint
ObjcHookGetImageName* = proc (cls: Class; outImageName: cstringArray): Bool {.cdecl.}
ObjcHookGetClass* = proc (name: cstring; outClass: ptr Class): Bool {.cdecl.}
MachHeader* = object
ObjcFuncLoadImage* = proc (header: ptr MachHeader) {.cdecl.}
ObjcHookLazyClassNamer* = proc (cls: Class): cstring {.cdecl.}
ObjcSwiftMetadataInitializer* = proc (cls: Class; arg: pointer): Class {.cdecl.}
const
OBJC_REALIZECLASSFROMSWIFT_DEFINED* = 1
OBJC_SETHOOK_LAZYCLASSNAMER_DEFINED* = 1
OBJC_ADDLOADIMAGEFUNC_DEFINED* = 1
OBJC_GETCLASSHOOK_DEFINED* = 1
OBJC_ASSOCIATION_ASSIGN* = 0
OBJC_ASSOCIATION_RETAIN_NONATOMIC* = 1
OBJC_ASSOCIATION_COPY_NONATOMIC* = 3
OBJC_ASSOCIATION_RETAIN* = 0o1401
OBJC_ASSOCIATION_COPY* = 0o1403
C_ID* = '@'
C_CLASS* = '#'
C_SEL* = ':'
C_CHR* = 'c'
C_UCHR* = 'C'
C_SHT* = 's'
C_USHT* = 'S'
C_INT* = 'i'
C_UINT* = 'I'
C_LNG* = 'l'
C_ULNG* = 'L'
C_LNG_LNG* = 'q'
C_ULNG_LNG* = 'Q'
C_INT128* = 't'
C_UINT128* = 'T'
C_FLT* = 'f'
C_DBL* = 'd'
C_LNG_DBL* = 'D'
C_BFLD* = 'b'
C_BOOL* = 'B'
C_VOID* = 'v'
C_UNDEF* = '?'
C_PTR* = '^'
C_CHARPTR* = '*'
C_ATOM* = '%'
C_ARY_B* = '['
C_ARY_E* = ']'
C_UNION_B* = '('
C_UNION_E* = ')'
C_STRUCT_B* = '{'
C_STRUCT_E* = '}'
C_VECTOR* = '!'
C_COMPLEX* = 'j'
C_ATOMIC* = 'A'
C_CONST* = 'r'
C_IN* = 'n'
C_INOUT* = 'N'
C_OUT* = 'o'
C_BYCOPY* = 'O'
C_BYREF* = 'R'
C_ONEWAY* = 'V'
C_GNUREGISTER* = '+'
proc objectCopy*(obj: Id; size: csize_t): Id {.cdecl, importc: "object_copy",
dynlib: libobjc.}
proc objectDispose*(obj: Id): Id {.cdecl, importc: "object_dispose", dynlib: libobjc.}
proc objectGetClass*(obj: Id): Class {.cdecl, importc: "object_getClass",
dynlib: libobjc.}
proc objectSetClass*(obj: Id; cls: Class): Class {.cdecl, importc: "object_setClass",
dynlib: libobjc.}
proc objectIsClass*(obj: Id): Bool {.cdecl, importc: "object_isClass", dynlib: libobjc.}
proc objectGetIvar*(obj: Id; ivar: Ivar): Id {.cdecl, importc: "object_getIvar",
dynlib: libobjc.}
proc objectSetIvar*(obj: Id; ivar: Ivar; value: Id) {.cdecl, importc: "object_setIvar",
dynlib: libobjc.}
proc objectSetIvarWithStrongDefault*(obj: Id; ivar: Ivar; value: Id) {.cdecl,
importc: "object_setIvarWithStrongDefault", dynlib: libobjc.}
proc objectSetInstanceVariable*(obj: Id; name: cstring; value: pointer): Ivar {.cdecl,
importc: "object_setInstanceVariable", dynlib: libobjc.}
proc objectSetInstanceVariableWithStrongDefault*(obj: Id; name: cstring;
value: pointer): Ivar {.cdecl, importc: "object_setInstanceVariableWithStrongDefault",
dynlib: libobjc.}
proc objectGetInstanceVariable*(obj: Id; name: cstring; outValue: ptr pointer): Ivar {.
cdecl, importc: "object_getInstanceVariable", dynlib: libobjc.}
proc objcGetClass*(name: cstring): Class {.cdecl, importc: "objc_getClass",
dynlib: libobjc.}
proc objcGetMetaClass*(name: cstring): Class {.cdecl, importc: "objc_getMetaClass",
dynlib: libobjc.}
proc objcLookUpClass*(name: cstring): Class {.cdecl, importc: "objc_lookUpClass",
dynlib: libobjc.}
proc objcGetRequiredClass*(name: cstring): Class {.cdecl,
importc: "objc_getRequiredClass", dynlib: libobjc.}
proc objcGetClassList*(buffer: ptr Class; bufferCount: cint): cint {.cdecl,
importc: "objc_getClassList", dynlib: libobjc.}
proc objcCopyClassList*(outCount: ptr cuint): ptr Class {.cdecl,
importc: "objc_copyClassList", dynlib: libobjc.}
proc classGetName*(cls: Class): cstring {.cdecl, importc: "class_getName",
dynlib: libobjc.}
proc classIsMetaClass*(cls: Class): Bool {.cdecl, importc: "class_isMetaClass",
dynlib: libobjc.}
proc classGetSuperclass*(cls: Class): Class {.cdecl, importc: "class_getSuperclass",
dynlib: libobjc.}
proc classSetSuperclass*(cls: Class; newSuper: Class): Class {.cdecl,
importc: "class_setSuperclass", dynlib: libobjc.}
proc classGetVersion*(cls: Class): cint {.cdecl, importc: "class_getVersion",
dynlib: libobjc.}
proc classSetVersion*(cls: Class; version: cint) {.cdecl, importc: "class_setVersion",
dynlib: libobjc.}
proc classGetInstanceSize*(cls: Class): csize_t {.cdecl,
importc: "class_getInstanceSize", dynlib: libobjc.}
proc classGetInstanceVariable*(cls: Class; name: cstring): Ivar {.cdecl,
importc: "class_getInstanceVariable", dynlib: libobjc.}
proc classGetClassVariable*(cls: Class; name: cstring): Ivar {.cdecl,
importc: "class_getClassVariable", dynlib: libobjc.}
proc classCopyIvarList*(cls: Class; outCount: ptr cuint): ptr Ivar {.cdecl,
importc: "class_copyIvarList", dynlib: libobjc.}
proc classGetInstanceMethod*(cls: Class; name: Sel): Method {.cdecl,
importc: "class_getInstanceMethod", dynlib: libobjc.}
proc classGetClassMethod*(cls: Class; name: Sel): Method {.cdecl,
importc: "class_getClassMethod", dynlib: libobjc.}
proc classGetMethodImplementation*(cls: Class; name: Sel): Imp {.cdecl,
importc: "class_getMethodImplementation", dynlib: libobjc.}
proc classGetMethodImplementationStret*(cls: Class; name: Sel): Imp {.cdecl,
importc: "class_getMethodImplementation_stret", dynlib: libobjc.}
proc classRespondsToSelector*(cls: Class; sel: Sel): Bool {.cdecl,
importc: "class_respondsToSelector", dynlib: libobjc.}
proc classCopyMethodList*(cls: Class; outCount: ptr cuint): ptr Method {.cdecl,
importc: "class_copyMethodList", dynlib: libobjc.}
proc classConformsToProtocol*(cls: Class; protocol: ptr Protocol): Bool {.cdecl,
importc: "class_conformsToProtocol", dynlib: libobjc.}
proc classCopyProtocolList*(cls: Class; outCount: ptr cuint): ptr ptr Protocol {.cdecl,
importc: "class_copyProtocolList", dynlib: libobjc.}
proc classGetProperty*(cls: Class; name: cstring): ObjcPropertyT {.cdecl,
importc: "class_getProperty", dynlib: libobjc.}
proc classCopyPropertyList*(cls: Class; outCount: ptr cuint): ptr ObjcPropertyT {.cdecl,
importc: "class_copyPropertyList", dynlib: libobjc.}
proc classGetIvarLayout*(cls: Class): ptr uint8 {.cdecl,
importc: "class_getIvarLayout", dynlib: libobjc.}
proc classGetWeakIvarLayout*(cls: Class): ptr uint8 {.cdecl,
importc: "class_getWeakIvarLayout", dynlib: libobjc.}
proc classAddMethod*(cls: Class; name: Sel; imp: Imp; types: cstring): Bool {.cdecl,
importc: "class_addMethod", dynlib: libobjc.}
proc classReplaceMethod*(cls: Class; name: Sel; imp: Imp; types: cstring): Imp {.cdecl,
importc: "class_replaceMethod", dynlib: libobjc.}
proc classAddIvar*(cls: Class; name: cstring; size: csize_t; alignment: uint8;
types: cstring): Bool {.cdecl, importc: "class_addIvar",
dynlib: libobjc.}
proc classAddProtocol*(cls: Class; protocol: ptr Protocol): Bool {.cdecl,
importc: "class_addProtocol", dynlib: libobjc.}
proc classAddProperty*(cls: Class; name: cstring;
attributes: ptr ObjcPropertyAttributeT; attributeCount: cuint): Bool {.
cdecl, importc: "class_addProperty", dynlib: libobjc.}
proc classReplaceProperty*(cls: Class; name: cstring;
attributes: ptr ObjcPropertyAttributeT;
attributeCount: cuint) {.cdecl,
importc: "class_replaceProperty", dynlib: libobjc.}
proc classSetIvarLayout*(cls: Class; layout: ptr uint8) {.cdecl,
importc: "class_setIvarLayout", dynlib: libobjc.}
proc classSetWeakIvarLayout*(cls: Class; layout: ptr uint8) {.cdecl,
importc: "class_setWeakIvarLayout", dynlib: libobjc.}
proc objcGetFutureClass*(name: cstring): Class {.cdecl,
importc: "objc_getFutureClass", dynlib: libobjc.}
proc classCreateInstance*(cls: Class; extraBytes: csize_t): Id {.cdecl,
importc: "class_createInstance", dynlib: libobjc.}
proc objcConstructInstance*(cls: Class; bytes: pointer): Id {.cdecl,
importc: "objc_constructInstance", dynlib: libobjc.}
proc objcDestructInstance*(obj: Id): pointer {.cdecl,
importc: "objc_destructInstance", dynlib: libobjc.}
proc objcAllocateClassPair*(superclass: Class; name: cstring; extraBytes: csize_t): Class {.
cdecl, importc: "objc_allocateClassPair", dynlib: libobjc.}
proc objcRegisterClassPair*(cls: Class) {.cdecl, importc: "objc_registerClassPair",
dynlib: libobjc.}
proc objcDuplicateClass*(original: Class; name: cstring; extraBytes: csize_t): Class {.
cdecl, importc: "objc_duplicateClass", dynlib: libobjc.}
proc objcDisposeClassPair*(cls: Class) {.cdecl, importc: "objc_disposeClassPair",
dynlib: libobjc.}
proc methodGetName*(m: Method): Sel {.cdecl, importc: "method_getName", dynlib: libobjc.}
proc methodGetImplementation*(m: Method): Imp {.cdecl,
importc: "method_getImplementation", dynlib: libobjc.}
proc methodGetTypeEncoding*(m: Method): cstring {.cdecl,
importc: "method_getTypeEncoding", dynlib: libobjc.}
proc methodGetNumberOfArguments*(m: Method): cuint {.cdecl,
importc: "method_getNumberOfArguments", dynlib: libobjc.}
proc methodCopyReturnType*(m: Method): cstring {.cdecl,
importc: "method_copyReturnType", dynlib: libobjc.}
proc methodCopyArgumentType*(m: Method; index: cuint): cstring {.cdecl,
importc: "method_copyArgumentType", dynlib: libobjc.}
proc methodGetReturnType*(m: Method; dst: cstring; dstLen: csize_t) {.cdecl,
importc: "method_getReturnType", dynlib: libobjc.}
proc methodGetArgumentType*(m: Method; index: cuint; dst: cstring; dstLen: csize_t) {.
cdecl, importc: "method_getArgumentType", dynlib: libobjc.}
proc methodGetDescription*(m: Method): ptr ObjcMethodDescription {.cdecl,
importc: "method_getDescription", dynlib: libobjc.}
proc methodSetImplementation*(m: Method; imp: Imp): Imp {.cdecl,
importc: "method_setImplementation", dynlib: libobjc.}
proc methodExchangeImplementations*(m1: Method; m2: Method) {.cdecl,
importc: "method_exchangeImplementations", dynlib: libobjc.}
proc ivarGetName*(v: Ivar): cstring {.cdecl, importc: "ivar_getName", dynlib: libobjc.}
proc ivarGetTypeEncoding*(v: Ivar): cstring {.cdecl, importc: "ivar_getTypeEncoding",
dynlib: libobjc.}
proc ivarGetOffset*(v: Ivar): int {.cdecl, importc: "ivar_getOffset",
dynlib: libobjc.}
proc propertyGetName*(property: ObjcPropertyT): cstring {.cdecl,
importc: "property_getName", dynlib: libobjc.}
proc propertyGetAttributes*(property: ObjcPropertyT): cstring {.cdecl,
importc: "property_getAttributes", dynlib: libobjc.}
proc propertyCopyAttributeList*(property: ObjcPropertyT; outCount: ptr cuint): ptr ObjcPropertyAttributeT {.
cdecl, importc: "property_copyAttributeList", dynlib: libobjc.}
proc propertyCopyAttributeValue*(property: ObjcPropertyT; attributeName: cstring): cstring {.
cdecl, importc: "property_copyAttributeValue", dynlib: libobjc.}
proc objcGetProtocol*(name: cstring): ptr Protocol {.cdecl,
importc: "objc_getProtocol", dynlib: libobjc.}
proc objcCopyProtocolList*(outCount: ptr cuint): ptr ptr Protocol {.cdecl,
importc: "objc_copyProtocolList", dynlib: libobjc.}
proc protocolConformsToProtocol*(proto: ptr Protocol; other: ptr Protocol): Bool {.
cdecl, importc: "protocol_conformsToProtocol", dynlib: libobjc.}
proc protocolIsEqual*(proto: ptr Protocol; other: ptr Protocol): Bool {.cdecl,
importc: "protocol_isEqual", dynlib: libobjc.}
proc protocolGetName*(proto: ptr Protocol): cstring {.cdecl,
importc: "protocol_getName", dynlib: libobjc.}
proc protocolGetMethodDescription*(proto: ptr Protocol; aSel: Sel;
isRequiredMethod: Bool; isInstanceMethod: Bool): ObjcMethodDescription {.
cdecl, importc: "protocol_getMethodDescription", dynlib: libobjc.}
proc protocolCopyMethodDescriptionList*(proto: ptr Protocol; isRequiredMethod: Bool;
isInstanceMethod: Bool; outCount: ptr cuint): ptr ObjcMethodDescription {.
cdecl, importc: "protocol_copyMethodDescriptionList", dynlib: libobjc.}
proc protocolGetProperty*(proto: ptr Protocol; name: cstring;
isRequiredProperty: Bool; isInstanceProperty: Bool): ObjcPropertyT {.
cdecl, importc: "protocol_getProperty", dynlib: libobjc.}
proc protocolCopyPropertyList*(proto: ptr Protocol; outCount: ptr cuint): ptr ObjcPropertyT {.
cdecl, importc: "protocol_copyPropertyList", dynlib: libobjc.}
proc protocolCopyPropertyList2*(proto: ptr Protocol; outCount: ptr cuint;
isRequiredProperty: Bool; isInstanceProperty: Bool): ptr ObjcPropertyT {.
cdecl, importc: "protocol_copyPropertyList2", dynlib: libobjc.}
proc protocolCopyProtocolList*(proto: ptr Protocol; outCount: ptr cuint): ptr ptr Protocol {.
cdecl, importc: "protocol_copyProtocolList", dynlib: libobjc.}
proc objcAllocateProtocol*(name: cstring): ptr Protocol {.cdecl,
importc: "objc_allocateProtocol", dynlib: libobjc.}
proc objcRegisterProtocol*(proto: ptr Protocol) {.cdecl,
importc: "objc_registerProtocol", dynlib: libobjc.}
proc protocolAddMethodDescription*(proto: ptr Protocol; name: Sel; types: cstring;
isRequiredMethod: Bool; isInstanceMethod: Bool) {.
cdecl, importc: "protocol_addMethodDescription", dynlib: libobjc.}
proc protocolAddProtocol*(proto: ptr Protocol; addition: ptr Protocol) {.cdecl,
importc: "protocol_addProtocol", dynlib: libobjc.}
proc protocolAddProperty*(proto: ptr Protocol; name: cstring;
attributes: ptr ObjcPropertyAttributeT;
attributeCount: cuint; isRequiredProperty: Bool;
isInstanceProperty: Bool) {.cdecl,
importc: "protocol_addProperty", dynlib: libobjc.}
proc objcCopyImageNames*(outCount: ptr cuint): cstringArray {.cdecl,
importc: "objc_copyImageNames", dynlib: libobjc.}
proc classGetImageName*(cls: Class): cstring {.cdecl, importc: "class_getImageName",
dynlib: libobjc.}
proc objcCopyClassNamesForImage*(image: cstring; outCount: ptr cuint): cstringArray {.
cdecl, importc: "objc_copyClassNamesForImage", dynlib: libobjc.}
proc selGetName*(sel: Sel): cstring {.cdecl, importc: "sel_getName", dynlib: libobjc.}
proc selRegisterName*(str: cstring): Sel {.cdecl, importc: "sel_registerName",
dynlib: libobjc.}
proc selIsEqual*(lhs: Sel; rhs: Sel): Bool {.cdecl, importc: "sel_isEqual",
dynlib: libobjc.}
proc objcEnumerationMutation*(obj: Id) {.cdecl, importc: "objc_enumerationMutation",
dynlib: libobjc.}
proc objcSetEnumerationMutationHandler*(handler: proc (a1: Id) {.cdecl.}) {.cdecl,
importc: "objc_setEnumerationMutationHandler", dynlib: libobjc.}
proc objcSetForwardHandler*(fwd: pointer; fwdStret: pointer) {.cdecl,
importc: "objc_setForwardHandler", dynlib: libobjc.}
proc impImplementationWithBlock*(`block`: Id): Imp {.cdecl,
importc: "imp_implementationWithBlock", dynlib: libobjc.}
proc impGetBlock*(anImp: Imp): Id {.cdecl, importc: "imp_getBlock", dynlib: libobjc.}
proc impRemoveBlock*(anImp: Imp): Bool {.cdecl, importc: "imp_removeBlock",
dynlib: libobjc.}
proc objcLoadWeak*(location: ptr Id): Id {.cdecl, importc: "objc_loadWeak",
dynlib: libobjc.}
proc objcStoreWeak*(location: ptr Id; obj: Id): Id {.cdecl, importc: "objc_storeWeak",
dynlib: libobjc.}
proc objcSetAssociatedObject*(`object`: Id; key: pointer; value: Id;
policy: ObjcAssociationPolicy) {.cdecl,
importc: "objc_setAssociatedObject", dynlib: libobjc.}
proc objcGetAssociatedObject*(`object`: Id; key: pointer): Id {.cdecl,
importc: "objc_getAssociatedObject", dynlib: libobjc.}
proc objcRemoveAssociatedObjects*(`object`: Id) {.cdecl,
importc: "objc_removeAssociatedObjects", dynlib: libobjc.}
proc objcSetHookGetImageName*(newValue: ObjcHookGetImageName;
outOldValue: ptr ObjcHookGetImageName) {.cdecl,
importc: "objc_setHook_getImageName", dynlib: libobjc.}
proc objcSetHookGetClass*(newValue: ObjcHookGetClass;
outOldValue: ptr ObjcHookGetClass) {.cdecl,
importc: "objc_setHook_getClass", dynlib: libobjc.}
proc objcAddLoadImageFunc*(`func`: ObjcFuncLoadImage) {.cdecl,
importc: "objc_addLoadImageFunc", dynlib: libobjc.}
proc objcSetHookLazyClassNamer*(newValue: ObjcHookLazyClassNamer;
oldOutValue: ptr ObjcHookLazyClassNamer) {.cdecl,
importc: "objc_setHook_lazyClassNamer", dynlib: libobjc.}
proc objcRealizeClassFromSwift*(cls: Class; previously: pointer): Class {.cdecl,
importc: "_objc_realizeClassFromSwift", dynlib: libobjc.}
proc classLookupMethod*(cls: Class; sel: Sel): Imp {.cdecl,
importc: "class_lookupMethod", dynlib: libobjc.}
proc classRespondsToMethod*(cls: Class; sel: Sel): Bool {.cdecl,
importc: "class_respondsToMethod", dynlib: libobjc.}
proc objcFlushCaches*(cls: Class) {.cdecl, importc: "_objc_flush_caches",
dynlib: libobjc.}
proc objectCopyFromZone*(anObject: Id; nBytes: csize_t; z: pointer): Id {.cdecl,
importc: "object_copyFromZone", dynlib: libobjc.}
proc classCreateInstanceFromZone*(a1: Class; idxIvars: csize_t; z: pointer): Id {.cdecl,
importc: "class_createInstanceFromZone", dynlib: libobjc.}