swig/SWIG/Examples/chicken/class/test-tinyclos-class.scm
Jonah Beckford 3def239916 Changed module technique from <module_name>- to <module_name>: which
conforms with chicken "egg" standard.  Got rid of ##csi#run for
relinking the Scheme interpreter as no longer needed.  Changed all
documentation to reflect both changes.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4411 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-02-27 02:00:15 +00:00

76 lines
1.7 KiB
Scheme

;; This file illustrates the shadow C++ interface generated
;; by SWIG.
;; All generic methods must be included first
(include "example_generic")
;; After generic are defined, can include TinyCLOS code
(include "example_clos")
;; ----- Object creation -----
(display "Creating some objects:\n")
(define c (make <example:Circle> 10.0))
(display " Created circle ")
(display c)
(display "\n")
(define s (make <example:Square> 10.0))
(display " Created square ")
(display s)
(display "\n")
;; ----- Access a static member -----
(display "\nA total of ")
(display (+example:Shape-nshapes+))
(display " shapes were created\n")
;; ----- Member data access -----
;; Set the location of the object
(-set-x!- c 20.0)
(-set-y!- c 30.0)
(-set-x!- s -10.0)
(-set-y!- s 5.0)
(display "\nHere is their current position:\n")
(display " Circle = (")
(display (-get-x- c))
(display ", ")
(display (-get-y- c))
(display ")\n")
(display " Square = (")
(display (-get-x- s))
(display ", ")
(display (-get-y- s))
(display ")\n")
;; ----- Call some methods -----
(display "\nHere are some properties of the shapes:\n")
(let
((disp (lambda (o)
(display " ")
(display o)
(display "\n")
(display " area = ")
(display (-area- o))
(display "\n")
(display " perimeter = ")
(display (-perimeter- o))
(display "\n"))))
(disp c)
(disp s))
(display "\nGuess I'll clean up now\n")
;; Note: Invoke the virtual destructors by forcing garbage collection
(set! c 77)
(set! s 88)
(gc #t)
(display (+example:Shape-nshapes+))
(display " shapes remain\n")
(display "Goodbye\n")