caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: Camlp4 and Cocoa
Date: Sat, 9 Jun 2007 13:42:33 +0100	[thread overview]
Message-ID: <A6276182-9F79-42C9-B6F9-3ECECC983F37@gmail.com> (raw)

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






                 reply	other threads:[~2007-06-09 12:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A6276182-9F79-42C9-B6F9-3ECECC983F37@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).