Chicken - make check-examples run like other examples - not all run very well though!
This commit is contained in:
parent
2b2305cce9
commit
58a59919dd
12 changed files with 32 additions and 33 deletions
|
|
@ -1122,7 +1122,7 @@ CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS)
|
|||
CHICKEN_CFLAGS = @CHICKENOPTS@
|
||||
CHICKENOPTS = -quiet
|
||||
CHICKEN_MAIN =
|
||||
CHICKEN_SCRIPT = $(RUNME).ss
|
||||
CHICKEN_SCRIPT = $(RUNME).scm
|
||||
|
||||
# SWIG produces $(ISRCS) (the C wrapper file)
|
||||
# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
|
||||
|
|
@ -1208,7 +1208,7 @@ chicken_externalhdr:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
chicken_run:
|
||||
$(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE)
|
||||
env LD_LIBRARY_PATH=. $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
|
|
|
|||
|
|
@ -10,27 +10,27 @@ CFLAGS =
|
|||
VARIANT =
|
||||
|
||||
# uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
|
||||
#CHICKEN_MAIN = test-lowlevel-class.scm
|
||||
#CHICKEN_MAIN = test-tinyclos-class.scm
|
||||
#CHICKEN_MAIN = runme-lowlevel.scm
|
||||
#CHICKEN_MAIN = runme-tinyclos.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm
|
||||
$(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run
|
||||
$(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run
|
||||
|
||||
build: $(TARGET) $(TARGET)_proxy
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
$(TARGET)_proxy: $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
|
|
|
|||
76
Examples/chicken/class/runme-lowlevel.scm
Normal file
76
Examples/chicken/class/runme-lowlevel.scm
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
;; This file illustrates the low-level C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(load-library 'example "class.so")
|
||||
(declare (uses example))
|
||||
|
||||
;; ----- Object creation -----
|
||||
|
||||
(display "Creating some objects:\n")
|
||||
(define c (new-Circle 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (new-Square 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
||||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
||||
;; Set the location of the object
|
||||
|
||||
(Shape-x-set c 20.0)
|
||||
(Shape-y-set c 30.0)
|
||||
|
||||
(Shape-x-set s -10.0)
|
||||
(Shape-y-set s 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (Shape-x-get c))
|
||||
(display ", ")
|
||||
(display (Shape-y-get c))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (Shape-x-get s))
|
||||
(display ", ")
|
||||
(display (Shape-y-get 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 (Shape-area o))
|
||||
(display "\n")
|
||||
(display " perimeter = ")
|
||||
(display (Shape-perimeter o))
|
||||
(display "\n"))))
|
||||
(disp c)
|
||||
(disp s))
|
||||
|
||||
(display "\nGuess I'll clean up now\n")
|
||||
|
||||
;; Note: this invokes the virtual destructor
|
||||
(set! c #f)
|
||||
(set! s #f)
|
||||
(gc #t)
|
||||
|
||||
(set! s 3)
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
76
Examples/chicken/class/runme-tinyclos.scm
Normal file
76
Examples/chicken/class/runme-tinyclos.scm
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
;; This file illustrates the proxy C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(load-library 'example "class_proxy.so")
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; ----- Object creation -----
|
||||
|
||||
(display "Creating some objects:\n")
|
||||
(define c (make <Circle> 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (make <Square> 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
||||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
||||
;; Set the location of the object
|
||||
|
||||
(slot-set! c 'x 20.0)
|
||||
(slot-set! c 'y 30.0)
|
||||
|
||||
(slot-set! s 'x -10.0)
|
||||
(slot-set! s 'y 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (slot-ref c 'x))
|
||||
(display ", ")
|
||||
(display (slot-ref c 'y))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (slot-ref s 'x))
|
||||
(display ", ")
|
||||
(display (slot-ref s 'y))
|
||||
(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 (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -10,19 +10,19 @@ CFLAGS =
|
|||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-constants.scm
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
csi test-constants.scm
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
|
|
|
|||
16
Examples/chicken/constants/runme.scm
Normal file
16
Examples/chicken/constants/runme.scm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "./constants.so")
|
||||
|
||||
(display "starting test ... you will see 'finished' if successful.\n")
|
||||
(or (= (ICONST) 42) (exit 1))
|
||||
(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1))
|
||||
(or (char=? (CCONST) #\x) (exit 1))
|
||||
(or (char=? (CCONST2) #\newline) (exit 1))
|
||||
(or (string=? (SCONST) "Hello World") (exit 1))
|
||||
(or (string=? (SCONST2) "\"Hello World\"") (exit 1))
|
||||
(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1))
|
||||
(or (= (iconstX) 37) (exit 1))
|
||||
(or (< (abs (- (fconstX) 3.14)) 0.00001) (exit 1))
|
||||
(display "finished test.\n")
|
||||
(exit 0)
|
||||
|
|
@ -10,19 +10,19 @@ CFLAGS =
|
|||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-multimap.scm
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
|
|
|
|||
58
Examples/chicken/multimap/runme.scm
Normal file
58
Examples/chicken/multimap/runme.scm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "multimap.so")
|
||||
|
||||
(display "(gcd 90 12): ")
|
||||
(display (gcd 90 12))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 0.5 0.5): ")
|
||||
(display (circle 0.5 0.5))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 1.0 1.0): ")
|
||||
(handle-exceptions exvar
|
||||
(if (= (car exvar) 9)
|
||||
(display "success: exception thrown")
|
||||
(display "an incorrect exception was thrown"))
|
||||
(begin
|
||||
(circle 1.0 1.0)
|
||||
(display "an exception was not thrown when it should have been")))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 1 1): ")
|
||||
(handle-exceptions exvar
|
||||
(if (= (car exvar) 9)
|
||||
(display "success: exception thrown")
|
||||
(display "an incorrect exception was thrown"))
|
||||
(begin
|
||||
(circle 1 1)
|
||||
(display "an exception was not thrown when it should have been")))
|
||||
(display "\n")
|
||||
|
||||
(display "(capitalize \"will this be all capital letters?\"): ")
|
||||
(display (capitalize "will this be all capital letters?"))
|
||||
(display "\n")
|
||||
|
||||
(display "(count \"jumpity little spider\" #\\t): ")
|
||||
(display (count "jumpity little spider" #\t))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"hi\" \"there\")): ")
|
||||
(display (gcdmain '#("hi" "there")))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"gcd\" \"9\" \"28\")): ")
|
||||
(gcdmain '#("gcd" "9" "28"))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"gcd\" \"12\" \"90\")): ")
|
||||
(gcdmain '#("gcd" "12" "90"))
|
||||
(display "\n")
|
||||
|
||||
(display "squarecubed 3: ")
|
||||
(call-with-values (lambda() (squareCubed 3))
|
||||
(lambda (a b) (printf "~A ~A" a b)))
|
||||
(display "\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -10,19 +10,19 @@ CFLAGS =
|
|||
VARIANT =
|
||||
|
||||
# uncomment the following lines to build a static exe
|
||||
#CHICKEN_MAIN = test-overload.scm
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
|
|
|
|||
45
Examples/chicken/overload/runme.scm
Normal file
45
Examples/chicken/overload/runme.scm
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
;; This file demonstrates the overloading capabilities of SWIG
|
||||
|
||||
(load-library 'example "overload.so")
|
||||
|
||||
;; Low level
|
||||
;; ---------
|
||||
|
||||
(display "
|
||||
Trying low level code ...
|
||||
(foo 1)
|
||||
(foo \"some string\")
|
||||
(define A-FOO (new-Foo))
|
||||
(define ANOTHER-FOO (new-Foo A-FOO)) ;; copy constructor
|
||||
(Foo-bar A-FOO 2)
|
||||
(Foo-bar ANOTHER-FOO \"another string\" 3)
|
||||
")
|
||||
|
||||
(primitive:foo 1)
|
||||
(primitive:foo "some string")
|
||||
(define A-FOO (slot-ref (primitive:new-Foo) 'swig-this))
|
||||
(define ANOTHER-FOO (slot-ref (primitive:new-Foo A-FOO) 'swig-this)) ;; copy constructor
|
||||
(primitive:Foo-bar A-FOO 2)
|
||||
(primitive:Foo-bar ANOTHER-FOO "another string" 3)
|
||||
|
||||
;; TinyCLOS
|
||||
;; --------
|
||||
|
||||
(display "
|
||||
Trying TinyCLOS code ...
|
||||
(+foo+ 1)
|
||||
(+foo+ \"some string\")
|
||||
(define A-FOO (make <Foo>))
|
||||
(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
|
||||
(-bar- A-FOO 2)
|
||||
(-bar- ANOTHER-FOO \"another string\" 3)
|
||||
")
|
||||
|
||||
(foo 1)
|
||||
(foo "some string")
|
||||
(define A-FOO (make <Foo>))
|
||||
(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
|
||||
(bar A-FOO 2)
|
||||
(bar ANOTHER-FOO "another string" 3)
|
||||
|
||||
(exit)
|
||||
|
|
@ -10,19 +10,19 @@ CFLAGS =
|
|||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-simple.scm
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
|
|
|
|||
28
Examples/chicken/simple/runme.scm
Normal file
28
Examples/chicken/simple/runme.scm
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
(load-library 'example "simple.so")
|
||||
|
||||
(display "(My-variable): ")
|
||||
(display (My-variable))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable 3.141259): ")
|
||||
(display (My-variable 3.141259))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable): ")
|
||||
(display (My-variable))
|
||||
(display "\n")
|
||||
|
||||
(display "(fact 5): ")
|
||||
(display (fact 5))
|
||||
(display "\n")
|
||||
|
||||
(display "(mod 75 7): ")
|
||||
(display (mod 75 7))
|
||||
(display "\n")
|
||||
|
||||
(display "(get-time): ")
|
||||
(display (get-time))
|
||||
(display "\n")
|
||||
|
||||
(exit)
|
||||
Loading…
Reference in a new issue