Browse thread
Camlp4 and Cocoa
- 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: | Camlp4 and Cocoa |
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