Merge branch 'master' into C

Merge with the latest master before making more changes.
This commit is contained in:
Vadim Zeitlin 2021-10-04 16:03:36 +02:00
commit ac4f3c78be
1118 changed files with 15064 additions and 34376 deletions

View file

@ -58,6 +58,7 @@ INTERFACE =
INTERFACEDIR =
INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
SWIGOPT =
PCHSUPPORT = @PCHSUPPORT@
# SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile
SWIG_LIB_DIR = ./Lib
@ -164,6 +165,7 @@ TCL_SO = @TCL_SO@
TCLLDSHARED = @TCLLDSHARED@
TCLCXXSHARED = @TCLCXXSHARED@
TCL_SCRIPT = $(SRCDIR)$(RUNME).tcl
TCL_LINK = @TCLLINK@
# -----------------------------------------------------------
# Build a new version of the tclsh shell
@ -186,7 +188,7 @@ tclsh_cpp: $(SRCDIR_SRCS)
tcl: $(SRCDIR_SRCS)
$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
# -----------------------------------------------------------
# Build a Tcl7.5 dynamic loadable module for C++
@ -195,7 +197,7 @@ tcl: $(SRCDIR_SRCS)
tcl_cpp: $(SRCDIR_SRCS)
$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
# -----------------------------------------------------------------
# Run Tcl example
@ -380,13 +382,7 @@ python_static_cpp: $(SRCDIR_SRCS)
# Running a Python example
# -----------------------------------------------------------------
ifeq (,$(PY3))
PYSCRIPT = $(RUNME).py
else
PYSCRIPT = $(RUNME)3.py
endif
PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
PYSCRIPT = $(RUNME).py
python_run: $(PYSCRIPT)
ifneq (,$(PYCODESTYLE))
@ -399,10 +395,6 @@ $(RUNME).py: $(SRCDIR)$(RUNME).py
cp $< $@
endif
$(RUNME)3.py: $(SRCDIR)$(RUNME).py
cp $< $@
$(PY2TO3) -w $@ >/dev/null 2>&1
# -----------------------------------------------------------------
# Version display
# -----------------------------------------------------------------
@ -420,7 +412,6 @@ python_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO)
rm -f $(TARGET).py
if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac
@ -438,14 +429,37 @@ OCTAVE_SO = @OCTAVE_SO@
OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m
# ----------------------------------------------------------------
# Pre-compile Octave headers, if supported
# ----------------------------------------------------------------
ifeq (yes,$(PCHSUPPORT))
octave_precompile_headers:
echo "precompiling $(OCTHEADERS)"
cp -f $(OCTHEADERSSRC) $(OCTHEADERS)
if $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(OCTAVE_CXX) $(OCTHEADERS); then \
: ; \
else \
rm -f $(OCTHEADERSGCH); \
exit 1; \
fi
else
octave_precompile_headers:
echo "precompiling Octave headers not supported"; exit 1
endif
# ----------------------------------------------------------------
# Build a C dynamically loadable module
# Note: Octave requires C++ compiler when compiling C wrappers
# ----------------------------------------------------------------
octave: $(SRCDIR_SRCS)
$(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(SWIG) -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
@ -454,8 +468,8 @@ octave: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
octave_cpp: $(SRCDIR_SRCS)
$(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(SWIG) -c++ -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
# -----------------------------------------------------------------
@ -481,6 +495,7 @@ octave_clean:
rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO)
rm -f $(OCTHEADERS) $(OCTHEADERSGCH)
##################################################################
##### GUILE ######
@ -1031,20 +1046,21 @@ ruby_clean:
rm -f *.@OBJEXT@ *$(RUBY_SO)
##################################################################
##### PHP7 ######
##### PHP ######
##################################################################
PHP = @PHP@
PHP_INCLUDE = @PHPINC@
PHP_SO = @PHP_SO@
PHP_SCRIPT = $(SRCDIR)$(RUNME).php
PHP_EXTENSION = example$(PHP_SO)
# -------------------------------------------------------------------
# Build a PHP dynamically loadable module (C)
# -------------------------------------------------------------------
php: $(SRCDIR_SRCS)
$(SWIG) -php7 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(SWIG) -php $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
@ -1053,7 +1069,7 @@ php: $(SRCDIR_SRCS)
# --------------------------------------------------------------------
php_cpp: $(SRCDIR_SRCS)
$(SWIG) -php7 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(SWIG) -php -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
@ -1062,7 +1078,7 @@ php_cpp: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
php_run:
$(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off -d display_errors=stderr $(PHP_SCRIPT) $(RUNPIPE)
$(RUNTOOL) $(PHP) -n -d extension_dir=. -d extension=$(PHP_EXTENSION) -d display_errors=stderr -r 'set_error_handler(function($$n,$$s,$$f,$$l){if($$f!==Null){print$$f;if($$l!==Null)print":$$l";print": ";}print"$$s\n";exit(1);});include($$argv[1]);' $(PHP_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@ -1234,46 +1250,6 @@ lua_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *$(LUA_SO)
##################################################################
##### ALLEGRO CL ######
##################################################################
ALLEGROCL = @ALLEGROCLBIN@
ALLEGROCL_SCRIPT=$(RUNME).lisp
allegrocl: $(SRCDIR_SRCS)
$(SWIG) -allegrocl -cwrap $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_cpp: $(SRCDIR_SRCS)
$(SWIG) -c++ -allegrocl $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Run ALLEGRO CL example
# -----------------------------------------------------------------
allegrocl_run:
$(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
# -----------------------------------------------------------------
allegrocl_version:
$(ALLEGROCL) --version
# -----------------------------------------------------------------
# Cleaning the ALLEGRO CL examples
# -----------------------------------------------------------------
allegrocl_clean:
rm -f *_wrap* *~ .~*
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
##################################################################
##### CFFI ######
##################################################################
@ -1494,34 +1470,20 @@ scilab_clean:
GO = @GO@
GOGCC = @GOGCC@
GCCGO = @GCCGO@
GO1 = @GO1@
GO12 = @GO12@
GO13 = @GO13@
GO15 = @GO15@
GOC = @GOC@
GOOPT = @GOOPT@
GCCGOOPT = @GCCGOOPT@
GOVERSIONOPTION = @GOVERSIONOPTION@
GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) || $(GO15); then echo -pack ; fi`
GOSRCS = $(INTERFACE:.i=.go)
GOCSRCS = $(INTERFACE:.i=_gc.c)
GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
GOTOOL = `if $(GO1) ; then echo go tool; fi`
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
GOPACKAGE = $(notdir $(INTERFACE:.i=.a))
GOPATHPARENTDIR = gopath/$(GOMOD)/src
GOPATHDIR = $(GOPATHPARENTDIR)/$(INTERFACE:.i=)
GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
# ----------------------------------------------------------------
# Build a Go module (C)
# ----------------------------------------------------------------
@ -1536,49 +1498,13 @@ $(GOPATHPARENTDIR)/go.mod:
echo "go 1.12" >> $(GOPATHDIR)/go.mod
mv -f $(GOPATHDIR)/go.mod $(GOPATHPARENTDIR)/go.mod
go_nocgo: $(SRCDIR_SRCS)
$(SWIG) -go -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
$(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
else \
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
fi
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -g -c -I . $(GOSRCS); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS); \
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
rm -f $(GOPACKAGE); \
if $(GO13) || $(GO15); then \
cp $(GOGCOBJS) $(GOPACKAGE); \
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
elif $(GO12); then \
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
else \
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
fi; \
fi
if test -f $(SRCDIR)$(RUNME).go; then \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
elif $(GO12) || $(GO13) || $(GO15); then \
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
else \
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
fi; \
fi
go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
$(SWIG) -go -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
@mkdir gopath 2>/dev/null || true
@mkdir gopath/$(GOMOD) 2>/dev/null || true
@mkdir gopath/$(GOMOD)/src 2>/dev/null || true
@mkdir $(GOPATHDIR) 2>/dev/null || true
rm -f $(GOPATHDIR)/*
rm -rf $(GOPATHDIR)/*
cp $(ISRCS) $(GOPATHDIR)/
if test -f $(IWRAP:.i=.h); then \
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@ -1587,6 +1513,13 @@ go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
fi
cp $(GOSRCS) $(GOPATHDIR)/
@if test -f $(SRCDIR)$(RUNME).go; then \
mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
rm -f gopath/$(GOMOD)/src/runme/*; \
fi
if test -f $(SRCDIR)$(RUNME).go; then \
cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
fi
GOPATH=`pwd`/gopath/$(GOMOD); \
export GOPATH; \
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
@ -1595,82 +1528,29 @@ go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
export CGO_CFLAGS; \
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
export CGO_LDFLAGS; \
(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
if $(GOGCC); then \
cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
fi
fi; \
if test -f $(SRCDIR)$(RUNME).go; then \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -c -g -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE); \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
fi; \
mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
(cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
fi
# ----------------------------------------------------------------
# Build a Go module (C++)
# ----------------------------------------------------------------
go_cpp_nocgo: $(SRCDIR_SRCS)
$(SWIG) -go -c++ -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \
fi; \
$(foreach f,$(ICXXSRCS), \
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) -o $(addsuffix .@OBJEXT@,$(basename $f)) $f $(INCLUDES); \
) \
else \
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
fi
if ! $(GOGCC) ; then \
$(foreach f,$(GOSRCS), \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f \
); \
$(foreach f,$(GOCSRCS), \
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} \
-o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f; \
) \
rm -f $(GOPACKAGE); \
if $(GO13) || $(GO15); then \
cp $(GOGCOBJS) $(GOPACKAGE); \
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
elif $(GO12); then \
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
else \
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
fi; \
else \
$(foreach f,$(GOSRCS), \
$(COMPILETOOL) $(GCCGO) -g -c -I . -o $(addsuffix .@OBJEXT@,$(basename $f)) $f \
); \
fi
if test -f $(SRCDIR)$(RUNME).go; then \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
else \
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
fi; \
fi
go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
$(SWIG) -go -c++ -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
@mkdir gopath 2>/dev/null || true
@mkdir gopath/$(GOMOD) 2>/dev/null || true
@mkdir gopath/$(GOMOD)/src 2>/dev/null || true
@mkdir $(GOPATHDIR) 2>/dev/null || true
rm -f $(GOPATHDIR)/*
rm -rf $(GOPATHDIR)/*
cp $(ICXXSRCS) $(GOPATHDIR)/
if test -f $(IWRAP:.i=.h); then \
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@ -1682,6 +1562,13 @@ go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
fi
cp $(GOSRCS) $(GOPATHDIR)/
@if test -f $(SRCDIR)$(RUNME).go; then \
mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
rm -f gopath/$(GOMOD)/src/runme/*; \
fi
if test -f $(SRCDIR)$(RUNME).go; then \
cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
fi
GOPATH=`pwd`/gopath/$(GOMOD); \
export GOPATH; \
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
@ -1692,21 +1579,16 @@ go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
export CGO_CXXFLAGS; \
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
export CGO_LDFLAGS; \
(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
if $(GOGCC); then \
cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
fi
fi; \
if test -f $(SRCDIR)$(RUNME).go; then \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -g -c -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE) -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
fi; \
mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
(cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
fi
# -----------------------------------------------------------------

View file

@ -1,12 +0,0 @@
This directory contains examples for CHICKEN.
class -- illustrates the proxy class C++ interface
constants -- handling #define and %constant literals
egg -- examples of building chicken extension libraries
multimap -- typemaps with multiple sub-types
overload -- C++ function overloading
simple -- the simple example from the user manual
zlib -- a wrapping of the zlib compression library
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.

View file

@ -1,6 +0,0 @@
# see top-level Makefile.in
class
constants
multimap
overload
simple

View file

@ -1,40 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
INTERFACE = example.i
SRCS =
CXXSRCS = example.cxx
TARGET = class
INCLUDE =
SWIGOPT =
VARIANT =
# uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
#CHICKEN_MAIN = runme-lowlevel.scm
#CHICKEN_MAIN = runme-tinyclos.scm
#VARIANT = _static
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run
build: $(TARGET) $(TARGET)_proxy
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
$(TARGET)_proxy: $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f example.scm
rm -f $(TARGET)

View file

@ -1,28 +0,0 @@
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area() {
return width*width;
}
double Square::perimeter() {
return 4*width;
}

View file

@ -1,41 +0,0 @@
/* File : example.h */
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
enum SomeEnum {
First = 0,
Second,
Third,
Last = 1000
};
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};

View file

@ -1,9 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -1,76 +0,0 @@
;; 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)

View file

@ -1,76 +0,0 @@
;; 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)

View file

@ -1,31 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
INTERFACE = example.i
SRCS =
CXXSRCS =
TARGET = constants
INCLUDE =
SWIGOPT =
VARIANT =
# uncomment the following two lines to build a static exe
#CHICKEN_MAIN = runme.scm
#VARIANT = _static
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
build: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f example.scm
rm -f $(TARGET)

View file

@ -1,27 +0,0 @@
/* 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;

View file

@ -1,16 +0,0 @@
;; 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)

View file

@ -1,41 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
check: build
cd eggs/install && csi ../../test.scm
build: single multi
# This creates an egg which contains only the single module. Any additional implementation files
# that implement the interface being wrapped should also be added to this egg
single: single_wrap.cxx
mkdir -p eggs
tar czf eggs/single.egg single.setup single.scm single_wrap.cxx
rm -f single.scm single_wrap.cxx
# compile the single module with -nounit
single_wrap.cxx: single.i
$(SWIGEXE) -chicken -c++ -proxy -nounit single.i
# Now build both mod1 and mod2 into a single egg
multi: mod1_wrap.cxx mod2_wrap.cxx
mkdir -p eggs
tar czf eggs/multi.egg multi.setup multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
mod1_wrap.cxx: mod1.i
$(SWIGEXE) -chicken -c++ -proxy mod1.i
mod2_wrap.cxx: mod2.i
$(SWIGEXE) -chicken -c++ -proxy mod2.i
clean:
rm -rf eggs
# this part is for testing...
setup:
cd eggs && \
mkdir -p install && \
chicken-setup -repository `pwd`/install single.egg && \
chicken-setup -repository `pwd`/install multi.egg

View file

@ -1,19 +0,0 @@
These examples show how to build a chicken extension module in the form of an
egg. There are two eggs that get built, single.egg which contains a single
module which is built with -nounit and multi.egg, which contains two modules
mod1 and mod2. These are built normally, and multi_init.scm loads them both.
Read section "17.4.2 Building chicken extension libraries" in the manual
for a description of these two techniques.
To build:
$ make
$ make setup
$ make run
$ make clean
The eggs are built into an eggs subdirectory, because chicken-setup has
problems installing eggs when there are other files named similar in
the same directory. The make setup step runs chicken-setup to install
the eggs into the eggs/install directory.

View file

@ -1,8 +0,0 @@
%module mod1
%inline %{
class Bar {
public:
int b;
};
%}

View file

@ -1,17 +0,0 @@
%module mod2
%import "mod1.i"
%{
class Bar {
public:
int b;
};
%}
%inline %{
class Bar2 : public Bar {
public:
int c;
};
%}

View file

@ -1,2 +0,0 @@
(run (csc -s -o multi.so multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx))
(install-extension 'multi '("multi.so"))

View file

@ -1,2 +0,0 @@
(declare (uses mod1))
(declare (uses mod2))

View file

@ -1,8 +0,0 @@
%module single
%inline %{
class Foo {
public:
int a;
};
%}

View file

@ -1,2 +0,0 @@
(run (csc -s -o single.so single.scm single_wrap.cxx))
(install-extension 'single '("single.so"))

View file

@ -1,18 +0,0 @@
(require-extension single)
(require-extension multi)
(define f (make <Foo>))
(slot-set! f 'a 3)
(print (slot-ref f 'a))
(define b (make <Bar>))
(slot-set! b 'b 2)
(print (slot-ref b 'b))
(define b2 (make <Bar2>))
(slot-set! b2 'b 4)
(slot-set! b2 'c 6)
(print (slot-ref b2 'b))
(print (slot-ref b2 'c))
(exit 0)

View file

@ -1,31 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
INTERFACE = example.i
SRCS = example.c
CXXSRCS =
TARGET = multimap
INCLUDE =
SWIGOPT =
VARIANT =
# uncomment the following two lines to build a static exe
#CHICKEN_MAIN = runme.scm
#VARIANT = _static
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
build: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f example.scm
rm -f $(TARGET)

View file

@ -1,53 +0,0 @@
/* File : example.c */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}
int gcdmain(int argc, char *argv[]) {
int x,y;
if (argc != 3) {
printf("usage: gcd x y\n");
return -1;
}
x = atoi(argv[1]);
y = atoi(argv[2]);
printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y));
return 0;
}
int count(char *bytes, int len, char c) {
int i;
int count = 0;
for (i = 0; i < len; i++) {
if (bytes[i] == c) count++;
}
return count;
}
void capitalize(char *str, int len) {
int i;
for (i = 0; i < len; i++) {
str[i] = (char)toupper(str[i]);
}
}
void circle(double x, double y) {
double a = x*x + y*y;
if (a > 1.0) {
printf("Bad points %g, %g\n", x,y);
} else {
printf("Good points %g, %g\n", x,y);
}
}

View file

@ -1,96 +0,0 @@
/* File : example.i */
%module example
%{
extern int gcd(int x, int y);
extern int gcdmain(int argc, char *argv[]);
extern int count(char *bytes, int len, char c);
extern void capitalize (char *str, int len);
extern void circle (double cx, double cy);
extern int squareCubed (int n, int *OUTPUT);
%}
%include exception.i
%include typemaps.i
extern int gcd(int x, int y);
%typemap(in) (int argc, char *argv[]) {
int i;
if (!C_swig_is_vector ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a vector");
}
$1 = C_header_size ($input);
$2 = (char **) malloc(($1+1)*sizeof(char *));
for (i = 0; i < $1; i++) {
C_word o = C_block_item ($input, i);
if (!C_swig_is_string (o)) {
char err[50];
free($2);
sprintf (err, "$input[%d] is not a string", i);
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, err);
}
$2[i] = C_c_string (o);
}
$2[i] = 0;
}
%typemap(freearg) (int argc, char *argv[]) {
free($2);
}
extern int gcdmain(int argc, char *argv[]);
%typemap(in) (char *bytes, int len) {
if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
}
$1 = C_c_string ($input);
$2 = C_header_size ($input);
}
extern int count(char *bytes, int len, char c);
/* This example shows how to wrap a function that mutates a string */
%typemap(in) (char *str, int len)
%{ if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
}
$2 = C_header_size ($input);
$1 = (char *) malloc ($2+1);
memmove ($1, C_c_string ($input), $2);
%}
/* Return the mutated string as a new object. Notice the if MANY construct ... they must be at column 0. */
%typemap(argout) (char *str, int len) (C_word *scmstr)
%{ scmstr = C_alloc (C_SIZEOF_STRING ($2));
SWIG_APPEND_VALUE(C_string (&scmstr, $2, $1));
free ($1);
%}
extern void capitalize (char *str, int len);
/* A multi-valued constraint. Force two arguments to lie
inside the unit circle */
%typemap(check) (double cx, double cy) {
double a = $1*$1 + $2*$2;
if (a > 1.0) {
SWIG_exception (SWIG_ValueError, "cx and cy must be in unit circle");
}
}
extern void circle (double cx, double cy);
/* Test out multiple return values */
extern int squareCubed (int n, int *OUTPUT);
%{
/* Returns n^3 and set n2 to n^2 */
int squareCubed (int n, int *n2) {
*n2 = n * n;
return (*n2) * n;
};
%}

View file

@ -1,58 +0,0 @@
;; 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)

View file

@ -1,31 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
INTERFACE = example.i
SRCS =
CXXSRCS = example.cxx
TARGET = overload
INCLUDE =
SWIGOPT = -proxy -unhideprimitive
VARIANT =
# uncomment the following lines to build a static exe
#CHICKEN_MAIN = runme.scm
#VARIANT = _static
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
build: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f example.scm
rm -f $(TARGET)

View file

@ -1,2 +0,0 @@
Overloading example from Chapter 5.14 of SWIG Core Documentation for
version 1.3.

View file

@ -1,33 +0,0 @@
/* File : example.c */
#include "example.h"
#include <stdio.h>
void foo(int x) {
printf("x is %d\n", x);
}
void foo(char *x) {
printf("x is '%s'\n", x);
}
Foo::Foo () {
myvar = 55;
printf ("Foo constructor called\n");
}
Foo::Foo (const Foo &) {
myvar = 66;
printf ("Foo copy constructor called\n");
}
void Foo::bar (int x) {
printf ("Foo::bar(x) method ... \n");
printf("x is %d\n", x);
}
void Foo::bar (char *s, int y) {
printf ("Foo::bar(s,y) method ... \n");
printf ("s is '%s'\n", s);
printf ("y is %d\n", y);
}

View file

@ -1,14 +0,0 @@
/* File : example.h */
extern void foo (int x);
extern void foo (char *x);
class Foo {
private:
int myvar;
public:
Foo();
Foo(const Foo &); // Copy constructor
void bar(int x);
void bar(char *s, int y);
};

View file

@ -1,16 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let "Foo" objects be converted back and forth from TinyCLOS into
low-level CHICKEN SWIG procedures */
%typemap(clos_in) Foo * = SIMPLE_CLOS_OBJECT *;
%typemap(clos_out) Foo * = SIMPLE_CLOS_OBJECT *;
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -1,45 +0,0 @@
;; 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)

View file

@ -1,31 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
INTERFACE = example.i
SRCS = example.c
CXXSRCS =
TARGET = simple
INCLUDE =
SWIGOPT =
VARIANT =
# uncomment the following two lines to build a static exe
#CHICKEN_MAIN = runme.scm
#VARIANT = _static
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
build: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET)

View file

@ -1 +0,0 @@
Simple example from users manual.

View file

@ -1,24 +0,0 @@
/* Simple example from documentation */
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
/* Compute factorial of n */
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
/* Compute n mod m */
int my_mod(int n, int m) {
return (n % m);
}
char *get_time() {
long ltime;
time(&ltime);
return ctime(&ltime);
}

View file

@ -1,16 +0,0 @@
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
%}
%include typemaps.i
%rename(mod) my_mod;
%inline %{
extern double My_variable;
extern int fact(int);
extern int my_mod(int n, int m);
extern char *get_time();
%}

View file

@ -1,28 +0,0 @@
;; 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)

View file

@ -1,11 +0,0 @@
#include <stdio.h>
int Circle (int x, int y, int radius) {
/* Draw Circle */
printf("Drawing the circle...\n");
/* Return -1 to test contract post assertion */
if (radius == 2)
return -1;
else
return 1;
}

View file

@ -1,19 +0,0 @@
/* File : example.i */
/* Basic C example for swig contract */
/* Tiger, University of Chicago, 2003 */
%module example
%contract Circle (int x, int y, int radius) {
require:
x >= 0;
y >= 0;
radius > x;
ensure:
Circle >= 0;
}
%inline %{
extern int Circle (int x, int y, int radius);
%}

View file

@ -1,17 +0,0 @@
import example
# Call the Circle() function correctly
x = 1;
y = 1;
r = 3;
c = example.Circle(x, y, r)
# test post-assertion
x = 1;
y = 1;
r = 2;
c = example.Circle(x, y, r)
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)

View file

@ -1,20 +0,0 @@
import example
# Call the Circle() function correctly
x = 1;
y = 1;
r = 3;
c = example.Circle(x, y, r)
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
# test pre-assertion
x = 1;
y = -1;
r = 3;
c = example.Circle(x, y, r)
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)

View file

@ -1,30 +0,0 @@
#include "example.h"
#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
double Circle::area(void) {
/* return -1 is to test post-assertion */
if (radius == 1)
return -1;
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
return 2*M_PI*radius;
}
double Square::area(void) {
return width*width;
}
double Square::perimeter(void) {
return 4*width;
}

View file

@ -1,34 +0,0 @@
/* File : example.h */
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area(void) = 0;
virtual double perimeter(void) = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area(void);
virtual double perimeter(void);
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area(void);
virtual double perimeter(void);
};

View file

@ -1,28 +0,0 @@
%module example
%contract Circle::Circle(double radius) {
require:
radius > 0;
}
%contract Circle::area(void) {
ensure:
area > 0;
}
%contract Shape::move(double dx, double dy) {
require:
dx > 0;
}
/* should be no effect, since there is no move() for class Circle */
%contract Circle::move(double dx, double dy) {
require:
dy > 1;
}
# include must be after contracts
%{
#include "example.h"
%}
%include "example.h"

View file

@ -1,33 +0,0 @@
import example
# Create the Circle object
r = 2;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)
# Set the location of the object
c.x = 20
c.y = 30
print " Here is its current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
# ----- Call some methods -----
print "\n Here are some properties of the Circle:"
print " area = ", c.area()
print " perimeter = ", c.perimeter()
dx = 1;
dy = 1;
print " Moving with (%d, %d)..." % (dx, dy)
c.move(dx, dy)
del c
print "==================================="
# test construction */
r = -1;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)

View file

@ -1,44 +0,0 @@
import example
# Create the Circle object
r = 2;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)
# Set the location of the object
c.x = 20
c.y = 30
print " Here is its current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
# ----- Call some methods -----
print "\n Here are some properties of the Circle:"
print " area = ", c.area()
print " perimeter = ", c.perimeter()
dx = 1;
dy = 1;
print " Moving with (%d, %d)..." % (dx, dy)
c.move(dx, dy)
del c
print "==================================="
# test area function */
r = 1;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)
# Set the location of the object
c.x = 20
c.y = 30
print " Here is its current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
# ----- Call some methods -----
print "\n Here are some properties of the Circle:"
print " area = ", c.area()

View file

@ -1,57 +0,0 @@
import example
# Create the Circle object
r = 2;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)
# Set the location of the object
c.x = 20
c.y = 30
print " Here is its current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
# ----- Call some methods -----
print "\n Here are some properties of the Circle:"
print " area = ", c.area()
print " perimeter = ", c.perimeter()
dx = 1;
dy = 1;
print " Moving with (%d, %d)..." % (dx, dy)
c.move(dx, dy)
del c
print "==================================="
# test move function */
r = 2;
print " Creating circle (radium: %d) :" % r
c = example.Circle(r)
# Set the location of the object
c.x = 20
c.y = 30
print " Here is its current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
# ----- Call some methods -----
print "\n Here are some properties of the Circle:"
print " area = ", c.area()
print " perimeter = ", c.perimeter()
# no error for Circle's pre-assertion
dx = 1;
dy = -1;
print " Moving with (%d, %d)..." % (dx, dy)
c.move(dx, dy)
# error with Shape's pre-assertion
dx = -1;
dy = 1;
print " Moving with (%d, %d)..." % (dx, dy)
c.move(dx, dy)

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -5,7 +5,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
"example"
"swigtests/example"
)
func main() {

View file

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"example"
"swigtests/example"
)
func Compare(name string, got string, exp string) error {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -5,7 +5,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -5,7 +5,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -3,7 +3,7 @@ package main
import (
"fmt"
"example"
"swigtests/example"
)
func main() {

View file

@ -5,7 +5,7 @@ package main
import (
"fmt"
. "example"
. "swigtests/example"
)
func main() {

View file

@ -5,7 +5,7 @@ package main
import (
"fmt"
"example"
"swigtests/example"
)
func main() {

View file

@ -1,9 +1,9 @@
# see top-level Makefile.in
constants
class
port
simple
std_vector
constants
matrix
multimap
multivalue
port
simple
std_vector

View file

@ -3,6 +3,7 @@ constant
enum
exception
functor
native
nspace
operator
overload

View file

@ -0,0 +1,3 @@
SRCS =
include $(SRCDIR)../example.mk

View file

@ -0,0 +1,9 @@
{
"targets": [
{
"target_name": "example",
"sources": [ "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
}

View file

@ -0,0 +1,47 @@
/* File : example.i */
%module example
// placeholder() used to help SWIG generate "SWIG_From_int" call
%{
int placeholder();
%}
int placeholder() { return 0; }
// actual demo code
%wrapper
%{
#ifdef SWIG_V8_VERSION /* Engine: Node || V8 */
static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
const int MY_MAGIC_NUMBER = 5;
SWIGV8_VALUE jsresult =
SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER));
if (args.Length() != 0)
SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
SWIGV8_RETURN(jsresult);
fail:
SWIGV8_RETURN(SWIGV8_UNDEFINED());
}
#else /* Engine: JavaScriptCore */
static JSValueRef JavaScript_do_work(JSContextRef context,
JSObjectRef function, JSObjectRef thisObject, size_t argc,
const JSValueRef argv[], JSValueRef* exception) {
const int MY_MAGIC_NUMBER = 5;
JSValueRef jsresult =
SWIG_From_int SWIG_JSC_FROM_CALL_ARGS(
static_cast< int >(MY_MAGIC_NUMBER));
if (argc != 0)
SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
return jsresult;
fail:
return JSValueMakeUndefined(context);
}
#endif
%}
%native(magicNumber) void JavaScript_do_work();

View file

@ -0,0 +1 @@
module.exports = require("build/Release/example");

View file

@ -0,0 +1,31 @@
<html>
<head>
<title>SWIG:Examples:javascript:native</title>
</head>
<body bgcolor="#ffffff">
<tt>SWIG/Examples/javascript/native/</tt>
<hr>
<H2>Manually wrapped callback function in JavaScript</H2>
<p>
This example demonstrates how to manually add callback feature support to a SWIG module.
</p>
<ul>
<li><a href="example.i">example.i</a>. Interface file containing the API function and async behind-the-scenes functions.
<li><a href="runme.java">runme.js</a>. Sample JavaScript program showing the API function being called with a callback function parameter.
</ul>
<h2>Notes</h2>
The V8 code queues the callback request for processing using the UV interface. An async function callback is invoked when the system is ready to process the next request. When the async function finishes, a completion function callback is invoked to finalize the request. Here the callback function parameter is invoked.
<br/><br/>
UV request queueing is only necessary for operations that would take a really long or otherwise unpredictable amount of time (async operations). A callback parameter could also be invoked immediately within the API function.
<hr>
</body>
</html>

View file

@ -0,0 +1,3 @@
var example = require("example");
console.log("My magic number is: ", example.magicNumber());

View file

@ -3,7 +3,9 @@
#include "example.h"
#include <stdio.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {

View file

@ -1,7 +0,0 @@
# see top-level Makefile.in
class
enum
exception
reference
simple
typemap

View file

@ -1,26 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
PLATFORM = LINUXLIBC6
INTERFACE = example.i
SWIGOPT = -c++
MODULA3SRCS = *.[im]3
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
m3ppinplace $(MODULA3SRCS)
# compilation of example_wrap.cxx is started by cm3
# $(CXX) -c $(TARGET)_wrap.cxx
mv example_wrap.cxx m3makefile $(MODULA3SRCS) src/
ln -sf ../example.h src/example.h
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,28 +0,0 @@
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area() {
return width*width;
}
double Square::perimeter() {
return 4*width;
}

View file

@ -1,34 +0,0 @@
/* File : example.h */
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};

View file

@ -1,32 +0,0 @@
/* File : example.i */
%module Example
%{
#include "example.h"
%}
%insert(m3makefile) %{template("../swig")
cxx_source("example_wrap")%}
%typemap(m3rawinmode) Shape *, Circle *, Square * ""
%typemap(m3rawrettype) Shape *, Circle *, Square * "$1_basetype"
%typemap(m3wrapinmode) Shape *, Circle *, Square * ""
%typemap(m3wrapargraw) Shape *, Circle *, Square * "self.cxxObj"
%typemap(m3wrapretvar) Circle *, Square * "cxxObj : ExampleRaw.$1_basetype;"
%typemap(m3wrapretraw) Circle *, Square * "cxxObj"
%typemap(m3wrapretconv) Circle *, Square * "NEW($1_basetype,cxxObj:=cxxObj)"
%typemap(m3wraprettype) Circle *, Square * "$1_basetype"
/* Should work with and without renaming
%rename(M3Shape) Shape;
%rename(M3Circle) Circle;
%rename(M3Square) Square;
%typemap(m3wrapintype) Shape *, Circle *, Square * "M3$1_basetype"
%typemap(m3wraprettype) Shape *, Circle *, Square * "M3$1_basetype"
%typemap(m3wrapretconv) Circle *, Square * "NEW(M3$1_basetype,cxxObj:=cxxObj)"
*/
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -1,11 +0,0 @@
readonly proc cxx_source (X) is
local cxxfile = X&".cxx"
local objfile = X&".o"
%exec("echo $PWD")
if stale(objfile,cxxfile)
exec("cd",path(),"; g++ -I.. -c -o",objfile,cxxfile)
end
import_obj(X)
%unlink_file(path()&SL&objfile)
end

View file

@ -1,27 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
CONSTNUMERIC = example_const
SWIGOPT = -c++
MODULA3SRCS = *.[im]3
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(SWIGEXE) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h
$(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC)
$(CONSTNUMERIC) >$(CONSTNUMERIC).i
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
m3ppinplace $(MODULA3SRCS)
mv m3makefile $(MODULA3SRCS) src/
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,32 +0,0 @@
/* File : example.cxx */
#include "example.h"
#include <stdio.h>
void Foo::enum_test(speed s) {
if (s == IMPULSE) {
printf("IMPULSE speed\n");
} else if (s == WARP) {
printf("WARP speed\n");
} else if (s == LUDICROUS) {
printf("LUDICROUS speed\n");
} else if (s == HYPER) {
printf("HYPER speed\n");
} else {
printf("Unknown speed\n");
}
}
void enum_test(color c, Foo::speed s) {
if (c == RED) {
printf("color = RED, ");
} else if (c == BLUE) {
printf("color = BLUE, ");
} else if (c == GREEN) {
printf("color = GREEN, ");
} else {
printf("color = Unknown color!, ");
}
Foo obj;
obj.enum_test(s);
}

View file

@ -1,83 +0,0 @@
/* File : example.h */
#define PI 3.141
#define DAY_MONDAY 0
#define DAY_TUESDAY 1
#define DAY_WEDNESDAY 2
#define DAY_THURSDAY 3
#define DAY_FRIDAY 4
#define DAY_SATURDAY 5
#define DAY_SUNDAY 6
enum color { BLUE, RED, GREEN };
#define CLB_BLACK 0
#define CLB_BLUE 1
#define CLB_RED 2
#define CLB_MAGENTA 3
#define CLB_GREEN 4
#define CLB_CYAN 5
#define CLB_YELLOW 6
#define CLB_WHITE 7
/* Using this would be good style
which cannot be expected for general C header files.
Instead I want to demonstrate how to live without it.
enum month {
MTHF_JANUARY,
MTHF_FEBRUARY,
MTHF_MARCH,
MTHF_APRIL,
MTHF_MAY,
MTHF_JUNE,
MTHF_JULY,
MTHF_AUGUST,
MTHF_SEPTEMBER,
MTHF_OCTOBER,
MTHF_NOVEMBER,
MTHF_DECEMBER,
}
*/
/* Since there are no compile time constants in C / C++
it is a common abuse
to declare bit set (flag) constants
as enumerations. */
enum calendar {
MTHB_JANUARY = 1 << 0, /* 1 << MTHF_JANUARY, */
MTHB_FEBRUARY = 1 << 1, /* 1 << MTHF_FEBRUARY, */
MTHB_MARCH = 1 << 2, /* 1 << MTHF_MARCH, */
MTHB_APRIL = 1 << 3, /* 1 << MTHF_APRIL, */
MTHB_MAY = 1 << 4, /* 1 << MTHF_MAY, */
MTHB_JUNE = 1 << 5, /* 1 << MTHF_JUNE, */
MTHB_JULY = 1 << 6, /* 1 << MTHF_JULY, */
MTHB_AUGUST = 1 << 7, /* 1 << MTHF_AUGUST, */
MTHB_SEPTEMBER = 1 << 8, /* 1 << MTHF_SEPTEMBER, */
MTHB_OCTOBER = 1 << 9, /* 1 << MTHF_OCTOBER, */
MTHB_NOVEMBER = 1 << 10, /* 1 << MTHF_NOVEMBER, */
MTHB_DECEMBER = 1 << 11, /* 1 << MTHF_DECEMBER, */
MTHB_SPRING = MTHB_MARCH | MTHB_APRIL | MTHB_MAY,
MTHB_SUMMER = MTHB_JUNE | MTHB_JULY | MTHB_AUGUST,
MTHB_AUTUMN = MTHB_SEPTEMBER | MTHB_OCTOBER | MTHB_NOVEMBER,
MTHB_WINTER = MTHB_DECEMBER | MTHB_JANUARY | MTHB_FEBRUARY,
};
namespace Answer {
enum {
UNIVERSE_AND_EVERYTHING = 42,
SEVENTEEN_AND_FOUR = 21,
TWOHUNDRED_PERCENT_OF_NOTHING = 0,
};
class Foo {
public:
Foo() { }
enum speed { IMPULSE = -2, WARP = 0, HYPER, LUDICROUS = 3};
void enum_test(speed s);
};
};
void enum_test(color c, Answer::Foo::speed s);

View file

@ -1,72 +0,0 @@
/* File : example.i */
%module Example
%{
#include "example.h"
%}
%include "example_const.i"
// such features are generated by the following pragmas
#if 0
%feature("modula3:enumitem:enum","Days") DAY_MONDAY;
%feature("modula3:enumitem:name","monday") DAY_MONDAY;
%feature("modula3:enumitem:conv","int:int") DAY_MONDAY;
%feature("modula3:enumitem:enum","Month") MTHB_JANUARY;
%feature("modula3:enumitem:name","january") MTHB_JANUARY;
%feature("modula3:enumitem:conv","set:int") MTHB_JANUARY;
//%feature("modula3:constset:type","MonthSet") MTHB_JANUARY; /*type in the constant definition*/
%feature("modula3:constset:set", "MonthSet") MTHB_JANUARY; /*remarks that the 'type' is a set type*/
%feature("modula3:constset:base","Month") MTHB_JANUARY;
%feature("modula3:constset:name","monthsJanuary") MTHB_JANUARY;
%feature("modula3:constset:conv","set:set") MTHB_JANUARY; /*conversion of the bit pattern: no change*/
%feature("modula3:enumitem:enum","Color") BLUE;
%feature("modula3:enumitem:name","blue") BLUE;
%feature("modula3:enumitem:conv","int:int") BLUE;
%feature("modula3:constint:type","INTEGER") Foo::IMPULSE;
%feature("modula3:constint:name","impulse") Foo::IMPULSE;
%feature("modula3:constint:conv","int:int") Foo::IMPULSE;
#endif
%rename(pi) PI;
%pragma(modula3) enumitem="prefix=DAY_;int;srcstyle=underscore;Day";
%pragma(modula3) enumitem="enum=color;int;srcstyle=underscore;Color";
%pragma(modula3) makesetofenum="Color";
%pragma(modula3) constset="prefix=CLB_;set;srcstyle=underscore,prefix=clb;ColorSet,Color";
%pragma(modula3) enumitem="prefix=MTHB_,enum=calendar;set;srcstyle=underscore;Month";
%pragma(modula3) makesetofenum="Month";
%pragma(modula3) constset="prefix=MTHB_,enum=calendar;set;srcstyle=underscore,prefix=monthset;MonthSet,Month";
%pragma(modula3) constint="prefix=Answer::Foo::,enum=Answer::Foo::speed;int;srcstyle=underscore,prefix=speed;INTEGER";
%pragma(modula3) constint="prefix=Answer::,enum=Answer::;int;srcstyle=underscore,prefix=answer;CARDINAL";
%rename(AnswerFoo) Answer::Foo;
%typemap("m3rawrettype") Answer::Foo * %{AnswerFoo%}
%typemap("m3rawintype") Answer::Foo * %{AnswerFoo%}
%typemap("m3rawinmode") Answer::Foo * %{%}
%typemap("m3wraprettype") Answer::Foo * %{AnswerFoo%}
%typemap("m3wrapintype") Answer::Foo * %{AnswerFoo%}
%typemap("m3wrapinmode") Answer::Foo * %{%}
%typemap("m3wrapargraw") Answer::Foo * %{self.cxxObj%}
%typemap("m3wrapretvar") Answer::Foo * %{cxxObj : ExampleRaw.AnswerFoo;%}
%typemap("m3wrapretraw") Answer::Foo * %{cxxObj%}
%typemap("m3wrapretconv") Answer::Foo * %{NEW(AnswerFoo,cxxObj:=cxxObj)%}
%typemap("m3rawintype") Answer::Foo::speed %{C.int%};
%typemap("m3rawintype:import") Answer::Foo::speed %{Ctypes AS C%};
%typemap("m3wrapintype") Answer::Foo::speed %{[-2..3]%};
%typemap("m3wrapintype") color %{Color%};
%typemap("m3wrapargraw") color %{ORD($1_name)%};
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -1,24 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
MODULA3SRCS = *.[im]3
MODULA3FLAGS= -o runme
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp
# $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile
m3ppinplace $(MODULA3SRCS)
mv m3makefile $(MODULA3SRCS) src/
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,18 +0,0 @@
/* File : example.h */
enum error {OK, OVERFLOW, DIVISION_BY_ZERO, NEGATIVE_RADICAND, NEGATIVE_BASE};
typedef error errorstate; /* just to separate the typemaps */
error acc_add (double &x, double y);
error acc_sub (double &x, double y);
error acc_mul (double &x, double y);
error acc_div (double &x, double y);
double op_add (double x, double y, errorstate &err);
double op_sub (double x, double y, errorstate &err);
double op_mul (double x, double y, errorstate &err);
double op_div (double x, double y, errorstate &err);
double op_sqrt (double x, errorstate &err);
double op_pow (double x, double y, errorstate &err);
double op_noexc (double x, double y);

View file

@ -1,43 +0,0 @@
/* File : example.i */
%module Example
%{
#include "example.h"
%}
%insert(m3wrapintf) %{
EXCEPTION E(Error);
%}
%insert(m3wrapimpl) %{
IMPORT Ctypes AS C;
%}
%pragma(modula3) enumitem="enum=error;int;srcstyle=underscore;Error";
%typemap("m3rawintype") double & %{C.double%};
%typemap("m3wrapintype") double & %{LONGREAL%};
%typemap("m3wraprettype") error ""
%typemap("m3wrapretvar") error "rawerr: C.int;"
%typemap("m3wrapretraw") error "rawerr"
%typemap("m3wrapretcheck:throws") error "E"
%typemap("m3wrapretcheck") error
%{VAR err := VAL(rawerr, Error);
BEGIN
IF err # Error.ok THEN
RAISE E(err);
END;
END;%}
%typemap("m3rawintype") errorstate & %{C.int%};
%typemap("m3wrapintype",numinputs=0) errorstate & %{%};
%typemap("m3wrapargvar") errorstate & %{err:C.int:=ORD(Error.ok);%};
%typemap("m3wrapoutcheck:throws") errorstate & "E";
%typemap("m3wrapoutcheck") errorstate &
%{IF VAL(err,Error) # Error.ok THEN
RAISE E(VAL(err,Error));
END;%}
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -1,22 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT = -c++
MODULA3SRCS = *.[im]3
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
m3ppinplace $(MODULA3SRCS)
mv m3makefile $(MODULA3SRCS) src/
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,46 +0,0 @@
/* File : example.cxx */
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
#endif
#include "example.h"
#include <stdio.h>
#include <stdlib.h>
Vector operator+(const Vector &a, const Vector &b) {
Vector r;
r.x = a.x + b.x;
r.y = a.y + b.y;
r.z = a.z + b.z;
return r;
}
char *Vector::print() {
static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp;
}
VectorArray::VectorArray(int size) {
items = new Vector[size];
maxsize = size;
}
VectorArray::~VectorArray() {
delete [] items;
}
Vector &VectorArray::operator[](int index) {
if ((index < 0) || (index >= maxsize)) {
printf("Panic! Array index out of bounds.\n");
exit(1);
}
return items[index];
}
int VectorArray::size() {
return maxsize;
}

View file

@ -1,22 +0,0 @@
/* File : example.h */
struct Vector {
private:
double x,y,z;
public:
Vector() : x(0), y(0), z(0) { }
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
Vector operator+(const Vector &b) const;
char *print();
};
struct VectorArray {
private:
Vector *items;
int maxsize;
public:
VectorArray(int maxsize);
~VectorArray();
Vector &operator[](int);
int size();
};

View file

@ -1,32 +0,0 @@
/* File : example.i */
/* This file has a few "typical" uses of C++ references. */
%module Example
%{
#include "example.h"
%}
%pragma(modula3) unsafe="1";
%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
%typemap(m3wrapretvar) Vector %{vec: UNTRACED REF Vector;%}
%typemap(m3wrapretraw) Vector %{vec%}
%typemap(m3wrapretconv) Vector %{vec^%}
/* This helper function calls an overloaded operator */
%inline %{
Vector addv(const Vector &a, const Vector &b) {
return a+b;
}
%}
%rename(Vector_Clear) Vector::Vector();
%rename(Add) Vector::operator+;
%rename(GetItem) VectorArray::operator[];
%include "example.h"

View file

@ -1,22 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
MODULA3SRCS = *.[im]3
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
m3ppinplace $(MODULA3SRCS)
mv m3makefile $(MODULA3SRCS) src/
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,18 +0,0 @@
/* File : example.c */
/* A global variable */
double Foo = 3.0;
/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}

View file

@ -1,7 +0,0 @@
/* File : example.i */
%module Example
%inline %{
extern int gcd(int x, int y);
extern double Foo;
%}

View file

@ -1,22 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
MODULA3SRCS = *.[im]3
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
m3ppinplace $(MODULA3SRCS)
mv m3makefile $(MODULA3SRCS) src/
cm3
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean

View file

@ -1,90 +0,0 @@
/* File : example.i */
%module Example
%pragma(modula3) unsafe="true";
%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point;
%}
%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point;
IMPORT M3toC;
IMPORT Ctypes AS C;
%}
/* Typemap applied to patterns of multiple arguments */
%typemap(m3rawinmode) (char *outstr) %{VAR%}
%typemap(m3rawintype) (char *outstr) %{CHAR%}
%typemap(m3wrapinmode) (char *outstr, int size) %{VAR%}
%typemap(m3wrapintype) (char *outstr, int size) %{ARRAY OF CHAR%}
%typemap(m3wrapargraw) (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%}
%typemap(m3rawinmode) (const struct Window *) %{READONLY%}
%typemap(m3wrapinmode) (const struct Window *) %{READONLY%}
%typemap(m3rawintype) ( struct Window *) %{Window%}
%typemap(m3wrapintype) ( struct Window *) %{Window%}
%typemap(m3rawinmode) (const char *str []) %{READONLY%}
%typemap(m3wrapinmode) (const char *str []) %{READONLY%}
%typemap(m3rawintype) (const char *str []) %{(*ARRAY OF*) C.char_star%}
%typemap(m3wrapintype) (const char *str []) %{ARRAY OF TEXT%}
%typemap(m3wrapargvar) (const char *str []) %{$1: REF ARRAY OF C.char_star;%}
%typemap(m3wrapargraw) (const char *str []) %{$1[0]%}
%typemap(m3wrapinconv) (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name));
FOR i:=FIRST($1_name) TO LAST($1_name) DO
$1[i]:=M3toC.SharedTtoS($1_name[i]);
END;%}
%typemap(m3wrapfreearg) (const char *str [])
%{FOR i:=FIRST($1_name) TO LAST($1_name) DO
M3toC.FreeSharedS($1_name[i],$1[i]);
END;%}
%typemap(m3wraprettype) char * %{TEXT%}
%typemap(m3wrapretvar) char * %{result_string: C.char_star;%}
%typemap(m3wrapretraw) char * %{result_string%}
%typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%}
struct Window {
char *label;
int left,top,width,height;
};
%typemap(m3wrapinname) (int x, int y) %{p%}
%typemap(m3wrapinmode) (int x, int y) %{READONLY%}
%typemap(m3wrapintype) (int x, int y) %{Point%}
%typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%}
%typemap(m3wrapargraw) (int &x, int &y) %{p.$1_name, p.$2_name%}
%typemap(m3wrapintype) (int &x, int &y) %{Point%}
%typemap(m3wrapoutname) (int &x, int &y) %{p%}
%typemap(m3wrapouttype) (int &x, int &y) %{Point%}
%typemap(m3wrapargdir) (int &x, int &y) "out"
%typemap(m3wrapargvar) int &left, int &top, int &width, int &height "$1:C.int;"
%typemap(m3wrapargraw) int &left, int &top, int &width, int &height "$1"
%typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1"
%typemap(m3wrapargdir) int &left, int &top "out"
%typemap(m3wrapouttype) int &width, int &height "CARDINAL"
%typemap(m3wrapargdir) int &width, int &height "out"
struct Point {
int x,y;
};
%m3multiretval get_box;
void set_label ( struct Window *win, const char *str, bool activate);
void set_multi_label ( struct Window *win, const char *str []);
void write_label (const struct Window *win, char *outstr, int size);
int get_label (const struct Window *win, char *outstr, int size);
char *get_label_ptr (const struct Window *win);
void move(struct Window *win, int x, int y);
int get_area(const struct Window *win);
void get_box(const struct Window *win, int &left, int &top, int &width, int &height);
void get_left(const struct Window *win, int &left);
void get_mouse(const struct Window *win, int &x, int &y);
int get_attached_data(const struct Window *win, const char *id);

View file

@ -1,10 +1,8 @@
/* File : example.i */
%module(directors="1") example
#ifndef SWIGSEXP
%{
#include "example.h"
%}
#endif
%feature("director");
%include "example.h"

View file

@ -8,8 +8,8 @@ extend
funcptr
funcptr2
functor
operator
module_load
operator
pointer
reference
simple

View file

@ -8,25 +8,25 @@ TARGET = swigexample
INTERFACE = example.i
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_run
build:
ifneq (,$(SRCS))
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
else
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
endif
ifneq (,$(TARGET2)$(SWIGOPT2))
ifneq (,$(SRCS))
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
else
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
endif
@ -34,4 +34,4 @@ endif
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_clean

View file

@ -2,8 +2,6 @@
# This file illustrates the cross language polymorphism using directors.
require("example.php");
# Class, which overwrites Callback::run().
class PhpCallback extends Callback {
@ -43,5 +41,3 @@ $caller->delCallback();
# All done.
print "php exit\n";
?>

View file

@ -2,8 +2,6 @@
# This example illustrates how member variables are wrapped.
require("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
@ -56,5 +54,3 @@ $o = NULL;
print Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
?>

View file

@ -1,7 +1,5 @@
<?php
require "example.php";
print "ICONST = " . ICONST . " (should be 42)\n";
print "FCONST = " . FCONST . " (should be 2.1828)\n";
print "CCONST = " . CCONST . " (should be 'x')\n";
@ -19,6 +17,3 @@ if (array_key_exists("EXTERN", $c)) {
if (array_key_exists("FOO", $c)) {
print "FOO = " . $c["FOO"] . " (Arg! This shouldn't print anything)\n";
}
?>

View file

@ -1,7 +1,5 @@
<?php
require "example.php";
# First create some objects using the pointer library.
print "Testing the pointer library\n";
@ -43,5 +41,3 @@
# $q = $a[0]
# $r = $a[1]
# print " 42/37 = $q remainder $r\n";
?>

View file

@ -4,8 +4,6 @@
# created by SWIG. In this case, all of our C++ classes
# get converted into function calls.
require("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
@ -45,5 +43,3 @@ $container = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
?>

View file

@ -1,7 +1,5 @@
<?php
require "example.php";
# ----- Object creation -----
# Print out the value of some enums
@ -28,5 +26,3 @@ $f = new Foo();
$f->enum_test(Foo::IMPULSE);
$f->enum_test(Foo::WARP);
$f->enum_test(Foo::LUDICROUS);
?>

View file

@ -2,8 +2,6 @@
# This file illustrates the cross language polymorphism using directors.
require("example.php");
# CEO class, which overrides Employee::getPosition().
class CEO extends Manager {
@ -72,5 +70,3 @@ print "----------------------\n";
# All done.
print "php exit\n";
?>

Some files were not shown because too many files have changed in this diff Show more