massive typemap unification
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5bbd841acc
commit
7e5e4fd1f9
28 changed files with 6234 additions and 7104 deletions
|
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = my_tclsh
|
||||
DLTARGET = example
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class quat;
|
||||
class Quat;
|
||||
class matrix4;
|
||||
class tacka3;
|
||||
|
||||
class quat {
|
||||
class Quat {
|
||||
public:
|
||||
quat::quat(void){}
|
||||
quat::quat(float in_w, float x, float y, float z){}
|
||||
quat::quat(const tacka3& axis, float angle){}
|
||||
quat::quat(const matrix4& m){}
|
||||
Quat::Quat(void){}
|
||||
Quat::Quat(float in_w, float x, float y, float z){}
|
||||
Quat::Quat(const tacka3& axis, float angle){}
|
||||
Quat::Quat(const matrix4& m){}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -346,6 +346,7 @@ C_TEST_CASES += \
|
|||
sizeof_pointer \
|
||||
sneaky1 \
|
||||
struct_rename \
|
||||
typedef_struct \
|
||||
typemap_subst \
|
||||
unions
|
||||
|
||||
|
|
|
|||
49
Examples/test-suite/director_wstring.i
Normal file
49
Examples/test-suite/director_wstring.i
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
%module(directors="1") director_wstring;
|
||||
%include stl.i
|
||||
%include std_vector.i
|
||||
%include std_wstring.i
|
||||
|
||||
// Using thread unsafe wrapping
|
||||
%warnfilter(470) A;
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%feature("director") A;
|
||||
%inline %{
|
||||
|
||||
struct A
|
||||
{
|
||||
A(const std::wstring& first)
|
||||
: m_strings(1, first)
|
||||
{}
|
||||
|
||||
virtual ~A() {}
|
||||
|
||||
virtual const std::wstring& get_first() const
|
||||
{ return get(0); }
|
||||
|
||||
virtual const std::wstring& get(int n) const
|
||||
{ return m_strings[n]; }
|
||||
|
||||
virtual const std::wstring& call_get_first() const
|
||||
{ return get_first(); }
|
||||
|
||||
virtual const std::wstring& call_get(int n) const
|
||||
{ return get(n); }
|
||||
|
||||
std::vector<std::wstring> m_strings;
|
||||
|
||||
|
||||
virtual void process_text(const char *text)
|
||||
{
|
||||
}
|
||||
|
||||
void call_process_func() { process_text("hello"); }
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%template(StringVector) std::vector<std::wstring>;
|
||||
|
|
@ -63,6 +63,7 @@ struct SpeedClass {
|
|||
enum speed { slow=10, medium=20, fast=30, lightning };
|
||||
typedef enum speed speedtd1;
|
||||
|
||||
int speedTest0(int s) { return s; }
|
||||
speed speedTest1(speed s) { return s; }
|
||||
enum speed speedTest2(enum speed s) { return s; }
|
||||
const speed speedTest3(const speed s) { return s; }
|
||||
|
|
@ -77,6 +78,7 @@ struct SpeedClass {
|
|||
SpeedClass() : myColour2(red), mySpeedtd1(slow) { }
|
||||
};
|
||||
|
||||
int speedTest0(int s) { return s; }
|
||||
SpeedClass::speed speedTest1(SpeedClass::speed s) { return s; }
|
||||
enum SpeedClass::speed speedTest2(enum SpeedClass::speed s) { return s; }
|
||||
const SpeedClass::speed speedTest3(const SpeedClass::speed s) { return s; }
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ SWIGEXPORT extern int externexport(int);
|
|||
extern int SWIGSTDCALL externstdcall(int);
|
||||
|
||||
%{
|
||||
// externimport ought to be using MYDLLIMPORT and compiled into another dll, but that is
|
||||
// a bit tricky to do in the test framework
|
||||
/*
|
||||
externimport ought to be using MYDLLIMPORT and compiled into another dll, but that is
|
||||
a bit tricky to do in the test framework
|
||||
*/
|
||||
SWIGEXPORT extern int externimport(int i) { return i; }
|
||||
SWIGEXPORT extern int externexport(int i) { return i; }
|
||||
extern int SWIGSTDCALL externstdcall(int i) { return i; }
|
||||
|
|
|
|||
22
Examples/test-suite/li_implicit.i
Normal file
22
Examples/test-suite/li_implicit.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
%module li_implicit
|
||||
%include implicit.i
|
||||
|
||||
%inline
|
||||
{
|
||||
struct B { };
|
||||
}
|
||||
|
||||
%implicit(A, int, double, B);
|
||||
|
||||
%inline
|
||||
{
|
||||
struct A
|
||||
{
|
||||
int ii;
|
||||
A(int i) { ii = 1; }
|
||||
A(double d) { ii = 2; }
|
||||
A(const B& b) { ii = 3; }
|
||||
};
|
||||
|
||||
int get(const A& a) { return a.ii; }
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
// Massive primitive datatype test.
|
||||
%module(directors="1") primitive_types
|
||||
|
||||
// Ruby constant names
|
||||
#pragma SWIG nowarn=801
|
||||
|
||||
// Using thread unsafe wrapping
|
||||
#pragma SWIG nowarn=470
|
||||
/*
|
||||
|
|
@ -217,8 +220,8 @@ macro(long, pfx, long)
|
|||
macro(unsigned long, pfx, ulong)
|
||||
macro(long long, pfx, llong)
|
||||
macro(unsigned long long, pfx, ullong)
|
||||
//macro(float, pfx, float)
|
||||
//macro(double, pfx, double)
|
||||
macro(float, pfx, float)
|
||||
macro(double, pfx, double)
|
||||
macro(char, pfx, char)
|
||||
%enddef
|
||||
|
||||
|
|
@ -345,9 +348,7 @@ macro(size_t, pfx, sizet)
|
|||
%enddef
|
||||
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%apply (char *STRING, int LENGTH) { (const char *str, size_t len) }
|
||||
#endif
|
||||
|
||||
%inline {
|
||||
struct Foo
|
||||
|
|
|
|||
|
|
@ -18,14 +18,15 @@ CPP_TEST_CASES += \
|
|||
complextest \
|
||||
director_stl \
|
||||
director_thread \
|
||||
director_wstring \
|
||||
file_test \
|
||||
implicittest \
|
||||
inout \
|
||||
input \
|
||||
inplaceadd \
|
||||
kwargs \
|
||||
li_cstring \
|
||||
li_cwstring \
|
||||
li_implicit \
|
||||
li_std_except \
|
||||
li_std_vectora \
|
||||
li_std_map \
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ if mainc(largs) != 3:
|
|||
|
||||
targs=('hi','hola')
|
||||
if mainv(targs,1) != 'hola':
|
||||
print mainv(targs,1)
|
||||
raise RuntimeError, "bad main typemap"
|
||||
|
||||
targs=('hi', 'hola')
|
||||
|
|
|
|||
1
Examples/test-suite/python/empty_runme.py
Normal file
1
Examples/test-suite/python/empty_runme.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
import empty
|
||||
|
|
@ -32,6 +32,10 @@
|
|||
p->second += 1;
|
||||
}
|
||||
|
||||
inline void AddOne1r(double& a) {
|
||||
a += 1;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template() std::pair<double, double>;
|
||||
|
|
@ -41,3 +45,4 @@ void AddOne3(double* INOUT, double* INOUT, double* INOUT);
|
|||
void AddOne1p(std::pair<double, double>* INOUT);
|
||||
void AddOne2p(std::pair<double, double>* INOUT, double* INOUT);
|
||||
void AddOne3p(double* INOUT, std::pair<double, double>* INOUT, double* INOUT);
|
||||
void AddOne1r(double& INOUT);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
|
|||
raise RuntimeError
|
||||
|
||||
if test3("hello") != "hello-suffix":
|
||||
print test3("hello")
|
||||
raise RuntimeError
|
||||
|
||||
if test4("hello") != "hello-suffix":
|
||||
print test4("hello")
|
||||
raise RuntimeError
|
||||
|
||||
if test5(4) != 'xxxx':
|
||||
|
|
|
|||
17
Examples/test-suite/python/li_implicit_runme.py
Normal file
17
Examples/test-suite/python/li_implicit_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from li_implicit import *
|
||||
b = B()
|
||||
ai = A(1)
|
||||
ad = A(2.0)
|
||||
ab = A(b)
|
||||
|
||||
ai, get(ai)
|
||||
ad, get(ad)
|
||||
ab, get(ab)
|
||||
|
||||
if get(ai) != get(1):
|
||||
raise RuntimeError,"bad implicit type"
|
||||
if get(ad) != get(2.0):
|
||||
raise RuntimeError,"bad implicit type"
|
||||
if get(ab) != get(b):
|
||||
raise RuntimeError,"bad implicit type"
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ if li_std_string.test_cvalue(x) != x:
|
|||
raise RuntimeError, "bad string mapping"
|
||||
|
||||
if li_std_string.test_value(x) != x:
|
||||
print x, li_std_string.test_value(x)
|
||||
raise RuntimeError, "bad string mapping"
|
||||
|
||||
if li_std_string.test_const_reference(x) != x:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import li_std_wstring
|
|||
x=u"h"
|
||||
|
||||
if li_std_wstring.test_wcvalue(x) != x:
|
||||
print li_std_wstring.test_wcvalue(x)
|
||||
raise RuntimeError, "bad string mapping"
|
||||
|
||||
x=u"hello"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ cvar.var_long = sct_long
|
|||
cvar.var_ulong = sct_ulong
|
||||
cvar.var_llong = sct_llong
|
||||
cvar.var_ullong = sct_ullong
|
||||
#cvar.var_float = sct_float
|
||||
#cvar.var_double = sct_double
|
||||
cvar.var_float = sct_float
|
||||
cvar.var_double = sct_double
|
||||
cvar.var_char = sct_char
|
||||
cvar.var_pchar = sct_pchar
|
||||
cvar.var_pcharc = sct_pcharc
|
||||
|
|
@ -46,8 +46,8 @@ if cvar.var_long != cct_long: pyerror("long", cvar.var_long, cct_long)
|
|||
if cvar.var_ulong != cct_ulong: pyerror("ulong", cvar.var_ulong, cct_ulong)
|
||||
if cvar.var_llong != cct_llong: pyerror("llong", cvar.var_llong, cct_llong)
|
||||
if cvar.var_ullong != cct_ullong: pyerror("ullong", cvar.var_ullong, cct_ullong)
|
||||
#if cvar.var_float != cct_float: pyerror("float", cvar.var_float, cct_float)
|
||||
#if cvar.var_double != cct_double: pyerror("double", cvar.var_double, cct_double)
|
||||
if cvar.var_float != cct_float: pyerror("float", cvar.var_float, cct_float)
|
||||
if cvar.var_double != cct_double: pyerror("double", cvar.var_double, cct_double)
|
||||
if cvar.var_char != cct_char: pyerror("char", cvar.var_char, cct_char)
|
||||
if cvar.var_pchar != cct_pchar: pyerror("pchar", cvar.var_pchar, cct_pchar)
|
||||
if cvar.var_pcharc != cct_pcharc: pyerror("pchar", cvar.var_pcharc, cct_pcharc)
|
||||
|
|
@ -128,8 +128,8 @@ p.var_long = p.stc_long
|
|||
p.var_ulong = p.stc_ulong
|
||||
p.var_llong = p.stc_llong
|
||||
p.var_ullong = p.stc_ullong
|
||||
#p.var_float = p.stc_float
|
||||
#p.var_double = p.stc_double
|
||||
p.var_float = p.stc_float
|
||||
p.var_double = p.stc_double
|
||||
p.var_char = p.stc_char
|
||||
p.var_pchar = sct_pchar
|
||||
p.var_pcharc = sct_pcharc
|
||||
|
|
@ -156,8 +156,8 @@ t.var_long = t.stc_long
|
|||
t.var_ulong = t.stc_ulong
|
||||
t.var_llong = t.stc_llong
|
||||
t.var_ullong = t.stc_ullong
|
||||
#t.var_float = t.stc_float
|
||||
#t.var_double = t.stc_double
|
||||
t.var_float = t.stc_float
|
||||
t.var_double = t.stc_double
|
||||
t.var_char = t.stc_char
|
||||
t.var_pchar = sct_pchar
|
||||
t.var_pcharc = sct_pcharc
|
||||
|
|
@ -215,6 +215,7 @@ if cvar.var_char != '\0':
|
|||
cvar.var_namet = '\0'
|
||||
#if cvar.var_namet != '\0\0\0\0\0':
|
||||
if cvar.var_namet != '':
|
||||
print 'hola', '', cvar.var_namet
|
||||
raise RuntimeError, "bad char '\0' case"
|
||||
|
||||
cvar.var_namet = ''
|
||||
|
|
@ -301,7 +302,7 @@ try:
|
|||
a = t.var_uint
|
||||
t.var_uint = -1
|
||||
error = 1
|
||||
except TypeError:
|
||||
except OverflowError:
|
||||
if a != t.var_uint:
|
||||
error = 1
|
||||
pass
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue