|
BridgeSupport
BridgeSupport is an xml file describing C functions, structures, Objective C methods and their encodings to make them callable at runtime. BridgeSupport files are stored in a framework's Resources/BridgeSupport. There are two kinds of .bridgesupport :
Both versions describe all constants, C functions, structs, ObjC classes. Full versions fully describe ObjC method parameters where vanilla versions only use method names. JSCocoa uses vanilla versions and retrive ObjC MethodEncodings at runtime. In JSCocoa, BridgeSupportController handles BridgeSupport. Vanilla classLists all method names of a class, with some modifier hints. Here, type_modifier marks the second parameter as 'out' : pointer to pointer. ObjC methods are called with objc_msgsend. <class name='NSPersistentDocument'>
<method selector='configurePersistentStoreCoordinatorForURL:ofType:error:'>
<arg index='2' type_modifier='o'/>
<retval type='B'/>
</method>
...
</class>Full classLists all method and MethodEncoding of a class. type refers to TypeEncoding, declared_type refers to parenthesized types from the method declaration. In - (void)openURL:(NSURL*)url', the declared_type is NSURL`. <class name='NSPersistentDocument'>
<method selector='configurePersistentStoreCoordinatorForURL:ofType:error:'>
<arg name='url' declared_type='NSURL*' type='@' index='0'/>
<arg name='fileType' declared_type='NSString*' type='@' index='1'/>
<arg name='error' declared_type='NSError**' type='^@' index='2'/>
<retval declared_type='BOOL' type='B'/>
</method>
...
</class>ConstantsConstants are pointers to static NSStrings, retrieved with dlsym. They are converted to Javascript strings. <constant name='NSToolbarSpaceItemIdentifier' declared_type='NSString*' type='@'/> EnumsEnums are number constants, converted to Javascript numbers. <enum name='NSAlternateKeyMask' value='524288'/> C functionsC functions are called by libffi after JSCocoa retrieves their symbol address with dlsym. BridgeSupport fully lists all parameters. type and type64 refer to TypeEncoding. <function name='NSGetWindowServerMemory'>
<arg name='context' declared_type='NSInteger' type='i' type64='q'/>
<arg name='virtualMemory' declared_type='NSInteger*' type='^i' type64='^q' type_modifier='o'/>
<arg name='windowBackingMemory' declared_type='NSInteger*' type='^i' type64='^q' type_modifier='o'/>
<arg name='windowDumpString' declared_type='NSString**' type='^@' type_modifier='o'/>
<retval declared_type='NSInteger' type='i' type64='q'/>
</function>dylibSome frameworks may carry a dynamic library (.dylib), storing callable versions of inline functions. NSMakePoint, NSMakeRect and others are functions inlined at compile time — they have no address that dlsym can resolve. The dylib 'un-inlines' these functions, creating a runtime callable equivalent of an inline function. |