[gambit-list] Problem with interactive development using remote REPL of iOS Sim.
mevins at me.com
Thu Feb 28 16:07:43 EST 2013
On Feb 28, 2013, at 2:41 PM, Jason Felice <jason.m.felice at gmail.com> wrote:
> 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."
> 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.
> 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.
> IMHO, this does not solve the method dispatch problem, but it can add a lot of value for Mac OS X.
> 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.
> As an optimization on iOS, it would be cool to run some stats on the most commonly called function signatures and fast path those.
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.
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.
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.
If that interests you, you can find a page about how to build and install ffigen here:
...and there's a page about how to use it with CCL here:
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:
(defun parse-standard-ffi-files (dirname &optional target)
(let* ((backend (if target (find-backend target) *target-backend*))
(ftd (backend-target-foreign-type-data backend))
(d (use-interface-dir dirname ftd))
(getf (ftd-attributes ftd) :prepend-underscores))
(*ffi-global-typedefs* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-unions* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-transparent-unions* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-structs* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-objc-classes* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-objc-messages* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-functions* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-constants* (make-hash-table :test 'string= :hash-function 'sxhash))
(*ffi-global-vars* (make-hash-table :test 'string= :hash-function 'sxhash)))
(But for this purpose, you would want to download it from http://ccl.clozure.com/download.html, rather than getting the free App Store version, so that you have the sources handy.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gambit-list