Merge branch 'master' into doxygen
This commit is contained in:
commit
b7f78dd5a7
232 changed files with 5648 additions and 2419 deletions
|
|
@ -334,8 +334,8 @@ else
|
|||
SWIGOPTPY3 = -py3
|
||||
endif
|
||||
|
||||
PEP8 = @PEP8@
|
||||
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||
PYCODESTYLE = @PYCODESTYLE@
|
||||
PYCODESTYLE_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a C dynamically loadable module
|
||||
|
|
@ -386,11 +386,11 @@ else
|
|||
PYSCRIPT = $(RUNME)3.py
|
||||
endif
|
||||
|
||||
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||
PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||
|
||||
python_run: $(PYSCRIPT)
|
||||
ifneq (,$(PEP8))
|
||||
$(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
|
||||
ifneq (,$(PYCODESTYLE))
|
||||
$(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(PYSCRIPT)
|
||||
endif
|
||||
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ constants2
|
|||
extend
|
||||
funcptr
|
||||
import
|
||||
java
|
||||
multimap
|
||||
multiple_inheritance
|
||||
pointer
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
public class Example {
|
||||
public int mPublicInt;
|
||||
|
||||
public Example() {
|
||||
mPublicInt = 0;
|
||||
}
|
||||
|
||||
public Example(int IntVal) {
|
||||
mPublicInt = IntVal;
|
||||
}
|
||||
|
||||
|
||||
public int Add(int a, int b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public float Add(float a, float b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public String Add(String a, String b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public Example Add(Example a, Example b) {
|
||||
return new Example(a.mPublicInt + b.mPublicInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
|
||||
|
||||
build: Example.class Example.h
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
|
||||
rm -f *.class Example.h
|
||||
|
||||
Example.class Example.h: $(SRCDIR)Example.java
|
||||
gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
|
||||
gcjh Example.class
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
%module example
|
||||
|
||||
%include <cni.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include Example.h
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use example;
|
||||
|
||||
example::JvCreateJavaVM(undef);
|
||||
example::JvAttachCurrentThread(undef, undef);
|
||||
|
||||
$e1 = new example::Example(1);
|
||||
print $e1->{mPublicInt},"\n";
|
||||
|
||||
$e2 = new example::Example(2);
|
||||
print $e2->{mPublicInt},"\n";
|
||||
|
||||
$i = $e1->Add(1,2);
|
||||
print $i,"\n";
|
||||
|
||||
$d = $e2->Add(1.0,2.0);
|
||||
print $d,"\n";
|
||||
|
||||
$d = $e2->Add("1","2");
|
||||
print $d,"\n";
|
||||
|
||||
$e3 = $e1->Add($e1,$e2);
|
||||
print $e3->{mPublicInt},"\n";
|
||||
|
||||
|
||||
$s = $e2->Add("a","b");
|
||||
print $s,"\n";
|
||||
|
||||
|
||||
example::JvDetachCurrentThread()
|
||||
|
|
@ -14,7 +14,6 @@ functor
|
|||
import
|
||||
import_template
|
||||
import_packages
|
||||
java
|
||||
#libffi
|
||||
multimap
|
||||
operator
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import_packages_subdirs = \
|
|||
relativeimport2 \
|
||||
relativeimport3 \
|
||||
split_modules \
|
||||
namespace_pkg
|
||||
namespace_pkg \
|
||||
|
||||
|
||||
check: build
|
||||
|
|
@ -21,19 +21,19 @@ check: build
|
|||
mkdir -p `dirname $$file`; \
|
||||
cp "${SRCDIR}$$file" "$$file" || exit 1; \
|
||||
done; \
|
||||
fi; \
|
||||
fi
|
||||
for s in $(import_packages_subdirs); do \
|
||||
(cd $$s && $(MAKE) check); \
|
||||
(cd $$s && $(MAKE) check) || exit 1; \
|
||||
done
|
||||
|
||||
build:
|
||||
for s in $(import_packages_subdirs); do \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \
|
||||
done
|
||||
|
||||
static:
|
||||
for s in $(import_packages_subdirs); do \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \
|
||||
done
|
||||
|
||||
clean:
|
||||
|
|
@ -42,7 +42,7 @@ clean:
|
|||
for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
|
||||
rm -f "$$file" || exit 1; \
|
||||
done; \
|
||||
fi; \
|
||||
fi
|
||||
for s in $(import_packages_subdirs); do \
|
||||
(cd $$s && $(MAKE) clean); \
|
||||
(cd $$s && $(MAKE) clean) || exit 1; \
|
||||
done
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ 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 < (2, 5):
|
||||
print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'"
|
||||
sys.exit(0)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ subdirs = vanilla vanilla_split
|
|||
|
||||
check: build
|
||||
for s in $(subdirs); do \
|
||||
(cd $$s && $(MAKE) check); \
|
||||
(cd $$s && $(MAKE) check) || exit 1; \
|
||||
done
|
||||
|
||||
build:
|
||||
for s in $(subdirs); do \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \
|
||||
done
|
||||
|
||||
static:
|
||||
for s in $(subdirs); do \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
|
||||
(cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \
|
||||
done
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
for s in $(subdirs); do \
|
||||
(cd $$s && $(MAKE) clean); \
|
||||
(cd $$s && $(MAKE) clean) || exit 1; \
|
||||
done
|
||||
|
|
|
|||
|
|
@ -19,4 +19,6 @@ static:
|
|||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
|
||||
cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
|
||||
if test -d pkg1; then \
|
||||
cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean; \
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
public class Example {
|
||||
public int mPublicInt;
|
||||
|
||||
public Example() {
|
||||
mPublicInt = 0;
|
||||
}
|
||||
|
||||
public Example(int IntVal) {
|
||||
mPublicInt = IntVal;
|
||||
}
|
||||
|
||||
|
||||
public int Add(int a, int b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public float Add(float a, float b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public String Add(String a, String b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public Example Add(Example a, Example b) {
|
||||
return new Example(a.mPublicInt + b.mPublicInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
|
||||
|
||||
build: Example.class Example.h
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
rm -f $(TARGET).py
|
||||
rm -f *.class Example.h
|
||||
|
||||
Example.class Example.h: $(SRCDIR)Example.java
|
||||
gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
|
||||
gcjh Example.class
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
%module example
|
||||
%include <cni.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include Example.h
|
||||
|
||||
%extend Example {
|
||||
~Example() {}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
from example import *
|
||||
|
||||
JvCreateJavaVM(None)
|
||||
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 e3.mPublicInt
|
||||
|
||||
print e1.Add("1", "2")
|
||||
|
||||
JvDetachCurrentThread()
|
||||
|
|
@ -39,7 +39,11 @@ extern int gcd(int x, int y);
|
|||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
{
|
||||
PyObject *utf8str = PyUnicode_AsUTF8String(s);
|
||||
const char *cstr = PyBytes_AsString(utf8str);
|
||||
const char *cstr;
|
||||
if (!utf8str) {
|
||||
SWIG_fail;
|
||||
}
|
||||
cstr = PyBytes_AsString(utf8str);
|
||||
$2[i] = strdup(cstr);
|
||||
Py_DECREF(utf8str);
|
||||
}
|
||||
|
|
@ -72,6 +76,9 @@ extern int gcdmain(int argc, char *argv[]);
|
|||
SWIG_fail;
|
||||
}
|
||||
utf8str = PyUnicode_AsUTF8String($input);
|
||||
if (!utf8str) {
|
||||
SWIG_fail;
|
||||
}
|
||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||
$2 = (int)len;
|
||||
|
|
@ -105,6 +112,9 @@ extern int count(char *bytes, int len, char c);
|
|||
char *cstr;
|
||||
Py_ssize_t len;
|
||||
PyObject *utf8str = PyUnicode_AsUTF8String($input);
|
||||
if (!utf8str) {
|
||||
SWIG_fail;
|
||||
}
|
||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||
$2 = (int)len;
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ print " Tring to set 'path'"
|
|||
try:
|
||||
example.cvar.path = "Whoa!"
|
||||
print "Hey, what's going on?!?! This shouldn't work"
|
||||
except:
|
||||
except Exception:
|
||||
print "Good."
|
||||
|
||||
print " Trying to set 'status'"
|
||||
try:
|
||||
example.cvar.status = 0
|
||||
print "Hey, what's going on?!?! This shouldn't work"
|
||||
except:
|
||||
except Exception:
|
||||
print "Good."
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ functor
|
|||
hashargs
|
||||
import
|
||||
import_template
|
||||
java
|
||||
mark_function
|
||||
multimap
|
||||
operator
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ GC.start
|
|||
# C++ object
|
||||
ok = false
|
||||
begin
|
||||
puts tiger2.get_name
|
||||
# Let's stress the GC a bit, a single pass might not be enough.
|
||||
10.times {
|
||||
GC.start
|
||||
puts tiger2.get_name
|
||||
}
|
||||
rescue ObjectPreviouslyDeleted => error
|
||||
ok = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
public class Example {
|
||||
public int mPublicInt;
|
||||
|
||||
public Example() {
|
||||
mPublicInt = 0;
|
||||
}
|
||||
|
||||
public Example(int IntVal) {
|
||||
mPublicInt = IntVal;
|
||||
}
|
||||
|
||||
|
||||
public int Add(int a, int b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public float Add(float a, float b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public String Add(String a, String b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public Example Add(Example a, Example b) {
|
||||
return new Example(a.mPublicInt + b.mPublicInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
|
||||
|
||||
build: Example.class Example.h
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
|
||||
rm -f *.class Example.h
|
||||
|
||||
Example.class Example.h: $(SRCDIR)Example.java
|
||||
gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
|
||||
gcjh Example.class
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
%module example
|
||||
%include <cni.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include Example.h
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
require 'example'
|
||||
|
||||
Example.JvCreateJavaVM(nil)
|
||||
Example.JvAttachCurrentThread(nil, nil)
|
||||
|
||||
e1 = Example::Example.new(1)
|
||||
e2 = Example::Example.new(2)
|
||||
|
||||
print e1.Add(1,2),"\n"
|
||||
print e1.Add(1.0,2.0),"\n"
|
||||
e3 = e1.Add(e1,e2)
|
||||
print e3.mPublicInt,"\n"
|
||||
|
||||
|
||||
print e1.Add("1","2"),"\n"
|
||||
|
||||
Example.JvDetachCurrentThread()
|
||||
|
||||
|
|
@ -5,7 +5,6 @@ contract
|
|||
enum
|
||||
funcptr
|
||||
import
|
||||
java
|
||||
multimap
|
||||
operator
|
||||
pointer
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
public class Example {
|
||||
public int mPublicInt;
|
||||
|
||||
public Example() {
|
||||
mPublicInt = 0;
|
||||
}
|
||||
|
||||
public Example(int IntVal) {
|
||||
mPublicInt = IntVal;
|
||||
}
|
||||
|
||||
|
||||
public int Add(int a, int b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public float Add(float a, float b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public String Add(String a, String b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public Example Add(Example a, Example b) {
|
||||
return new Example(a.mPublicInt + b.mPublicInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
|
||||
|
||||
build: Example.class Example.h
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
|
||||
rm -f *.class Example.h
|
||||
|
||||
Example.class Example.h: $(SRCDIR)Example.java
|
||||
gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
|
||||
gcjh Example.class
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
%module example
|
||||
%include <cni.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
%include Example.h
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
catch { load ./example[info sharedlibextension] example}
|
||||
|
||||
JvCreateJavaVM NULL
|
||||
JvAttachCurrentThread NULL NULL
|
||||
Example e1 1
|
||||
Example e2 2
|
||||
|
||||
puts "[e1 cget -mPublicInt]"
|
||||
puts "[e2 cget -mPublicInt]"
|
||||
|
||||
puts "[e2 Add 1 2]"
|
||||
puts "[e2 Add 1.0 2.0]"
|
||||
puts "[e2 Add '1' '2']"
|
||||
|
||||
JvDetachCurrentThread
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
%module class_scope_namespace
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) H::HH;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I::II;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I_::II;
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
|
|
@ -107,12 +107,12 @@ void hhh(H::HH) {}
|
|||
|
||||
namespace Space8 {
|
||||
struct II;
|
||||
struct I {
|
||||
struct I_ {
|
||||
struct II {
|
||||
void ii(Space8::I::II, I::II) {}
|
||||
void ii(Space8::I_::II, I_::II) {}
|
||||
};
|
||||
};
|
||||
void iii(Space8::I::II, I::II) {}
|
||||
void iii(Space8::I_::II, I_::II) {}
|
||||
}
|
||||
|
||||
struct J;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ CPP_TEST_BROKEN += \
|
|||
extend_variable \
|
||||
li_boost_shared_ptr_template \
|
||||
nested_private \
|
||||
overload_complicated \
|
||||
rename_camel \
|
||||
template_default_pointer \
|
||||
template_private_assignment \
|
||||
|
|
@ -165,6 +164,7 @@ CPP_TEST_CASES += \
|
|||
cpp_typedef \
|
||||
curiously_recurring_template_pattern \
|
||||
default_args \
|
||||
default_arg_expressions \
|
||||
default_arg_values \
|
||||
default_constructor \
|
||||
defvalue_constructor \
|
||||
|
|
@ -182,6 +182,7 @@ CPP_TEST_CASES += \
|
|||
director_detect \
|
||||
director_enum \
|
||||
director_exception \
|
||||
director_exception_catches \
|
||||
director_extend \
|
||||
director_finalizer \
|
||||
director_frob \
|
||||
|
|
@ -193,6 +194,7 @@ CPP_TEST_CASES += \
|
|||
director_nspace_director_name_collision \
|
||||
director_overload \
|
||||
director_overload2 \
|
||||
director_ownership \
|
||||
director_pass_by_value \
|
||||
director_primitives \
|
||||
director_property \
|
||||
|
|
@ -264,9 +266,10 @@ CPP_TEST_CASES += \
|
|||
li_attribute \
|
||||
li_attribute_template \
|
||||
li_boost_shared_ptr \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_template \
|
||||
li_boost_shared_ptr_attribute \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_director \
|
||||
li_boost_shared_ptr_template \
|
||||
li_carrays_cpp \
|
||||
li_cdata_cpp \
|
||||
li_cpointer_cpp \
|
||||
|
|
@ -317,6 +320,7 @@ CPP_TEST_CASES += \
|
|||
nested_template_base \
|
||||
nested_workaround \
|
||||
newobject1 \
|
||||
newobject3 \
|
||||
null_pointer \
|
||||
operator_overload \
|
||||
operator_overload_break \
|
||||
|
|
@ -325,6 +329,7 @@ CPP_TEST_CASES += \
|
|||
ordering \
|
||||
overload_arrays \
|
||||
overload_bool \
|
||||
overload_complicated \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
overload_method \
|
||||
|
|
@ -405,6 +410,7 @@ CPP_TEST_CASES += \
|
|||
template_basic \
|
||||
template_base_template \
|
||||
template_classes \
|
||||
template_class_reuse_name \
|
||||
template_const_ref \
|
||||
template_construct \
|
||||
template_templated_constructors \
|
||||
|
|
@ -486,6 +492,7 @@ CPP_TEST_CASES += \
|
|||
throw_exception \
|
||||
typedef_array_member \
|
||||
typedef_class \
|
||||
typedef_classforward_same_name \
|
||||
typedef_funcptr \
|
||||
typedef_inherit \
|
||||
typedef_mptr \
|
||||
|
|
@ -506,6 +513,7 @@ CPP_TEST_CASES += \
|
|||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_template_parm_typedef \
|
||||
typemap_template_typedef \
|
||||
typemap_out_optimal \
|
||||
typemap_qualifier_strip \
|
||||
typemap_variables \
|
||||
|
|
@ -534,6 +542,7 @@ CPP_TEST_CASES += \
|
|||
varargs_overload \
|
||||
variable_replacement \
|
||||
virtual_destructor \
|
||||
virtual_derivation \
|
||||
virtual_poly \
|
||||
virtual_vs_nonvirtual_base \
|
||||
voidtest \
|
||||
|
|
@ -650,6 +659,7 @@ C_TEST_CASES += \
|
|||
char_constant \
|
||||
const_const \
|
||||
constant_expr \
|
||||
default_args_c \
|
||||
empty_c \
|
||||
enums \
|
||||
enum_forward \
|
||||
|
|
@ -692,6 +702,7 @@ C_TEST_CASES += \
|
|||
string_simple \
|
||||
struct_rename \
|
||||
struct_initialization \
|
||||
typedef_classforward_same_name \
|
||||
typedef_struct \
|
||||
typemap_subst \
|
||||
union_parameter \
|
||||
|
|
|
|||
|
|
@ -14,31 +14,53 @@
|
|||
%template(VectorStdCplx) std::vector<std::complex<double> >;
|
||||
#endif
|
||||
|
||||
%inline
|
||||
%inline
|
||||
{
|
||||
std::complex<double> Conj(const std::complex<double>& a)
|
||||
std::complex<double> Conj(std::complex<double> a)
|
||||
{
|
||||
return std::conj(a);
|
||||
}
|
||||
}
|
||||
|
||||
std::complex<float> Conjf(const std::complex<float>& a)
|
||||
std::complex<float> Conjf(std::complex<float> a)
|
||||
{
|
||||
return std::conj(a);
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
std::vector<std::complex<double> > Copy_h(const std::vector<std::complex<double> >& a)
|
||||
std::vector<std::complex<double> > CopyHalf(std::vector<std::complex<double> > a)
|
||||
{
|
||||
std::vector<std::complex<double> > b(a.size()/2);
|
||||
std::copy(a.begin(), a.begin()+a.size()/2, b.begin());
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct ComplexPair
|
||||
{
|
||||
std::complex<double> z1, z2;
|
||||
std::complex<double> z1;
|
||||
complex<double> z2;
|
||||
};
|
||||
|
||||
const complex<double>& Conj2(const complex<double>& a)
|
||||
{
|
||||
static complex<double> ret;
|
||||
ret = std::conj(a);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const complex<float>& Conjf2(const complex<float>& a)
|
||||
{
|
||||
static complex<float> ret;
|
||||
ret = std::conj(a);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const vector<complex<double> >& CopyHalfRef(const vector<complex<double> >& a)
|
||||
{
|
||||
static vector<complex<double> > b;
|
||||
b = CopyHalf(a);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -48,7 +70,7 @@
|
|||
%{
|
||||
%}
|
||||
|
||||
%inline
|
||||
%inline
|
||||
{
|
||||
complex Conj(complex a)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
%module(directors="1") cpp11_directors
|
||||
%feature("director");
|
||||
|
||||
%{
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() noexcept {}
|
||||
virtual int ping() noexcept = 0;
|
||||
virtual int pong() noexcept = 0;
|
||||
virtual int pang() const& noexcept = 0;
|
||||
virtual int peng() & noexcept = 0;
|
||||
virtual int pung() & = 0;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() noexcept {}
|
||||
virtual int ping() noexcept = 0;
|
||||
virtual int pong() noexcept = 0;
|
||||
};
|
||||
|
|
@ -6,6 +6,16 @@
|
|||
%warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final'
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override'
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
struct Base {
|
||||
|
|
@ -131,3 +141,12 @@ void DerivedNoVirtualStruct::cd() {}
|
|||
void DerivedNoVirtualStruct::ef() {}
|
||||
DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {}
|
||||
%}
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@
|
|||
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::lambda19;
|
||||
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20;
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
/* Defined lambda function with return value. */
|
||||
auto lambda1 = [](int x, int y) -> int { return x+y; };
|
||||
|
|
@ -105,3 +115,11 @@ int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
|||
void lambda_init(int = ([=]{ return 0; })());
|
||||
%}
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
class Foo
|
||||
{
|
||||
int m;
|
||||
public:
|
||||
Foo(int i) : m(i) {}
|
||||
int get_m() { return m;}
|
||||
int m;
|
||||
};
|
||||
|
||||
std::shared_ptr<Foo> foo(Foo v) {
|
||||
|
|
@ -45,10 +45,10 @@ std::vector<std::shared_ptr<const Foo> > const_foo_vec(Foo v) {
|
|||
|
||||
class Foo
|
||||
{
|
||||
int m;
|
||||
public:
|
||||
Foo(int i);
|
||||
int get_m();
|
||||
int m;
|
||||
};
|
||||
std::shared_ptr<Foo> foo(Foo v);
|
||||
std::shared_ptr<const Foo> const_foo(Foo v);
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ class C;
|
|||
%inline %{
|
||||
|
||||
class C {
|
||||
int m;
|
||||
public:
|
||||
C() : m(-1) {}
|
||||
C(int i) : m(i) {}
|
||||
int get_m() { return m; }
|
||||
int m;
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
89
Examples/test-suite/cpp11_shared_ptr_overload.i
Normal file
89
Examples/test-suite/cpp11_shared_ptr_overload.i
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
%module cpp11_shared_ptr_overload
|
||||
|
||||
// Tests to ensure valid overloading in C++ between shared_ptr and other types result in code that compiles
|
||||
// and all but the 1st overloaded method are automatically ignored/shadowed.
|
||||
// Tests the 'equivalent' attribute in the 'typecheck' typemap.
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_shared_ptr.i>
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseA(std::shared_ptr<MyType> mytype);
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseB(int, std::shared_ptr<MyType> mytype);
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseC(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>);
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseX(MyType &mytype);
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseY(int, MyType &mytype);
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseZ(int, MyType &mytype, std::shared_ptr<MyType>);
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo1;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo2;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo3;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo4;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo5;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo6;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo7;
|
||||
|
||||
%shared_ptr(MyType);
|
||||
|
||||
%inline %{
|
||||
#include <memory>
|
||||
#include <string>
|
||||
struct MyType {
|
||||
std::string val;
|
||||
MyType(std::string val = std::string()) : val(val) {}
|
||||
};
|
||||
|
||||
// ref
|
||||
std::string UseA(MyType &mytype) { return mytype.val + " ref"; }
|
||||
std::string UseA(std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
|
||||
|
||||
std::string UseB(int, MyType &mytype) { return mytype.val + " ref"; }
|
||||
std::string UseB(int, std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
|
||||
|
||||
std::string UseC(int, MyType &mytype, std::shared_ptr<MyType>) { return mytype.val + " ref"; }
|
||||
std::string UseC(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>) { return mytype->val + " sharedptr"; }
|
||||
|
||||
// sharedptr
|
||||
std::string UseX(std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
|
||||
std::string UseX(MyType &mytype) { return mytype.val + " ref"; }
|
||||
|
||||
std::string UseY(int, std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
|
||||
std::string UseY(int, MyType &mytype) { return mytype.val + " ref"; }
|
||||
|
||||
std::string UseZ(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>) { return mytype->val + " sharedptr"; }
|
||||
std::string UseZ(int, MyType &mytype, std::shared_ptr<MyType>) { return mytype.val + " ref"; }
|
||||
|
||||
// Combo1-4
|
||||
std::string Combo1(MyType mytype) { return mytype.val + "Combo1"; }
|
||||
std::string Combo1(MyType *mytype) { return ""; }
|
||||
std::string Combo1(std::shared_ptr<MyType> mytype) { return ""; }
|
||||
std::string Combo1(std::shared_ptr<MyType>* mytype) { return ""; }
|
||||
|
||||
std::string Combo2(MyType *mytype) { return mytype->val + "Combo2"; }
|
||||
std::string Combo2(std::shared_ptr<MyType> mytype) { return ""; }
|
||||
std::string Combo2(std::shared_ptr<MyType>* mytype) { return ""; }
|
||||
std::string Combo2(MyType mytype) { return ""; }
|
||||
|
||||
std::string Combo3(std::shared_ptr<MyType> mytype) { return mytype->val + "Combo3"; }
|
||||
std::string Combo3(std::shared_ptr<MyType>* mytype) { return ""; }
|
||||
std::string Combo3(MyType mytype) { return ""; }
|
||||
std::string Combo3(MyType *mytype) { return ""; }
|
||||
|
||||
std::string Combo4(std::shared_ptr<MyType>* mytype) { return (*mytype)->val + "Combo4"; }
|
||||
std::string Combo4(MyType mytype) { return ""; }
|
||||
std::string Combo4(MyType *mytype) { return ""; }
|
||||
std::string Combo4(std::shared_ptr<MyType> mytype) { return ""; }
|
||||
|
||||
// Combo5-7
|
||||
std::string Combo5(MyType &mytype) { return mytype.val + "Combo5"; }
|
||||
std::string Combo5(MyType *mytype) { return ""; }
|
||||
std::string Combo5(std::shared_ptr<MyType> mytype) { return ""; }
|
||||
|
||||
std::string Combo6(MyType *mytype) { return mytype->val + "Combo6"; }
|
||||
std::string Combo6(std::shared_ptr<MyType> mytype) { return ""; }
|
||||
std::string Combo6(MyType &mytype) { return ""; }
|
||||
|
||||
std::string Combo7(std::shared_ptr<MyType> mytype) { return mytype->val + "Combo7"; }
|
||||
std::string Combo7(MyType &mytype) { return ""; }
|
||||
std::string Combo7(MyType *mytype) { return ""; }
|
||||
%}
|
||||
|
|
@ -16,19 +16,19 @@
|
|||
%{
|
||||
|
||||
class Base {
|
||||
int m;
|
||||
public:
|
||||
Base() : m(-1) {}
|
||||
Base(int i) : m(i) {}
|
||||
int get_m() { return m; }
|
||||
int m;
|
||||
};
|
||||
|
||||
class Derived : public Base {
|
||||
int n;
|
||||
public:
|
||||
Derived() : n(-2) {}
|
||||
Derived(int i) : n(i) {}
|
||||
int get_n() { return n; }
|
||||
int n;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Base> BasePtr;
|
||||
|
|
@ -96,18 +96,18 @@ int base_num(std::map<int, BasePtr > v) {
|
|||
%template(DerivedMap) std::map<int, std::shared_ptr<Derived> >;
|
||||
|
||||
class Base {
|
||||
int m;
|
||||
public:
|
||||
Base();
|
||||
int get_m();
|
||||
int m;
|
||||
};
|
||||
|
||||
class Derived : public Base {
|
||||
int n;
|
||||
public:
|
||||
Derived();
|
||||
Derived(int i);
|
||||
int get_n();
|
||||
int n;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Base> BasePtr;
|
||||
|
|
@ -135,20 +135,20 @@ int base_num(std::map<int, BasePtr > v);
|
|||
|
||||
%inline %{
|
||||
class Base2 {
|
||||
int m;
|
||||
public:
|
||||
Base2() : m(-1) {}
|
||||
Base2(int i) : m(i) {}
|
||||
int get_m() { return m; }
|
||||
int m;
|
||||
};
|
||||
|
||||
|
||||
class Derived2 : public Base2 {
|
||||
int n;
|
||||
public:
|
||||
Derived2() : n(0) {}
|
||||
Derived2(int i) : n(i) {}
|
||||
int get_n_2() { return n; }
|
||||
int n;
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ CPP_TEST_CASES = \
|
|||
li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_shared_ptr_const \
|
||||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_overload \
|
||||
cpp11_shared_ptr_upcast \
|
||||
cpp11_strongly_typed_enumerations_simple \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
|
|
|||
|
|
@ -16,14 +16,23 @@ public class complextest_runme {
|
|||
if ( complextest.Conjf(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<float> test failed");
|
||||
|
||||
if ( complextest.Conj2(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<double> test failed");
|
||||
|
||||
if ( complextest.Conjf2(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<float> test failed");
|
||||
|
||||
var vec = new VectorStdCplx();
|
||||
vec.Add(new Complex(1, 2));
|
||||
vec.Add(new Complex(2, 3));
|
||||
vec.Add(new Complex(4, 3));
|
||||
vec.Add(new Complex(1, 0));
|
||||
|
||||
if ( complextest.Copy_h(vec).Count != 2 )
|
||||
throw new Exception("vector<complex> test failed");
|
||||
if ( complextest.CopyHalf(vec).Count != 2 )
|
||||
throw new Exception("CopyHalf test failed");
|
||||
|
||||
if ( complextest.CopyHalfRef(vec).Count != 2 )
|
||||
throw new Exception("CopyHalfRef test failed");
|
||||
|
||||
var p = new ComplexPair();
|
||||
p.z1 = new Complex(0, 1);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Expected output if PrintDebug enabled:
|
|||
Base - Val(444.555)
|
||||
Base - Ref(444.555)
|
||||
Base - Ptr(444.555)
|
||||
Base - ConstPtrRef(444.555)
|
||||
Base - FullyOverloaded(int 10)
|
||||
Base - FullyOverloaded(bool 1)
|
||||
Base - SemiOverloaded(int -678)
|
||||
|
|
@ -26,6 +27,7 @@ Base - DefaultParms(10, 1.1)
|
|||
Derived - Val(444.555)
|
||||
Derived - Ref(444.555)
|
||||
Derived - Ptr(444.555)
|
||||
Derived - ConstPtrRef(444.555)
|
||||
Derived - FullyOverloaded(int 10)
|
||||
Derived - FullyOverloaded(bool 1)
|
||||
Derived - SemiOverloaded(int -678)
|
||||
|
|
@ -36,6 +38,7 @@ Derived - DefaultParms(10, 1.1)
|
|||
CSharpDerived - Val(444.555)
|
||||
CSharpDerived - Ref(444.555)
|
||||
CSharpDerived - Ptr(444.555)
|
||||
CSharpDerived - ConstPtrRef(444.555)
|
||||
CSharpDerived - FullyOverloaded(int 10)
|
||||
CSharpDerived - FullyOverloaded(bool True)
|
||||
CSharpDerived - SemiOverloaded(-678)
|
||||
|
|
@ -59,7 +62,7 @@ public class runme
|
|||
|
||||
void run()
|
||||
{
|
||||
if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------ ");
|
||||
if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------");
|
||||
|
||||
Caller myCaller = new Caller();
|
||||
|
||||
|
|
@ -85,7 +88,7 @@ public class runme
|
|||
makeCalls(myCaller, myBase);
|
||||
}
|
||||
|
||||
if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
|
||||
if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------");
|
||||
}
|
||||
|
||||
void makeCalls(Caller myCaller, Base myBase)
|
||||
|
|
@ -99,6 +102,7 @@ public class runme
|
|||
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("failed");
|
||||
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("failed");
|
||||
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("failed");
|
||||
if (myCaller.ConstPtrRefCall(dh).val != dh.val) throw new Exception("failed");
|
||||
|
||||
// Fully overloaded method test (all methods in base class are overloaded)
|
||||
if (NAMESPACE + myCaller.FullyOverloadedCall(10) != myBase.GetType() + "::FullyOverloaded(int)") throw new Exception("failed");
|
||||
|
|
@ -142,6 +146,11 @@ public class CSharpDerived : Base
|
|||
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ptr({0})", x.val);
|
||||
return x;
|
||||
}
|
||||
public override DoubleHolder ConstPtrRef(DoubleHolder x)
|
||||
{
|
||||
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - ConstPtrRef({0})", x.val);
|
||||
return x;
|
||||
}
|
||||
public override String FullyOverloaded(int x)
|
||||
{
|
||||
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(int {0})", x);
|
||||
|
|
|
|||
111
Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs
Normal file
111
Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using li_boost_shared_ptr_directorNamespace;
|
||||
|
||||
public class li_boost_shared_ptr_director_runme {
|
||||
|
||||
private static void check(int got, int expected) {
|
||||
if (got != expected)
|
||||
throw new Exception("Failed, got: " + got + " expected: " + expected);
|
||||
}
|
||||
|
||||
public static void Main() {
|
||||
Derived a = new Derived(false);
|
||||
Derived b = new Derived(true);
|
||||
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
|
||||
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
|
||||
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_value(a), 5);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_ref(a), 6);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer(a), 7);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref(a), 8);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value(a), 9);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref(a), 10);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer(a), 11);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref(a), 12);
|
||||
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_with_null(a), -2);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref_with_null(a), -3);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value_with_null(a), -4);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref_with_null(a), -5);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_with_null(a), -6);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
|
||||
private bool return_none;
|
||||
|
||||
public Derived(bool flag) : base() {
|
||||
this.return_none = flag;
|
||||
}
|
||||
|
||||
public override C ret_c_shared_ptr() {
|
||||
if (this.return_none)
|
||||
return null;
|
||||
else
|
||||
return new C();
|
||||
}
|
||||
|
||||
public override C ret_c_by_value() {
|
||||
return new C();
|
||||
}
|
||||
|
||||
public override int take_c_by_value(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
public override int take_c_by_ref(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
public override int take_c_by_pointer(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -2;
|
||||
}
|
||||
|
||||
public override int take_c_by_pointer_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -3;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_value(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -4;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -5;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_pointer(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -6;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_pointer_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -7;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -177,6 +177,17 @@ public class li_std_vector_runme {
|
|||
if (doubleArray[i] != dvCopy[i])
|
||||
throw new Exception("Copy constructor failed, index:" + i);
|
||||
}
|
||||
if (dvCopy.Count != doubleArray.Length)
|
||||
throw new Exception("Copy constructor lengths mismatch");
|
||||
|
||||
// ToArray test
|
||||
double[] dvArray = dv.ToArray();
|
||||
for (int i=0; i<doubleArray.Length; i++) {
|
||||
if (doubleArray[i] != dvArray[i])
|
||||
throw new Exception("ToArray failed, index:" + i);
|
||||
}
|
||||
if (dvArray.Length != doubleArray.Length)
|
||||
throw new Exception("ToArray lengths mismatch");
|
||||
}
|
||||
{
|
||||
// Repeat() test
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ CPP_TEST_CASES = \
|
|||
d_nativepointers \
|
||||
exception_partial_info
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_shared_ptr_const \
|
||||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_overload \
|
||||
cpp11_shared_ptr_upcast \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* Base - Val(444.555)
|
||||
* Base - Ref(444.555)
|
||||
* Base - Ptr(444.555)
|
||||
* Base - ConstPtrRef(444.555)
|
||||
* Base - FullyOverloaded(int 10)
|
||||
* Base - FullyOverloaded(bool 1)
|
||||
* Base - SemiOverloaded(int -678)
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
* Derived - Val(444.555)
|
||||
* Derived - Ref(444.555)
|
||||
* Derived - Ptr(444.555)
|
||||
* Derived - ConstPtrRef(444.555)
|
||||
* Derived - FullyOverloaded(int 10)
|
||||
* Derived - FullyOverloaded(bool 1)
|
||||
* Derived - SemiOverloaded(int -678)
|
||||
|
|
@ -38,6 +40,7 @@
|
|||
* DDerived - Val(444.555)
|
||||
* DDerived - Ref(444.555)
|
||||
* DDerived - Ptr(444.555)
|
||||
* DDerived - ConstPtrRef(444.555)
|
||||
* DDerived - FullyOverloaded(int 10)
|
||||
* DDerived - FullyOverloaded(bool True)
|
||||
* DDerived - SemiOverloaded(-678)
|
||||
|
|
@ -57,7 +60,7 @@ import director_classes.Derived;
|
|||
import director_classes.DoubleHolder;
|
||||
|
||||
void main() {
|
||||
if (PrintDebug) Stdout.formatln("------------ Start ------------ ");
|
||||
if (PrintDebug) Stdout.formatln("------------ Start ------------");
|
||||
|
||||
auto myCaller = new Caller();
|
||||
|
||||
|
|
@ -83,7 +86,7 @@ void main() {
|
|||
makeCalls(myCaller, myBase);
|
||||
}
|
||||
|
||||
if (PrintDebug) Stdout.formatln("------------ Finish ------------ ");
|
||||
if (PrintDebug) Stdout.formatln("------------ Finish ------------");
|
||||
}
|
||||
|
||||
void makeCalls(Caller myCaller, Base myBase) {
|
||||
|
|
@ -96,6 +99,7 @@ void makeCalls(Caller myCaller, Base myBase) {
|
|||
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("[1] failed");
|
||||
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("[2] failed");
|
||||
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("[3] failed");
|
||||
if (myCaller.ConstPtrRefCall(dh).val != dh.val) throw new Exception("[3] failed");
|
||||
|
||||
// Fully overloaded method test (all methods in base class are overloaded)
|
||||
if (myCaller.FullyOverloadedCall(10) != myBaseType ~ "::FullyOverloaded(int)") throw new Exception("[4] failed");
|
||||
|
|
@ -136,6 +140,11 @@ public class DDerived : Base {
|
|||
return x;
|
||||
}
|
||||
|
||||
public override DoubleHolder ConstPtrRef(DoubleHolder x) {
|
||||
if (PrintDebug) Stdout.formatln("DDerived - ConstPtrRef({0:d3})", x.val);
|
||||
return x;
|
||||
}
|
||||
|
||||
public override char[] FullyOverloaded(int x) {
|
||||
if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(int {0})", x);
|
||||
return "DDerived::FullyOverloaded(int)";
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* Base - Val(444.555)
|
||||
* Base - Ref(444.555)
|
||||
* Base - Ptr(444.555)
|
||||
* Base - ConstPtrRef(444.555)
|
||||
* Base - FullyOverloaded(int 10)
|
||||
* Base - FullyOverloaded(bool 1)
|
||||
* Base - SemiOverloaded(int -678)
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
* Derived - Val(444.555)
|
||||
* Derived - Ref(444.555)
|
||||
* Derived - Ptr(444.555)
|
||||
* Derived - ConstPtrRef(444.555)
|
||||
* Derived - FullyOverloaded(int 10)
|
||||
* Derived - FullyOverloaded(bool 1)
|
||||
* Derived - SemiOverloaded(int -678)
|
||||
|
|
@ -38,6 +40,7 @@
|
|||
* DDerived - Val(444.555)
|
||||
* DDerived - Ref(444.555)
|
||||
* DDerived - Ptr(444.555)
|
||||
* DDerived - ConstPtrRef(444.555)
|
||||
* DDerived - FullyOverloaded(int 10)
|
||||
* DDerived - FullyOverloaded(bool true)
|
||||
* DDerived - SemiOverloaded(-678)
|
||||
|
|
@ -58,7 +61,7 @@ import director_classes.Derived;
|
|||
import director_classes.DoubleHolder;
|
||||
|
||||
void main() {
|
||||
if (PrintDebug) writeln("------------ Start ------------ ");
|
||||
if (PrintDebug) writeln("------------ Start ------------");
|
||||
|
||||
auto myCaller = new Caller();
|
||||
|
||||
|
|
@ -84,7 +87,7 @@ void main() {
|
|||
makeCalls(myCaller, myBase);
|
||||
}
|
||||
|
||||
if (PrintDebug) writeln("------------ Finish ------------ ");
|
||||
if (PrintDebug) writeln("------------ Finish ------------");
|
||||
}
|
||||
|
||||
void makeCalls(Caller myCaller, Base myBase) {
|
||||
|
|
@ -97,6 +100,7 @@ void makeCalls(Caller myCaller, Base myBase) {
|
|||
enforce(myCaller.ValCall(dh).val == dh.val, "[1] failed");
|
||||
enforce(myCaller.RefCall(dh).val == dh.val, "[2] failed");
|
||||
enforce(myCaller.PtrCall(dh).val == dh.val, "[3] failed");
|
||||
enforce(myCaller.ConstPtrRefCall(dh).val == dh.val, "[3] failed");
|
||||
|
||||
// Fully overloaded method test (all methods in base class are overloaded)
|
||||
enforce(myCaller.FullyOverloadedCall(10) == myBaseType ~ "::FullyOverloaded(int)", "[4] failed");
|
||||
|
|
@ -137,6 +141,11 @@ public class DDerived : Base {
|
|||
return x;
|
||||
}
|
||||
|
||||
public override DoubleHolder ConstPtrRef(DoubleHolder x) {
|
||||
if (PrintDebug) writefln("DDerived - ConstPtrRef(%s)", x.val);
|
||||
return x;
|
||||
}
|
||||
|
||||
public override string FullyOverloaded(int x) {
|
||||
if (PrintDebug) writefln("DDerived - FullyOverloaded(int %s)", x);
|
||||
return "DDerived::FullyOverloaded(int)";
|
||||
|
|
|
|||
114
Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d
Normal file
114
Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
module li_boost_shared_ptr_director_runme;
|
||||
|
||||
import std.conv;
|
||||
import std.exception;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import li_boost_shared_ptr_director.li_boost_shared_ptr_director;
|
||||
import li_boost_shared_ptr_director.Base;
|
||||
import li_boost_shared_ptr_director.C;
|
||||
|
||||
void check(int got, int expected) {
|
||||
enforce(got == expected, "Failed. got: " ~ to!string(got) ~ " Expected: " ~ to!string(expected));
|
||||
}
|
||||
|
||||
void main() {
|
||||
Derived a = new Derived(false);
|
||||
Derived b = new Derived(true);
|
||||
|
||||
check(call_ret_c_shared_ptr(a), 1);
|
||||
check(call_ret_c_shared_ptr(b), -1);
|
||||
check(call_ret_c_by_value(a), 1);
|
||||
|
||||
check(call_ret_c_shared_ptr(a), 1);
|
||||
check(call_ret_c_shared_ptr(b), -1);
|
||||
check(call_ret_c_by_value(a), 1);
|
||||
|
||||
check(call_take_c_by_value(a), 5);
|
||||
check(call_take_c_by_ref(a), 6);
|
||||
check(call_take_c_by_pointer(a), 7);
|
||||
check(call_take_c_by_pointer_ref(a), 8);
|
||||
check(call_take_c_shared_ptr_by_value(a), 9);
|
||||
check(call_take_c_shared_ptr_by_ref(a), 10);
|
||||
check(call_take_c_shared_ptr_by_pointer(a), 11);
|
||||
check(call_take_c_shared_ptr_by_pointer_ref(a), 12);
|
||||
|
||||
check(call_take_c_by_pointer_with_null(a), -2);
|
||||
check(call_take_c_by_pointer_ref_with_null(a), -3);
|
||||
check(call_take_c_shared_ptr_by_value_with_null(a), -4);
|
||||
check(call_take_c_shared_ptr_by_ref_with_null(a), -5);
|
||||
check(call_take_c_shared_ptr_by_pointer_with_null(a), -6);
|
||||
check(call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
|
||||
}
|
||||
|
||||
public class Derived : Base {
|
||||
|
||||
private bool return_none;
|
||||
|
||||
public this(bool flag) {
|
||||
super();
|
||||
this.return_none = flag;
|
||||
}
|
||||
|
||||
public override C ret_c_shared_ptr() {
|
||||
if (this.return_none)
|
||||
return null;
|
||||
else
|
||||
return new C();
|
||||
}
|
||||
|
||||
public override C ret_c_by_value() {
|
||||
return new C();
|
||||
}
|
||||
|
||||
public override int take_c_by_value(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
public override int take_c_by_ref(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
public override int take_c_by_pointer(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -2;
|
||||
}
|
||||
|
||||
public override int take_c_by_pointer_ref(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -3;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_value(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -4;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_ref(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -5;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_pointer(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -6;
|
||||
}
|
||||
|
||||
public override int take_c_shared_ptr_by_pointer_ref(C c) {
|
||||
if (c !is null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -7;
|
||||
}
|
||||
|
||||
}
|
||||
30
Examples/test-suite/default_arg_expressions.i
Normal file
30
Examples/test-suite/default_arg_expressions.i
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
%module default_arg_expressions
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ptr;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) UsdGeomTokensPtr;
|
||||
%immutable UsdGeomTokens;
|
||||
|
||||
%inline %{
|
||||
struct Numbers {
|
||||
int val;
|
||||
int *ptr;
|
||||
Numbers() : val(), ptr(&val) {}
|
||||
};
|
||||
struct TfToken {
|
||||
Numbers val;
|
||||
Numbers *ptr;
|
||||
TfToken() : val(), ptr(&val) {}
|
||||
};
|
||||
struct Tokens {
|
||||
const TfToken face;
|
||||
const TfToken *pface;
|
||||
Tokens() : face(), pface(&face) {}
|
||||
};
|
||||
static Tokens UsdGeomTokens;
|
||||
static Tokens *UsdGeomTokensPtr = &UsdGeomTokens;
|
||||
void CreateMaterialBindSubset1(const Tokens &elementType = UsdGeomTokens) {}
|
||||
void CreateMaterialBindSubset2(int num = UsdGeomTokensPtr->pface->val.val) {}
|
||||
void CreateMaterialBindSubset3(int num = UsdGeomTokensPtr->pface->ptr->val) {}
|
||||
void CreateMaterialBindSubset4(int num = UsdGeomTokensPtr->face.val.val) {}
|
||||
//void CreateMaterialBindSubset5(int num = UsdGeomTokens.face.val.val) {}
|
||||
%}
|
||||
|
|
@ -28,6 +28,13 @@
|
|||
int value_perm(int first, int mode = 0640 | 0004) { return mode; }
|
||||
int value_m01(int first, int val = -01) { return val; }
|
||||
bool booltest2(bool x = 0 | 1) { return x; }
|
||||
int max_32bit_int1(int a = 0x7FFFFFFF) { return a; }
|
||||
int max_32bit_int2(int a = 2147483647) { return a; }
|
||||
int min_32bit_int1(int a = -0x80000000) { return a; }
|
||||
long long too_big_32bit_int1(long long a = 0x80000000) { return a; }
|
||||
long long too_big_32bit_int2(long long a = 2147483648LL) { return a; }
|
||||
long long too_small_32bit_int1(long long a = -0x80000001) { return a; }
|
||||
long long too_small_32bit_int2(long long a = -2147483649LL) { return a; }
|
||||
};
|
||||
|
||||
void doublevalue1(int first, double num = 0.0e-1) {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
%module default_args_c
|
||||
|
||||
%{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
// Suppress: use of logical '||' with constant operand
|
||||
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* Default arguments for C code */
|
||||
int foo1(int x = 42 || 3);
|
||||
int foo43(int x = 42 | 3);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::ConstPtrRef;
|
||||
|
||||
%module(directors="1") director_classes
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ public:
|
|||
virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Base - Val(" << x.val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Base - Ref(" << x.val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Base - Ptr(" << x->val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder *const& ConstPtrRef(DoubleHolder *const& cprx) { if (PrintDebug) std::cout << "Base - ConstPtrRef(" << cprx->val << ")" << std::endl; return cprx; }
|
||||
|
||||
virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(int " << x << ")" << std::endl; return "Base::FullyOverloaded(int)"; }
|
||||
virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(bool " << x << ")" << std::endl; return "Base::FullyOverloaded(bool)"; }
|
||||
|
|
@ -68,6 +70,7 @@ public:
|
|||
virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Derived - Val(" << x.val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Derived - Ref(" << x.val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Derived - Ptr(" << x->val << ")" << std::endl; return x; }
|
||||
virtual DoubleHolder *const& ConstPtrRef(DoubleHolder *const& cprx) { if (PrintDebug) std::cout << "Derived - ConstPtrRef(" << cprx->val << ")" << std::endl; return cprx; }
|
||||
|
||||
virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(int " << x << ")" << std::endl; return "Derived::FullyOverloaded(int)"; }
|
||||
virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(bool " << x << ")" << std::endl; return "Derived::FullyOverloaded(bool)"; }
|
||||
|
|
@ -99,6 +102,7 @@ public:
|
|||
DoubleHolder ValCall(DoubleHolder x) { return m_base->Val(x); }
|
||||
DoubleHolder& RefCall(DoubleHolder& x) { return m_base->Ref(x); }
|
||||
DoubleHolder* PtrCall(DoubleHolder* x) { return m_base->Ptr(x); }
|
||||
DoubleHolder *const& ConstPtrRefCall(DoubleHolder *const& cprx) { return m_base->ConstPtrRef(cprx); }
|
||||
std::string FullyOverloadedCall(int x) { return m_base->FullyOverloaded(x); }
|
||||
std::string FullyOverloadedCall(bool x) { return m_base->FullyOverloaded(x); }
|
||||
std::string SemiOverloadedCall(int x) { return m_base->SemiOverloaded(x); }
|
||||
|
|
|
|||
|
|
@ -20,14 +20,10 @@
|
|||
|
||||
#ifndef SWIG_DIRECTORS
|
||||
namespace Swig {
|
||||
class DirectorException {};
|
||||
class DirectorMethodException: public Swig::DirectorException {};
|
||||
class DirectorException {};
|
||||
class DirectorMethodException: public Swig::DirectorException {};
|
||||
}
|
||||
#ifndef SWIG_fail
|
||||
#define SWIG_fail
|
||||
#endif
|
||||
#endif /* !SWIG_DIRECTORS */
|
||||
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
|
@ -41,8 +37,8 @@ class DirectorMethodException: public Swig::DirectorException {};
|
|||
}
|
||||
|
||||
%exception {
|
||||
try { $action }
|
||||
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||
try { $action }
|
||||
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -56,8 +52,8 @@ class DirectorMethodException: public Swig::DirectorException {};
|
|||
}
|
||||
|
||||
%exception {
|
||||
try { $action }
|
||||
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||
try { $action }
|
||||
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -75,12 +71,12 @@ class DirectorMethodException: public Swig::DirectorException {};
|
|||
// Change back to old 2.0 default behavior
|
||||
|
||||
%feature("director:except") {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
// Dont clear exception, still be active when return to java execution
|
||||
// Essentially ignore exception occurred -- old behavior.
|
||||
return $null;
|
||||
}
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
// Dont clear exception, still be active when return to java execution
|
||||
// Essentially ignore exception occurred -- old behavior.
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
25
Examples/test-suite/director_exception_catches.i
Normal file
25
Examples/test-suite/director_exception_catches.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%module(directors="1") director_exception_catches
|
||||
|
||||
%include <std_string.i>
|
||||
%feature("director") BaseClass;
|
||||
|
||||
%{
|
||||
// define dummy director exception classes to prevent spurious errors
|
||||
// in target languages that do not support directors.
|
||||
|
||||
#ifndef SWIG_DIRECTORS
|
||||
namespace Swig {
|
||||
class DirectorException {};
|
||||
}
|
||||
#endif /* !SWIG_DIRECTORS */
|
||||
%}
|
||||
|
||||
%catches(Swig::DirectorException) BaseClass::call_description;
|
||||
|
||||
%inline %{
|
||||
struct BaseClass {
|
||||
virtual std::string description() const = 0;
|
||||
static std::string call_description(BaseClass& bc) { return bc.description(); }
|
||||
virtual ~BaseClass() {}
|
||||
};
|
||||
%}
|
||||
72
Examples/test-suite/director_ownership.i
Normal file
72
Examples/test-suite/director_ownership.i
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
%module(directors="1") director_ownership
|
||||
|
||||
// Github issue #1184
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
%feature("director") example::ContentBase;
|
||||
%feature("director") example::ContentDerived;
|
||||
|
||||
%newobject example::make_content;
|
||||
|
||||
%inline %{
|
||||
#include <string>
|
||||
|
||||
namespace example
|
||||
{
|
||||
|
||||
class ContentBase
|
||||
{
|
||||
public:
|
||||
ContentBase() {}
|
||||
virtual ~ContentBase() {}
|
||||
virtual std::string get_name() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class ContentDerived: public ContentBase
|
||||
{
|
||||
public:
|
||||
ContentDerived():ContentBase() { m_name = "ContentDerived"; }
|
||||
virtual ~ContentDerived() {}
|
||||
virtual std::string get_name() const { return m_name; }
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
class Container
|
||||
{
|
||||
public:
|
||||
Container() { m_content = 0; }
|
||||
~Container()
|
||||
{
|
||||
clear_content();
|
||||
}
|
||||
// the container takes the ownership of the content
|
||||
void set_content(ContentBase* content)
|
||||
{
|
||||
clear_content();
|
||||
m_content = content;
|
||||
}
|
||||
ContentBase* get_content() { return m_content; }
|
||||
|
||||
private:
|
||||
void clear_content()
|
||||
{
|
||||
if(m_content)
|
||||
{
|
||||
delete m_content;
|
||||
m_content = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ContentBase* m_content;
|
||||
};
|
||||
|
||||
static ContentBase* make_content() { return new ContentDerived(); }
|
||||
|
||||
} // namespace example
|
||||
%}
|
||||
4
Examples/test-suite/errors/cpp_invalid_exponents1.i
Normal file
4
Examples/test-suite/errors/cpp_invalid_exponents1.i
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
%module xxx
|
||||
|
||||
void bad(double nn = 5e);
|
||||
|
||||
2
Examples/test-suite/errors/cpp_invalid_exponents1.stderr
Normal file
2
Examples/test-suite/errors/cpp_invalid_exponents1.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cpp_invalid_exponents1.i:3: Error: Exponent does not have any digits
|
||||
cpp_invalid_exponents1.i:3: Error: Syntax error in input(1).
|
||||
4
Examples/test-suite/errors/cpp_invalid_exponents2.i
Normal file
4
Examples/test-suite/errors/cpp_invalid_exponents2.i
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
%module xxx
|
||||
|
||||
void bad(double nn = 6.6e);
|
||||
|
||||
2
Examples/test-suite/errors/cpp_invalid_exponents2.stderr
Normal file
2
Examples/test-suite/errors/cpp_invalid_exponents2.stderr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cpp_invalid_exponents2.i:3: Error: Exponent does not have any digits
|
||||
cpp_invalid_exponents2.i:3: Error: Syntax error in input(1).
|
||||
51
Examples/test-suite/errors/cpp_template_duplicate_names.i
Normal file
51
Examples/test-suite/errors/cpp_template_duplicate_names.i
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
%module cpp_template_duplicate_names
|
||||
|
||||
// From test-suite/template_class_reuse.i test
|
||||
|
||||
%{
|
||||
namespace Space {
|
||||
template <bool B> struct Duplicate1 { void f(){}; };
|
||||
}
|
||||
%}
|
||||
|
||||
// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate1;
|
||||
namespace Space {
|
||||
template <bool B> struct Duplicate1 { void f(){}; };
|
||||
template <bool B> struct Duplicate1 { void f(){}; };
|
||||
}
|
||||
|
||||
|
||||
// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate2;
|
||||
%inline %{
|
||||
namespace Space {
|
||||
template <int I> struct Duplicate2 { void n(){}; };
|
||||
}
|
||||
%}
|
||||
%template(Duplicate2_0) Space::Duplicate2<0>;
|
||||
%template(Duplicate2_0) Space::Duplicate2<0>;
|
||||
|
||||
|
||||
// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate3;
|
||||
%inline %{
|
||||
namespace Space {
|
||||
template <int I> struct Duplicate3 { void n(){}; };
|
||||
}
|
||||
%}
|
||||
%template(Duplicate3) Space::Duplicate3<0>;
|
||||
%template(Duplicate3) Space::Duplicate3<0>;
|
||||
|
||||
|
||||
%{
|
||||
namespace Space {
|
||||
template <bool B> struct Duplicate4 { void f(){}; };
|
||||
}
|
||||
%}
|
||||
|
||||
// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate4;
|
||||
namespace Space {
|
||||
template <bool B> struct Duplicate4 { void f(){}; };
|
||||
template <bool B> struct Duplicate4 { void f(){}; };
|
||||
}
|
||||
%template(Duplicate4) Space::Duplicate4<0>;
|
||||
%template(Duplicate4) Space::Duplicate4<0>;
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
|
||||
cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
|
||||
cpp_template_duplicate_names.i:25: Warning 302: Identifier 'Duplicate2_0' redefined (ignored) (Renamed from 'Duplicate2< 0 >'),
|
||||
cpp_template_duplicate_names.i:24: Warning 302: previous definition of 'Duplicate2_0' (Renamed from 'Duplicate2< 0 >').
|
||||
cpp_template_duplicate_names.i:35: Warning 302: Identifier 'Duplicate3' redefined (ignored) (Renamed from 'Duplicate3< 0 >'),
|
||||
cpp_template_duplicate_names.i:31: Warning 302: previous definition of 'Duplicate3'.
|
||||
cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
cpp_template_duplicate_names.i:50: Warning 302: Identifier 'Duplicate4' redefined (ignored) (Renamed from 'Duplicate4< 0 >'),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
43
Examples/test-suite/errors/pp_expressions_bad.i
Normal file
43
Examples/test-suite/errors/pp_expressions_bad.i
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
%module xxx
|
||||
/* Note: needs -Wextra to see these warnings */
|
||||
|
||||
/* Divide by zero */
|
||||
#define ZERO 0
|
||||
|
||||
#if 1%ZERO
|
||||
#endif
|
||||
#if 2/ZERO
|
||||
#endif
|
||||
|
||||
#if 1%(5-5)
|
||||
#endif
|
||||
#if 2/(55-55)
|
||||
#endif
|
||||
|
||||
/* Floating point */
|
||||
#if 1.2
|
||||
#endif
|
||||
|
||||
#if 2e3
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#elif 8.8
|
||||
#endif
|
||||
|
||||
/* Missing whitespace after preproc directive */
|
||||
#if123
|
||||
#endif
|
||||
|
||||
#if456e
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#warning This should not warn
|
||||
#elif1
|
||||
#warning This should also not warn
|
||||
#endif
|
||||
|
||||
#if(1)
|
||||
#warning Warning okay: #if(1)
|
||||
#endif
|
||||
19
Examples/test-suite/errors/pp_expressions_bad.stderr
Normal file
19
Examples/test-suite/errors/pp_expressions_bad.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '1%ZERO'
|
||||
pp_expressions_bad.i:7: Warning 202: Error: 'Modulo by zero in expression'
|
||||
pp_expressions_bad.i:9: Warning 202: Could not evaluate expression '2/ZERO'
|
||||
pp_expressions_bad.i:9: Warning 202: Error: 'Division by zero in expression'
|
||||
pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '1%(5-5)'
|
||||
pp_expressions_bad.i:12: Warning 202: Error: 'Modulo by zero in expression'
|
||||
pp_expressions_bad.i:14: Warning 202: Could not evaluate expression '2/(55-55)'
|
||||
pp_expressions_bad.i:14: Warning 202: Error: 'Division by zero in expression'
|
||||
pp_expressions_bad.i:18: Warning 202: Could not evaluate expression '1.2'
|
||||
pp_expressions_bad.i:18: Warning 202: Error: 'Floating point constant in preprocessor expression'
|
||||
pp_expressions_bad.i:21: Warning 202: Could not evaluate expression '2e3'
|
||||
pp_expressions_bad.i:21: Warning 202: Error: 'Floating point constant in preprocessor expression'
|
||||
pp_expressions_bad.i:25: Warning 202: Could not evaluate expression '8.8'
|
||||
pp_expressions_bad.i:25: Warning 202: Error: 'Floating point constant in preprocessor expression'
|
||||
pp_expressions_bad.i:29: Error: Unknown SWIG preprocessor directive: if123 (if this is a block of target language code, delimit it with %{ and %})
|
||||
pp_expressions_bad.i:30: Error: Extraneous #endif.
|
||||
pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %})
|
||||
pp_expressions_bad.i:33: Error: Extraneous #endif.
|
||||
pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)".
|
||||
7
Examples/test-suite/errors/pp_invalid_exponents.i
Normal file
7
Examples/test-suite/errors/pp_invalid_exponents.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module xxx
|
||||
|
||||
#if 123e
|
||||
#endif
|
||||
|
||||
#if 456.e
|
||||
#endif
|
||||
6
Examples/test-suite/errors/pp_invalid_exponents.stderr
Normal file
6
Examples/test-suite/errors/pp_invalid_exponents.stderr
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:EOF: Error: Exponent does not have any digits
|
||||
pp_invalid_exponents.i:3: Warning 202: Could not evaluate expression '123e'
|
||||
pp_invalid_exponents.i:3: Warning 202: Error: 'Syntax error'
|
||||
:EOF: Error: Exponent does not have any digits
|
||||
pp_invalid_exponents.i:6: Warning 202: Could not evaluate expression '456.e'
|
||||
pp_invalid_exponents.i:6: Warning 202: Error: 'Syntax error'
|
||||
|
|
@ -6,6 +6,10 @@
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
|
|
@ -49,3 +53,11 @@ class Impl
|
|||
#warning "UTL needs fixing for partial exception information"
|
||||
#endif
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
(check (=~ (foo 1 2 "bar" 4) 15))
|
||||
|
||||
;; Check second method
|
||||
(check (=~ (foo 1 2) 4811.4))
|
||||
(check (=~ (foo 1 2 3.2) 4797.2))
|
||||
(check (=~ (foo 1 2 3.2 #\Q) 4798.2))
|
||||
(check (=~ (foo 1 2) 118))
|
||||
(check (=~ (foo 1 2 3.2) 104))
|
||||
(check (=~ (foo 1 2 3.2 #\Q) 4798))
|
||||
|
||||
(exit 0)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ template<class T> class vector {
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
|
||||
#endif
|
||||
|
||||
class Base {
|
||||
public:
|
||||
|
|
@ -70,6 +74,9 @@ public:
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#if __GNUC__ >= 7
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
%}
|
||||
|
||||
%template(maxint) maximum<int>;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ CPP_TEST_CASES = \
|
|||
# li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_shared_ptr_const \
|
||||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_overload \
|
||||
cpp11_shared_ptr_upcast \
|
||||
cpp11_strongly_typed_enumerations_simple \
|
||||
|
||||
DOXYGEN_TEST_CASES := \
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class class_scope_namespace_runme {
|
|||
F f = new F();
|
||||
G g = new G();
|
||||
H.HH h = new H.HH();
|
||||
I.II i = new I.II();
|
||||
I_.II i = new I_.II();
|
||||
J j = new J();
|
||||
K k = new K();
|
||||
L l = new L();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
import cpp11_shared_ptr_overload.*;
|
||||
|
||||
public class cpp11_shared_ptr_overload_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_shared_ptr_overload");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
String ret = null;
|
||||
|
||||
// ref
|
||||
ret = cpp11_shared_ptr_overload.UseA(new MyType("123"));
|
||||
if (!ret.equals("123 ref")) throw new RuntimeException("UseA fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.UseB(0, new MyType("123"));
|
||||
if (!ret.equals("123 ref")) throw new RuntimeException("UseB fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.UseC(0, new MyType("123"), new MyType("456"));
|
||||
if (!ret.equals("123 ref")) throw new RuntimeException("UseC fail:" + ret);
|
||||
|
||||
// sharedptr
|
||||
ret = cpp11_shared_ptr_overload.UseX(new MyType("123"));
|
||||
if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseX fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.UseY(0, new MyType("123"));
|
||||
if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseY fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.UseZ(0, new MyType("123"), new MyType("456"));
|
||||
if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseZ fail:" + ret);
|
||||
|
||||
// Combo1-4
|
||||
ret = cpp11_shared_ptr_overload.Combo1(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo1")) throw new RuntimeException("Combo1 fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.Combo2(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo2")) throw new RuntimeException("Combo2 fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.Combo3(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo3")) throw new RuntimeException("Combo3 fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.Combo4(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo4")) throw new RuntimeException("Combo4 fail:" + ret);
|
||||
|
||||
// Combo5-7
|
||||
ret = cpp11_shared_ptr_overload.Combo5(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo5")) throw new RuntimeException("Combo5 fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.Combo6(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo6")) throw new RuntimeException("Combo6 fail:" + ret);
|
||||
|
||||
ret = cpp11_shared_ptr_overload.Combo7(new MyType("XXX"));
|
||||
if (!ret.equals("XXXCombo7")) throw new RuntimeException("Combo7 fail:" + ret);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ Expected output if PrintDebug enabled:
|
|||
Base - Val(444.555)
|
||||
Base - Ref(444.555)
|
||||
Base - Ptr(444.555)
|
||||
Base - ConstPtrRef(444.555)
|
||||
Base - FullyOverloaded(int 10)
|
||||
Base - FullyOverloaded(bool 1)
|
||||
Base - SemiOverloaded(int -678)
|
||||
|
|
@ -26,6 +27,7 @@ Base - DefaultParms(10, 1.1)
|
|||
Derived - Val(444.555)
|
||||
Derived - Ref(444.555)
|
||||
Derived - Ptr(444.555)
|
||||
Derived - ConstPtrRef(444.555)
|
||||
Derived - FullyOverloaded(int 10)
|
||||
Derived - FullyOverloaded(bool 1)
|
||||
Derived - SemiOverloaded(int -678)
|
||||
|
|
@ -36,6 +38,7 @@ Derived - DefaultParms(10, 1.1)
|
|||
JavaDerived - Val(444.555)
|
||||
JavaDerived - Ref(444.555)
|
||||
JavaDerived - Ptr(444.555)
|
||||
JavaDerived - ConstPtrRef(444.555)
|
||||
JavaDerived - FullyOverloaded(int 10)
|
||||
JavaDerived - FullyOverloaded(bool True)
|
||||
JavaDerived - SemiOverloaded(-678)
|
||||
|
|
@ -67,7 +70,7 @@ public class director_classes_runme {
|
|||
|
||||
void run()
|
||||
{
|
||||
if (director_classes.getPrintDebug()) System.out.println("------------ Start ------------ ");
|
||||
if (director_classes.getPrintDebug()) System.out.println("------------ Start ------------");
|
||||
|
||||
Caller myCaller = new Caller();
|
||||
|
||||
|
|
@ -96,7 +99,7 @@ public class director_classes_runme {
|
|||
myBase.delete();
|
||||
}
|
||||
|
||||
if (director_classes.getPrintDebug()) System.out.println("------------ Finish ------------ ");
|
||||
if (director_classes.getPrintDebug()) System.out.println("------------ Finish ------------");
|
||||
}
|
||||
|
||||
void makeCalls(Caller myCaller, Base myBase)
|
||||
|
|
@ -111,6 +114,7 @@ public class director_classes_runme {
|
|||
if (myCaller.ValCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
|
||||
if (myCaller.RefCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
|
||||
if (myCaller.PtrCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
|
||||
if (myCaller.ConstPtrRefCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
|
||||
|
||||
// Fully overloaded method test (all methods in base class are overloaded)
|
||||
if (!myCaller.FullyOverloadedCall(10).equals(baseSimpleName + "::FullyOverloaded(int)")) {
|
||||
|
|
@ -170,6 +174,11 @@ class JavaDerived extends Base
|
|||
if (director_classes.getPrintDebug()) System.out.println("JavaDerived - Ptr(" + x.getVal() + ")");
|
||||
return x;
|
||||
}
|
||||
public DoubleHolder ConstPtrRef(DoubleHolder x)
|
||||
{
|
||||
if (director_classes.getPrintDebug()) System.out.println("JavaDerived - ConstPtrRef(" + x.getVal() + ")");
|
||||
return x;
|
||||
}
|
||||
public String FullyOverloaded(int x)
|
||||
{
|
||||
if (director_classes.getPrintDebug()) System.out.println("JavaDerived - FullyOverloaded(int " + x + ")");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
import director_exception_catches.*;
|
||||
|
||||
public class director_exception_catches_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_exception_catches");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
BaseClass b = new director_exception_catches_MyClass();
|
||||
|
||||
try {
|
||||
String s = BaseClass.call_description(b);
|
||||
throw new RuntimeException("Failed to catch exception");
|
||||
} catch (NullPointerException e) {
|
||||
if (!e.getMessage().startsWith("Testing exception thrown in BaseClass.description"))
|
||||
throw new RuntimeException("Unexpected exception message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class director_exception_catches_MyClass extends BaseClass {
|
||||
@Override
|
||||
public String description() {
|
||||
throw new NullPointerException("Testing exception thrown in BaseClass.description");
|
||||
}
|
||||
}
|
||||
|
||||
42
Examples/test-suite/java/director_ownership_runme.java
Normal file
42
Examples/test-suite/java/director_ownership_runme.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import director_ownership.*;
|
||||
|
||||
public class director_ownership_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_ownership");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void set_content_and_release(Container container, ContentBase content) {
|
||||
content.swigReleaseOwnership();
|
||||
container.set_content(content);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
Container container = new Container();
|
||||
|
||||
// make a content in java (cMemoryOwn true)
|
||||
ContentBase content_java = new ContentDerived();
|
||||
|
||||
// make a content in c++ (cMemoryOwn true)
|
||||
ContentBase content_cpp = director_ownership.make_content();
|
||||
|
||||
set_content_and_release(container, content_java);
|
||||
if (!container.get_content().get_name().equals("ContentDerived"))
|
||||
throw new RuntimeException("did not get ContentDerived");
|
||||
|
||||
// when swigReleaseOwnership() is called on content_cpp, swig tries a static_cast to director and calls the method
|
||||
// director->swig_java_change_ownership. The content created in c++ native library is not a director, therefore a
|
||||
// segfault may occur.
|
||||
// With a check done using dynamic_cast this issue could be avoided.
|
||||
set_content_and_release(container, content_cpp);
|
||||
if (!container.get_content().get_name().equals("ContentDerived"))
|
||||
throw new RuntimeException("did not get ContentDerived");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,19 +126,28 @@ public class java_director_exception_feature_nspace_runme {
|
|||
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
|
||||
catch (MyJavaException1 e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
|
||||
catch (java_director_exception_feature_nspace_NewCheckedException e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
|
||||
catch (java_director_exception_feature_nspace_NewUncheckedException e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
|
||||
catch (RuntimeException e) {
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RuntimeException");
|
||||
failif( ! "Unspecified DirectorException message".equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -127,19 +127,28 @@ public class java_director_exception_feature_runme {
|
|||
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
|
||||
catch (MyJavaException1 e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
|
||||
catch (NewCheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
|
||||
catch (NewUncheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
failif( st.length != 5, "Stack length is only " + st.length);
|
||||
failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
|
||||
}
|
||||
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
|
||||
catch (RuntimeException e) {
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RuntimeException");
|
||||
failif( ! "Unspecified DirectorException message".equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,28 @@ public class java_throws_runme {
|
|||
if (!pass)
|
||||
throw new RuntimeException("Test 6 failed");
|
||||
|
||||
// Interface function
|
||||
pass = false;
|
||||
try {
|
||||
InterfaceTestImpl iti = new InterfaceTestImpl();
|
||||
iti.imethod(true);
|
||||
}
|
||||
catch (MyException e) { pass = true; }
|
||||
|
||||
if (!pass)
|
||||
throw new RuntimeException("Test interface 1 failed");
|
||||
|
||||
pass = false;
|
||||
try {
|
||||
InterfaceTestImpl iti = new InterfaceTestImpl();
|
||||
iti.imethod(false);
|
||||
pass = true;
|
||||
}
|
||||
catch (MyException e) { pass = false; }
|
||||
|
||||
if (!pass)
|
||||
throw new RuntimeException("Test interface 2 failed");
|
||||
|
||||
// Global function
|
||||
pass = false;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,60 +1,129 @@
|
|||
public class li_boost_shared_ptr_runme {
|
||||
import li_boost_shared_ptr_director.*;
|
||||
|
||||
public class li_boost_shared_ptr_director_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_boost_shared_ptr");
|
||||
System.loadLibrary("li_boost_shared_ptr_director");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(String got, String expected) {
|
||||
if (!got.equals(expected))
|
||||
private static void check(int got, int expected) {
|
||||
if (got != expected)
|
||||
throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
li_boost_shared_ptr_director_Derived a = li_boost_shared_ptr_director_Derived.new(false);
|
||||
li_boost_shared_ptr_director_Derived b = li_boost_shared_ptr_director_Derived.new(true);
|
||||
li_boost_shared_ptr_director_Derived a = new li_boost_shared_ptr_director_Derived(false);
|
||||
li_boost_shared_ptr_director_Derived b = new li_boost_shared_ptr_director_Derived(true);
|
||||
|
||||
check(call_ret_c_shared_ptr(a) == 1);
|
||||
check(call_ret_c_shared_ptr(b) == -1);
|
||||
check(call_ret_c_by_value(a) == 1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
|
||||
|
||||
check(call_take_c_by_value(a) == 5);
|
||||
check(call_take_c_shared_ptr_by_value(a) == 6);
|
||||
check(call_take_c_shared_ptr_by_ref(a) == 7);
|
||||
check(call_take_c_shared_ptr_by_pointer(a) == 8);
|
||||
check(call_take_c_shared_ptr_by_pointer_ref(a) == 9);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
|
||||
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
|
||||
|
||||
check(call_take_c_shared_ptr_by_value_with_null(a) == -2);
|
||||
check(call_take_c_shared_ptr_by_ref_with_null(a) == -3);
|
||||
check(call_take_c_shared_ptr_by_pointer_with_null(a) == -4);
|
||||
check(call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -5);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_value(a), 5);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_ref(a), 6);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer(a), 7);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref(a), 8);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value(a), 9);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref(a), 10);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer(a), 11);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref(a), 12);
|
||||
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_with_null(a), -2);
|
||||
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref_with_null(a), -3);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value_with_null(a), -4);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref_with_null(a), -5);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_with_null(a), -6);
|
||||
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
|
||||
}
|
||||
}
|
||||
|
||||
class li_boost_shared_ptr_director_Derived extends li_boost_shared_ptr_director.Base {
|
||||
class li_boost_shared_ptr_director_Derived extends Base {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "li_boost_shared_ptr_director_MyBarFoo.ping()";
|
||||
private boolean return_none;
|
||||
|
||||
li_boost_shared_ptr_director_Derived(boolean flag) {
|
||||
super();
|
||||
this.return_none = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pong() {
|
||||
return "li_boost_shared_ptr_director_MyBarFoo.pong();" + ping();
|
||||
public C ret_c_shared_ptr() {
|
||||
if (this.return_none)
|
||||
return null;
|
||||
else
|
||||
return new C();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upcall(li_boost_shared_ptr_director.FooBar fooBarPtr) {
|
||||
return "override;" + fooBarPtr.FooBarDo();
|
||||
public C ret_c_by_value() {
|
||||
return new C();
|
||||
}
|
||||
|
||||
@Override
|
||||
public li_boost_shared_ptr_director.Foo makeFoo() {
|
||||
return new li_boost_shared_ptr_director.Foo();
|
||||
public int take_c_by_value(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_by_ref(C c) {
|
||||
return c.get_m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_by_pointer(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_by_pointer_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_shared_ptr_by_value(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_shared_ptr_by_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_shared_ptr_by_pointer(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int take_c_shared_ptr_by_pointer_ref(C c) {
|
||||
if (c != null)
|
||||
return c.get_m();
|
||||
else
|
||||
return -7;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
import template_class_reuse_name.*;
|
||||
|
||||
public class template_class_reuse_name_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_class_reuse_name");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
new Bool1().tt();
|
||||
new Bool1False().ff();
|
||||
|
||||
new Bool2().tt();
|
||||
new Bool2False().ff();
|
||||
|
||||
new Bool3().tt();
|
||||
new Bool3False().ff();
|
||||
|
||||
new Bool4().tt();
|
||||
new Bool4False().ff();
|
||||
|
||||
|
||||
new BoolForward1().tt();
|
||||
new BoolForward1False().ff();
|
||||
|
||||
new BoolForward2().tt();
|
||||
new BoolForward2False().ff();
|
||||
|
||||
new BoolForward3().tt();
|
||||
new BoolForward3False().ff();
|
||||
|
||||
new BoolForward4().tt();
|
||||
new BoolForward4False().ff();
|
||||
|
||||
|
||||
new IntBool1().tt();
|
||||
new IntBool1False().ff();
|
||||
|
||||
new IntBool2().tt();
|
||||
new IntBool2False().ff();
|
||||
|
||||
new IntBool3().tt();
|
||||
new IntBool3False().ff();
|
||||
|
||||
new IntBool4().tt();
|
||||
new IntBool4False().ff();
|
||||
|
||||
new Duplicate2_0().n();
|
||||
new Duplicate3().n();
|
||||
}
|
||||
}
|
||||
|
|
@ -23,10 +23,10 @@ public class template_partial_specialization_runme {
|
|||
new G().g();
|
||||
new H().h();
|
||||
|
||||
new I().i();
|
||||
new J().j();
|
||||
new K().k();
|
||||
new L().l();
|
||||
new M().m();
|
||||
new N().n();
|
||||
|
||||
new BB().b();
|
||||
new BBB().b();
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ public class template_partial_specialization_typedef_runme {
|
|||
new G().g();
|
||||
new H().h();
|
||||
|
||||
new I().i();
|
||||
new J().j();
|
||||
new K().k();
|
||||
new L().l();
|
||||
new M().m();
|
||||
new N().n();
|
||||
|
||||
new BB().b();
|
||||
new BBB().b();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import typedef_classforward_same_name.*;
|
||||
|
||||
public class typedef_classforward_same_name_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("typedef_classforward_same_name");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
Foo foo = new Foo();
|
||||
foo.setX(5);
|
||||
if (typedef_classforward_same_name.extractFoo(foo) != 5)
|
||||
throw new RuntimeException("unexpected value");
|
||||
|
||||
Boo boo = new Boo();
|
||||
boo.setX(5);
|
||||
if (typedef_classforward_same_name.extractBoo(boo) != 5)
|
||||
throw new RuntimeException("unexpected value");
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,6 @@
|
|||
%feature("director:except") MyNS::Foo::ping {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear(); // clear java exception since mapping to c++ exception
|
||||
if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException1")) {
|
||||
throw 1;
|
||||
} else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException2")) {
|
||||
|
|
@ -71,7 +70,6 @@
|
|||
%feature("director:except") MyNS::Foo::pong %{
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
$directorthrowshandlers
|
||||
throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message());
|
||||
}
|
||||
|
|
@ -121,7 +119,10 @@
|
|||
%feature("director:except") MyNS::Foo::genericpong {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
if (Swig::ExceptionMatches(jenv,$error,"UnconstructableException")) {
|
||||
// Purposefully test NULL
|
||||
throw Swig::DirectorException(jenv, NULL);
|
||||
}
|
||||
throw Swig::DirectorException(jenv,$error);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,9 +132,10 @@
|
|||
%}
|
||||
|
||||
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
||||
try { $action }
|
||||
catch (Swig::DirectorException & direxcp) {
|
||||
direxcp.raiseJavaException(jenv); // jenv always available in JNI code
|
||||
try {
|
||||
$action
|
||||
} catch (Swig::DirectorException & direxcp) {
|
||||
direxcp.throwException(jenv); // jenv always available in JNI code
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@
|
|||
%feature("director:except") MyNS::Foo::ping {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear(); // clear java exception since mapping to c++ exception
|
||||
if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException1")) {
|
||||
throw 1;
|
||||
} else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException2")) {
|
||||
|
|
@ -78,7 +77,6 @@
|
|||
%feature("director:except") MyNS::Foo::pong %{
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
$directorthrowshandlers
|
||||
throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message());
|
||||
}
|
||||
|
|
@ -128,7 +126,10 @@
|
|||
%feature("director:except") MyNS::Foo::genericpong {
|
||||
jthrowable $error = jenv->ExceptionOccurred();
|
||||
if ($error) {
|
||||
jenv->ExceptionClear();
|
||||
if (Swig::ExceptionMatches(jenv,$error,"java_director_exception_feature_nspace_UnconstructibleException")) {
|
||||
// Purposefully test NULL
|
||||
throw Swig::DirectorException(jenv, NULL);
|
||||
}
|
||||
throw Swig::DirectorException(jenv,$error);
|
||||
}
|
||||
}
|
||||
|
|
@ -138,9 +139,10 @@
|
|||
%}
|
||||
|
||||
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
|
||||
try { $action }
|
||||
catch (Swig::DirectorException & direxcp) {
|
||||
direxcp.raiseJavaException(jenv); // jenv always available in JNI code
|
||||
try {
|
||||
$action
|
||||
} catch (Swig::DirectorException & direxcp) {
|
||||
direxcp.throwException(jenv); // jenv always available in JNI code
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,24 @@ JAVAEXCEPTION(FeatureTest::staticMethod)
|
|||
};
|
||||
%}
|
||||
|
||||
%include <swiginterface.i>
|
||||
%interface_impl(InterfaceTest);
|
||||
JAVAEXCEPTION(imethod)
|
||||
|
||||
%inline %{
|
||||
struct InterfaceTest {
|
||||
virtual void imethod(bool raise) = 0;
|
||||
virtual ~InterfaceTest() {}
|
||||
};
|
||||
|
||||
struct InterfaceTestImpl : InterfaceTest {
|
||||
void imethod(bool raise) {
|
||||
if (raise)
|
||||
throw MyException("raise message");
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
// Mixing except feature and typemaps when both generate a class for the throws clause
|
||||
%typemap(in, throws="ClassNotFoundException") int both {
|
||||
$1 = (int)$input;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,16 @@ a_c = complextest.Conj(a);
|
|||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conj(a)";
|
||||
|
||||
a_c_f = complextest.Conjf(a);
|
||||
if (a_c_f.toString() != expected.toString())
|
||||
a_c = complextest.Conjf(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conjf(a)";
|
||||
|
||||
a_c = complextest.Conj2(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conj(a)";
|
||||
|
||||
a_c = complextest.Conjf2(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conjf(a)";
|
||||
|
||||
v = new complextest.VectorStdCplx();
|
||||
|
|
@ -19,4 +27,5 @@ v.add([4,3]);
|
|||
v.add(1);
|
||||
|
||||
// TODO: how to check validity?
|
||||
complextest.Copy_h(v);
|
||||
complextest.CopyHalf(v);
|
||||
complextest.CopyHalfRef(v);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,13 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
%}
|
||||
|
||||
%include "boost_shared_ptr.i";
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGR)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <boost_shared_ptr.i>
|
||||
%shared_ptr(C);
|
||||
%feature("director") Base;
|
||||
|
||||
|
|
@ -13,6 +19,7 @@ struct C {
|
|||
C() : m(1) {}
|
||||
C(int n) : m(n) {}
|
||||
int get_m() { return m; }
|
||||
private:
|
||||
int m;
|
||||
};
|
||||
|
||||
|
|
@ -21,10 +28,23 @@ struct Base {
|
|||
virtual boost::shared_ptr<C> ret_c_shared_ptr() = 0;
|
||||
virtual C ret_c_by_value() = 0;
|
||||
virtual int take_c_by_value(C c) = 0;
|
||||
virtual int take_c_by_ref(C& c) = 0;
|
||||
virtual int take_c_by_pointer(C* c) = 0;
|
||||
virtual int take_c_by_pointer_ref(C*const& c) = 0;
|
||||
virtual int take_c_shared_ptr_by_value(boost::shared_ptr<C> c) = 0;
|
||||
virtual int take_c_shared_ptr_by_ref(boost::shared_ptr<C>& c) = 0;
|
||||
virtual int take_c_shared_ptr_by_pointer(boost::shared_ptr<C>* c) = 0;
|
||||
virtual int take_c_shared_ptr_by_pointer_ref(boost::shared_ptr<C>*const&c) = 0;
|
||||
virtual int take_many_args(
|
||||
C v1, C v2,
|
||||
C &r1, C &r2,
|
||||
C *p1, C *p2,
|
||||
C *const& cr1, C *const& cr2,
|
||||
boost::shared_ptr<C> sv1, boost::shared_ptr<C> sv2,
|
||||
boost::shared_ptr<C> &sr1, boost::shared_ptr<C> &sr2,
|
||||
boost::shared_ptr<C> *sp1, boost::shared_ptr<C> *sp2,
|
||||
boost::shared_ptr<C> *const& spr1, boost::shared_ptr<C> *const& spr2
|
||||
) = 0;
|
||||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
|
|
@ -47,8 +67,34 @@ int call_take_c_by_value(Base* b) {
|
|||
return b->take_c_by_value(c);
|
||||
}
|
||||
|
||||
int call_take_c_by_ref(Base* b) {
|
||||
C c(6);
|
||||
return b->take_c_by_ref(c);
|
||||
}
|
||||
|
||||
int call_take_c_by_pointer(Base* b) {
|
||||
C c(7);
|
||||
return b->take_c_by_pointer(&c);
|
||||
}
|
||||
|
||||
int call_take_c_by_pointer_ref(Base* b) {
|
||||
C c(8);
|
||||
C* p(&c);
|
||||
return b->take_c_by_pointer_ref(p);
|
||||
}
|
||||
|
||||
int call_take_c_by_pointer_with_null(Base* b) {
|
||||
C* p = NULL;
|
||||
return b->take_c_by_pointer(p);
|
||||
}
|
||||
|
||||
int call_take_c_by_pointer_ref_with_null(Base* b) {
|
||||
C* p = NULL;
|
||||
return b->take_c_by_pointer_ref(p);
|
||||
}
|
||||
|
||||
int call_take_c_shared_ptr_by_value(Base* b) {
|
||||
boost::shared_ptr<C> ptr(new C(6));
|
||||
boost::shared_ptr<C> ptr(new C(9));
|
||||
return b->take_c_shared_ptr_by_value(ptr);
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +104,7 @@ int call_take_c_shared_ptr_by_value_with_null(Base* b) {
|
|||
}
|
||||
|
||||
int call_take_c_shared_ptr_by_ref(Base* b) {
|
||||
boost::shared_ptr<C> ptr(new C(7));
|
||||
boost::shared_ptr<C> ptr(new C(10));
|
||||
return b->take_c_shared_ptr_by_ref(ptr);
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +114,7 @@ int call_take_c_shared_ptr_by_ref_with_null(Base* b) {
|
|||
}
|
||||
|
||||
int call_take_c_shared_ptr_by_pointer(Base* b) {
|
||||
boost::shared_ptr<C> ptr(new C(8));
|
||||
boost::shared_ptr<C> ptr(new C(11));
|
||||
return b->take_c_shared_ptr_by_pointer(&ptr);
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +124,7 @@ int call_take_c_shared_ptr_by_pointer_with_null(Base* b) {
|
|||
}
|
||||
|
||||
int call_take_c_shared_ptr_by_pointer_ref(Base* b) {
|
||||
boost::shared_ptr<C> *ptr = new boost::shared_ptr<C>(new C(9));
|
||||
boost::shared_ptr<C> *ptr = new boost::shared_ptr<C>(new C(12));
|
||||
return b->take_c_shared_ptr_by_pointer_ref(ptr);
|
||||
}
|
||||
|
||||
|
|
@ -88,3 +134,5 @@ int call_take_c_shared_ptr_by_pointer_ref_with_null(Base* b) {
|
|||
}
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,6 +49,14 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
|
|||
return x;
|
||||
}
|
||||
|
||||
std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic_overload(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic_overload(int) {
|
||||
return "int";
|
||||
}
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ assert(oc.foo(1,1,"test",1) == 15)
|
|||
p1 = oc.Pop(nil)
|
||||
p1 = oc.Pop(nil,false)
|
||||
|
||||
assert(p1:hip(true) == 701)
|
||||
assert(p1:hip(false) == 701)
|
||||
assert(p1:hip(nil) == 702)
|
||||
|
||||
assert(p1:hop(true) == 801)
|
||||
assert(p1:hop(false) == 801)
|
||||
assert(p1:hop(nil) == 805)
|
||||
|
||||
assert(oc.muzak(true) == 3001)
|
||||
assert(oc.muzak(false) == 3001)
|
||||
assert(oc.muzak(nil) == 3002)
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@
|
|||
%shared_ptr(Space::Bottom3)
|
||||
|
||||
%include "swiginterface.i"
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::ABase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase2)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::ABase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase2)
|
||||
%interface_impl(Space::ABase1)
|
||||
%interface_impl(Space::CBase1)
|
||||
%interface_impl(Space::CBase2)
|
||||
|
|
|
|||
25
Examples/test-suite/newobject3.i
Normal file
25
Examples/test-suite/newobject3.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Regression test for PHP bug: https://sourceforge.net/p/swig/bugs/1350/
|
||||
*/
|
||||
|
||||
%module newobject3
|
||||
|
||||
%newobject factory::create;
|
||||
%inline %{
|
||||
class Product {};
|
||||
class factory {
|
||||
public:
|
||||
Product * create(short id, short type = 0);
|
||||
Product * create(const char * name, short type = 0);
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
Product * factory::create(short id, short type) {
|
||||
return (id && type >= 0) ? new Product : NULL;
|
||||
}
|
||||
|
||||
Product * factory::create(const char * name, short type) {
|
||||
return (name && type >= 0) ? new Product : NULL;
|
||||
}
|
||||
%}
|
||||
|
|
@ -16,6 +16,12 @@ CPP_TEST_CASES += \
|
|||
octave_cell_deref\
|
||||
octave_dim
|
||||
|
||||
CPP11_TEST_CASES += \
|
||||
cpp11_shared_ptr_const \
|
||||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_overload \
|
||||
cpp11_shared_ptr_upcast \
|
||||
|
||||
CPP_TEST_BROKEN += \
|
||||
implicittest \
|
||||
li_implicit \
|
||||
|
|
|
|||
|
|
@ -15,10 +15,16 @@ if (complextest.Conjf(a) != a.conjugate())
|
|||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
if (complextest.Conj2(a) != a.conjugate())
|
||||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
if (complextest.Conjf2(a) != a.conjugate())
|
||||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
|
||||
v = (complex(1,2), complex(2,3), complex(4,3), 1);
|
||||
|
||||
try
|
||||
complextest.Copy_h(v);
|
||||
catch
|
||||
end_try_catch
|
||||
complextest.CopyHalf(v);
|
||||
complextest.CopyHalfRef(v);
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ endif
|
|||
|
||||
overload_complicated
|
||||
|
||||
pInt = None;
|
||||
pInt = []; # NULL
|
||||
|
||||
# Check the correct constructors are available
|
||||
p = Pop(pInt);
|
||||
|
||||
p = Pop(pInt, 0);
|
||||
p = Pop(pInt, false);
|
||||
|
||||
# Check overloaded in const only and pointers/references which target languages cannot disambiguate
|
||||
if (p.hip(0) != 701)
|
||||
if (p.hip(false) != 701)
|
||||
error("Test 1 failed")
|
||||
endif
|
||||
|
||||
|
|
@ -26,16 +26,16 @@ if (p.hop(pInt) != 805)
|
|||
error("Test 3 failed")
|
||||
endif
|
||||
|
||||
if (p.hop(0) != 801)
|
||||
if (p.hop(false) != 801)
|
||||
error("Test 4 failed")
|
||||
endif
|
||||
|
||||
# Few more variations and order shuffled
|
||||
if (p.pop(0) != 901)
|
||||
if (p.pop(false) != 901)
|
||||
error("Test 5 failed")
|
||||
endif
|
||||
|
||||
if (p.pop(pInt) != 902)
|
||||
if (p.pop(pInt) != 904)
|
||||
error("Test 6 failed")
|
||||
endif
|
||||
|
||||
|
|
@ -48,12 +48,12 @@ if (p.bop(pInt) != 1001)
|
|||
error("Test 8 failed")
|
||||
endif
|
||||
|
||||
if (p.bip(pInt) != 2001)
|
||||
if (p.bip(pInt) != 2002)
|
||||
error("Test 9 failed")
|
||||
endif
|
||||
|
||||
# Globals
|
||||
if (muzak(0) != 3001)
|
||||
if (muzak(false) != 3001)
|
||||
error("Test 10 failed")
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef SWIG_NO_OVERLOAD
|
||||
%immutable Spam::type;
|
||||
|
||||
%inline %{
|
||||
|
|
@ -130,8 +128,6 @@ static char *bar(void *[SIZE]) {
|
|||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
%inline {
|
||||
class ClassA
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
// A complicated test of overloaded functions
|
||||
%module overload_complicated
|
||||
|
||||
#ifndef SWIG_NO_OVERLOAD
|
||||
|
||||
// Different warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
|
||||
%warnfilter(509, 516) Pop::Pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(509, 516) Pop::hip; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(509, 516) Pop::hop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(509, 516) Pop::pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(516) Pop::bop; // Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(516) Pop::bip; // Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
%warnfilter(509, 516) ::muzak; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
|
||||
// Different overloaded warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
|
||||
%warnfilter(509, 516) Pop::Pop;
|
||||
%warnfilter(509, 516) Pop::hip;
|
||||
%warnfilter(509, 516) Pop::hop;
|
||||
%warnfilter(509, 516) Pop::pop;
|
||||
%warnfilter(516) Pop::bop;
|
||||
%warnfilter(516) Pop::bip;
|
||||
%warnfilter(509, 516) ::muzak;
|
||||
%warnfilter(509, 516) foo;
|
||||
|
||||
%typemap(in, numinputs=0) int l { $1 = 4711; }
|
||||
|
||||
%inline %{
|
||||
|
||||
double foo(int, int, char *, int) {
|
||||
int foo(int, int, char *, int) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
double foo(int i, int j, double k = 17.4, int l = 18, char m = 'P') {
|
||||
return i + j + k + l + (int) m;
|
||||
int foo(int i, int j, double k = 17.4, int l = 18 /* Note numinputs typemap above */, char m = 'P') {
|
||||
int sum = i + j + (int)k + l + (int)m;
|
||||
return sum;
|
||||
}
|
||||
|
||||
struct Pop {
|
||||
|
|
@ -67,6 +67,3 @@ int muzak(int& i) { return 3003; }
|
|||
int muzak(const int* i) { return 3004; }
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
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