Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2324be428
commit
f2f1b9889f
112 changed files with 3262 additions and 3375 deletions
|
|
@ -155,6 +155,7 @@ CPP_TEST_CASES += \
|
|||
inherit_void_arg \
|
||||
inline_initializer \
|
||||
kind \
|
||||
langobj \
|
||||
li_carrays \
|
||||
li_cdata \
|
||||
li_cpointer \
|
||||
|
|
|
|||
|
|
@ -73,3 +73,37 @@ const int* globalRet1() {return &GlobalInt;}
|
|||
int* const globalRet2() {return &GlobalInt;}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%{
|
||||
struct A
|
||||
{
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%inline
|
||||
{
|
||||
typedef const A* Acptr;
|
||||
|
||||
Acptr opaque(Acptr aptr) {
|
||||
return aptr;
|
||||
}
|
||||
|
||||
struct B
|
||||
{
|
||||
const A ca;
|
||||
A a;
|
||||
A* ap;
|
||||
const A* cap;
|
||||
Acptr acptr;
|
||||
};
|
||||
|
||||
const B* bar(const B* b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
B const*& cbar(B const*& b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
38
SWIG/Examples/test-suite/langobj.i
Normal file
38
SWIG/Examples/test-suite/langobj.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
%module langobj
|
||||
|
||||
|
||||
#ifndef SWIG_Object
|
||||
#define SWIG_Object void *
|
||||
#endif
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
#ifdef SWIGTCL
|
||||
#define SWIG_Object Tcl_Obj *
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#define SWIG_Object PyObject *
|
||||
#endif
|
||||
|
||||
#ifdef SWIGRUBY
|
||||
#define SWIG_Object VALUE
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_Object
|
||||
#define SWIG_Object void *
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
SWIG_Object identity(SWIG_Object x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
75
SWIG/Examples/test-suite/li_std_wstring.i
Normal file
75
SWIG/Examples/test-suite/li_std_wstring.i
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
%module li_std_wstring
|
||||
%include <std_wstring.i>
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
typedef std::wstring A;
|
||||
|
||||
struct B
|
||||
{
|
||||
B(const std::wstring& s) : cname(0), name(s), a(s)
|
||||
{
|
||||
}
|
||||
|
||||
char *cname;
|
||||
std::wstring name;
|
||||
A a;
|
||||
|
||||
};
|
||||
|
||||
|
||||
wchar_t test_wcvalue(wchar_t x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const wchar_t* test_ccvalue(const wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
wchar_t* test_cvalue(wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
std::wstring test_value(std::wstring x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const std::wstring& test_const_reference(const std::wstring &x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
void test_pointer(std::wstring *x) {
|
||||
}
|
||||
|
||||
std::wstring *test_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_const_pointer(const std::wstring *x) {
|
||||
}
|
||||
|
||||
const std::wstring *test_const_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_reference(std::wstring &x) {
|
||||
}
|
||||
|
||||
std::wstring& test_reference_out() {
|
||||
static std::wstring x = L"x";
|
||||
return x;
|
||||
}
|
||||
|
||||
void test_throw() throw(std::wstring){
|
||||
static std::wstring x = L"x";
|
||||
|
||||
throw x;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
|
@ -9,6 +9,14 @@ srcdir = @srcdir@
|
|||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES += \
|
||||
primitive_types \
|
||||
li_cstring \
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cstring \
|
||||
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
|
|
|||
|
|
@ -1,9 +1,18 @@
|
|||
use enum_thorough;
|
||||
|
||||
|
||||
# Just test an in and out typemap for enum SWIGTYPE and const enum SWIGTYPE & typemaps
|
||||
if (enum_thorough::speedTest4(SpeedClass_slow) != SpeedClass_slow) {
|
||||
if (enum_thorough::speedTest4($enum_thorough::SpeedClass::slow) != $enum_thorough::SpeedClass::slow) {
|
||||
die "speedTest Global 4 failed";
|
||||
}
|
||||
if (enum_thorough::speedTest5(SpeedClass_slow) != SpeedClass_slow) {
|
||||
if (enum_thorough::speedTest5($enum_thorough::SpeedClass::slow) != $enum_thorough::SpeedClass::slow) {
|
||||
die "speedTest Global 5 failed";
|
||||
}
|
||||
|
||||
|
||||
if (enum_thorough::speedTest4($enum_thorough::SpeedClass::fast) != $enum_thorough::SpeedClass::fast) {
|
||||
die "speedTest Global 4 failed";
|
||||
}
|
||||
if (enum_thorough::speedTest5($enum_thorough::SpeedClass::fast) != $enum_thorough::SpeedClass::fast) {
|
||||
die "speedTest Global 5 failed";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -577,6 +577,22 @@ macro(size_t, pfx, sizet)
|
|||
using namespace DCTypes;
|
||||
unsigned int SetPos(cuint& x, cuint& y) {return x + y;}
|
||||
}
|
||||
|
||||
double val_double_2(double x, const double& y = 3.0) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
double val_double(double x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
float val_float_2(float x, const float& y = 3.0) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
float val_float(float x) {
|
||||
return x;
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -456,3 +456,6 @@ li_implicit.py
|
|||
director_wstring.py
|
||||
immutable.py
|
||||
inherit.py
|
||||
empty.py
|
||||
virtual_derivation.py
|
||||
langobj.py
|
||||
|
|
|
|||
7
SWIG/Examples/test-suite/python/langobj_runme.py
Normal file
7
SWIG/Examples/test-suite/python/langobj_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from langobj import *
|
||||
|
||||
|
||||
x ="hello"
|
||||
|
||||
if identity(x) != x:
|
||||
raise RuntimeError
|
||||
|
|
@ -38,3 +38,47 @@ rescue TypeError
|
|||
end
|
||||
|
||||
raise RuntimeError if fail != 1
|
||||
|
||||
|
||||
raise RuntimeError if val_double_2(1.0) != 4.0
|
||||
raise RuntimeError if val_double_2(1) != 4
|
||||
raise RuntimeError if val_double_2(1,1) != 2
|
||||
|
||||
fail = 0
|
||||
begin
|
||||
val_double_2("1.0",1.0)
|
||||
rescue
|
||||
fail = 1
|
||||
end
|
||||
raise RuntimeError if fail != 1
|
||||
|
||||
|
||||
fail = 0
|
||||
begin
|
||||
val_double_2(1.0,"1.0")
|
||||
rescue
|
||||
fail = 1
|
||||
end
|
||||
raise RuntimeError if fail != 1
|
||||
|
||||
|
||||
raise RuntimeError if val_float_2(1.0) != 4.0
|
||||
raise RuntimeError if val_float_2(1) != 4
|
||||
raise RuntimeError if val_float_2(1,1) != 2
|
||||
|
||||
fail = 0
|
||||
begin
|
||||
val_float_2("1.0",1.0)
|
||||
rescue
|
||||
fail = 1
|
||||
end
|
||||
raise RuntimeError if fail != 1
|
||||
|
||||
|
||||
fail = 0
|
||||
begin
|
||||
val_float_2(1.0,"1.0")
|
||||
rescue
|
||||
fail = 1
|
||||
end
|
||||
raise RuntimeError if fail != 1
|
||||
|
|
|
|||
|
|
@ -3,6 +3,5 @@ require 'virtual_derivation'
|
|||
b = Virtual_derivation::B.new 3
|
||||
|
||||
if b.get_a() != b.get_b()
|
||||
print "something is really wrong ", b.get_a(), "\n"
|
||||
raise RuntimeError
|
||||
print "something is still wrong ", b.get_a(), b.get_b(), "\n"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ top_builddir = @top_builddir@
|
|||
|
||||
CPP_TEST_CASES += \
|
||||
primitive_types \
|
||||
li_cstring \
|
||||
li_cwstring \
|
||||
li_std_wstring
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cstring \
|
||||
li_cwstring
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
|
|
@ -18,4 +18,16 @@ if {[val_uchar 10] != 10 } { error "bad uchar map" }
|
|||
if {[val_ushort 10] != 10 } { error "bad ushort map" }
|
||||
|
||||
|
||||
if {[val_double 10] != 10 } { error "bad double map" }
|
||||
if {[val_float 10] != 10 } { error "bad double map" }
|
||||
|
||||
|
||||
|
||||
if [catch { val_float hello } ] {} else { error "bad double map" }
|
||||
|
||||
if {[val_char c] != "c" } { error "bad char map" }
|
||||
if {[val_char "c"] != "c" } { error "bad char map" }
|
||||
if {[val_char 101] != "e" } { error "bad char map" }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue