Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12733 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
e48855bfbf
60 changed files with 1099 additions and 545 deletions
|
|
@ -118,6 +118,7 @@ CPP_TEST_CASES += \
|
|||
arrays_global \
|
||||
arrays_global_twodim \
|
||||
arrays_scope \
|
||||
autodoc \
|
||||
bloody_hell \
|
||||
bools \
|
||||
catches \
|
||||
|
|
@ -437,6 +438,7 @@ CPP_TEST_CASES += \
|
|||
varargs_overload \
|
||||
virtual_destructor \
|
||||
virtual_poly \
|
||||
virtual_vs_nonvirtual_base \
|
||||
voidtest \
|
||||
wallkw \
|
||||
wrapmacro
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = octave
|
||||
OCTAVE = @OCTAVE@ -q
|
||||
OCTAVE = @OCTAVE@ -qf
|
||||
SCRIPTSUFFIX = _runme.m
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
|
|
|||
|
|
@ -208,3 +208,9 @@ long long ll(long long ull) { return ull; }
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
int int_object(Spam *s) { return 999; }
|
||||
int int_object(int c) { return c; }
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ ok(not($@), '%rename handling');
|
|||
|
||||
# exception specifications
|
||||
eval { default_args::exceptionspec() };
|
||||
is($@, "ciao", "exceptionspec 1");
|
||||
like($@, qr/^ciao/, "exceptionspec 1");
|
||||
eval { default_args::exceptionspec(-1) };
|
||||
is($@, "ciao", "exceptionspec 2");
|
||||
like($@, qr/^ciao/, "exceptionspec 2");
|
||||
eval { default_args::exceptionspec(100) };
|
||||
is($@, '100', "exceptionspec 3");
|
||||
like($@, qr/^100/, "exceptionspec 3");
|
||||
|
||||
my $ex = new default_args::Except($false);
|
||||
|
||||
|
|
@ -54,13 +54,13 @@ eval { $ex->exspec(); $hit = 1; };
|
|||
# a zero was thrown, an exception occured, but $@ is false
|
||||
is($hit, 0, "exspec 1");
|
||||
eval { $ex->exspec(-1) };
|
||||
is($@, "ciao", "exspec 2");
|
||||
like($@, qr/^ciao/, "exspec 2");
|
||||
eval { $ex->exspec(100) };
|
||||
is($@, 100, "exspec 3");
|
||||
like($@, qr/^100/, "exspec 3");
|
||||
eval { $ex = default_args::Except->new($true) };
|
||||
is($@, -1, "Except constructor 1");
|
||||
like($@, qr/-1/, "Except constructor 1");
|
||||
eval { $ex = default_args::Except->new($true, -2) };
|
||||
is($@, -2, "Except constructor 2");
|
||||
like($@, qr/-2/, "Except constructor 2");
|
||||
|
||||
#Default parameters in static class methods
|
||||
is(default_args::Statics::staticmethod(), 60, "staticmethod 1");
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ li_std_string::test_reference($stringPtr);
|
|||
|
||||
# Check throw exception specification
|
||||
eval { li_std_string::test_throw() };
|
||||
is($@, "test_throw message", "Test 5");
|
||||
like($@, qr/^test_throw message/, "Test 5");
|
||||
{ local $TODO = "why is the error not a Perl string?";
|
||||
eval { li_std_string::test_const_reference_throw() };
|
||||
is($@, "<some kind of string>", "Test 6");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use overload_simple;
|
||||
use vars qw/$DOWARN/;
|
||||
use strict;
|
||||
use Test::More tests => 71;
|
||||
use Test::More tests => 75;
|
||||
|
||||
pass("loaded");
|
||||
|
||||
|
|
@ -189,3 +189,10 @@ is(overload_simple::fid("3", 3), "fid:intint", "fid:fid(int,int)");
|
|||
isnt(overload_simple::fbool(0), overload_simple::fbool(1), "fbool(bool)");
|
||||
|
||||
is(2, overload_simple::fbool(2), "fbool(int)");
|
||||
|
||||
# int and object overload
|
||||
|
||||
is(overload_simple::int_object(1), 1, "int_object(1)");
|
||||
is(overload_simple::int_object(0), 0, "int_object(0)");
|
||||
is(overload_simple::int_object(undef), 999, "int_object(Spam*)");
|
||||
is(overload_simple::int_object($s), 999, "int_object(Spam*)");
|
||||
|
|
|
|||
11
Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php
Normal file
11
Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?
|
||||
|
||||
require "tests.php";
|
||||
require "virtual_vs_nonvirtual_base.php";
|
||||
|
||||
$fail = new SimpleClassFail();
|
||||
$work = new SimpleClassWork();
|
||||
|
||||
check::equal($work->getInner()->get(), $fail->getInner()->get(), "should both be 10");
|
||||
|
||||
?>
|
||||
|
|
@ -31,42 +31,41 @@ PY2TO3 = 2to3 -x import
|
|||
|
||||
CPP_TEST_CASES += \
|
||||
argcargvtest \
|
||||
python_autodoc \
|
||||
python_append \
|
||||
callback \
|
||||
complextest \
|
||||
director_stl \
|
||||
director_wstring \
|
||||
file_test \
|
||||
iadd \
|
||||
inout \
|
||||
input \
|
||||
inplaceadd \
|
||||
implicittest \
|
||||
inout \
|
||||
inplaceadd \
|
||||
input \
|
||||
li_cstring \
|
||||
li_cwstring \
|
||||
li_factory \
|
||||
li_implicit \
|
||||
li_std_vectora \
|
||||
li_std_vector_extra \
|
||||
li_std_map_member \
|
||||
li_std_multimap \
|
||||
li_std_pair_extra \
|
||||
li_std_set \
|
||||
li_std_stream \
|
||||
li_std_string_extra \
|
||||
li_std_vectora \
|
||||
li_std_vector_extra \
|
||||
li_std_wstream \
|
||||
li_std_wstring \
|
||||
primitive_types \
|
||||
python_abstractbase \
|
||||
python_append \
|
||||
python_kwargs \
|
||||
python_nondynamic \
|
||||
python_overload_simple_cast \
|
||||
python_richcompare \
|
||||
simutry \
|
||||
std_containers \
|
||||
swigobject \
|
||||
template_matrix \
|
||||
simutry
|
||||
template_matrix
|
||||
|
||||
# li_std_carray
|
||||
# director_profile
|
||||
|
|
@ -88,11 +87,12 @@ C_TEST_CASES += \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
BUILTIN_BROKEN = \
|
||||
li_std_string_extra.cpptest \
|
||||
li_std_wstring.cpptest \
|
||||
default_constructor.cpptest \
|
||||
director_exception.cpptest \
|
||||
exception_order.cpptest \
|
||||
li_std_string_extra.cpptest \
|
||||
li_std_wstring.cpptest \
|
||||
python_abstractbase.cpptest \
|
||||
threads_exception.cpptest
|
||||
|
||||
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
||||
|
|
|
|||
|
|
@ -16,3 +16,21 @@ if varargs.test_def("Hello",1) != "Hello":
|
|||
|
||||
if varargs.test_def("Hello") != "Hello":
|
||||
raise RuntimeError, "Failed"
|
||||
|
||||
###
|
||||
if varargs.test_plenty("Hello") != "Hello":
|
||||
raise RuntimeError, "Failed"
|
||||
|
||||
if varargs.test_plenty("Hello", 1) != "Hello":
|
||||
raise RuntimeError, "Failed"
|
||||
|
||||
if varargs.test_plenty("Hello", 1, 2) != "Hello":
|
||||
raise RuntimeError, "Failed"
|
||||
|
||||
try:
|
||||
varargs.test_plenty("Hello", 1, 2, 3)
|
||||
raise RuntimeError
|
||||
except NotImplementedError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -4,40 +4,61 @@
|
|||
* chapter of the SWIG manual.
|
||||
*/
|
||||
|
||||
%{
|
||||
%}
|
||||
|
||||
%typemap(in) (...)(char *args[10]) {
|
||||
int i;
|
||||
int argc;
|
||||
for (i = 0; i < 10; i++) args[i] = 0;
|
||||
argc = PyTuple_Size(varargs);
|
||||
if (argc > 10) {
|
||||
PyErr_SetString(PyExc_ValueError,"Too many arguments");
|
||||
int i;
|
||||
int argc;
|
||||
for (i = 0; i < 10; i++) args[i] = 0;
|
||||
argc = PyTuple_Size(varargs);
|
||||
if (argc > 10) {
|
||||
PyErr_SetString(PyExc_ValueError, "Too many arguments");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
PyObject *pyobj = PyTuple_GetItem(varargs, i);
|
||||
char *str = 0;
|
||||
%#if PY_VERSION_HEX>=0x03000000
|
||||
PyObject *pystr;
|
||||
if (!PyUnicode_Check(pyobj)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
PyObject *o = PyTuple_GetItem(varargs,i);
|
||||
if (!PyString_Check(o)) {
|
||||
PyErr_SetString(PyExc_ValueError,"Expected a string");
|
||||
return NULL;
|
||||
}
|
||||
args[i] = PyString_AsString(o);
|
||||
pystr = PyUnicode_AsUTF8String(pyobj);
|
||||
str = PyBytes_AsString(pystr);
|
||||
Py_XDECREF(pystr);
|
||||
%#else
|
||||
if (!PyString_Check(pyobj)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
||||
return NULL;
|
||||
}
|
||||
$1 = (void *) args;
|
||||
str = PyString_AsString(pyobj);
|
||||
%#endif
|
||||
args[i] = str;
|
||||
}
|
||||
$1 = (void *) args;
|
||||
}
|
||||
|
||||
%feature("action") testfunc {
|
||||
char **args = (char **) arg3;
|
||||
result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
|
||||
args[5],args[6],args[7],args[8],args[9], NULL);
|
||||
char **args = (char **) arg3;
|
||||
result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
|
||||
args[5],args[6],args[7],args[8],args[9], NULL);
|
||||
}
|
||||
|
||||
%inline {
|
||||
char* testfunc (int arg1, double arg2, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *c;
|
||||
va_start(ap, arg2);
|
||||
c = va_arg(ap, char*);
|
||||
va_end(ap);
|
||||
return c;
|
||||
va_list ap;
|
||||
char *c;
|
||||
va_start(ap, arg2);
|
||||
c = va_arg(ap, char*);
|
||||
va_end(ap);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
char *doublecheck(char *inputval) { return inputval; }
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,25 @@
|
|||
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
|
||||
|
||||
%ignore Name::operator=;
|
||||
|
||||
%inline %{
|
||||
struct Name {
|
||||
Name(const char *n="none") : name(n) {}
|
||||
Name(const char *n="none") : name(strdup(n ? n : "")) {}
|
||||
Name(const Name& x) : name(strdup(x.name)) {}
|
||||
Name& operator= (const Name& x)
|
||||
{
|
||||
if (this != &x) {
|
||||
free(this->name);
|
||||
this->name = strdup(x.name);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~Name () { free(this->name); }
|
||||
const char *getName() const { return name; };
|
||||
Name *getNamePtr() { return this; };
|
||||
private:
|
||||
const char *name;
|
||||
char *name;
|
||||
};
|
||||
struct NameWrap {
|
||||
NameWrap(const char *n="casternone") : name(n) {}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
|
||||
# This is the imports runtime testcase.
|
||||
proc import {} {
|
||||
if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
exit 1
|
||||
}
|
||||
if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
exit 1
|
||||
}
|
||||
if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
exit 1
|
||||
}
|
||||
import
|
||||
|
||||
set x [new_B]
|
||||
A_hello $x
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
%varargs(int mode = 0) test_def;
|
||||
%varargs(int mode = 0) Foo::Foo;
|
||||
%varargs(int mode = 0) Foo::statictest(const char*fmt, ...);
|
||||
%varargs(2, int mode = 0) test_plenty(const char*fmt, ...);
|
||||
|
||||
%inline %{
|
||||
char *test(const char *fmt, ...) {
|
||||
|
|
@ -36,4 +37,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
const char *test_plenty(const char *fmt, ...) {
|
||||
return fmt;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
48
Examples/test-suite/virtual_vs_nonvirtual_base.i
Normal file
48
Examples/test-suite/virtual_vs_nonvirtual_base.i
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
%module virtual_vs_nonvirtual_base;
|
||||
// Regression test for SF#3124665.
|
||||
%inline {
|
||||
|
||||
class SimpleVirtual
|
||||
{
|
||||
public:
|
||||
virtual int implementMe() = 0;
|
||||
};
|
||||
|
||||
class SimpleNonVirtual
|
||||
{
|
||||
public:
|
||||
int dummy() { return 0; }
|
||||
};
|
||||
|
||||
class SimpleReturnClass
|
||||
{
|
||||
public:
|
||||
SimpleReturnClass(int i) : value(i) {};
|
||||
int get() const { return value; }
|
||||
private:
|
||||
int value;
|
||||
};
|
||||
|
||||
class SimpleClassFail : public SimpleVirtual
|
||||
{
|
||||
public:
|
||||
SimpleClassFail() : inner(10) {}
|
||||
SimpleReturnClass getInner() { return inner; }
|
||||
|
||||
virtual int implementMe() { return 0; }
|
||||
private:
|
||||
SimpleReturnClass inner;
|
||||
};
|
||||
|
||||
class SimpleClassWork : public SimpleNonVirtual
|
||||
{
|
||||
public:
|
||||
SimpleClassWork() : inner(10) {}
|
||||
SimpleReturnClass getInner() { return inner; }
|
||||
|
||||
virtual int implementMe() { return 0; }
|
||||
private:
|
||||
SimpleReturnClass inner;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue