Initial addition.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4313 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
eeace2a394
commit
6901abdf17
70 changed files with 9710 additions and 0 deletions
76
Examples/chicken/class/test-tinyclos-class.scm
Normal file
76
Examples/chicken/class/test-tinyclos-class.scm
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
;; 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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue