Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12976 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
02d58e0125
99 changed files with 1847 additions and 418 deletions
|
|
@ -83,6 +83,7 @@ CPP_TEST_BROKEN += \
|
|||
exception_partial_info \
|
||||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
li_boost_shared_ptr_template \
|
||||
overload_complicated \
|
||||
template_default_pointer \
|
||||
template_expr
|
||||
|
|
@ -472,6 +473,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_pair \
|
||||
li_std_string \
|
||||
li_std_vector \
|
||||
li_std_vector_enum \
|
||||
naturalvar \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
|
|
|
|||
27
Examples/test-suite/csharp/li_std_vector_enum_runme.cs
Normal file
27
Examples/test-suite/csharp/li_std_vector_enum_runme.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// This test tests all the methods in the C# collection wrapper
|
||||
|
||||
using System;
|
||||
using li_std_vector_enumNamespace;
|
||||
|
||||
public class li_std_vector_enum_runme {
|
||||
|
||||
public static void Main() {
|
||||
EnumVector ev = new EnumVector();
|
||||
|
||||
check((int)ev.nums[0], 10);
|
||||
check((int)ev.nums[1], 20);
|
||||
check((int)ev.nums[2], 30);
|
||||
|
||||
int expected = 10;
|
||||
foreach (EnumVector.numbers val in ev.nums) {
|
||||
check((int)val, expected);
|
||||
expected += 10;
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(int a, int b) {
|
||||
if (a != b)
|
||||
throw new ApplicationException("values don't match");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ namespace Bar
|
|||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static Foo* get_self(Foo *self) {return self;}
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +63,6 @@ namespace Bar
|
|||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self);
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
|
||||
LANGUAGE = go
|
||||
GO = @GO@
|
||||
GOGCC = false
|
||||
GOGCC = @GOGCC@
|
||||
GO1 = @GO1@
|
||||
GOC = @GOC@
|
||||
SCRIPTSUFFIX = _runme.go
|
||||
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi`
|
||||
GOC = $(GO:g=c)
|
||||
GOLD = $(GO:g=l)
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi`
|
||||
GOLD = $(GOC:c=l)
|
||||
GOTOOL = `if $(GO1) ; then echo go tool; fi`
|
||||
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
|
||||
|
||||
GOOBJEXT = $(GO:g=)
|
||||
GOOBJEXT = $(GOC:c=)
|
||||
|
||||
SO = @SO@
|
||||
|
||||
|
|
@ -53,23 +56,23 @@ multi_import.multicpptest:
|
|||
# Runs the testcase.
|
||||
run_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
run_multi_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = java
|
||||
JAVA = java
|
||||
JAVAC = javac
|
||||
JAVAFLAGS = -Xcheck:jni
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
|
|
@ -79,7 +80,7 @@ run_testcase = \
|
|||
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
27
Examples/test-suite/java/li_std_vector_enum_runme.java
Normal file
27
Examples/test-suite/java/li_std_vector_enum_runme.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import li_std_vector_enum.*;
|
||||
|
||||
public class li_std_vector_enum_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_std_vector_enum");
|
||||
} 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[]) throws Throwable
|
||||
{
|
||||
EnumVector ev = new EnumVector();
|
||||
|
||||
check(ev.getNums().get(0).swigValue(), 10);
|
||||
check(ev.getNums().get(1).swigValue(), 20);
|
||||
check(ev.getNums().get(2).swigValue(), 30);
|
||||
}
|
||||
|
||||
private static void check(int a, int b) {
|
||||
if (a != b)
|
||||
throw new RuntimeException("values don't match");
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,11 @@
|
|||
%{
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#ifdef SWIGR
|
||||
// remove naming conflict with R symbol
|
||||
#define INTEGER MYINTEGER
|
||||
#endif
|
||||
|
||||
typedef int INTEGER;
|
||||
|
||||
template <class T>
|
||||
|
|
|
|||
23
Examples/test-suite/li_std_vector_enum.i
Normal file
23
Examples/test-suite/li_std_vector_enum.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%module li_std_vector_enum
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%inline %{
|
||||
class EnumVector {
|
||||
public:
|
||||
EnumVector() { fill_numbers(); }
|
||||
|
||||
enum numbers {ten=10, twenty=20, thirty=30};
|
||||
|
||||
std::vector<numbers> nums;
|
||||
|
||||
void fill_numbers() {
|
||||
nums.push_back(ten);
|
||||
nums.push_back(twenty);
|
||||
nums.push_back(thirty);
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(vector_numbers) std::vector<EnumVector::numbers>;
|
||||
|
||||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("abstract_access") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- trying to instantiate pure virual classes
|
||||
-- should fail
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import("cpp_basic") -- import code
|
|||
cb=cpp_basic -- renaming import
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
f=cb.Foo(4)
|
||||
assert(f.num==4)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("disown") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
for x=0,100 do
|
||||
a=disown.A()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("enums") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- check values
|
||||
assert(enums.CSP_ITERATION_FWD==0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("exception_order") -- import lib into global
|
|||
eo=exception_order --alias
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
a = eo.A()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("import_nomodule") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
f = import_nomodule.create_Foo()
|
||||
import_nomodule.test1(f,42)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import("li_carrays") -- import code
|
|||
for k,v in pairs(li_carrays) do _G[k]=v end
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- Testing for %array_functions(int,intArray)
|
||||
ary = new_intArray(2)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("li_std_string") -- import lib
|
|||
for k,v in pairs(li_std_string) do _G[k]=v end -- move to global
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- helper to check type
|
||||
function is_std_string(s)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("li_typemaps") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- Check double INPUT typemaps
|
||||
assert(li_typemaps.in_double(22.22) == 22.22)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ for k,v in pairs(operator_overload) do _G[k]=v end -- move to global
|
|||
Op_sanity_check()
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- test routine:
|
||||
a=Op()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ top_builddir = @top_builddir@
|
|||
CPP_TEST_CASES += \
|
||||
li_std_pair_extra \
|
||||
li_std_string_extra \
|
||||
octave_cell_deref
|
||||
octave_cell_deref\
|
||||
octave_dim
|
||||
|
||||
CPP_TEST_BROKEN += \
|
||||
implicittest \
|
||||
|
|
@ -57,7 +58,7 @@ CSRCS = octave_empty.c
|
|||
# a file is found which has _runme.m appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: remove the generated .m file
|
||||
|
|
|
|||
27
Examples/test-suite/octave/li_std_vector_enum_runme.m
Normal file
27
Examples/test-suite/octave/li_std_vector_enum_runme.m
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
li_std_vector_enum
|
||||
|
||||
function check(a, b)
|
||||
if (a != b)
|
||||
error("incorrect match");
|
||||
endif
|
||||
end
|
||||
|
||||
ev = EnumVector();
|
||||
|
||||
check(ev.nums(0), 10);
|
||||
check(ev.nums(1), 20);
|
||||
check(ev.nums(2), 30);
|
||||
|
||||
it = ev.nums.begin();
|
||||
v = it.value();
|
||||
check(v, 10);
|
||||
it.next();
|
||||
v = it.value();
|
||||
check(v, 20);
|
||||
|
||||
#expected = 10
|
||||
#ev.nums.each do|val|
|
||||
# swig_assert(val == expected)
|
||||
# expected += 10
|
||||
#end
|
||||
|
||||
18
Examples/test-suite/octave/octave_dim_runme.m
Normal file
18
Examples/test-suite/octave/octave_dim_runme.m
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
octave_dim
|
||||
|
||||
assert(all(size(Foo45a())==[4 5]));
|
||||
assert(all(size(Foo456a())==[4 5 6]));
|
||||
assert(all(size(Foo4a())==[4 1]));
|
||||
assert(all(size(Foo4b())==[4 1]));
|
||||
assert(all(size(Foo())==[1 1]));
|
||||
assert(all(size(Bar1())==[1 1]));
|
||||
assert(all(size(Bar2())==[1 1]));
|
||||
assert(all(size(Baz1())==[3 4]));
|
||||
assert(all(size(Baz2())==[3 4]));
|
||||
assert(all(size(Baz3())==[3 4]));
|
||||
assert(all(size(Baz4())==[3 4]));
|
||||
|
||||
% Assertions will not work, but kept for future reference.
|
||||
%assert(all(size(Baz5())==[3 4]));
|
||||
%assert(all(size(Baz6())==[3 4]));
|
||||
%assert(all(size(Baz7())==[3 4]));
|
||||
160
Examples/test-suite/octave_dim.i
Normal file
160
Examples/test-suite/octave_dim.i
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
%module octave_dim
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) Matrix {
|
||||
$result = $1;
|
||||
}
|
||||
|
||||
// Code below will not work. Kept for future reference.
|
||||
// Reason: there is no octave_value(Array<octave_idx_type>) constructor
|
||||
//%typemap(out) Array<octave_idx_type> {
|
||||
// $result = octave_value($1,true);
|
||||
//}
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo45a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(2);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
// doubles are not converted to ints.
|
||||
class Bar1 {
|
||||
public:
|
||||
std::vector<double> __dims__() const {
|
||||
std::vector<double> ret(2);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class Bar2 {
|
||||
public:
|
||||
std::string __dims__() const {
|
||||
return "foo";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Foo4a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(1);
|
||||
ret[0] = 4;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class Foo4b {
|
||||
public:
|
||||
int __dims__() const {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
class Foo456a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(3);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
ret[2] = 6;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class Foo {
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Baz1 {
|
||||
public:
|
||||
Cell __dims__() const {
|
||||
Cell c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz2 {
|
||||
public:
|
||||
Cell __dims__() const {
|
||||
Cell c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz3 {
|
||||
public:
|
||||
Matrix __dims__() const {
|
||||
Matrix c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz4 {
|
||||
public:
|
||||
Matrix __dims__() const {
|
||||
Matrix c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz5 {
|
||||
public:
|
||||
Array<octave_idx_type> __dims__() const {
|
||||
Array<octave_idx_type> c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz6 {
|
||||
public:
|
||||
Array<octave_idx_type> __dims__() const {
|
||||
Array<octave_idx_type> c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
// Code below will not work. Kept for future reference.
|
||||
// Reason: there is no octave_value(dim_vector) constructor
|
||||
// class Baz7 {
|
||||
//public:
|
||||
// dim_vector __dims__() const {
|
||||
// octave_value v = dim_vector(3,4);
|
||||
// Array<int> a = v.int_vector_value();
|
||||
// if (error_state) return dim_vector(1,1);
|
||||
// int mysize = a.numel();
|
||||
// return dim_vector(3,4);
|
||||
// }
|
||||
//};
|
||||
|
||||
%}
|
||||
|
|
@ -80,3 +80,22 @@
|
|||
#define EXPR_LOR 0xFF || 1
|
||||
#define EXPR_CONDITIONAL true ? 2 : 2.2
|
||||
|
||||
|
||||
/// constant assignment in enum
|
||||
#if defined(SWIGCSHARP)
|
||||
%csconstvalue("1<<2") kValue;
|
||||
#endif
|
||||
|
||||
%{
|
||||
#define BIT(n) (1ULL << (n))
|
||||
|
||||
enum MyEnum {
|
||||
kValue = BIT(2)
|
||||
};
|
||||
%}
|
||||
|
||||
#define BIT(n) (1ULL << (n))
|
||||
|
||||
enum MyEnum {
|
||||
kValue = BIT(2)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,3 +35,18 @@ int multiply60(int a) { return a*60; }
|
|||
int multiply70(int a) { return a*70; }
|
||||
%}
|
||||
|
||||
%define nested_include_1(HEADER)
|
||||
%include <HEADER>
|
||||
%enddef
|
||||
|
||||
%define nested_include_2(HEADER)
|
||||
nested_include_1(HEADER);
|
||||
%enddef
|
||||
|
||||
%define nested_include_3(HEADER)
|
||||
nested_include_2(HEADER);
|
||||
%enddef
|
||||
|
||||
nested_include_1(preproc_include_h1.i);
|
||||
nested_include_2(preproc_include_h2.i);
|
||||
nested_include_3(preproc_include_h3.i);
|
||||
|
|
|
|||
1
Examples/test-suite/preproc_include_h1.i
Normal file
1
Examples/test-suite/preproc_include_h1.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const1 1
|
||||
1
Examples/test-suite/preproc_include_h2.i
Normal file
1
Examples/test-suite/preproc_include_h2.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const2 2
|
||||
1
Examples/test-suite/preproc_include_h3.i
Normal file
1
Examples/test-suite/preproc_include_h3.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const3 3
|
||||
24
Examples/test-suite/python/li_std_vector_enum_runme.py
Normal file
24
Examples/test-suite/python/li_std_vector_enum_runme.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import li_std_vector_enum
|
||||
|
||||
def check(a, b):
|
||||
if (a != b):
|
||||
raise RuntimeError("Not equal: ", a, b)
|
||||
|
||||
ev = li_std_vector_enum.EnumVector()
|
||||
|
||||
check(ev.nums[0], 10)
|
||||
check(ev.nums[1], 20)
|
||||
check(ev.nums[2], 30)
|
||||
|
||||
it = ev.nums.iterator()
|
||||
v = it.value()
|
||||
check(v, 10)
|
||||
it.next()
|
||||
v = it.value()
|
||||
check(v, 20)
|
||||
|
||||
expected = 10
|
||||
for val in ev.nums:
|
||||
check(val, expected)
|
||||
expected += 10
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
C_TEST_CASES = r_copy_struct r_legacy
|
||||
CPP_TEST_CASES = r_double_delete
|
||||
CPP_TEST_CASES = r_double_delete r_overload_array
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
20
Examples/test-suite/r_overload_array.i
Normal file
20
Examples/test-suite/r_overload_array.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module r_overload_array
|
||||
%include "stl.i"
|
||||
# this tests the situation in which there is a scalar function
|
||||
# corresponding with a vector one
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
double bar(double w) {return w;};
|
||||
double bar(double *w) {return w[0];}
|
||||
double bar(std::vector<double> w) {return w[0];}
|
||||
|
||||
int bar_int(int w) {return w;}
|
||||
int bar_int(int *w) {return w[0];}
|
||||
int bar_int(std::vector<int> w) {return w[0];}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
|
||||
25
Examples/test-suite/ruby/li_std_vector_enum_runme.rb
Executable file
25
Examples/test-suite/ruby/li_std_vector_enum_runme.rb
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'swig_assert'
|
||||
require 'li_std_vector_enum'
|
||||
include Li_std_vector_enum
|
||||
|
||||
ev = EnumVector.new()
|
||||
|
||||
swig_assert(ev.nums[0] == 10)
|
||||
swig_assert(ev.nums[1] == 20)
|
||||
swig_assert(ev.nums[2] == 30)
|
||||
|
||||
it = ev.nums.begin
|
||||
v = it.value()
|
||||
swig_assert(v == 10)
|
||||
it.next()
|
||||
v = it.value()
|
||||
swig_assert(v == 20)
|
||||
|
||||
expected = 10
|
||||
ev.nums.each do|val|
|
||||
swig_assert(val == expected)
|
||||
expected += 10
|
||||
end
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
%module template_typedef_virtual
|
||||
%module template_typedef_inherit
|
||||
|
||||
// Bug 3378145
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ template<class Key, class T, class J = int> class Multimap {
|
|||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef A key_type;
|
||||
typedef int mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ template<class Key, class T, class J = int> class Multimap {
|
|||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef A key_type;
|
||||
typedef int mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue