Browse thread
Design advice for declaring Objective-C classes in OCaml
- Joel Reymont
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Joel Reymont <joelr1@g...> |
| Subject: | Design advice for declaring Objective-C classes in OCaml |
I'm thinking about a Cocoa bridge for OCaml. I think it's best to start by thinking how a Cocoa / Objective-C class would be declared in OCaml. Once this part is done, code could be created that parses Cocoa header files and emits proper OCaml declarations. OCaml has classes and labels can be used to declare Objective-C keyword arguments. Various types could be declared in OCaml to match Cocoa types such as NSRange, NSPoint, etc. To declare a Cocoa class in OCaml it could be subclassed from ns_object or any other Cocoa class previously imported into OCaml (separate step). camlp4 could then be used to process classes in a given file and create code to register the class in the Objective C runtime based on method argument types and such. There's a problem, though, that makes the whole process cumbersome. This is where I need your advice... It looks like I will need to create C wrappers to invoke my OCaml code and register these wrappers with the Objective C runtime. The C wrappers will need to be generated during the camlp4 processing step and then compiled as part of the project. Could this be done seamlessly with ocamlbuild? camlp4 is maddeningly complex for me but it looks like I could reuse the approach from http://www.venge.net/graydon/talks/mkc/html/ index.html where camlp4 is also used to generate the C AST, C code is generated from the AST and then compiled. Any suggestions or ideas on how to make this whole process simple and transparent? Graydon uses a separate driver to compile C code, for example, something that I would like to avoid. Thanks, Joel -- http://wagerlabs.com