* Camlp4 and Cocoa
@ 2007-06-09 12:42 Joel Reymont
0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2007-06-09 12:42 UTC (permalink / raw)
To: Caml List
I'm trying to figure out how to define Cocoa classes in OCaml. The
definition needs to be parsed somehow, to make invoke code that
registers the classes with the Objective C runtime.
I think camlp4 can be somehow used to parse a regular OCaml class
definition and figure out the ObjC based on the types used. Trouble
is, I'm not even sure what this would look like.
Please let me know if you have any suggestions!
I'm including the original ObjC as well as the equivalent Scheme code
using the excellent Chicken Scheme Cocoa bridge.
Thanks, Joel
--- Original Objective-C ---
@interface ConverterController : NSObject {
IBOutlet id dollarField;
IBOutlet id rateField;
IBOutlet id totalField;
}
- (IBAction)convert:(id)sender;
@end
--- Chicken Scheme ---
(define-objc-class ConverterController NSObject ((outlet: amountField)
(outlet: dollarField)
(outlet: rateField)
(outlet: converter))
(- VOID ((convert: ID sender))
(let* ((currency (@ @dollarField float-value))
(rate (@ @rateField float-value))
(amount (@ @converter convert-currency: currency
at-rate: rate)))
(@ @amountField set-float-value: amount)
(@ @rateField select-text: self))))
--
http://topdog.cc - EasyLanguage to C# translator
http://wagerlabs.com - Blog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-09 12:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-09 12:42 Camlp4 and Cocoa Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox