Another merge with master.
Updated Doxygen error numbers yet again, as Python errors got added in the meanwhile, pushing the Doxygen ones further off. And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again (if anybody is looking for a motivating example about why significant whitespace is bad, here is a great use case).
This commit is contained in:
commit
302955a152
448 changed files with 8836 additions and 5079 deletions
|
|
@ -321,6 +321,9 @@ else
|
|||
SWIGPYTHON = $(SWIG) -python -py3
|
||||
endif
|
||||
|
||||
PEP8 = @PEP8@
|
||||
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a C dynamically loadable module
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -373,8 +376,10 @@ endif
|
|||
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||
|
||||
python_run: $(PYSCRIPT)
|
||||
export PYTHONPATH=".:$$PYTHONPATH"; \
|
||||
$(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||
ifneq (,$(PEP8))
|
||||
$(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
|
||||
endif
|
||||
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||
|
||||
ifneq (,$(SRCDIR))
|
||||
$(RUNME).py: $(SRCDIR)$(RUNME).py
|
||||
|
|
@ -883,7 +888,7 @@ OCAMLFIND=@OCAMLFIND@
|
|||
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
|
||||
NOLINK ?= false
|
||||
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
|
||||
OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where`
|
||||
OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where`
|
||||
OCAMLCORE=\
|
||||
rm -rf swig.mli swig.ml swigp4.ml && \
|
||||
$(SWIG) -ocaml -co swig.mli 2>/dev/null && \
|
||||
|
|
@ -1345,6 +1350,8 @@ CSHARPCOMPILER = @CSHARPCOMPILER@
|
|||
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
||||
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPCFLAGS = @CSHARPCFLAGS@
|
||||
CSHARPFLAGS =
|
||||
CSHARPOPTIONS =
|
||||
CSHARPSO = @CSHARPSO@
|
||||
CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe
|
||||
|
||||
|
|
@ -1377,7 +1384,7 @@ SRCDIR_CSHARPSRCS =
|
|||
endif
|
||||
|
||||
csharp_compile: $(SRCDIR_SRCS)
|
||||
$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS)
|
||||
$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPOPTIONS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run CSharp example
|
||||
|
|
@ -1710,7 +1717,7 @@ SCILAB_LIBPREFIX = lib
|
|||
|
||||
scilab:
|
||||
$(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
|
||||
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -1719,7 +1726,7 @@ scilab:
|
|||
|
||||
scilab_cpp:
|
||||
$(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
||||
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) $(CPP_DLLIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -1727,7 +1734,7 @@ scilab_cpp:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_run:
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
|
||||
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Scilab version
|
||||
|
|
@ -1750,28 +1757,37 @@ scilab_clean:
|
|||
##### Go ######
|
||||
##################################################################
|
||||
|
||||
# TODO: The Go make targets need simplifying to use configure time
|
||||
# configuration or to use Make's ifeq rather than using lots of
|
||||
# runtime shell code. The output will then be a lot less verbose.
|
||||
|
||||
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 $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) ; then echo -pack ; 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 = $(GOC:c=l)
|
||||
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 = $(INTERFACE:.i=.a)
|
||||
GOPACKAGE = $(notdir $(INTERFACE:.i=.a))
|
||||
|
||||
GOOBJEXT = $(GOC:c=)
|
||||
GOPATHDIR = gopath/src/$(INTERFACE:.i=)
|
||||
|
||||
GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
|
||||
GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
|
||||
GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
||||
|
||||
|
|
@ -1779,19 +1795,21 @@ GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
|||
# Build a Go module (C)
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
go: $(SRCDIR_SRCS)
|
||||
go_nocgo: $(SRCDIR_SRCS)
|
||||
$(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
if $(GO12) || $(GO13) || $(GOGCC); then \
|
||||
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
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
||||
if ! $(GOGCC) ; then \
|
||||
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); then \
|
||||
if $(GO13) || $(GO15); then \
|
||||
cp $(GOGCOBJS) $(GOPACKAGE); \
|
||||
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
||||
elif $(GO12); then \
|
||||
|
|
@ -1801,12 +1819,54 @@ go: $(SRCDIR_SRCS)
|
|||
fi; \
|
||||
fi
|
||||
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
|
||||
elif $(GO12) || $(GO13); 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)
|
||||
$(SWIG) -go -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
@mkdir gopath 2>/dev/null || true
|
||||
@mkdir gopath/src 2>/dev/null || true
|
||||
@mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
|
||||
rm -f $(GOPATHDIR)/*
|
||||
cp $(ISRCS) $(GOPATHDIR)/
|
||||
if test -f $(IWRAP:.i=.h); then \
|
||||
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
|
||||
fi
|
||||
if test -n "$(SRCDIR_SRCS)"; then \
|
||||
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
|
||||
fi
|
||||
cp $(GOSRCS) $(GOPATHDIR)/
|
||||
GOPATH=`pwd`/gopath; \
|
||||
export GOPATH; \
|
||||
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
|
||||
export CGO_CPPFLAGS; \
|
||||
CGO_CFLAGS="$(CFLAGS)"; \
|
||||
export CGO_CFLAGS; \
|
||||
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
|
||||
export CGO_LDFLAGS; \
|
||||
(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
|
||||
cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
|
||||
if $(GOGCC); then \
|
||||
cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
|
||||
fi
|
||||
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GCCGO) -c -g $(SRCDIR)$(RUNME).go; \
|
||||
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE); \
|
||||
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -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; \
|
||||
fi
|
||||
|
|
@ -1815,19 +1875,29 @@ go: $(SRCDIR_SRCS)
|
|||
# Build a Go module (C++)
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
go_cpp: $(SRCDIR_SRCS)
|
||||
go_cpp_nocgo: $(SRCDIR_SRCS)
|
||||
$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
if $(GO12) || $(GO13) || $(GOGCC); then \
|
||||
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
|
||||
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
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
||||
if ! $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
|
||||
$(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); then \
|
||||
if $(GO13) || $(GO15); then \
|
||||
cp $(GOGCOBJS) $(GOPACKAGE); \
|
||||
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
||||
elif $(GO12); then \
|
||||
|
|
@ -1835,14 +1905,65 @@ go_cpp: $(SRCDIR_SRCS)
|
|||
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 \
|
||||
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
|
||||
elif $(GO12) || $(GO13); 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)
|
||||
$(SWIG) -go -c++ -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
@mkdir gopath 2>/dev/null || true
|
||||
@mkdir gopath/src 2>/dev/null || true
|
||||
@mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
|
||||
rm -f $(GOPATHDIR)/*
|
||||
cp $(ICXXSRCS) $(GOPATHDIR)/
|
||||
if test -f $(IWRAP:.i=.h); then \
|
||||
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
|
||||
fi
|
||||
if test -n "$(SRCDIR_CXXSRCS)"; then \
|
||||
cp $(SRCDIR_CXXSRCS) $(GOPATHDIR)/; \
|
||||
fi
|
||||
if test -n "$(SRCDIR_SRCS)"; then \
|
||||
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
|
||||
fi
|
||||
cp $(GOSRCS) $(GOPATHDIR)/
|
||||
GOPATH=`pwd`/gopath; \
|
||||
export GOPATH; \
|
||||
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
|
||||
export CGO_CPPFLAGS; \
|
||||
CGO_CFLAGS="$(CFLAGS)"; \
|
||||
export CGO_CFLAGS; \
|
||||
CGO_CXXFLAGS="$(CXXFLAGS)"; \
|
||||
export CGO_CXXFLAGS; \
|
||||
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
|
||||
export CGO_LDFLAGS; \
|
||||
(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
|
||||
cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
|
||||
if $(GOGCC); then \
|
||||
cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
|
||||
fi
|
||||
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
|
||||
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE) -lstdc++; \
|
||||
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -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; \
|
||||
fi
|
||||
|
|
@ -1852,7 +1973,7 @@ go_cpp: $(SRCDIR_SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
go_run:
|
||||
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
|
||||
env $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
|
|
@ -1866,7 +1987,8 @@ go_version:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
go_clean:
|
||||
rm -f *_wrap* *_gc* .~* $(RUNME) $(GOSRCS)
|
||||
rm -f *_wrap* *_gc* *.gox .~* $(RUNME) $(GOSRCS)
|
||||
rm -rf gopath
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,16 +74,21 @@ extern int count(char *bytes, int len, char c);
|
|||
%}
|
||||
|
||||
/* Return the mutated string as a modified element in the array. */
|
||||
%typemap(argout) (char *str, int len)
|
||||
%typemap(argout,fragment="AllocateString") (char *str, int len)
|
||||
%{
|
||||
{
|
||||
_gostring_ *a;
|
||||
|
||||
a = (_gostring_*) $input.array;
|
||||
a[0] = _swig_makegostring($1, $2);
|
||||
a[0] = Swig_AllocateString($1, $2);
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(goargout,fragment="CopyString") (char *str, int len)
|
||||
%{
|
||||
$input[0] = swigCopyString($input[0])
|
||||
%}
|
||||
|
||||
%typemap(freearg) (char *str, int len)
|
||||
%{
|
||||
free($1);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = matrix.c vector.c
|
||||
TARGET = matrix
|
||||
TARGET = my-guile
|
||||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ type the following :
|
|||
|
||||
Alternatively, use the command-line:
|
||||
|
||||
./matrix -e do-test -s runme.scm
|
||||
./my-guile -e do-test -s runme.scm
|
||||
|
||||
Or, if your operating system is spiffy enough:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = port
|
||||
TARGET = my-guile
|
||||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
This example illustrates the translation from Scheme file ports to
|
||||
temporary FILE streams. Read the source and run ./port -s runme.scm
|
||||
temporary FILE streams. Read the source and run ./my-guile -s runme.scm
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,5 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
|
|||
|
||||
%apply int *OUTPUT { int *r };
|
||||
extern int divide(int n, int d, int *r);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
|
||||
class PyCallback(example.Callback):
|
||||
def __init__(self):
|
||||
example.Callback.__init__(self)
|
||||
def run(self):
|
||||
print "PyCallback.run()"
|
||||
|
||||
def __init__(self):
|
||||
example.Callback.__init__(self)
|
||||
|
||||
def run(self):
|
||||
print "PyCallback.run()"
|
||||
|
||||
# Create an Caller instance
|
||||
|
||||
|
|
@ -25,7 +27,7 @@ callback = example.Callback()
|
|||
callback.thisown = 0
|
||||
caller.setCallback(callback)
|
||||
caller.call()
|
||||
caller.delCallback();
|
||||
caller.delCallback()
|
||||
|
||||
print
|
||||
print "Adding and calling a Python callback"
|
||||
|
|
@ -53,4 +55,3 @@ caller.delCallback()
|
|||
|
||||
print
|
||||
print "python exit"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# This file illustrates the proxy class C++ interface generated
|
||||
# by SWIG.
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ print " Created square", s
|
|||
|
||||
# ----- Access a static member -----
|
||||
|
||||
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
|
||||
print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
|
||||
|
||||
# ----- Member data access -----
|
||||
|
||||
|
|
@ -28,16 +28,16 @@ s.x = -10
|
|||
s.y = 5
|
||||
|
||||
print "\nHere is their current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
print " Square = (%f, %f)" % (s.x,s.y)
|
||||
print " Circle = (%f, %f)" % (c.x, c.y)
|
||||
print " Square = (%f, %f)" % (s.x, s.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\nHere are some properties of the shapes:"
|
||||
for o in [c,s]:
|
||||
print " ", o
|
||||
print " area = ", o.area()
|
||||
print " perimeter = ", o.perimeter()
|
||||
for o in [c, s]:
|
||||
print " ", o
|
||||
print " area = ", o.area()
|
||||
print " perimeter = ", o.perimeter()
|
||||
# prevent o from holding a reference to the last object looked at
|
||||
o = None
|
||||
|
||||
|
|
@ -47,5 +47,5 @@ print "\nGuess I'll clean up now"
|
|||
del c
|
||||
del s
|
||||
|
||||
print example.cvar.Shape_nshapes,"shapes remain"
|
||||
print example.cvar.Shape_nshapes, "shapes remain"
|
||||
print "Goodbye"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
print "ICONST =", example.ICONST, "(should be 42)"
|
||||
print "FCONST =", example.FCONST, "(should be 2.1828)"
|
||||
|
|
@ -8,7 +8,7 @@ print "CCONST =", example.CCONST, "(should be 'x')"
|
|||
print "CCONST2 =", example.CCONST2, "(this should be on a new line)"
|
||||
print "SCONST =", example.SCONST, "(should be 'Hello World')"
|
||||
print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')"
|
||||
print "EXPR =", example.EXPR, "(should be 48.5484)"
|
||||
print "EXPR =", example.EXPR, "(should be 48.5484)"
|
||||
print "iconst =", example.iconst, "(should be 37)"
|
||||
print "fconst =", example.fconst, "(should be 3.14)"
|
||||
|
||||
|
|
@ -21,7 +21,3 @@ try:
|
|||
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
|
||||
except AttributeError:
|
||||
print "FOO isn't defined (good)"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
x = 42
|
||||
y = 105
|
||||
g = example.gcd(x,y)
|
||||
print "The gcd of %d and %d is %d" % (x,y,g)
|
||||
g = example.gcd(x, y)
|
||||
print "The gcd of %d and %d is %d" % (x, y, g)
|
||||
|
||||
# Manipulate the Foo global variable
|
||||
|
||||
|
|
@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
|
|||
|
||||
# See if the change took effect
|
||||
print "Foo = ", example.cvar.Foo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ print " Foo_LUDICROUS =", example.Foo.LUDICROUS
|
|||
print "\nTesting use of enums with functions\n"
|
||||
|
||||
example.enum_test(example.RED, example.Foo.IMPULSE)
|
||||
example.enum_test(example.BLUE, example.Foo.WARP)
|
||||
example.enum_test(example.BLUE, example.Foo.WARP)
|
||||
example.enum_test(example.GREEN, example.Foo.LUDICROUS)
|
||||
example.enum_test(1234,5678)
|
||||
example.enum_test(1234, 5678)
|
||||
|
||||
print "\nTesting use of enum with class method"
|
||||
f = example.Foo()
|
||||
|
|
@ -28,4 +28,3 @@ f = example.Foo()
|
|||
f.enum_test(example.Foo.IMPULSE)
|
||||
f.enum_test(example.Foo.WARP)
|
||||
f.enum_test(example.Foo.LUDICROUS)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,38 +6,37 @@ import example
|
|||
|
||||
t = example.Test()
|
||||
try:
|
||||
t.unknown()
|
||||
except RuntimeError,e:
|
||||
print "incomplete type", e.args[0]
|
||||
t.unknown()
|
||||
except RuntimeError, e:
|
||||
print "incomplete type", e.args[0]
|
||||
|
||||
try:
|
||||
t.simple()
|
||||
except RuntimeError,e:
|
||||
print e.args[0]
|
||||
t.simple()
|
||||
except RuntimeError, e:
|
||||
print e.args[0]
|
||||
|
||||
try:
|
||||
t.message()
|
||||
except RuntimeError,e:
|
||||
print e.args[0]
|
||||
t.message()
|
||||
except RuntimeError, e:
|
||||
print e.args[0]
|
||||
|
||||
if not example.is_python_builtin():
|
||||
try:
|
||||
try:
|
||||
t.hosed()
|
||||
except example.Exc,e:
|
||||
except example.Exc, e:
|
||||
print e.code, e.msg
|
||||
else:
|
||||
try:
|
||||
try:
|
||||
t.hosed()
|
||||
except BaseException,e:
|
||||
# Throwing builtin classes as exceptions not supported (-builtin option)
|
||||
except BaseException, e:
|
||||
# Throwing builtin classes as exceptions not supported (-builtin
|
||||
# option)
|
||||
print e
|
||||
|
||||
for i in range(1,4):
|
||||
try:
|
||||
t.multi(i)
|
||||
except RuntimeError,e:
|
||||
print e.args[0]
|
||||
except example.Exc,e:
|
||||
print e.code, e.msg
|
||||
|
||||
|
||||
for i in range(1, 4):
|
||||
try:
|
||||
t.multi(i)
|
||||
except RuntimeError, e:
|
||||
print e.args[0]
|
||||
except example.Exc, e:
|
||||
print e.code, e.msg
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
import example
|
||||
|
||||
if example.is_python_builtin():
|
||||
print "Skipping example: -builtin option does not support %exceptionclass"
|
||||
exit(0)
|
||||
print "Skipping example: -builtin option does not support %exceptionclass"
|
||||
exit(0)
|
||||
|
||||
q = example.intQueue(10)
|
||||
|
||||
|
|
@ -12,18 +12,18 @@ print "Inserting items into intQueue"
|
|||
print type(example.FullError)
|
||||
|
||||
try:
|
||||
for i in range(0,100):
|
||||
q.enqueue(i)
|
||||
except example.FullError,e:
|
||||
print "Maxsize is", e.maxsize
|
||||
for i in range(0, 100):
|
||||
q.enqueue(i)
|
||||
except example.FullError, e:
|
||||
print "Maxsize is", e.maxsize
|
||||
|
||||
print "Removing items"
|
||||
|
||||
try:
|
||||
while 1:
|
||||
q.dequeue()
|
||||
except example.EmptyError,e:
|
||||
pass
|
||||
while 1:
|
||||
q.dequeue()
|
||||
except example.EmptyError, e:
|
||||
pass
|
||||
|
||||
|
||||
q = example.doubleQueue(1000)
|
||||
|
|
@ -31,21 +31,15 @@ q = example.doubleQueue(1000)
|
|||
print "Inserting items into doubleQueue"
|
||||
|
||||
try:
|
||||
for i in range(0,10000):
|
||||
q.enqueue(i*1.5)
|
||||
except example.FullError,e:
|
||||
print "Maxsize is", e.maxsize
|
||||
for i in range(0, 10000):
|
||||
q.enqueue(i * 1.5)
|
||||
except example.FullError, e:
|
||||
print "Maxsize is", e.maxsize
|
||||
|
||||
print "Removing items"
|
||||
|
||||
try:
|
||||
while 1:
|
||||
q.dequeue()
|
||||
except example.EmptyError,e:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while 1:
|
||||
q.dequeue()
|
||||
except example.EmptyError, e:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,16 +2,18 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
|
||||
# CEO class, which overrides Employee::getPosition().
|
||||
|
||||
class CEO(example.Manager):
|
||||
def __init__(self, name):
|
||||
example.Manager.__init__(self, name)
|
||||
def getPosition(self):
|
||||
return "CEO"
|
||||
|
||||
def __init__(self, name):
|
||||
example.Manager.__init__(self, name)
|
||||
|
||||
def getPosition(self):
|
||||
return "CEO"
|
||||
|
||||
|
||||
# Create an instance of our employee extension class, CEO. The calls to
|
||||
|
|
@ -78,4 +80,3 @@ print "----------------------"
|
|||
# All done.
|
||||
|
||||
print "python exit"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
a = 37
|
||||
b = 42
|
||||
|
|
@ -10,9 +10,9 @@ b = 42
|
|||
print "Trying some C callback functions"
|
||||
print " a =", a
|
||||
print " b =", b
|
||||
print " ADD(a,b) =", example.do_op(a,b,example.ADD)
|
||||
print " SUB(a,b) =", example.do_op(a,b,example.SUB)
|
||||
print " MUL(a,b) =", example.do_op(a,b,example.MUL)
|
||||
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
|
||||
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
|
||||
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
|
||||
|
||||
print "Here is what the C callback function objects look like in Python"
|
||||
print " ADD =", example.ADD
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
a = 37
|
||||
b = 42
|
||||
|
|
@ -10,9 +10,9 @@ b = 42
|
|||
print "Trying some C callback functions"
|
||||
print " a =", a
|
||||
print " b =", b
|
||||
print " ADD(a,b) =", example.do_op(a,b,example.ADD)
|
||||
print " SUB(a,b) =", example.do_op(a,b,example.SUB)
|
||||
print " MUL(a,b) =", example.do_op(a,b,example.MUL)
|
||||
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
|
||||
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
|
||||
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
|
||||
|
||||
print "Here is what the C callback function objects look like in Python"
|
||||
print " ADD =", example.ADD
|
||||
|
|
@ -20,5 +20,5 @@ print " SUB =", example.SUB
|
|||
print " MUL =", example.MUL
|
||||
|
||||
print "Call the functions directly..."
|
||||
print " add(a,b) =", example.add(a,b)
|
||||
print " sub(a,b) =", example.sub(a,b)
|
||||
print " add(a,b) =", example.add(a, b)
|
||||
print " sub(a,b) =", example.sub(a, b)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@ b = example.doubleSum(100.0)
|
|||
# Use the objects. They should be callable just like a normal
|
||||
# python function.
|
||||
|
||||
for i in range(0,100):
|
||||
for i in range(0, 100):
|
||||
a(i) # Note: function call
|
||||
b(math.sqrt(i)) # Note: function call
|
||||
|
||||
print a.result()
|
||||
print b.result()
|
||||
|
||||
|
|
|
|||
|
|
@ -81,31 +81,27 @@ x = d.toBase()
|
|||
print " Spam -> Base -> Foo : ",
|
||||
y = foo.Foo_fromBase(x)
|
||||
if y:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
else:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
|
||||
print " Spam -> Base -> Bar : ",
|
||||
y = bar.Bar_fromBase(x)
|
||||
if y:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
else:
|
||||
print "bad swig"
|
||||
|
||||
print "bad swig"
|
||||
|
||||
print " Spam -> Base -> Spam : ",
|
||||
y = spam.Spam_fromBase(x)
|
||||
if y:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
else:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
|
||||
print " Foo -> Spam : ",
|
||||
y = spam.Spam_fromBase(b)
|
||||
if y:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
else:
|
||||
print "good swig"
|
||||
|
||||
|
||||
|
||||
|
||||
print "good swig"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
import_packages_subdirs = \
|
||||
same_modnames1 \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
else:
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
else:
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
else:
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
import py3.pkg2
|
||||
print " Finished importing py3.pkg2"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
else:
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
else:
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
|||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import os.path
|
|||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
else:
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ print " Finished importing pkg2.foo"
|
|||
|
||||
var2 = pkg2.foo.Pkg2_Foo()
|
||||
if str(type(var2)).find("'pkg2.foo.Pkg2_Foo'") == -1:
|
||||
raise RuntimeError("failed type checking: " + str(type(var2)))
|
||||
raise RuntimeError("failed type checking: " + str(type(var2)))
|
||||
print " Successfully created object pkg2.foo.Pkg2_Foo"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ print "Testing " + testname + " - %module(package=...) + python 'import' in __in
|
|||
import pkg1.pkg2.foo
|
||||
print " Finished importing pkg1.pkg2.foo"
|
||||
|
||||
var2 = pkg1.pkg2.foo.Pkg2_Foo();
|
||||
var2 = pkg1.pkg2.foo.Pkg2_Foo()
|
||||
if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1:
|
||||
raise RuntimeError("failed type checking: " + str(type(var2)))
|
||||
raise RuntimeError("failed type checking: " + str(type(var2)))
|
||||
print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo"
|
||||
|
|
|
|||
|
|
@ -81,31 +81,27 @@ x = d.toBase()
|
|||
print " Spam -> Base -> Foo : ",
|
||||
y = foo.intFoo_fromBase(x)
|
||||
if y:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
else:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
|
||||
print " Spam -> Base -> Bar : ",
|
||||
y = bar.intBar_fromBase(x)
|
||||
if y:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
else:
|
||||
print "bad swig"
|
||||
|
||||
print "bad swig"
|
||||
|
||||
print " Spam -> Base -> Spam : ",
|
||||
y = spam.intSpam_fromBase(x)
|
||||
if y:
|
||||
print "good swig"
|
||||
print "good swig"
|
||||
else:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
|
||||
print " Foo -> Spam : ",
|
||||
y = spam.intSpam_fromBase(b)
|
||||
if y:
|
||||
print "bad swig"
|
||||
print "bad swig"
|
||||
else:
|
||||
print "good swig"
|
||||
|
||||
|
||||
|
||||
|
||||
print "good swig"
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ JvAttachCurrentThread(None, None)
|
|||
e1 = Example(1)
|
||||
e2 = Example(2)
|
||||
|
||||
print e1.Add(1,2)
|
||||
print e1.Add(1.0,2.0)
|
||||
e3 = e1.Add(e1,e2)
|
||||
print e1.Add(1, 2)
|
||||
print e1.Add(1.0, 2.0)
|
||||
e3 = e1.Add(e1, e2)
|
||||
print e3.mPublicInt
|
||||
|
||||
print e1.Add("1","2")
|
||||
print e1.Add("1", "2")
|
||||
|
||||
JvDetachCurrentThread()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ extern int gcd(int x, int y);
|
|||
if (!PyList_Check($input)) {
|
||||
SWIG_exception(SWIG_ValueError, "Expecting a list");
|
||||
}
|
||||
$1 = PyList_Size($input);
|
||||
$1 = (int)PyList_Size($input);
|
||||
if ($1 == 0) {
|
||||
SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ extern int gcdmain(int argc, char *argv[]);
|
|||
}
|
||||
utf8str = PyUnicode_AsUTF8String($input);
|
||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||
$1 = strndup(cstr, (size_t)len);
|
||||
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||
$2 = (int)len;
|
||||
Py_DECREF(utf8str);
|
||||
%#else
|
||||
|
|
@ -82,7 +82,7 @@ extern int gcdmain(int argc, char *argv[]);
|
|||
return NULL;
|
||||
}
|
||||
$1 = PyString_AsString($input);
|
||||
$2 = PyString_Size($input);
|
||||
$2 = (int)PyString_Size($input);
|
||||
%#endif
|
||||
}
|
||||
|
||||
|
|
@ -106,11 +106,11 @@ extern int count(char *bytes, int len, char c);
|
|||
Py_ssize_t len;
|
||||
PyObject *utf8str = PyUnicode_AsUTF8String($input);
|
||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||
$1 = strndup(cstr, (size_t)len);
|
||||
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||
$2 = (int)len;
|
||||
Py_DECREF(utf8str);
|
||||
%#else
|
||||
$2 = PyString_Size($input);
|
||||
$2 = (int)PyString_Size($input);
|
||||
$1 = (char *) malloc($2+1);
|
||||
memmove($1,PyString_AsString($input),$2);
|
||||
%#endif
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
x = 42
|
||||
y = 105
|
||||
g = example.gcd(x,y)
|
||||
print "The gcd of %d and %d is %d" % (x,y,g)
|
||||
g = example.gcd(x, y)
|
||||
print "The gcd of %d and %d is %d" % (x, y, g)
|
||||
|
||||
# Call the gcdmain() function
|
||||
example.gcdmain(["gcdmain","42","105"])
|
||||
example.gcdmain(["gcdmain", "42", "105"])
|
||||
|
||||
# Call the count function
|
||||
print example.count("Hello World", "l")
|
||||
|
|
@ -18,10 +18,3 @@ print example.count("Hello World", "l")
|
|||
# Call the capitalize function
|
||||
|
||||
print example.capitalize("hello world")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
# Operator overloading example
|
||||
import example
|
||||
|
||||
a = example.Complex(2,3)
|
||||
b = example.Complex(-5,10)
|
||||
a = example.Complex(2, 3)
|
||||
b = example.Complex(-5, 10)
|
||||
|
||||
print "a =",a
|
||||
print "b =",b
|
||||
print "a =", a
|
||||
print "b =", b
|
||||
|
||||
c = a + b
|
||||
print "c =",c
|
||||
print "a*b =",a*b
|
||||
print "a-c =",a-c
|
||||
print "c =", c
|
||||
print "a*b =", a * b
|
||||
print "a-c =", a - c
|
||||
|
||||
e = example.ComplexCopy(a-c)
|
||||
print "e =",e
|
||||
e = example.ComplexCopy(a - c)
|
||||
print "e =", e
|
||||
|
||||
# Big expression
|
||||
f = ((a+b)*(c+b*e)) + (-a)
|
||||
print "f =",f
|
||||
|
||||
f = ((a + b) * (c + b * e)) + (-a)
|
||||
print "f =", f
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ import sys
|
|||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
for i in range(1000000) :
|
||||
|
||||
def proc(mod):
|
||||
for i in range(1000000):
|
||||
x = mod.MyClass()
|
||||
|
||||
harness.run(proc)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ import sys
|
|||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
|
||||
def proc(mod):
|
||||
x = mod.MyClass()
|
||||
for i in range(10000000) :
|
||||
for i in range(10000000):
|
||||
x.func()
|
||||
|
||||
harness.run(proc)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ import time
|
|||
import imp
|
||||
from subprocess import *
|
||||
|
||||
def run (proc) :
|
||||
|
||||
try :
|
||||
def run(proc):
|
||||
|
||||
try:
|
||||
mod = imp.find_module(sys.argv[1])
|
||||
mod = imp.load_module(sys.argv[1], *mod)
|
||||
|
||||
|
|
@ -14,15 +15,18 @@ def run (proc) :
|
|||
t2 = time.clock()
|
||||
print "%s took %f seconds" % (mod.__name__, t2 - t1)
|
||||
|
||||
except IndexError :
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
||||
except IndexError:
|
||||
proc = Popen(
|
||||
[sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
||||
proc = Popen(
|
||||
[sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
||||
proc = Popen(
|
||||
[sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ import sys
|
|||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
|
||||
def proc(mod):
|
||||
x = mod.H()
|
||||
for i in range(10000000) :
|
||||
for i in range(10000000):
|
||||
x.func()
|
||||
|
||||
harness.run(proc)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ import sys
|
|||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
|
||||
def proc(mod):
|
||||
x = mod.H()
|
||||
for i in range(10000000) :
|
||||
for i in range(10000000):
|
||||
x += i
|
||||
|
||||
harness.run(proc)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ import sys
|
|||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
|
||||
def proc(mod):
|
||||
x = mod.MyClass()
|
||||
for i in range(10000000) :
|
||||
for i in range(10000000):
|
||||
x = x + i
|
||||
|
||||
harness.run(proc)
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
# file: runme.py
|
||||
|
||||
import example;
|
||||
import example
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
print "Testing the pointer library";
|
||||
a = example.new_intp();
|
||||
b = example.new_intp();
|
||||
c = example.new_intp();
|
||||
example.intp_assign(a,37);
|
||||
example.intp_assign(b,42);
|
||||
print "Testing the pointer library"
|
||||
a = example.new_intp()
|
||||
b = example.new_intp()
|
||||
c = example.new_intp()
|
||||
example.intp_assign(a, 37)
|
||||
example.intp_assign(b, 42)
|
||||
|
||||
print " a =",a
|
||||
print " b =",b
|
||||
print " c =",c
|
||||
print " a =", a
|
||||
print " b =", b
|
||||
print " c =", c
|
||||
|
||||
# Call the add() function with some pointers
|
||||
example.add(a,b,c)
|
||||
example.add(a, b, c)
|
||||
|
||||
# Now get the result
|
||||
r = example.intp_value(c)
|
||||
print " 37 + 42 =",r
|
||||
print " 37 + 42 =", r
|
||||
|
||||
# Clean up the pointers
|
||||
example.delete_intp(a)
|
||||
|
|
@ -30,15 +30,12 @@ example.delete_intp(c)
|
|||
# This should be much easier. Now how it is no longer
|
||||
# necessary to manufacture pointers.
|
||||
|
||||
print "Trying the typemap library";
|
||||
r = example.sub(37,42)
|
||||
print " 37 - 42 =",r
|
||||
print "Trying the typemap library"
|
||||
r = example.sub(37, 42)
|
||||
print " 37 - 42 =", r
|
||||
|
||||
# Now try the version with multiple return values
|
||||
|
||||
print "Testing multiple return values";
|
||||
q,r = example.divide(42,37)
|
||||
print " 42/37 = %d remainder %d" % (q,r)
|
||||
|
||||
|
||||
|
||||
print "Testing multiple return values"
|
||||
q, r = example.divide(42, 37)
|
||||
print " 42/37 = %d remainder %d" % (q, r)
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@ import example
|
|||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:"
|
||||
a = example.Vector(3,4,5)
|
||||
b = example.Vector(10,11,12)
|
||||
a = example.Vector(3, 4, 5)
|
||||
b = example.Vector(10, 11, 12)
|
||||
|
||||
print " Created",a.cprint()
|
||||
print " Created",b.cprint()
|
||||
print " Created", a.cprint()
|
||||
print " Created", b.cprint()
|
||||
|
||||
# ----- Call an overloaded operator -----
|
||||
|
||||
# This calls the wrapper we placed around
|
||||
#
|
||||
# operator+(const Vector &a, const Vector &)
|
||||
# operator+(const Vector &a, const Vector &)
|
||||
#
|
||||
# It returns a new allocated object.
|
||||
|
||||
print "Adding a+b"
|
||||
c = example.addv(a,b)
|
||||
c = example.addv(a, b)
|
||||
print " a+b =", c.cprint()
|
||||
|
||||
# Note: Unless we free the result, a memory leak will occur
|
||||
|
|
@ -33,25 +33,25 @@ del c
|
|||
# Note: Using the high-level interface here
|
||||
print "Creating an array of vectors"
|
||||
va = example.VectorArray(10)
|
||||
print " va = ",va
|
||||
print " va = ", va
|
||||
|
||||
# ----- Set some values in the array -----
|
||||
|
||||
# These operators copy the value of $a and $b to the vector array
|
||||
va.set(0,a)
|
||||
va.set(1,b)
|
||||
va.set(0, a)
|
||||
va.set(1, b)
|
||||
|
||||
va.set(2,example.addv(a,b))
|
||||
va.set(2, example.addv(a, b))
|
||||
|
||||
# Get some values from the array
|
||||
|
||||
print "Getting some array values"
|
||||
for i in range(0,5):
|
||||
for i in range(0, 5):
|
||||
print " va(%d) = %s" % (i, va.get(i).cprint())
|
||||
|
||||
# Watch under resource meter to check on this
|
||||
print "Making sure we don't leak memory."
|
||||
for i in xrange(0,1000000):
|
||||
for i in xrange(0, 1000000):
|
||||
c = va.get(i % 10)
|
||||
|
||||
# ----- Clean up -----
|
||||
|
|
@ -60,4 +60,3 @@ print "Cleaning up"
|
|||
del va
|
||||
del a
|
||||
del b
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# file: runme.py
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
x = 42
|
||||
y = 105
|
||||
g = example.gcd(x,y)
|
||||
print "The gcd of %d and %d is %d" % (x,y,g)
|
||||
g = example.gcd(x, y)
|
||||
print "The gcd of %d and %d is %d" % (x, y, g)
|
||||
|
||||
# Manipulate the Foo global variable
|
||||
|
||||
|
|
@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
|
|||
|
||||
# See if the change took effect
|
||||
print "Foo = ", example.cvar.Foo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# This file illustrates the proxy class C++ interface generated
|
||||
# by SWIG.
|
||||
|
||||
import example
|
||||
import example
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ print " Created square", s
|
|||
|
||||
# ----- Access a static member -----
|
||||
|
||||
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
|
||||
print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
|
||||
|
||||
# ----- Member data access -----
|
||||
|
||||
|
|
@ -30,16 +30,16 @@ s.x = -10
|
|||
s.y = 5
|
||||
|
||||
print "\nHere is their current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
print " Square = (%f, %f)" % (s.x,s.y)
|
||||
print " Circle = (%f, %f)" % (c.x, c.y)
|
||||
print " Square = (%f, %f)" % (s.x, s.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\nHere are some properties of the shapes:"
|
||||
for o in [c,s]:
|
||||
print " ", o
|
||||
print " area = ", o.area()
|
||||
print " perimeter = ", o.perimeter()
|
||||
for o in [c, s]:
|
||||
print " ", o
|
||||
print " area = ", o.area()
|
||||
print " perimeter = ", o.perimeter()
|
||||
|
||||
print "\nGuess I'll clean up now"
|
||||
|
||||
|
|
@ -50,6 +50,5 @@ del cc
|
|||
del ss
|
||||
|
||||
s = 3
|
||||
print example.cvar.Shape_nshapes,"shapes remain"
|
||||
print example.cvar.Shape_nshapes, "shapes remain"
|
||||
print "Goodbye"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ pmap["hi"] = 1
|
|||
pmap["hello"] = 2
|
||||
|
||||
|
||||
|
||||
|
||||
dmap = {}
|
||||
dmap["hello"] = 1.0
|
||||
dmap["hi"] = 2.0
|
||||
|
|
@ -28,8 +26,8 @@ for i in dmap.iterkeys():
|
|||
for i in dmap.itervalues():
|
||||
print "val", i
|
||||
|
||||
for k,v in dmap.iteritems():
|
||||
print "item", k,v
|
||||
for k, v in dmap.iteritems():
|
||||
print "item", k, v
|
||||
|
||||
dmap = example.DoubleMap()
|
||||
dmap["hello"] = 1.0
|
||||
|
|
@ -41,8 +39,8 @@ for i in dmap.iterkeys():
|
|||
for i in dmap.itervalues():
|
||||
print "val", i
|
||||
|
||||
for k,v in dmap.iteritems():
|
||||
print "item", k,v
|
||||
for k, v in dmap.iteritems():
|
||||
print "item", k, v
|
||||
|
||||
|
||||
print dmap.items()
|
||||
|
|
@ -54,7 +52,6 @@ print hmap.keys()
|
|||
print hmap.values()
|
||||
|
||||
|
||||
|
||||
dmap = {}
|
||||
dmap["hello"] = 2
|
||||
dmap["hi"] = 4
|
||||
|
|
@ -76,7 +73,7 @@ for i in dmap.itervalues():
|
|||
for i in dmap.iteritems():
|
||||
print "item", i
|
||||
|
||||
for k,v in dmap.iteritems():
|
||||
print "item", k,v
|
||||
for k, v in dmap.iteritems():
|
||||
print "item", k, v
|
||||
|
||||
print dmap
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import example
|
|||
|
||||
# Call average with a Python list...
|
||||
|
||||
print example.average([1,2,3,4])
|
||||
print example.average([1, 2, 3, 4])
|
||||
|
||||
# ... or a wrapped std::vector<int>
|
||||
|
||||
v = example.IntVector(4)
|
||||
for i in range(len(v)):
|
||||
v[i] = i+1
|
||||
v[i] = i + 1
|
||||
print example.average(v)
|
||||
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ print example.half((1.0, 1.5, 2.0, 2.5, 3.0))
|
|||
# ... or a wrapped std::vector<double>
|
||||
|
||||
v = example.DoubleVector()
|
||||
for i in [1,2,3,4]:
|
||||
v.append(i)
|
||||
for i in [1, 2, 3, 4]:
|
||||
v.append(i)
|
||||
print example.half(v)
|
||||
|
||||
|
||||
|
|
@ -31,6 +31,5 @@ print example.half(v)
|
|||
|
||||
example.halve_in_place(v)
|
||||
for i in range(len(v)):
|
||||
print v[i], "; ",
|
||||
print v[i], "; ",
|
||||
print
|
||||
|
||||
|
|
|
|||
|
|
@ -3,32 +3,30 @@
|
|||
import example
|
||||
|
||||
# Call some templated functions
|
||||
print example.maxint(3,7)
|
||||
print example.maxdouble(3.14,2.18)
|
||||
print example.maxint(3, 7)
|
||||
print example.maxdouble(3.14, 2.18)
|
||||
|
||||
# Create some class
|
||||
|
||||
iv = example.vecint(100)
|
||||
dv = example.vecdouble(1000)
|
||||
|
||||
for i in range(0,100):
|
||||
iv.setitem(i,2*i)
|
||||
for i in range(0, 100):
|
||||
iv.setitem(i, 2 * i)
|
||||
|
||||
for i in range(0,1000):
|
||||
dv.setitem(i, 1.0/(i+1))
|
||||
for i in range(0, 1000):
|
||||
dv.setitem(i, 1.0 / (i + 1))
|
||||
|
||||
sum = 0
|
||||
for i in range(0,100):
|
||||
sum = sum + iv.getitem(i)
|
||||
for i in range(0, 100):
|
||||
sum = sum + iv.getitem(i)
|
||||
|
||||
print sum
|
||||
|
||||
sum = 0.0
|
||||
for i in range(0,1000):
|
||||
sum = sum + dv.getitem(i)
|
||||
for i in range(0, 1000):
|
||||
sum = sum + dv.getitem(i)
|
||||
print sum
|
||||
|
||||
del iv
|
||||
del dv
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# file: runme.py
|
||||
|
||||
import sys
|
||||
import example
|
||||
import example
|
||||
|
||||
# Call printf
|
||||
example.printf("Hello World. I'm printf\n")
|
||||
|
||||
# Note: We call printf, but use *python* string formatting
|
||||
for i in range(0,10):
|
||||
for i in range(0, 10):
|
||||
example.printf("i is %d\n" % i)
|
||||
|
||||
# This will probably be garbled because %d is interpreted by C
|
||||
|
|
@ -15,21 +15,13 @@ example.printf("The value is %d\n")
|
|||
|
||||
stdout = example.stdout_stream()
|
||||
# Call fprintf
|
||||
example.fprintf(stdout,"Hello World. I'm fprintf\n")
|
||||
for i in range(0,10):
|
||||
example.fprintf(stdout,"i is %d\n" % i)
|
||||
example.fprintf(stdout, "Hello World. I'm fprintf\n")
|
||||
for i in range(0, 10):
|
||||
example.fprintf(stdout, "i is %d\n" % i)
|
||||
|
||||
# This won't be garbled since %d is not interpreted
|
||||
example.fprintf(stdout,"The value is %d\n")
|
||||
example.fprintf(stdout, "The value is %d\n")
|
||||
|
||||
# This function calls our NULL-terminated function
|
||||
|
||||
example.printv("Hello","World","this","is","a","test.")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
example.printv("Hello", "World", "this", "is", "a", "test.")
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@ import example
|
|||
|
||||
# Try to set the values of some global variables
|
||||
|
||||
example.cvar.ivar = 42
|
||||
example.cvar.svar = -31000
|
||||
example.cvar.lvar = 65537
|
||||
example.cvar.uivar = 123456
|
||||
example.cvar.usvar = 61000
|
||||
example.cvar.ulvar = 654321
|
||||
example.cvar.scvar = -13
|
||||
example.cvar.ucvar = 251
|
||||
example.cvar.cvar = "S"
|
||||
example.cvar.fvar = 3.14159
|
||||
example.cvar.dvar = 2.1828
|
||||
example.cvar.strvar = "Hello World"
|
||||
example.cvar.iptrvar= example.new_int(37)
|
||||
example.cvar.ptptr = example.new_Point(37,42)
|
||||
example.cvar.name = "Bill"
|
||||
example.cvar.ivar = 42
|
||||
example.cvar.svar = -31000
|
||||
example.cvar.lvar = 65537
|
||||
example.cvar.uivar = 123456
|
||||
example.cvar.usvar = 61000
|
||||
example.cvar.ulvar = 654321
|
||||
example.cvar.scvar = -13
|
||||
example.cvar.ucvar = 251
|
||||
example.cvar.cvar = "S"
|
||||
example.cvar.fvar = 3.14159
|
||||
example.cvar.dvar = 2.1828
|
||||
example.cvar.strvar = "Hello World"
|
||||
example.cvar.iptrvar = example.new_int(37)
|
||||
example.cvar.ptptr = example.new_Point(37, 42)
|
||||
example.cvar.name = "Bill"
|
||||
|
||||
# Now print out the values of the variables
|
||||
|
||||
|
|
@ -46,16 +46,16 @@ print "\nVariables (values printed from C)"
|
|||
|
||||
example.print_vars()
|
||||
|
||||
print "\nNow I'm going to try and modify some read only variables";
|
||||
print "\nNow I'm going to try and modify some read only variables"
|
||||
|
||||
print " Tring to set 'path'";
|
||||
print " Tring to set 'path'"
|
||||
try:
|
||||
example.cvar.path = "Whoa!"
|
||||
print "Hey, what's going on?!?! This shouldn't work"
|
||||
except:
|
||||
print "Good."
|
||||
|
||||
print " Trying to set 'status'";
|
||||
print " Trying to set 'status'"
|
||||
try:
|
||||
example.cvar.status = 0
|
||||
print "Hey, what's going on?!?! This shouldn't work"
|
||||
|
|
@ -70,6 +70,3 @@ example.cvar.pt = example.cvar.ptptr
|
|||
print "The new value is"
|
||||
example.pt_print()
|
||||
print "You should see the value", example.Point_print(example.cvar.ptptr)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,8 @@ namespace ArrayExample
|
|||
{
|
||||
public:
|
||||
Eight node_list;
|
||||
#ifndef _MSC_VER
|
||||
const Eight node_list2;
|
||||
ConstEight node_list3;
|
||||
#else
|
||||
Eight node_list2;
|
||||
Eight node_list3;
|
||||
#endif
|
||||
|
||||
void fn1(Eight a) {}
|
||||
void fn2(const Eight a) {}
|
||||
|
|
@ -32,6 +27,8 @@ namespace ArrayExample
|
|||
void fn7(Eight*& a) {}
|
||||
void fn8(ConstEight*& a) {}
|
||||
void fn9(const ConstEight*& a) {}
|
||||
|
||||
ExampleDetail() : node_list(), node_list2(), node_list3() {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
15
Examples/test-suite/chartest.i
Normal file
15
Examples/test-suite/chartest.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%module chartest
|
||||
|
||||
%inline %{
|
||||
char printable_global_char = 'a';
|
||||
char unprintable_global_char = 0x7F;
|
||||
|
||||
char GetPrintableChar() {
|
||||
return 'a';
|
||||
}
|
||||
|
||||
char GetUnprintableChar() {
|
||||
return 0x7F;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -138,6 +138,7 @@ CPP_TEST_CASES += \
|
|||
casts \
|
||||
char_binary \
|
||||
char_strings \
|
||||
chartest \
|
||||
class_forward \
|
||||
class_ignore \
|
||||
class_scope_weird \
|
||||
|
|
@ -156,6 +157,7 @@ CPP_TEST_CASES += \
|
|||
conversion \
|
||||
conversion_namespace \
|
||||
conversion_ns_template \
|
||||
conversion_operators \
|
||||
cplusplus_throw \
|
||||
cpp_basic \
|
||||
cpp_enum \
|
||||
|
|
@ -198,6 +200,7 @@ CPP_TEST_CASES += \
|
|||
director_protected \
|
||||
director_protected_overloaded \
|
||||
director_redefined \
|
||||
director_ref \
|
||||
director_smartptr \
|
||||
director_thread \
|
||||
director_unroll \
|
||||
|
|
@ -233,6 +236,7 @@ CPP_TEST_CASES += \
|
|||
features \
|
||||
fragments \
|
||||
friends \
|
||||
friends_template \
|
||||
funcptr_cpp \
|
||||
fvirtual \
|
||||
global_namespace \
|
||||
|
|
@ -243,6 +247,7 @@ CPP_TEST_CASES += \
|
|||
ignore_parameter \
|
||||
import_nomodule \
|
||||
inherit \
|
||||
inherit_member \
|
||||
inherit_missing \
|
||||
inherit_same_name \
|
||||
inherit_target_language \
|
||||
|
|
@ -407,6 +412,7 @@ CPP_TEST_CASES += \
|
|||
template_inherit \
|
||||
template_inherit_abstract \
|
||||
template_int_const \
|
||||
template_keyword_in_type \
|
||||
template_methods \
|
||||
template_namespace_forward_declaration \
|
||||
template_using_directive_and_declaration_forward \
|
||||
|
|
@ -540,6 +546,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_template_explicit \
|
||||
cpp11_template_typedefs \
|
||||
cpp11_type_traits \
|
||||
cpp11_type_aliasing \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_unrestricted_unions \
|
||||
cpp11_userdefined_literals \
|
||||
|
|
|
|||
55
Examples/test-suite/conversion_operators.i
Normal file
55
Examples/test-suite/conversion_operators.i
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
%module conversion_operators
|
||||
|
||||
// Test bug #401 where the conversion operator name incorrectly included the newline character
|
||||
// Also test comments around conversion operators due to special handling in the scanner for conversion operators
|
||||
|
||||
// These one line ignores should match the conversion operator names to suppress Warning 503 - SWIGWARN_LANG_IDENTIFIER
|
||||
%ignore operator const EcReal;
|
||||
%ignore operator EcImaginary const;
|
||||
%ignore operator EcComplex const;
|
||||
|
||||
%inline %{
|
||||
|
||||
struct EcReal {};
|
||||
struct EcImaginary {};
|
||||
struct EcComplex {};
|
||||
|
||||
struct EcAngle {
|
||||
operator const EcReal
|
||||
(
|
||||
) const;
|
||||
operator EcImaginary
|
||||
const (
|
||||
) const;
|
||||
operator
|
||||
EcComplex
|
||||
const (
|
||||
) const;
|
||||
};
|
||||
|
||||
struct EcAngle2 {
|
||||
operator const EcReal/* C comment */
|
||||
(
|
||||
) const;
|
||||
operator EcImaginary/* C comment */
|
||||
const (
|
||||
) const;
|
||||
operator/* C comment */
|
||||
EcComplex
|
||||
const (
|
||||
) const;
|
||||
};
|
||||
|
||||
struct EcAngle3 {
|
||||
operator const EcReal // C++ comment
|
||||
(
|
||||
) const;
|
||||
operator EcImaginary // C++ comment
|
||||
const (
|
||||
) const;
|
||||
operator // C++ comment
|
||||
EcComplex
|
||||
const (
|
||||
) const;
|
||||
};
|
||||
%}
|
||||
|
|
@ -100,9 +100,6 @@ int runLambdaInline() {
|
|||
|
||||
%{
|
||||
// TODO
|
||||
struct LambdaStruct {
|
||||
static constexpr auto lambda_struct1 = [=]() { return thing; };
|
||||
};
|
||||
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
|
||||
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
||||
void lambda_init(int = ([=]{ return 0; })());
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct NoExceptClass {
|
|||
NoExceptClass() noexcept {}
|
||||
NoExceptClass(const NoExceptClass&) noexcept {}
|
||||
NoExceptClass(NoExceptClass&&) noexcept {}
|
||||
NoExceptClass& operator=(const NoExceptClass&) noexcept {}
|
||||
NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; }
|
||||
~NoExceptClass() noexcept {}
|
||||
|
||||
void noex0() noexcept {}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,17 @@ struct Thingy {
|
|||
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
|
||||
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
|
||||
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
|
||||
operator int &&() {}
|
||||
operator int &&() { return std::move(0); }
|
||||
Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {}
|
||||
Thingy& operator=(const Thingy& rhs) {
|
||||
val = rhs.val;
|
||||
lvalref = rhs.lvalref;
|
||||
rvalref = rhs.rvalref;
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
static const bool PrivateTrue;
|
||||
int copy_int(int& i) { return i; }
|
||||
Thingy();
|
||||
};
|
||||
const bool Thingy::PrivateTrue = true;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,14 @@
|
|||
%module cpp11_template_typedefs
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefNamePtr;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator1;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator2;
|
||||
|
||||
// This warning should go away when type aliasing is supported
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_USING_UNDEF // Nothing known about 'p.SomeType< char *,T2,4 >'.
|
||||
|
||||
%inline %{
|
||||
template< typename T1, typename T2, int >
|
||||
|
|
@ -16,6 +22,8 @@ class SomeType {
|
|||
// template aliasing
|
||||
template< typename T2 >
|
||||
using TypedefName = SomeType<char*, T2, 5>;
|
||||
template< typename T2 >
|
||||
using TypedefNamePtr = SomeType<char*, T2, 4>*;
|
||||
|
||||
// type aliasing
|
||||
typedef void (*PFD)(double); // Old style
|
||||
|
|
@ -28,5 +36,21 @@ class MyCPP11Class {
|
|||
};
|
||||
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
|
||||
MyIntKeyClass<char> intchar;
|
||||
|
||||
TypedefName<int> alias1(TypedefName<int> a) { return a; }
|
||||
TypedefNamePtr<int> alias1(TypedefNamePtr<int> a = nullptr) { return a; }
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef double Val;
|
||||
template<typename T> struct ListBucket {
|
||||
};
|
||||
namespace Alloc {
|
||||
template<typename T> struct rebind {
|
||||
typedef int other;
|
||||
};
|
||||
}
|
||||
|
||||
using BucketAllocator1 = typename Alloc::template rebind<ListBucket<Val>>::other;
|
||||
using BucketAllocator2 = typename Alloc::template rebind<::template ListBucket<double>>::other;
|
||||
%}
|
||||
|
|
|
|||
66
Examples/test-suite/cpp11_type_aliasing.i
Normal file
66
Examples/test-suite/cpp11_type_aliasing.i
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
%module cpp11_type_aliasing
|
||||
|
||||
// Type aliasing seg fault : Github issue #424
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
|
||||
|
||||
%inline %{
|
||||
namespace Halide {
|
||||
|
||||
struct Target {
|
||||
int bits;
|
||||
Target(int bits=32) : bits(bits) {}
|
||||
};
|
||||
|
||||
class NamesInterface {
|
||||
public:
|
||||
using Target = Halide::Target;
|
||||
};
|
||||
|
||||
Target get_host_target() {
|
||||
return Target();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
template <typename T> class GeneratorParam {
|
||||
T value;
|
||||
public:
|
||||
GeneratorParam(const char *name, const T &v) : value(v) {}
|
||||
|
||||
T getValue() {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
class GeneratorBase : public NamesInterface {
|
||||
public:
|
||||
GeneratorParam<Target> target{ "target", Halide::get_host_target() };
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%template(Halide_Target) Halide::Internal::GeneratorParam<Halide::Target>;
|
||||
|
||||
|
||||
%inline %{
|
||||
using Int = int;
|
||||
using IntRef = int&;
|
||||
using IntPtrRef = int*&;
|
||||
using IntRValueRef = int&&;
|
||||
using IntArray = int[];
|
||||
|
||||
using HalideTargetPtr1 = Halide::Target*;
|
||||
namespace Halide {
|
||||
using HalideTargetPtr2 = Target*;
|
||||
}
|
||||
%}
|
||||
|
|
@ -6,8 +6,7 @@ LANGUAGE = csharp
|
|||
SCRIPTSUFFIX = _runme.cs
|
||||
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
||||
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
||||
CSHARPCONVERTPATH = @top_srcdir@/@CSHARPCONVERTPATH@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
|
|
@ -79,13 +78,13 @@ run_testcase = \
|
|||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
CSHARPSRCS='`$(CSHARPCONVERTPATH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCONVERTPATH) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec ../$(CSHARPCONVERTPATH) "{}" \+`' csharp_compile; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
|
|
@ -12,13 +12,5 @@ public class runme
|
|||
throw new Exception("Protected destructor exception should have been thrown");
|
||||
} catch (MethodAccessException) {
|
||||
}
|
||||
|
||||
// calling private destructor test
|
||||
try {
|
||||
using (FFF f = new FFF()) {
|
||||
}
|
||||
throw new Exception("Private destructor exception should have been thrown");
|
||||
} catch (MethodAccessException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,5 +16,12 @@ public class runme
|
|||
|
||||
HiddenDestructor hidden = HiddenDestructor.create();
|
||||
hidden.Dispose();
|
||||
|
||||
HiddenPrivateDestructor hiddenPrivate = HiddenPrivateDestructor.create();
|
||||
if (HiddenPrivateDestructor.DeleteCount != 0)
|
||||
throw new ApplicationException("Count should be zero");
|
||||
hiddenPrivate.Dispose();
|
||||
if (HiddenPrivateDestructor.DeleteCount != 1)
|
||||
throw new ApplicationException("Count should be one");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class runme
|
|||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class li_std_auto_ptr_runme {
|
|||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
|
|
@ -51,7 +51,7 @@ public class li_std_auto_ptr_runme {
|
|||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
module default_constructor_runme;
|
||||
|
||||
import default_constructor.FFF;
|
||||
import default_constructor.G;
|
||||
|
||||
void main() {
|
||||
|
|
@ -15,16 +14,4 @@ void main() {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Private destructor test.
|
||||
try {
|
||||
{
|
||||
scope f = new FFF();
|
||||
}
|
||||
throw new Exception("Private destructor exception should have been thrown");
|
||||
} catch (Exception e) {
|
||||
if (e.msg != "C++ destructor does not have public access") {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
module default_constructor_runme;
|
||||
|
||||
import default_constructor.FFF;
|
||||
import default_constructor.G;
|
||||
|
||||
void main() {
|
||||
|
|
@ -8,7 +7,6 @@ void main() {
|
|||
// destruction yet.
|
||||
|
||||
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
|
||||
// enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
|
||||
}
|
||||
|
||||
private void enforceThrows(void delegate() dg, string errorMessage) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ struct Display {
|
|||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = 0) { return v; }
|
||||
float draw2(float *v = 0) { return v ? *v : 0; }
|
||||
bool bool0(bool x = 0) { return x; }
|
||||
bool bool1(bool x = 1) { return x; }
|
||||
|
||||
typedef bool mybool;
|
||||
bool mybool0(mybool x = 0) { return x; }
|
||||
bool mybool1(mybool x = 1) { return x; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
%}
|
||||
|
|
@ -14,5 +20,11 @@ struct Display {
|
|||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = NULL) { return v; }
|
||||
float draw2(float *v = NULL) { return v ? *v : 0; }
|
||||
bool bool0(bool x = 0) { return x; }
|
||||
bool bool1(bool x = 1) { return x; }
|
||||
|
||||
typedef bool mybool;
|
||||
bool mybool0(mybool x = 0) { return x; }
|
||||
bool mybool1(mybool x = 1) { return x; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
|
|
|
|||
|
|
@ -114,7 +114,10 @@
|
|||
%rename(renamed2arg) Foo::renameme(int x) const;
|
||||
%rename(renamed1arg) Foo::renameme() const;
|
||||
|
||||
%typemap(default) double* null_by_default "$1=0;";
|
||||
|
||||
%inline %{
|
||||
typedef void* MyHandle;
|
||||
|
||||
// Define a class
|
||||
class Foo {
|
||||
|
|
@ -139,6 +142,12 @@
|
|||
// test the method itself being renamed
|
||||
void oldname(int x = 1234) {}
|
||||
void renameme(int x = 1234, double d=123.4) const {}
|
||||
|
||||
// test default values for pointer arguments
|
||||
int double_if_void_ptr_is_null(int n, void* p = NULL) { return p ? n : 2*n; }
|
||||
int double_if_handle_is_null(int n, MyHandle h = 0) { return h ? n : 2*n; }
|
||||
int double_if_dbl_ptr_is_null(int n, double* null_by_default)
|
||||
{ return null_by_default ? n : 2*n; }
|
||||
};
|
||||
int Foo::bar = 1;
|
||||
int Foo::spam = 2;
|
||||
|
|
@ -269,3 +278,26 @@ struct ConstMethods {
|
|||
} Pointf;
|
||||
}
|
||||
%}
|
||||
|
||||
// Default arguments after ignored ones.
|
||||
%typemap(in, numinputs=0) int square_error { $1 = 2; };
|
||||
%typemap(default, noblock=1) int def17 { $1 = 17; };
|
||||
|
||||
// Enabling autodoc feature has a side effect of disabling the generation of
|
||||
// aliases for functions that can hide problems with default arguments at
|
||||
// Python level.
|
||||
%feature("autodoc","0") slightly_off_square;
|
||||
|
||||
%inline %{
|
||||
inline int slightly_off_square(int square_error, int def17) { return def17*def17 + square_error; }
|
||||
%}
|
||||
|
||||
// Python C default args
|
||||
%feature("python:cdefaultargs") CDA::cdefaultargs_test1;
|
||||
%inline %{
|
||||
struct CDA {
|
||||
int cdefaultargs_test1(int a = 1) { return a; }
|
||||
int cdefaultargs_test2(int a = 1) { return a; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@
|
|||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
|
||||
|
||||
%delobject F::destroy;
|
||||
|
|
@ -103,14 +113,15 @@ public:
|
|||
|
||||
void bar(F *) { }
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
|
||||
#endif
|
||||
// Single inheritance, base has private destructor
|
||||
class FFF : public F {
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
|
||||
#endif
|
||||
|
||||
// Multiple inheritance, one base has private destructor
|
||||
class GGG : public A, public F {
|
||||
};
|
||||
class HHH : public F, public A {
|
||||
};
|
||||
|
||||
/* A class with a protected destructor */
|
||||
class G {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
|
||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
|
||||
%apply (char* STRING, size_t LENGTH) { (const void* data, size_t datalen) };
|
||||
|
||||
%inline %{
|
||||
#include <stdlib.h>
|
||||
|
|
@ -20,6 +21,7 @@ public:
|
|||
if (dataBufferBB)
|
||||
memset(dataBufferBB, -1, sizeBB);
|
||||
}
|
||||
virtual void writeData(const void* data, size_t datalen) = 0;
|
||||
};
|
||||
|
||||
class Caller {
|
||||
|
|
@ -50,6 +52,17 @@ public:
|
|||
void call_null() {
|
||||
_callback->run(NULL, 0, NULL, 0);
|
||||
}
|
||||
int callWriteData() {
|
||||
int sum = 0;
|
||||
if (_callback) {
|
||||
char* aa = (char*)malloc(BUFFER_SIZE_AA);
|
||||
memset(aa, 9, BUFFER_SIZE_AA);
|
||||
_callback->writeData(aa, BUFFER_SIZE_AA);
|
||||
for (int i = 0; i < BUFFER_SIZE_AA; i++)
|
||||
sum += aa[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
|
||||
%ignore DIgnoreConstructor(bool b);
|
||||
%ignore DIgnoreOnlyConstructor(bool b);
|
||||
%ignore DIgnoreDestructor::~DIgnoreDestructor;
|
||||
%ignore Pointers;
|
||||
%ignore References;
|
||||
%ignore PublicMethod1;
|
||||
|
|
@ -101,6 +102,13 @@ class DIgnoreOnlyConstructor
|
|||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreDestructor
|
||||
{
|
||||
public:
|
||||
DIgnoreDestructor() {}
|
||||
virtual ~DIgnoreDestructor() {}
|
||||
};
|
||||
|
||||
%{
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
|
|
@ -118,5 +126,12 @@ class DIgnoreOnlyConstructor
|
|||
private: // Hide constructor
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
%}
|
||||
|
||||
class DIgnoreDestructor
|
||||
{
|
||||
public:
|
||||
DIgnoreDestructor() {}
|
||||
virtual ~DIgnoreDestructor() {}
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
82
Examples/test-suite/director_ref.i
Normal file
82
Examples/test-suite/director_ref.i
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
%module(directors="1") director_ref
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo(int i = -1) : count(0) {}
|
||||
virtual void OnDelete() {}
|
||||
virtual ~Foo() {}
|
||||
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
|
||||
|
||||
std::string GetMsg() { return Msg(); }
|
||||
std::string GetMsg(std::string msg) { return Msg(msg); }
|
||||
|
||||
void Ref() { ++count; }
|
||||
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
|
||||
int GetRefCount() { return count; }
|
||||
private:
|
||||
int count;
|
||||
};
|
||||
|
||||
class FooPtr {
|
||||
public:
|
||||
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
|
||||
~FooPtr() { if (my_f) { my_f->Unref(); } }
|
||||
void Reset(Foo* f = NULL) {
|
||||
if (f) { f->Ref(); }
|
||||
if (my_f) { my_f->Unref(); }
|
||||
my_f = f;
|
||||
}
|
||||
int GetOwnedRefCount() {
|
||||
if (my_f) { return my_f->GetRefCount(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Foo* my_f;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%feature("director") Foo;
|
||||
%feature("ref") Foo "$this->Ref();"
|
||||
%feature("unref") Foo "$this->Unref();"
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo(int i = -1) : count(0) {}
|
||||
virtual void OnDelete() {}
|
||||
virtual ~Foo() {}
|
||||
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
|
||||
|
||||
std::string GetMsg() { return Msg(); }
|
||||
std::string GetMsg(std::string msg) { return Msg(msg); }
|
||||
|
||||
void Ref() { ++count; }
|
||||
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
|
||||
int GetRefCount() { return count; }
|
||||
private:
|
||||
int count;
|
||||
};
|
||||
|
||||
class FooPtr {
|
||||
public:
|
||||
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
|
||||
~FooPtr() { if (my_f) { my_f->Unref(); } }
|
||||
void Reset(Foo* f = NULL) {
|
||||
if (f) { f->Ref(); }
|
||||
if (my_f) { my_f->Unref(); }
|
||||
my_f = f;
|
||||
}
|
||||
int GetOwnedRefCount() {
|
||||
if (my_f) { return my_f->GetRefCount(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Foo* my_f;
|
||||
};
|
||||
|
|
@ -100,4 +100,9 @@ void overloadinline2(const int *) {}
|
|||
void overload5(int *) {}
|
||||
void overload5(const int *) {}
|
||||
|
||||
|
||||
%ignore Outer2::QuietInner;
|
||||
struct Outer2 {
|
||||
struct QuietInner {
|
||||
VARIABLEMACRO(MyInnerVar)
|
||||
};
|
||||
};
|
||||
|
|
|
|||
26
Examples/test-suite/errors/cpp_template_friend.i
Normal file
26
Examples/test-suite/errors/cpp_template_friend.i
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%module cpp_template_friend
|
||||
|
||||
template<typename T> T template_friend1(T);
|
||||
template<typename T> T template_friend1(T);
|
||||
struct MyTemplate1 {
|
||||
template<typename T> friend T template_friend1(T);
|
||||
};
|
||||
|
||||
template<typename T> T template_friend2(T);
|
||||
struct MyTemplate2 {
|
||||
template<typename T> friend T template_friend2(T);
|
||||
};
|
||||
template<typename T> T template_friend2(T);
|
||||
|
||||
|
||||
int normal_friend1(int);
|
||||
int normal_friend1(int);
|
||||
struct MyClass1 {
|
||||
friend int normal_friend1(int);
|
||||
};
|
||||
|
||||
int normal_friend2(int);
|
||||
struct MyClass2 {
|
||||
friend int normal_friend2(int);
|
||||
};
|
||||
int normal_friend2(int);
|
||||
8
Examples/test-suite/errors/cpp_template_friend.stderr
Normal file
8
Examples/test-suite/errors/cpp_template_friend.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
cpp_template_friend.i:4: Warning 302: Identifier 'template_friend1' redefined (ignored),
|
||||
cpp_template_friend.i:3: Warning 302: previous definition of 'template_friend1'.
|
||||
cpp_template_friend.i:13: Warning 302: Identifier 'template_friend2' redefined (ignored),
|
||||
cpp_template_friend.i:9: Warning 302: previous definition of 'template_friend2'.
|
||||
cpp_template_friend.i:17: Warning 322: Redundant redeclaration of 'normal_friend1',
|
||||
cpp_template_friend.i:16: Warning 322: previous declaration of 'normal_friend1'.
|
||||
cpp_template_friend.i:26: Warning 322: Redundant redeclaration of 'normal_friend2',
|
||||
cpp_template_friend.i:22: Warning 322: previous declaration of 'normal_friend2'.
|
||||
13
Examples/test-suite/errors/cpp_using_type_aliasing.i
Normal file
13
Examples/test-suite/errors/cpp_using_type_aliasing.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module cpp_using_type_aliasing
|
||||
|
||||
namespace Space {
|
||||
template<typename T> struct Okay {
|
||||
};
|
||||
struct User {
|
||||
protected:
|
||||
using OkayInt = Okay<int>;
|
||||
};
|
||||
struct Derived : User {
|
||||
Okay<OkayInt> ff();
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
cpp_using_type_aliasing.i:8: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
|
||||
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
|
||||
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
|
||||
|
|
@ -1 +1 @@
|
|||
doxygen_unknown_command.i:4: Warning 740: Doxygen parser warning: unknown command "unknown".
|
||||
doxygen_unknown_command.i:4: Warning 760: Doxygen parser warning: unknown command "unknown".
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
%module xxx
|
||||
|
||||
/* Regression test for bug introduced in 3.0.4 and fixed in 3.0.6 - the '%std'
|
||||
* here led to SWIG calling abort().
|
||||
*/
|
||||
%typemap(jstype) std::vector<std::string>, const %std::vector<std::string>&, std::vector<std::string>& "List<String>"
|
||||
|
||||
/* This used to give the rather cryptic "Syntax error in input(1)." prior to
|
||||
* SWIG 3.0.4. This testcase checks that the improved message is actually
|
||||
* issued.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
|
||||
pp_unknowndirective.i:12: Error: Unknown directive '%remane'.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
%module xxx
|
||||
|
||||
#ifdef FOO
|
||||
#ifndef FOO
|
||||
long long i;
|
||||
/* Check we get an error for an unknown directive (this should be #elif).
|
||||
* Unknown directives were silently ignored by SWIG < 3.0.3. */
|
||||
|
|
|
|||
7
Examples/test-suite/errors/swig_pythoncode_bad.i
Normal file
7
Examples/test-suite/errors/swig_pythoncode_bad.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module xxx
|
||||
|
||||
%pythoncode %{
|
||||
def foo():
|
||||
a = 1 # This line starts with a tab instead of 8 spaces.
|
||||
return 2
|
||||
%}
|
||||
1
Examples/test-suite/errors/swig_pythoncode_bad.stderr
Normal file
1
Examples/test-suite/errors/swig_pythoncode_bad.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of pythoncode)
|
||||
13
Examples/test-suite/errors/swig_pythoncode_bad2.i
Normal file
13
Examples/test-suite/errors/swig_pythoncode_bad2.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module xxx
|
||||
|
||||
%pythoncode %{
|
||||
def one():
|
||||
print "in one"
|
||||
%}
|
||||
|
||||
%pythoncode %{
|
||||
print "still in one"
|
||||
|
||||
def two():
|
||||
print "in two"
|
||||
%}
|
||||
1
Examples/test-suite/errors/swig_pythoncode_bad2.stderr
Normal file
1
Examples/test-suite/errors/swig_pythoncode_bad2.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of pythoncode)
|
||||
|
|
@ -14,3 +14,18 @@ typedef int Integer2;
|
|||
void RealFunction(int value) {}
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
extern "C" {
|
||||
typedef void (*Hook1_t)(int, const char *);
|
||||
}
|
||||
extern "C" typedef void (*Hook2_t)(int, const char *);
|
||||
void funcy1(Hook1_t) {}
|
||||
void funcy2(Hook2_t) {}
|
||||
Hook1_t hook1;
|
||||
Hook2_t hook2;
|
||||
|
||||
extern "C" typedef int Integer;
|
||||
Integer int1;
|
||||
%}
|
||||
|
||||
|
|
|
|||
46
Examples/test-suite/friends_template.i
Normal file
46
Examples/test-suite/friends_template.i
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
%module friends_template
|
||||
|
||||
%{
|
||||
template <typename Type> class MyClass;
|
||||
|
||||
template <typename Type> int operator<<(double un, const MyClass <Type> & x) { return 0; }
|
||||
template <typename Type> int funk_hidden(double is, MyClass <Type> & x) { return 2; }
|
||||
|
||||
template <typename T> T template_friend_hidden(T t) { return t + 1; }
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
template <typename Type> int operator>>(double is, MyClass <Type> & x) { return 1; }
|
||||
template <typename Type> int funk_seen(double is, MyClass <Type> & x) { return 2; }
|
||||
template <typename T> T template_friend_seen(T t1, T t2) { return t1 + t2; }
|
||||
int friend_plain_seen(int i) { return i; }
|
||||
|
||||
template <class Type> class MyClass
|
||||
{
|
||||
friend int operator<< <Type>(double un, const MyClass <Type> & x);
|
||||
friend int operator>> <Type>(double is, MyClass <Type> & x);
|
||||
friend int funk_hidden <Type>(double is, MyClass <Type> & x);
|
||||
friend int funk_seen <Type>(double is, MyClass <Type> & x);
|
||||
};
|
||||
|
||||
struct MyTemplate {
|
||||
template <typename T> friend T template_friend_hidden(T);
|
||||
template <typename T> friend T template_friend_seen(T, T);
|
||||
friend int friend_plain_seen(int i);
|
||||
};
|
||||
|
||||
MyClass<int> makeMyClassInt() { return MyClass<int>(); }
|
||||
%}
|
||||
|
||||
// Although the friends in MyClass are automatically instantiated via %template(MyClassDouble) MyClass<int>,
|
||||
// the operator friends are not valid and hence %rename is needed.
|
||||
%rename(OperatorInputDouble) operator>> <double>;
|
||||
%rename(OperatorOutputDouble) operator<< <double>;
|
||||
%template(MyClassDouble) MyClass<double>;
|
||||
|
||||
%template(TemplateFriendHiddenInt) template_friend_hidden<int>;
|
||||
%template(TemplateFriendSeenInt) template_friend_seen<int>;
|
||||
|
||||
// These have no %template(XX) MyClass<int> to instantiate, but they can be instantiated separately...
|
||||
%template(OperatorInputInt) operator>> <int>;
|
||||
%template(OperatorFunkSeenInt) funk_seen <int>;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue