More work on the chicken module. The test suite, zlib, and overload examples are still broken.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6610 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5206f539fd
commit
2cdf91de5d
17 changed files with 305 additions and 181 deletions
|
|
@ -5,16 +5,16 @@ SRCS =
|
|||
CXXSRCS = example.cxx
|
||||
TARGET = class
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
VARIANT = _csc
|
||||
|
||||
# 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
|
||||
#VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
all:: $(TARGET) $(TARGET)_proxy
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
|
|
@ -22,10 +22,17 @@ $(TARGET): $(INTERFACE) $(SRCS)
|
|||
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
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check::
|
||||
csi -batch $(TARGET).so test-lowlevel-class.scm test-tinyclos-class.scm
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let "Shape" objects be converted back and forth from TinyCLOS into
|
||||
low-level CHICKEN SWIG procedures */
|
||||
|
||||
%typemap(clos_in) Shape * = SIMPLE_CLOS_OBJECT *;
|
||||
%typemap(clos_out) Shape * = SIMPLE_CLOS_OBJECT *;
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
;; 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 (example:new-Circle 10.0))
|
||||
(define c (new-Circle 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (example:new-Square 10.0))
|
||||
(define s (new-Square 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
|
@ -18,29 +19,29 @@
|
|||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (example:Shape-nshapes))
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
||||
;; Set the location of the object
|
||||
|
||||
(example:Shape-x-set c 20.0)
|
||||
(example:Shape-y-set c 30.0)
|
||||
(Shape-x-set c 20.0)
|
||||
(Shape-y-set c 30.0)
|
||||
|
||||
(example:Shape-x-set s -10.0)
|
||||
(example:Shape-y-set s 5.0)
|
||||
(Shape-x-set s -10.0)
|
||||
(Shape-y-set s 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (example:Shape-x-get c))
|
||||
(display (Shape-x-get c))
|
||||
(display ", ")
|
||||
(display (example:Shape-y-get c))
|
||||
(display (Shape-y-get c))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (example:Shape-x-get s))
|
||||
(display (Shape-x-get s))
|
||||
(display ", ")
|
||||
(display (example:Shape-y-get s))
|
||||
(display (Shape-y-get s))
|
||||
(display ")\n")
|
||||
|
||||
;; ----- Call some methods -----
|
||||
|
|
@ -52,10 +53,10 @@
|
|||
(display o)
|
||||
(display "\n")
|
||||
(display " area = ")
|
||||
(display (example:Shape-area o))
|
||||
(display (Shape-area o))
|
||||
(display "\n")
|
||||
(display " perimeter = ")
|
||||
(display (example:Shape-perimeter o))
|
||||
(display (Shape-perimeter o))
|
||||
(display "\n"))))
|
||||
(disp c)
|
||||
(disp s))
|
||||
|
|
@ -63,10 +64,12 @@
|
|||
(display "\nGuess I'll clean up now\n")
|
||||
|
||||
;; Note: this invokes the virtual destructor
|
||||
(example:delete-Shape c)
|
||||
(example:delete-Shape s)
|
||||
(delete-Shape c)
|
||||
(delete-Shape s)
|
||||
|
||||
(set! s 3)
|
||||
(display (example:Shape-nshapes))
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
;; This file illustrates the shadow C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(load-library 'example "class_proxy.so")
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; 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))
|
||||
(define c (make <Circle> 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (make <example:Square> 10.0))
|
||||
(define s (make <Square> 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
|
@ -25,29 +20,29 @@
|
|||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (+example:Shape-nshapes+))
|
||||
(display (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)
|
||||
(slot-set! c 'x 20.0)
|
||||
(slot-set! c 'y 30.0)
|
||||
|
||||
(-set-x!- s -10.0)
|
||||
(-set-y!- s 5.0)
|
||||
(slot-set! s 'x -10.0)
|
||||
(slot-set! s 'y 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (-get-x- c))
|
||||
(display (slot-ref c 'x))
|
||||
(display ", ")
|
||||
(display (-get-y- c))
|
||||
(display (slot-ref c 'y))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (-get-x- s))
|
||||
(display (slot-ref s 'x))
|
||||
(display ", ")
|
||||
(display (-get-y- s))
|
||||
(display (slot-ref s 'y))
|
||||
(display ")\n")
|
||||
|
||||
;; ----- Call some methods -----
|
||||
|
|
@ -59,10 +54,10 @@
|
|||
(display o)
|
||||
(display "\n")
|
||||
(display " area = ")
|
||||
(display (-area- o))
|
||||
(display (area o))
|
||||
(display "\n")
|
||||
(display " perimeter = ")
|
||||
(display (-perimeter- o))
|
||||
(display (perimeter o))
|
||||
(display "\n"))))
|
||||
(disp c)
|
||||
(disp s))
|
||||
|
|
@ -72,8 +67,10 @@
|
|||
;; Note: Invoke the virtual destructors by forcing garbage collection
|
||||
(set! c 77)
|
||||
(set! s 88)
|
||||
(gc #t)
|
||||
;(gc #t)
|
||||
|
||||
(display (+example:Shape-nshapes+))
|
||||
(display (nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue