chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] zobjc egg


From: Zbigniew
Subject: [Chicken-users] zobjc egg
Date: Fri, 9 Dec 2005 06:06:43 -0600

I integrated Felix's objc egg into mine, and added classes, instance
variables, and automatic memory management.  The result is called
"zobjc" to avoid clobbering the existing objc egg.  I plan to write up
an eggdoc shortly, but in the meantime I could not resist creating the
first Cocoa application for Chicken. :) That code is included below,
and also in the egg (cd tests/; make).

Get zobjc at: http://jiyu.gnook.org/~zbigniew/eggs/zobjc.egg

Oh, and it's a cold, snowy 19F here... or -7.222222222222222 C.

;;; ------------------------------------------

;;; test f->c app
;;; Derived from the gauche-objc bridge test application.

(use cocoa)   ;; and compile with -X zobjc

(objc:nsbeep)
(print "Starting F->C application...")

(define (f2c f)
  (/ (- f 32.0) 1.8))

(define (c2f c)
  (+ (* 1.8 c) 32))

(define-objc-class Controller NSObject ((ID far) (ID cel))
  (- VOID awakeFromNib
     (let ((far @far)
           (cel @cel))
       @[far setTitle: "Far"]
       @[cel setTitle: "Cel"]
       @[cel setFloatValue: 0.0]
       @[far setFloatValue: (c2f 0.0)]))

  (- VOID ((convertToCel: ID sender))
     (print "convertToCel: called; sender " sender)

     @[ @cel setDoubleValue:
             (f2c @[ @far doubleValue])])

  (- VOID ((convertToFar: ID sender))
     (print "convertToFar: called; sender " sender)

     @[ @far setDoubleValue:
             (c2f @[ @cel doubleValue ] )])
  )

(objc:nsapplication-main)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]