<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>On Feb 28, 2013, at 2:41 PM, Jason Felice <<a href="mailto:jason.m.felice@gmail.com">jason.m.felice@gmail.com</a>> wrote:<br><br><blockquote type="cite">The man page for BridgeSupport claims that it describes API symbols which cannot be introspected at runtime.  It also says, "Only classes where additional metadata is needed are described."<br><br>It seems the additional metadata is what kind of sentinel is used for variable-argument methods and which classes are toll-free bridged to which other types.<br><br>Also, no bridgesupport files appear for the iOS or iOS simulator platforms, though there is a tool which might generate this information based on headers.<br><br>IMHO, this does not solve the method dispatch problem, but it can add a lot of value for Mac OS X.<br><br>For my purposes - which is iOS development - I want to be able to call third-party class methods and even undocumented methods (in the simulator), so I'd like to keep the dynamic dispatch.<br><br>As an optimization on iOS, it would be cool to run some stats on the most commonly called function signatures and fast path those.</blockquote><div><br></div>It's been a while since the last time I parsed BridgeSupport files (in Common Lisp that time), but if I remember correctly, you can use gen_bridge_metadata --framework FooBar to generate the BridgeSupport files for the FooBar framework, whether it's an OSX framework, or an iOS framework, or even some random third-party framework like CHDataStructures or something. One advantage of doing that is that it's an automated tool that gives you the APIs that Apple is claiming are the canonical ones for any given release of its system.<br><br><div>I doesn't always give you everything you need, but most of Cocoa automatically plus a little bit by hand is still a lot less work than all of Cocoa by hand.</div><div><br></div><div>ffigen does much the same thing, with a couple of notable differences. One is that it generates interface information for everything you point it at, whether Apple thinks you should use it or not. Another difference is that it parses C, C++, and Objective-C headers into s-expressions, which might be more congenial to work with than XML. It's primarily used to generate the (very good) Objective-C bridge for CCL, but there's no reason you couldn't use it for the same purpose with Gambit.</div><div><br></div><div>If that interests you, you can find a page about how to build and install ffigen here:</div><div><br></div><div><a href="http://trac.clozure.com/ccl/wiki/BuildFFIGEN">http://trac.clozure.com/ccl/wiki/BuildFFIGEN</a></div><div><br></div><div>...and there's a page about how to use it with CCL here:</div><div><br></div><div><a href="http://ccl.clozure.com/manual/chapter12.7.html">http://ccl.clozure.com/manual/chapter12.7.html</a></div><div><br></div><div>If you decided that you did want to try doing things the way CCL does them, you'd probably want to download CCL and rummage around in its sources. That's pretty easy to do from either a SLIME session or the Cocoa IDE supplied with CCL. For example, I just launched the Cocoa app, typed in (require :parse-ffi), then ccl::parse-standard-ffi-files (actually, ccl::parse-s and then Option-/ to complete), and then stuck the insertion point in the symbol name and hit Option-period. CCL obligingly popped open a window with this in it:</div><div><br></div><div><font face="Monaco">(defun parse-standard-ffi-files (dirname &optional target)<br>  (let* ((backend (if target (find-backend target) *target-backend*))<br>         (ftd (backend-target-foreign-type-data backend))<br>         (*parse-ffi-target-ftd* ftd)<br>         (*target-ftd* ftd)<br>         (*target-backend* backend)<br><span class="Apple-tab-span" style="white-space:pre"> </span> (d (use-interface-dir dirname ftd))<br><span class="Apple-tab-span" style="white-space:pre"> </span> (interface-dir (merge-pathnames<br><span class="Apple-tab-span" style="white-space:pre">                     </span> (interface-dir-subdir d)<br><span class="Apple-tab-span" style="white-space:pre">                    </span> (ftd-interface-db-directory ftd)))<br><span class="Apple-tab-span" style="white-space:pre">  </span> (*prepend-underscores-to-ffi-function-names*<br>          (getf (ftd-attributes ftd) :prepend-underscores))<br><span class="Apple-tab-span" style="white-space:pre">  </span> (*ffi-global-typedefs* (make-hash-table :test 'string= :hash-function 'sxhash))<br><span class="Apple-tab-span" style="white-space:pre">     </span> (*ffi-global-unions* (make-hash-table :test 'string= :hash-function 'sxhash))<br>         (*ffi-global-transparent-unions* (make-hash-table :test 'string= :hash-function 'sxhash))<br><span class="Apple-tab-span" style="white-space:pre">  </span> (*ffi-global-structs* (make-hash-table :test 'string= :hash-function 'sxhash))<br>         (*ffi-global-objc-classes* (make-hash-table :test 'string= :hash-function 'sxhash))<br>         (*ffi-global-objc-messages* (make-hash-table :test 'string= :hash-function 'sxhash)) <br><span class="Apple-tab-span" style="white-space:pre"> </span> (*ffi-global-functions* (make-hash-table :test 'string= :hash-function 'sxhash))<br><span class="Apple-tab-span" style="white-space:pre">    </span> (*ffi-global-constants* (make-hash-table :test 'string= :hash-function 'sxhash))<br>         (*ffi-global-vars* (make-hash-table :test 'string= :hash-function 'sxhash)))</font></div><div><br></div><div><br></div><div>(But for this purpose, you would want to download it from <a href="http://ccl.clozure.com/download.html">http://ccl.clozure.com/download.html</a>, rather than getting the free App Store version, so that you have the sources handy.)</div><div><br></div><div>--me</div><div><br></div><div><br></div></body></html>