Initial addition.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4313 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
870e6457d1
commit
85ace8facd
70 changed files with 9710 additions and 0 deletions
2
SWIG/Examples/chicken/constants/.cvsignore
Normal file
2
SWIG/Examples/chicken/constants/.cvsignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
example_wrap.c
|
||||
my-guile
|
||||
59
SWIG/Examples/chicken/constants/Makefile.in
Normal file
59
SWIG/Examples/chicken/constants/Makefile.in
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
@SET_MAKE@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
SOURCE_DIR = $(top_srcdir)/Examples/chicken/constants
|
||||
TOP = ../..
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
OBJEXT = @OBJEXT@
|
||||
EXEEXT = @EXEEXT@
|
||||
SWIG = $(TOP)/../swig$(EXEEXT)
|
||||
CHICKGEN = example_wrap.$(OBJEXT) csi.$(OBJEXT) precsi.$(OBJEXT) \
|
||||
oexample.$(OBJEXT)
|
||||
CHICKSRC = csi.c precsi.c oexample.c
|
||||
SRCS = $(CHICKGEN)
|
||||
TARGET = constants$(EXEEXT)
|
||||
INCLUDE = -I$(SOURCE_DIR)
|
||||
SWIGOPT =
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
.SUFFIXES: .cxx
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: $(SOURCE_DIR)/precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken
|
||||
|
||||
example_wrap.c example.scm: $(SOURCE_DIR)/example.i
|
||||
(test $< -nt example.i && cp -p $< example.i) || echo example.i is up-to-date
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken
|
||||
|
||||
$(TARGET): $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.$(OBJEXT) core *~ *.so *.stackdump STACKTRACE
|
||||
rm -f $(CHICKGEN) $(CHICKSRC)
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check: all
|
||||
27
SWIG/Examples/chicken/constants/example.i
Normal file
27
SWIG/Examples/chicken/constants/example.i
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
/* A few preprocessor macros */
|
||||
|
||||
#define ICONST 42
|
||||
#define FCONST 2.1828
|
||||
#define CCONST 'x'
|
||||
#define CCONST2 '\n'
|
||||
#define SCONST "Hello World"
|
||||
#define SCONST2 "\"Hello World\""
|
||||
|
||||
/* This should work just fine */
|
||||
#define EXPR ICONST + 3*(FCONST)
|
||||
|
||||
/* This shouldn't do anything */
|
||||
#define EXTERN extern
|
||||
|
||||
/* Neither should this (BAR isn't defined) */
|
||||
#define FOO (ICONST + BAR)
|
||||
|
||||
/* The following directives also produce constants. Remember that
|
||||
CHICKEN is normally case-insensitive, so don't rely on differing
|
||||
case to differentiate variable names */
|
||||
|
||||
%constant int iconstX = 37;
|
||||
%constant double fconstX = 3.14;
|
||||
42
SWIG/Examples/chicken/constants/precsi.scm
Normal file
42
SWIG/Examples/chicken/constants/precsi.scm
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
(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")
|
||||
15
SWIG/Examples/chicken/constants/test-constants.scm
Normal file
15
SWIG/Examples/chicken/constants/test-constants.scm
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
;; run with './constants test-constants.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
|
||||
(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))
|
||||
(or (char=? (example-CCONST) #\x) (exit 1))
|
||||
(or (char=? (example-CCONST2) #\newline) (exit 1))
|
||||
(or (string=? (example-SCONST) "Hello World") (exit 1))
|
||||
(or (string=? (example-SCONST2) "\"Hello World\"") (exit 1))
|
||||
(or (< (abs (- (example-EXPR) (+ (example-ICONST) (* 3 (example-FCONST))))) 0.00001) (exit 1))
|
||||
(or (= (example-iconstX) 37) (exit 1))
|
||||
(or (< (abs (- (example-fconstX) 3.14)) 0.00001) (exit 1))
|
||||
(display "finished test.\n")
|
||||
(exit 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue