Rewrite chicken example and test-suite building code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5948 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
830e72dba7
commit
acd0b021b1
35 changed files with 315 additions and 844 deletions
|
|
@ -7,19 +7,7 @@ overload -- C++ function overloading
|
|||
simple -- the simple example from the user manual
|
||||
zlib -- a wrapping of the zlib compression library
|
||||
|
||||
Note that the examples in this directory build a special version of
|
||||
the CHICKEN interpreter (statically linked) which includes the wrapped
|
||||
functions in the top-level module. Just run "make" in any example
|
||||
directory.
|
||||
You should be able to run make in each of the examples. By default, a shared
|
||||
library will be built. Run make check to execute the test.
|
||||
|
||||
** If you have a platform that supports dynamic linking (most UNIXes
|
||||
** and Win32), then you can run "make module" in any example
|
||||
** directory. This will create a dynamic module called
|
||||
** module.dll/module.so/module.shl (depending on your platform), which
|
||||
** you can use with the following:
|
||||
|
||||
(load-library 'precsi "module.dll")
|
||||
|
||||
or
|
||||
|
||||
(load-library 'example "module.dll")
|
||||
You can uncomment a few lines in the Makefile to build a static test exe.
|
||||
|
|
|
|||
|
|
@ -1,49 +1,31 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS =
|
||||
CXXSRCS = example_wrap.cxx example.cxx
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.cxx
|
||||
TARGET = class
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = class
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
all:: $(TARGET) example-generic.scm example-clos.scm
|
||||
# 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
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
all:: $(TARGET)
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.cxx example.scm example-generic.scm example-clos.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_cpp
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static_cpp
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module_cpp
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch $(TARGET).so test-lowlevel-class.scm test-tinyclos-class.scm
|
||||
|
|
|
|||
|
|
@ -1,105 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
(if (not (member "-quiet" (cdr (argv))))
|
||||
(begin
|
||||
;; display prelude to csi
|
||||
(display "class\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, December 2002\n\n")
|
||||
|
||||
(display "C++ Interface\n")
|
||||
(display "-------------\n")
|
||||
(display "
|
||||
class Shape {
|
||||
public:
|
||||
Shape();
|
||||
virtual ~Shape();
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
virtual double perimeter(void) = 0;
|
||||
static int nshapes;
|
||||
enum SomeEnum {
|
||||
First = 0,
|
||||
Second,
|
||||
Third,
|
||||
Last = 1000
|
||||
};
|
||||
};
|
||||
|
||||
class Circle : public Shape {
|
||||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r);
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
||||
class Square : public Shape {
|
||||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w);
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
")
|
||||
|
||||
(display "\n")
|
||||
|
||||
(display "CHICKEN Low-Level Procedures\n")
|
||||
(display "----------------------------\n")
|
||||
(display "
|
||||
(define A-CIRCLE-SHAPE (example:new-Circle %radius))
|
||||
(example:Circle-area %circle)
|
||||
(example:Circle-perimeter %circle)
|
||||
(example:delete-Circle %circle)
|
||||
|
||||
(define A-SQUARE-SHAPE (example:new-Square %width))
|
||||
(example:Square-area %square)
|
||||
(example:Square-perimeter %square)
|
||||
(example:delete-Square %square)
|
||||
|
||||
(example:delete-Shape %shape)
|
||||
(example:Shape-x-set %shape %x)
|
||||
(example:Shape-x-get %shape)
|
||||
(example:Shape-y-set %shape %y)
|
||||
(example:Shape-y-get %shape)
|
||||
(example:Shape-move %shape %dx %dy)
|
||||
(example:Shape-area %shape)
|
||||
(example:Shape-perimeter %shape)
|
||||
(example:Shape-nshapes)
|
||||
(example:Shape-nshapes %nshapes-int)
|
||||
(example:Shape-First)
|
||||
(example:Shape-Second)
|
||||
(example:Shape-Third)
|
||||
(example:Shape-Last)
|
||||
")
|
||||
|
||||
(display "\n")
|
||||
|
||||
(display "TinyCLOS Classes\n")
|
||||
(display "----------------\n")
|
||||
(display "
|
||||
;; ALL generic methods must be included first
|
||||
(include \"example-generic\")
|
||||
;; After generic methods are defined, can include TinyCLOS code
|
||||
(include \"example-clos\")
|
||||
|
||||
(define A-CIRCLE-SHAPE (make <example:Circle> %radius))
|
||||
(-get-x- %shapeObject)
|
||||
(-set-x!- %shapeObject %x)
|
||||
(-get-y- %shapeObject)
|
||||
(-set-y!- %shapeObject %y)
|
||||
(-move!- %shapeObject %dx %dy)
|
||||
(-area- %shapeObject)
|
||||
(-perimeter- %shapeObject)
|
||||
(+example:Shape-nshapes+)
|
||||
(+example:Shape-nshapes+ %nshapes-int)
|
||||
;; do not use (example:delete-Shape (slot-ref %shapeObject 'this))
|
||||
;; as %shapeObject is always garbage-collected
|
||||
")
|
||||
(display "\n")))
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
;; This file illustrates the low-level C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(declare (uses example))
|
||||
|
||||
;; ----- Object creation -----
|
||||
|
||||
(display "Creating some objects:\n")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
;; This file illustrates the shadow C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; All generic methods must be included first
|
||||
(include "example-generic")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,30 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS = example_wrap.c
|
||||
CXXSRCS =
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.c
|
||||
TARGET = constants
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = constants
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-constants.scm
|
||||
#VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.c example.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch $(TARGET).so test-constants.scm
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
;; display prelude to csi
|
||||
(display "constants\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, December 2002\n\n")
|
||||
|
||||
(display "C Procedures:\n")
|
||||
(display " #define ICONST 42\n")
|
||||
(display " #define FCONST 2.1828\n")
|
||||
(display " #define CCONST 'x'\n")
|
||||
(display " #define CCONST2 '\n'\n")
|
||||
(display " #define SCONST \"Hello World\"\n")
|
||||
(display " #define SCONST2 \"\\\"Hello World\\\"\"\n")
|
||||
(display " /* This should work just fine */\n")
|
||||
(display " #define EXPR ICONST + 3*(FCONST)\n")
|
||||
(display " /* This shouldn't do anything */\n")
|
||||
(display " #define EXTERN extern\n")
|
||||
(display " /* Neither should this (BAR isn't defined) */\n")
|
||||
(display " #define FOO (ICONST + BAR)\n")
|
||||
(display " /* The following directives also produce constants. Remember that\n")
|
||||
(display " CHICKEN is normally case-insensitive, so don't rely on differing\n")
|
||||
(display " case to differentiate variable names */\n")
|
||||
(display " %constant int iconstX = 37;\n")
|
||||
(display " %constant double fconstX = 3.14;\n")
|
||||
(display "\n")
|
||||
|
||||
(display "Scheme Procedures:\n")
|
||||
(display " (example:ICONST)\n")
|
||||
(display " (example:FCONST)\n")
|
||||
(display " (example:CCONST)\n")
|
||||
(display " (example:CCONST2)\n")
|
||||
(display " (example:SCONST)\n")
|
||||
(display " (example:SCONST2)\n")
|
||||
(display " (example:EXPR)\n")
|
||||
(display " (example:EXTERN)\n")
|
||||
(display " (example:FOO)\n")
|
||||
(display " (example:iconstX)\n")
|
||||
(display " (example:fconstX)\n")
|
||||
(display "\n")
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
;; run with './constants test-constants.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
|
||||
(declare (uses example))
|
||||
|
||||
(display "starting test ... you will see 'finished' if successful.\n")
|
||||
(or (= (example:ICONST) 42) (exit 1))
|
||||
(or (< (abs (- (example:FCONST) 2.1828)) 0.00001) (exit 1))
|
||||
|
|
|
|||
|
|
@ -1,49 +1,30 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS = example.c example_wrap.c
|
||||
CXXSRCS =
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.c
|
||||
TARGET = multimap
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS = example.c
|
||||
CXXSRCS =
|
||||
TARGET = multimap
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-multimap.scm
|
||||
#VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.c example.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS) csi.c' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch $(TARGET).so test-multimap.scm
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
;; display prelude to csi
|
||||
(display "multimap\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, November 2002\n\n")
|
||||
|
||||
(display "C Procedures:\n")
|
||||
(display " int gcd (int n, int m);\n")
|
||||
(display " int gcdmain (int argc, char *argv[]);")
|
||||
(display " int count (char *bytes, int len, char c);")
|
||||
(display " void capitalize (char *str, int len);")
|
||||
(display " void circle (double x, double y);")
|
||||
(display "\n")
|
||||
|
||||
(display "Scheme Procedures:\n")
|
||||
(display " (example:gcd %n %m)\n")
|
||||
(display " (example:gcdmain '(%string %string ...))\n")
|
||||
(display " (example:count %string %character)\n")
|
||||
(display " (example:capitalize %string)\n")
|
||||
(display " (example:circle %x %y)\n")
|
||||
(display "\n")
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
;; run with './multimap test-multimap.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
|
||||
(declare (uses example))
|
||||
|
||||
(display "(example:gcd 90 12): ")
|
||||
(display (example:gcd 90 12))
|
||||
(display "\n")
|
||||
|
|
@ -50,5 +52,5 @@
|
|||
(display "\n")
|
||||
|
||||
(display "(example:squarecubed 3: ")
|
||||
(display (example:squarecubed 3))
|
||||
(display (example:squareCubed 3))
|
||||
(display "\n")
|
||||
|
|
|
|||
|
|
@ -1,49 +1,30 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS =
|
||||
CXXSRCS = example_wrap.cxx example.cxx
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.cxx
|
||||
TARGET = overload
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = overload
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
all:: $(TARGET) example-generic.scm example-clos.scm
|
||||
# uncomment the following lines to build a static exe
|
||||
#CHICKEN_MAIN = test-overload.scm
|
||||
#VARIANT = _static
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
all:: $(TARGET)
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.cxx example.scm example-generic.scm example-clos.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_cpp
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static_cpp
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module_cpp
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch $(TARGET).so test-overload.scm
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
(if (not (member "-quiet" (cdr (argv))))
|
||||
(begin
|
||||
;; display prelude to csi
|
||||
(display "overload\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, December 2002\n\n")
|
||||
|
||||
(display "C++ Interface\n")
|
||||
(display "-------------\n")
|
||||
(display "
|
||||
extern void foo (int x);
|
||||
extern void foo (char *x);
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo();
|
||||
Foo(const Foo &); // Copy constructor
|
||||
void bar(int x);
|
||||
void bar(char *s, int y);
|
||||
};
|
||||
")
|
||||
|
||||
(display "\n")
|
||||
|
||||
(display "CHICKEN Low-Level Procedures\n")
|
||||
(display "----------------------------\n")
|
||||
(display "
|
||||
(example:foo %x-int)
|
||||
(example:foo %x-string)
|
||||
(define A-FOO (example:new-Foo))
|
||||
(define ANOTHER-FOO (example:new-Foo %foo)) ;; copy constructor
|
||||
(example:Foo-bar %foo %x-int)
|
||||
(example:Foo-bar %foo %s-string %y-int)
|
||||
")
|
||||
|
||||
(display "\n")
|
||||
|
||||
(display "TinyCLOS Classes\n")
|
||||
(display "----------------\n")
|
||||
(display "
|
||||
;; ALL generic methods must be included first
|
||||
(include \"example-generic\")
|
||||
;; After generic methods are defined, can include TinyCLOS code
|
||||
(include \"example-clos\")
|
||||
|
||||
(+example:foo+ %x-int)
|
||||
(+example:foo+ %x-string)
|
||||
(define A-FOO (make <example:Foo>))
|
||||
(define ANOTHER-FOO (make <example:Foo> %fooObject)) ;; copy constructor
|
||||
(-bar- %fooObject %x-int)
|
||||
(-bar- %fooObject %s-string %y-int)
|
||||
")
|
||||
(display "\n")))
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
;; This file demonstrates the overloading capabilities of SWIG
|
||||
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; Low level
|
||||
;; ---------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,30 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS = example.c example_wrap.c
|
||||
CXXSRCS =
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.c
|
||||
TARGET = simple
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS = example.c
|
||||
CXXSRCS =
|
||||
TARGET = simple
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-simple.scm
|
||||
#VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.c example.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch simple.so test-simple.scm
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
;; display prelude to csi
|
||||
(display "simple\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, December 2002\n\n")
|
||||
|
||||
(display "C Procedures:\n")
|
||||
(display " double My_variable;\n")
|
||||
(display " int fact(int);\n")
|
||||
(display " %name(mod) int my_mod(int n, int m);\n")
|
||||
(display " int my_mod(int n, int m);\n")
|
||||
(display " char *get_time();\n")
|
||||
|
||||
(display "\n")
|
||||
|
||||
(display "Scheme Procedures:\n")
|
||||
(display " (example:My-variable) or (example:My-variable %x)\n");
|
||||
(display " (example:fact %n)\n")
|
||||
(display " (example:mod %n %m)\n")
|
||||
(display " (example:my-mod %n %m)\n")
|
||||
(display " (example:get-time)\n")
|
||||
(display "\n")
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
;; run with './simple test-simple.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
(declare (uses example))
|
||||
|
||||
(display "(example:My-variable): ")
|
||||
(display (example:My-variable))
|
||||
|
|
|
|||
|
|
@ -1,49 +1,31 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS = example_wrap.c
|
||||
CXXSRCS =
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.c
|
||||
TARGET = zlib
|
||||
INCLUDE = -I.
|
||||
LIBS = -lz
|
||||
SWIGOPT = -prefix zlib -mixed -I/usr/include
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = zlib
|
||||
INCLUDE =
|
||||
SWIGOPT = -I/usr/include -mixed -prefix zlib
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
LIBS = -lz
|
||||
|
||||
# comment out the following two lines to build a dynamic exe
|
||||
CHICKEN_MAIN = test-zlib.scm
|
||||
VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.c example.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile LIBS='$(LIBS)' \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile LIBS='$(LIBS)' \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch simple.so test-zlib.scm
|
||||
|
|
|
|||
|
|
@ -1,123 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
;; display prelude to csi
|
||||
(display "zlib\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, February 2003\n\n")
|
||||
|
||||
(display "Scheme Procedures:\n")
|
||||
(display "
|
||||
zlib:max-mem-level
|
||||
zlib:max-wbits
|
||||
zlib:seek-set
|
||||
zlib:seek-cur
|
||||
zlib:seek-end
|
||||
zlib:version
|
||||
zlib:z-stream-next-in-set
|
||||
zlib:z-stream-next-in-get
|
||||
zlib:z-stream-avail-in-set
|
||||
zlib:z-stream-avail-in-get
|
||||
zlib:z-stream-total-in-set
|
||||
zlib:z-stream-total-in-get
|
||||
zlib:z-stream-next-out-set
|
||||
zlib:z-stream-next-out-get
|
||||
zlib:z-stream-avail-out-set
|
||||
zlib:z-stream-avail-out-get
|
||||
zlib:z-stream-total-out-set
|
||||
zlib:z-stream-total-out-get
|
||||
zlib:z-stream-msg-set
|
||||
zlib:z-stream-msg-get
|
||||
zlib:z-stream-state-set
|
||||
zlib:z-stream-state-get
|
||||
zlib:z-stream-zalloc-set
|
||||
zlib:z-stream-zalloc-get
|
||||
zlib:z-stream-zfree-set
|
||||
zlib:z-stream-zfree-get
|
||||
zlib:z-stream-opaque-set
|
||||
zlib:z-stream-opaque-get
|
||||
zlib:z-stream-data-type-set
|
||||
zlib:z-stream-data-type-get
|
||||
zlib:z-stream-adler-set
|
||||
zlib:z-stream-adler-get
|
||||
zlib:z-stream-reserved-set
|
||||
zlib:z-stream-reserved-get
|
||||
zlib:new-z-stream
|
||||
zlib:delete-z-stream
|
||||
zlib:z-no-flush
|
||||
zlib:z-partial-flush
|
||||
zlib:z-sync-flush
|
||||
zlib:z-full-flush
|
||||
zlib:z-finish
|
||||
zlib:z-ok
|
||||
zlib:z-stream-end
|
||||
zlib:z-need-dict
|
||||
zlib:z-errno
|
||||
zlib:z-stream-error
|
||||
zlib:z-data-error
|
||||
zlib:z-mem-error
|
||||
zlib:z-buf-error
|
||||
zlib:z-version-error
|
||||
zlib:z-no-compression
|
||||
zlib:z-best-speed
|
||||
zlib:z-best-compression
|
||||
zlib:z-default-compression
|
||||
zlib:z-filtered
|
||||
zlib:z-huffman-only
|
||||
zlib:z-default-strategy
|
||||
zlib:z-binary
|
||||
zlib:z-ascii
|
||||
zlib:z-unknown
|
||||
zlib:z-deflated
|
||||
zlib:z-null
|
||||
zlib:version
|
||||
zlib:deflate
|
||||
zlib:deflate-end
|
||||
zlib:inflate
|
||||
zlib:inflate-end
|
||||
zlib:deflate-set-dictionary
|
||||
zlib:deflate-copy
|
||||
zlib:deflate-reset
|
||||
zlib:deflate-params
|
||||
zlib:inflate-set-dictionary
|
||||
zlib:inflate-sync
|
||||
zlib:inflate-reset
|
||||
zlib:compress
|
||||
zlib:compress2
|
||||
zlib:uncompress
|
||||
zlib:gzopen
|
||||
zlib:gzdopen
|
||||
zlib:gzsetparams
|
||||
zlib:gzread
|
||||
zlib:gzwrite
|
||||
zlib:gzprintf
|
||||
zlib:gzputs
|
||||
zlib:gzgets
|
||||
zlib:gzputc
|
||||
zlib:gzgetc
|
||||
zlib:gzflush
|
||||
zlib:gzseek
|
||||
zlib:gzrewind
|
||||
zlib:gztell
|
||||
zlib:gzeof
|
||||
zlib:gzclose
|
||||
zlib:gzerror
|
||||
zlib:adler32
|
||||
zlib:crc32
|
||||
zlib:deflate-init-
|
||||
zlib:inflate-init-
|
||||
zlib:deflate-init2-
|
||||
zlib:inflate-init2-
|
||||
zlib:internal-state-dummy-set
|
||||
zlib:internal-state-dummy-get
|
||||
zlib:new-internal-state
|
||||
zlib:delete-internal-state
|
||||
zlib:z-error
|
||||
zlib:inflate-sync-point
|
||||
zlib:get-crc-table
|
||||
zlib:deflate-init
|
||||
zlib:inflate-init
|
||||
zlib:z-stream-save-next-out
|
||||
zlib:z-stream-get-next-chunk
|
||||
")
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
;; run with './zlib test-zlib.scm'
|
||||
|
||||
(declare (uses example))
|
||||
(declare (uses format))
|
||||
|
||||
;; Init zstream
|
||||
(define s (zlib:new-z-stream))
|
||||
(zlib:z-stream-zalloc-set s #f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue