On Sun, Jul 12, 2009 at 5:00 PM, Ryan Spanglerpatch_work8848@yahoo.com wrote:
James:
That sounds great. I am wondering what your strategy is for exposing an objective-c object to scheme like that, as so far I have only been able to send basic data types (int, double etc) between c and scheme. Something like keeping some reference to the c object and implementing the various methods in scheme?
Yep, that's right. Since it's not a native type that can simply be converted into a Scheme type, you just pass a reference to it to the Scheme world and provide Scheme FFI functions for getting data out of the datatype (see c-define-type and c-lambda). I plan on writing my Touch FFI this week and will release it, make another blog post about it, etc.
In particular, I would like to make a list of x,y pairs that get sent from the c event handler to the corresponding scheme function, is that possible? I imagine there could be some way to construct scheme lists from c, but not sure how that could be done at the moment. As I say, I am still learning the ropes around here.
That is possible. You have to know Gambit's C API to do so, which isn't very well documented yet. You can search the gambit mailing list by googling "site:https://webmail.iro.umontreal.ca/pipermail/gambit-list/", there should be some examples in there if you are interested. I would give some examples but I don't have time to remember them myself.
I believe it would be easier to provide access to Obj-C's API which can query out this data. I've found that by exposing the raw API to Scheme, you can avoid having to write a bunch of translation code which awkwardly constructs Scheme data structures from C.
- James