Merge branch 'master' into devel
Conflicts: .travis.yml Examples/test-suite/common.mk
This commit is contained in:
commit
158c8b6732
114 changed files with 2861 additions and 1708 deletions
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -unsafe -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -unsafe -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -debug -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ TARGET = example
|
|||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
CSHARPSRCS = *.cs
|
||||
CSHARPFLAGS= -nologo -out:runme.exe
|
||||
CSHARPFLAGS= -nologo -debug+ -out:runme.exe
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile csharp_run
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ CPP_TEST_CASES += \
|
|||
naturalvar_more \
|
||||
naturalvar_onoff \
|
||||
nested_class \
|
||||
nested_directors \
|
||||
nested_comment \
|
||||
nested_scope \
|
||||
nested_workaround \
|
||||
|
|
@ -298,6 +299,7 @@ CPP_TEST_CASES += \
|
|||
operator_pointer_ref \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_bool \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
overload_method \
|
||||
|
|
@ -351,6 +353,7 @@ CPP_TEST_CASES += \
|
|||
smart_pointer_simple \
|
||||
smart_pointer_static \
|
||||
smart_pointer_template_const_overload \
|
||||
smart_pointer_template_defaults_overload \
|
||||
smart_pointer_templatemethods \
|
||||
smart_pointer_templatevariables \
|
||||
smart_pointer_typedef \
|
||||
|
|
@ -501,7 +504,8 @@ ifndef SMOKE_TESTS_ONLY
|
|||
|
||||
# C++11 test cases.
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_alternate_function_syntax \
|
||||
cpp11_alignment \
|
||||
cpp11_alternate_function_syntax \
|
||||
cpp11_constexpr \
|
||||
cpp11_decltype \
|
||||
cpp11_default_delete \
|
||||
|
|
@ -516,6 +520,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_noexcept \
|
||||
cpp11_null_pointer_constant \
|
||||
cpp11_raw_string_literals \
|
||||
cpp11_result_of \
|
||||
cpp11_rvalue_reference \
|
||||
cpp11_rvalue_reference2 \
|
||||
cpp11_rvalue_reference3 \
|
||||
|
|
@ -525,19 +530,19 @@ CPP11_TEST_CASES = \
|
|||
cpp11_template_double_brackets \
|
||||
cpp11_template_explicit \
|
||||
cpp11_template_typedefs \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_type_traits \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_unrestricted_unions \
|
||||
cpp11_userdefined_literals \
|
||||
cpp11_variadic_templates
|
||||
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_result_of \ # SWIG does not support
|
||||
# cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
|
||||
|
||||
endif # SMOKE_TESTS_ONLY
|
||||
|
||||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN =
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
ifndef SMOKE_TESTS_ONLY
|
||||
|
||||
|
|
@ -589,6 +594,7 @@ C_TEST_CASES += \
|
|||
enums \
|
||||
enum_forward \
|
||||
enum_macro \
|
||||
enum_missing \
|
||||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
|
|
|
|||
16
Examples/test-suite/cpp11_alignment.i
Normal file
16
Examples/test-suite/cpp11_alignment.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module cpp11_alignment
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
int member;
|
||||
};
|
||||
const int align1 = alignof(A::member);
|
||||
%}
|
||||
|
||||
%{
|
||||
// alignas - not yet working
|
||||
struct alignas(16) S {
|
||||
int num;
|
||||
};
|
||||
alignas(double) unsigned char c[sizeof(double)];
|
||||
%}
|
||||
|
|
@ -4,9 +4,31 @@
|
|||
%module cpp11_constexpr
|
||||
|
||||
%inline %{
|
||||
class TestClass {
|
||||
public:
|
||||
constexpr int func() { return 10; }
|
||||
constexpr int AAA = 10;
|
||||
constexpr const int BBB = 20;
|
||||
constexpr int CCC() { return 30; }
|
||||
constexpr const int DDD() { return 40; }
|
||||
|
||||
constexpr int XXX() { return 10; }
|
||||
constexpr int YYY = XXX() + 100;
|
||||
|
||||
struct ConstExpressions {
|
||||
static constexpr const int JJJ = 100;
|
||||
static constexpr int KKK = 200;
|
||||
static const int LLL = 300;
|
||||
constexpr int MMM() { return 400; }
|
||||
constexpr const int NNN() { return 500; }
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
int Array10[AAA];
|
||||
int Array20[BBB];
|
||||
int Array30[CCC()];
|
||||
int Array40[DDD()];
|
||||
int Array100[ConstExpressions::JJJ];
|
||||
int Array200[ConstExpressions::KKK];
|
||||
int Array300[ConstExpressions::LLL];
|
||||
//int Array400[ConstExpressions::MMM()];
|
||||
//int Array500[ConstExpressions::NNN()];
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
%module cpp11_explicit_conversion_operators
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_IDENTIFIER) Testable::operator bool;
|
||||
%rename(AsInteger) Testable::operator int;
|
||||
|
||||
%inline %{
|
||||
|
||||
class U {
|
||||
|
|
@ -24,5 +27,15 @@ public:
|
|||
|
||||
int t;
|
||||
};
|
||||
|
||||
struct Testable {
|
||||
// explicit conversion operator
|
||||
explicit operator bool() const {
|
||||
return false;
|
||||
}
|
||||
explicit operator int() {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
%module cpp11_inheriting_constructors
|
||||
|
||||
%inline %{
|
||||
// Delegating constructors
|
||||
class BaseClass {
|
||||
private:
|
||||
int _val;
|
||||
|
|
@ -11,8 +12,18 @@ public:
|
|||
BaseClass(int iValue) { _val = iValue; }
|
||||
};
|
||||
|
||||
// Constructor inheritance via using declaration
|
||||
class DerivedClass: public BaseClass {
|
||||
public:
|
||||
using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
|
||||
};
|
||||
|
||||
// Member initialization at the site of the declaration
|
||||
class SomeClass {
|
||||
public:
|
||||
SomeClass() {}
|
||||
explicit SomeClass(int new_value) : value(new_value) {}
|
||||
|
||||
int value = 5;
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
36
Examples/test-suite/cpp11_reference_wrapper.i
Normal file
36
Examples/test-suite/cpp11_reference_wrapper.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
%module cpp11_reference_wrapper
|
||||
|
||||
// SWIG could provide some sort of typemaps for reference_wrapper which is acts like a C++ reference,
|
||||
// but is copy-constructible and copy-assignable
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
using namespace std;
|
||||
|
||||
struct B {
|
||||
B(int &val) : val(val) {}
|
||||
std::reference_wrapper<int> val;
|
||||
// int &val;
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void go() {
|
||||
int val(999);
|
||||
B b1(val);
|
||||
int const& aa1 = b1.val;
|
||||
cout << aa1 << endl;
|
||||
|
||||
// copy constructible
|
||||
B b2(b1);
|
||||
int const& aa2 = b2.val;
|
||||
cout << aa2 << endl;
|
||||
|
||||
// copy assignable
|
||||
B b3(val);
|
||||
b3 = b1;
|
||||
int const& aa3 = b3.val;
|
||||
cout << aa3 << endl;
|
||||
}
|
||||
%}
|
||||
|
|
@ -4,7 +4,21 @@
|
|||
|
||||
%inline %{
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
typedef double(*fn_ptr)(double);
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
// Forward declaration of result_of
|
||||
template<typename Func> struct result_of;
|
||||
// Add in the required partial specialization of result_of
|
||||
template<> struct result_of< fn_ptr(double) > {
|
||||
typedef double type;
|
||||
};
|
||||
}
|
||||
|
||||
%template() std::result_of< fn_ptr(double) >;
|
||||
|
||||
%inline %{
|
||||
|
||||
double square(double x) {
|
||||
return (x * x);
|
||||
|
|
@ -14,7 +28,30 @@ template<class Fun, class Arg>
|
|||
typename std::result_of<Fun(Arg)>::type test_result_impl(Fun fun, Arg arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
|
||||
std::result_of< fn_ptr(double) >::type test_result_alternative1(double(*fun)(double), double arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
%}
|
||||
|
||||
%template(test_result) test_result_impl<double(*)(double), double>;
|
||||
%{
|
||||
// Another alternative approach using decltype (not very SWIG friendly)
|
||||
std::result_of< decltype(square)&(double) >::type test_result_alternative2(double(*fun)(double), double arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
|
||||
void cpp_testing() {
|
||||
std::cout << "result: " << test_result_impl(square, 3) << std::endl;
|
||||
std::cout << "result: " << test_result_impl<double(*)(double), double>(square, 4) << std::endl;
|
||||
std::cout << "result: " << test_result_impl< fn_ptr, double >(square, 5) << std::endl;
|
||||
std::cout << "result: " << test_result_alternative1(square, 6) << std::endl;
|
||||
std::cout << "result: " << test_result_alternative2(square, 7) << std::endl;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(test_result) test_result_impl< fn_ptr, double>;
|
||||
%constant double (*SQUARE)(double) = square;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
#pragma SWIG nowarn=SWIGWARN_PARSE_EXPLICIT_TEMPLATE
|
||||
|
||||
%inline %{
|
||||
#include <vector>
|
||||
|
||||
template<typename T> struct Temper {
|
||||
T val;
|
||||
};
|
||||
|
||||
class A {
|
||||
public:
|
||||
|
|
@ -15,10 +18,14 @@ public:
|
|||
int memberFunction() { return 100; }
|
||||
};
|
||||
|
||||
template class std::vector<A>;
|
||||
extern template class std::vector<A>;
|
||||
template class Temper<A>;
|
||||
extern template class Temper<A>;
|
||||
|
||||
template class std::vector<A*>;
|
||||
extern template class std::vector<A*>;
|
||||
template class Temper<A*>;
|
||||
extern template class Temper<A*>;
|
||||
|
||||
template class Temper<int>;
|
||||
extern template class Temper<int>;
|
||||
%}
|
||||
|
||||
%template(TemperInt) Temper<int>;
|
||||
|
|
|
|||
29
Examples/test-suite/cpp11_type_traits.i
Normal file
29
Examples/test-suite/cpp11_type_traits.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
%module cpp11_type_traits
|
||||
|
||||
// The example in the CPlusPlus11.html documentation.
|
||||
// This doesn't really directly test functionality in type_traits as it doesn't provide
|
||||
// much for use by target languages, rather it tests usage of it.
|
||||
|
||||
%inline %{
|
||||
#include <type_traits>
|
||||
|
||||
// First way of operating.
|
||||
template< bool B > struct algorithm {
|
||||
template< class T1, class T2 > static int do_it(T1 &, T2 &) { /*...*/ return 1; }
|
||||
};
|
||||
|
||||
// Second way of operating.
|
||||
template<> struct algorithm<true> {
|
||||
template< class T1, class T2 > static int do_it(T1, T2) { /*...*/ return 2; }
|
||||
};
|
||||
|
||||
// Instantiating 'elaborate' will automatically instantiate the correct way to operate, depending on the types used.
|
||||
template< class T1, class T2 > int elaborate(T1 A, T2 B) {
|
||||
// Use the second way only if 'T1' is an integer and if 'T2' is
|
||||
// a floating point, otherwise use the first way.
|
||||
return algorithm< std::is_integral<T1>::value && std::is_floating_point<T2>::value >::do_it(A, B);
|
||||
}
|
||||
%}
|
||||
|
||||
%template(Elaborate) elaborate<int, int>;
|
||||
%template(Elaborate) elaborate<int, double>;
|
||||
|
|
@ -6,6 +6,13 @@ public class runme
|
|||
// Debugging flag
|
||||
public static bool debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.GC.Collect();
|
||||
System.GC.WaitForPendingFinalizers();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -27,22 +34,24 @@ public class runme
|
|||
if (debug)
|
||||
Console.WriteLine("Nearly finished");
|
||||
|
||||
int countdown = 100;
|
||||
while (true) {
|
||||
System.GC.Collect();
|
||||
System.GC.WaitForPendingFinalizers();
|
||||
System.Threading.Thread.Sleep(10);
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new ApplicationException("Klass.total_count=" + Klass.getTotal_count());
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount) // Expect the one global variable (GlobalValue)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING)
|
||||
if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
|
||||
if (wrapper_count != 1) // Expect the one global variable (GlobalSmartValue)
|
||||
throw new ApplicationException("shared_ptr wrapper count=" + wrapper_count);
|
||||
|
||||
if (debug)
|
||||
|
|
|
|||
|
|
@ -20,18 +20,38 @@ public class li_std_auto_ptr_runme {
|
|||
throw new Exception("number of objects should be 2");
|
||||
|
||||
k1 = null;
|
||||
WaitForGC();
|
||||
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("number of objects should be 1");
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2 = null;
|
||||
WaitForGC();
|
||||
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new Exception("no objects should be left");
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
Examples/test-suite/csharp/nested_directors_runme.cs
Normal file
20
Examples/test-suite/csharp/nested_directors_runme.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using nested_directorsNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class CNested : Base.Nest {
|
||||
public override bool GetValue() {return true;}
|
||||
}
|
||||
public class CSub : Sub {
|
||||
protected override bool GetValue() { return base.GetValue(); }
|
||||
public bool Test(){ return GetValue(); }
|
||||
}
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
CNested n = new CNested();
|
||||
CSub s = new CSub();
|
||||
if (!s.Test())
|
||||
throw new Exception("Sub.GetValue");
|
||||
}
|
||||
}
|
||||
39
Examples/test-suite/enum_missing.i
Normal file
39
Examples/test-suite/enum_missing.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
%module enum_missing
|
||||
|
||||
// Test when SWIG does not parse the enum definition
|
||||
%{
|
||||
enum AVPixelFormat {
|
||||
AV_PIX_FMT_NONE = -1,
|
||||
AV_PIX_FMT_YUV420P
|
||||
};
|
||||
enum AVPixelFormat2 {
|
||||
AV_PIX_FMT_NONE2 = -1,
|
||||
AV_PIX_FMT_YUV420P2
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef struct AVCodecContext {
|
||||
enum AVPixelFormat pix_fmt;
|
||||
enum AVPixelFormat2 pix_fmt2;
|
||||
} AVCodecContext;
|
||||
|
||||
enum AVPixelFormat global_fmt;
|
||||
enum AVPixelFormat2 global_fmt2;
|
||||
|
||||
enum AVPixelFormat use_pixel_format(enum AVPixelFormat px) {
|
||||
return px;
|
||||
}
|
||||
enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
|
||||
return px;
|
||||
}
|
||||
|
||||
const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
|
||||
return px;
|
||||
}
|
||||
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {
|
||||
return px;
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -15,6 +15,9 @@
|
|||
|
||||
LANGUAGE = python
|
||||
ERROR_EXT = newerr
|
||||
# Portable dos2unix / todos for stripping CR
|
||||
TODOS = tr -d '\r'
|
||||
#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
|
@ -34,18 +37,18 @@ include $(srcdir)/../common.mk
|
|||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
echo "$(ACTION)ing errors testcase $*"
|
||||
-$(SWIG) -c++ -python -Wall $(SWIGOPT) $*.i 2> $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $*.stderr $*.newerr
|
||||
-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
|
||||
|
||||
%.ctest:
|
||||
echo "$(ACTION)ing errors testcase $*"
|
||||
-$(SWIG) -python -Wall $(SWIGOPT) $*.i 2> $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $*.stderr $*.newerr
|
||||
-$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT)
|
||||
$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
|
||||
|
||||
%.clean:
|
||||
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile $(LANGUAGE)_clean
|
||||
@rm -f *.newerr *.py
|
||||
@rm -f *.$(ERROR_EXT) *.py
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,30 @@
|
|||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string"))
|
||||
; Note: when working with non-ascii strings in guile 2
|
||||
; locale must be set explicitly
|
||||
; Guile doesn't handle non-ascii characters in the default C locale
|
||||
; The locale must be set explicitly
|
||||
; The setlocale call below takes care of that
|
||||
(setlocale LC_ALL "en_US.utf8")
|
||||
; The locale needs to be a UTF-8 locale to handle the non-ASCII characters
|
||||
; But they are named differently on different systems so we try a few until one works
|
||||
|
||||
(define (try-set-locale name)
|
||||
; (display "testing ")
|
||||
; (display name)
|
||||
; (display "\n")
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(setlocale LC_ALL name)
|
||||
#t
|
||||
)
|
||||
(lambda (key . parameters)
|
||||
#f
|
||||
))
|
||||
)
|
||||
|
||||
(if (not (try-set-locale "C.UTF-8")) ; Linux
|
||||
(if (not (try-set-locale "en_US.utf8")) ; Linux
|
||||
(if (not (try-set-locale "en_US.UTF-8")) ; Mac OSX
|
||||
(error "Failed to set any UTF-8 locale")
|
||||
)))
|
||||
|
||||
(load "../schemerunme/li_std_string.scm")
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ setup = \
|
|||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* $(LANGUAGE)" ; \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi; \
|
||||
if [ ! -d $(JAVA_PACKAGE) ]; then \
|
||||
mkdir $(JAVA_PACKAGE); \
|
||||
|
|
|
|||
24
Examples/test-suite/java/cpp11_result_of_runme.java
Normal file
24
Examples/test-suite/java/cpp11_result_of_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import cpp11_result_of.*;
|
||||
|
||||
public class cpp11_result_of_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_result_of");
|
||||
} 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[])
|
||||
{
|
||||
double result = cpp11_result_of.test_result(cpp11_result_ofConstants.SQUARE, 3.0);
|
||||
if (result != 9.0)
|
||||
throw new RuntimeException("test_result(square, 3.0) is not 9.0. Got: " + Double.toString(result));
|
||||
|
||||
result = cpp11_result_of.test_result_alternative1(cpp11_result_ofConstants.SQUARE, 3.0);
|
||||
if (result != 9.0)
|
||||
throw new RuntimeException("test_result_alternative1(square, 3.0) is not 9.0. Got: " + Double.toString(result));
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,16 @@ public class java_director_runme {
|
|||
}
|
||||
}
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
QuuxContainer qc = createContainer();
|
||||
|
||||
|
|
@ -31,24 +41,21 @@ public class java_director_runme {
|
|||
qc = null;
|
||||
/* Watch qc get reaped, which causes the C++ object to delete
|
||||
objects from the internal vector */
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
|
||||
// Give the finalizers a chance to run
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Quux.instances() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Quux.instances();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
/* Watch the Quux objects formerly in the QuuxContainer object
|
||||
get reaped */
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
|
||||
instances = Quux.instances();
|
||||
if (instances != 0)
|
||||
throw new RuntimeException("Quux instances should be 0, actually " + instances);
|
||||
|
||||
/* Test Quux1's director disconnect method rename */
|
||||
Quux1 quux1 = new Quux1("quux1");
|
||||
if (quux1.disconnectMethodCalled)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@ public class li_boost_intrusive_ptr_runme {
|
|||
// Debugging flag
|
||||
public final static boolean debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -39,12 +49,7 @@ public class li_boost_intrusive_ptr_runme {
|
|||
|
||||
int countdown = 50;
|
||||
while (true) {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(100);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
|
||||
|
|
@ -52,7 +57,7 @@ public class li_boost_intrusive_ptr_runme {
|
|||
KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
|
||||
// Expect 1 Klass instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
}
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
||||
if (KlassWithoutRefCount.getTotal_count() != 0)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@ public class li_boost_shared_ptr_runme {
|
|||
// Debugging flag
|
||||
public final static boolean debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -37,21 +47,20 @@ public class li_boost_shared_ptr_runme {
|
|||
if (debug)
|
||||
System.out.println("Nearly finished");
|
||||
|
||||
int countdown = 100;
|
||||
while (true) {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount) // Expect the one global variable (GlobalValue)
|
||||
break;
|
||||
}
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
if (wrapper_count != li_boost_shared_ptr.getNOT_COUNTING())
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class li_std_auto_ptr_runme {
|
|||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(1);
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
|
@ -31,18 +31,38 @@ public class li_std_auto_ptr_runme {
|
|||
throw new RuntimeException("number of objects should be 2");
|
||||
|
||||
k1 = null;
|
||||
WaitForGC();
|
||||
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new RuntimeException("number of objects should be 1");
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
if (!k2.getLabel().equals("second"))
|
||||
throw new RuntimeException("wrong object label");
|
||||
|
||||
k2 = null;
|
||||
WaitForGC();
|
||||
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new RuntimeException("no objects should be left");
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
// throws typemaps for c++->java exception conversions
|
||||
%typemap(throws,throws="MyJavaException1") MyNS::Exception1 %{
|
||||
(void)$1;
|
||||
jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaException1");
|
||||
if (excpcls) {
|
||||
jenv->ThrowNew(excpcls, $1.what());
|
||||
|
|
@ -88,6 +89,7 @@
|
|||
%}
|
||||
|
||||
%typemap(throws,throws="MyJavaException1") int %{
|
||||
(void)$1;
|
||||
jclass excpcls = jenv->FindClass("java_director_exception_feature/MyJavaException1");
|
||||
if (excpcls) {
|
||||
jenv->ThrowNew(excpcls, "Threw some integer");
|
||||
|
|
@ -180,7 +182,7 @@ public:
|
|||
virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0;
|
||||
virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0;
|
||||
virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0;
|
||||
virtual std::string directorthrows_warning(int excp) throw(double) {}
|
||||
virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); }
|
||||
};
|
||||
|
||||
// Make a bar from a foo, so a call to Java Bar
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@
|
|||
%}
|
||||
|
||||
%typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException1") int %{
|
||||
(void)$1;
|
||||
jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException1");
|
||||
if (excpcls) {
|
||||
jenv->ThrowNew(excpcls, "Threw some integer");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
%inline %{
|
||||
#include <iostream>
|
||||
struct XXX {
|
||||
XXX(int value) : value(value) {
|
||||
XXX(int v) : value(v) {
|
||||
if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
|
||||
count++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,3 +73,6 @@ f.func_ptr=func1_ptr
|
|||
assert(cb.test_func_ptr(f,2)==16)
|
||||
f.func_ptr=func2_ptr
|
||||
assert(cb.test_func_ptr(f,2)==-8)
|
||||
|
||||
-- Test that __tostring metamethod produce no internal asserts
|
||||
f2_name = tostring(f2)
|
||||
|
|
|
|||
|
|
@ -62,6 +62,18 @@ sc = ns.Outer.SomeClass()
|
|||
assert( sc:GetInner1ColorChannel() ~= sc:GetInner2Channel() )
|
||||
assert( sc:GetInner1Channel() ~= sc:GetInner2Channel() )
|
||||
|
||||
-- Backward compatibility
|
||||
assert(ns.Outer.Inner1.Diffuse ~= nil)
|
||||
-- Enums within class within namespace shouldn't have backward compatible name. Same for static methods
|
||||
assert(ns.Outer.Inner1.Color_Diffuse == nil)
|
||||
assert(ns.Outer.Inner1.Color_colorStaticMethod == nil)
|
||||
|
||||
|
||||
-- Enums and static methods of class marked as %nonspace should have backward compatible name
|
||||
assert(ns.NoNSpacePlease_noNspaceStaticFunc() == 10)
|
||||
assert(ns.Outer.Inner2.NoNSpacePlease_NoNspace == nil)
|
||||
-- ReallyNoNSpaceEnum is wrapped into %nonspace and thus handled correctly.
|
||||
-- NoNSpaceEnum is not (although both of them are in %nonspace-wrapped class) and thus
|
||||
-- handled rather unexpectedly
|
||||
assert(ns.NoNSpacePlease_ReallyNoNspace1 == 1)
|
||||
assert(ns.NoNSpacePlease.ReallyNoNspace2 == 10)
|
||||
|
||||
|
|
|
|||
35
Examples/test-suite/nested_directors.i
Normal file
35
Examples/test-suite/nested_directors.i
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
%module(directors="1", allprotected="1") nested_directors
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) NN::Base::Nest;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) NN::Sub::IListener;
|
||||
|
||||
%feature("director") Base;
|
||||
%feature("director") Sub;
|
||||
%feature("director") Base::Nest;
|
||||
|
||||
%inline %{
|
||||
namespace NN {
|
||||
class Base {
|
||||
public:
|
||||
virtual ~Base(){}
|
||||
class Nest {
|
||||
public:
|
||||
virtual ~Nest(){}
|
||||
virtual bool GetValue(){ return false; }
|
||||
};
|
||||
protected:
|
||||
virtual bool DoNothing() = 0;
|
||||
};
|
||||
|
||||
class Sub : public Base {
|
||||
public:
|
||||
class IListener {
|
||||
};
|
||||
public:
|
||||
virtual ~Sub(){}
|
||||
protected:
|
||||
void DoSomething(){}
|
||||
virtual bool GetValue() const { return true; }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
|
@ -33,6 +33,7 @@ int getInside1Val(struct Outer *n) { return n->inside1.val; }
|
|||
Below was causing problems in Octave as wrappers were compiled as C++.
|
||||
Solution requires regenerating the inner struct into
|
||||
the global C++ namespace (which is where it is intended to be in C).
|
||||
See cparse_cplusplusout / Swig_cparse_cplusplusout in the Source.
|
||||
*/
|
||||
%inline %{
|
||||
int nestedByVal(struct Named s);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
|||
|
||||
%nspace;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease::ReallyNoNSpaceEnum;
|
||||
|
||||
%copyctor;
|
||||
%ignore Outer::Inner2::Color::Color();
|
||||
|
|
@ -67,7 +68,12 @@ namespace Outer {
|
|||
const Outer::Inner2::Color& col2c) {}
|
||||
}; // Color
|
||||
int Color::staticMemberVariable = 0;
|
||||
class NoNSpacePlease {};
|
||||
class NoNSpacePlease {
|
||||
public:
|
||||
enum NoNSpaceEnum { NoNspace1 = 1, NoNspace2 = 10 };
|
||||
enum ReallyNoNSpaceEnum { ReallyNoNspace1 = 1, ReallyNoNspace2 = 10 };
|
||||
static int noNspaceStaticFunc() { return 10; }
|
||||
};
|
||||
} // Inner2
|
||||
|
||||
// Derived class
|
||||
|
|
|
|||
19
Examples/test-suite/overload_bool.i
Normal file
19
Examples/test-suite/overload_bool.i
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
%module overload_bool
|
||||
|
||||
%inline %{
|
||||
const char* overloaded(bool value) { return "bool"; }
|
||||
const char* overloaded(int value) { return "int"; }
|
||||
const char* overloaded(const char *value) { return "string"; }
|
||||
|
||||
const char* boolfunction(bool value) { return value ? "true" : "false"; }
|
||||
const char* intfunction(int value) { return "int"; }
|
||||
|
||||
|
||||
// Const references
|
||||
const char* overloaded_ref(bool const& value) { return "bool"; }
|
||||
const char* overloaded_ref(int const& value) { return "int"; }
|
||||
const char* overloaded_ref(const char *value) { return "string"; }
|
||||
|
||||
const char* boolfunction_ref(bool const& value) { return value ? "true" : "false"; }
|
||||
const char* intfunction_ref(int const& value) { return "int"; }
|
||||
%}
|
||||
|
|
@ -32,8 +32,8 @@
|
|||
};
|
||||
|
||||
struct prev {
|
||||
prev & operator++() { }
|
||||
prev operator++(int) { }
|
||||
prev & operator++() { return *this; }
|
||||
prev operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
import cpp11_result_of
|
||||
if cpp11_result_of.test_result(cpp11_result_of.square, 3.0) != 9.0:
|
||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0."
|
||||
|
||||
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
|
||||
if result != 9.0:
|
||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(result)
|
||||
|
||||
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
|
||||
if result != 9.0:
|
||||
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(result)
|
||||
|
|
|
|||
7
Examples/test-suite/python/cpp11_type_traits_runme.py
Normal file
7
Examples/test-suite/python/cpp11_type_traits_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from cpp11_type_traits import *
|
||||
|
||||
if Elaborate(0, 0) != 1:
|
||||
raise RuntimeError("Elaborate should have returned 1")
|
||||
|
||||
if Elaborate(0, 0.0) != 2:
|
||||
raise RuntimeError("Elaborate should have returned 2")
|
||||
|
|
@ -17,10 +17,10 @@ halve_in_place(dv)
|
|||
|
||||
|
||||
bv = BoolVector(4)
|
||||
bv[0]= 1
|
||||
bv[1]= 0
|
||||
bv[2]= 4
|
||||
bv[3]= 0
|
||||
bv[0]= bool(1)
|
||||
bv[1]= bool(0)
|
||||
bv[2]= bool(4)
|
||||
bv[3]= bool(0)
|
||||
|
||||
if bv[0] != bv[2]:
|
||||
raise RuntimeError,"bad std::vector<bool> mapping"
|
||||
|
|
|
|||
55
Examples/test-suite/python/overload_bool_runme.py
Normal file
55
Examples/test-suite/python/overload_bool_runme.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import overload_bool
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overload_bool.overloaded(True) != "bool":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded(False) != "bool":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
if overload_bool.overloaded(0) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded(1) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded(2) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
if overload_bool.overloaded("1234") != "string":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
# Test bool masquerading as int
|
||||
if overload_bool.intfunction(True) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.intfunction(False) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
# Test int masquerading as bool
|
||||
# Not possible
|
||||
|
||||
|
||||
#############################################
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overload_bool.overloaded_ref(True) != "bool":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded_ref(False) != "bool":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
if overload_bool.overloaded_ref(0) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded_ref(1) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.overloaded_ref(2) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
if overload_bool.overloaded_ref("1234") != "string":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
# Test bool masquerading as int
|
||||
if overload_bool.intfunction_ref(True) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
if overload_bool.intfunction_ref(False) != "int":
|
||||
raise RuntimeError("wrong!")
|
||||
|
||||
# Test int masquerading as bool
|
||||
# Not possible
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ if ref_float(3.5) != 3.5:
|
|||
if ref_double(3.5) != 3.5:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_bool(1) != 1:
|
||||
if ref_bool(True) != True:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_char('x') != 'x':
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ if getconstTC().num != 33:
|
|||
raise RuntimeError
|
||||
|
||||
# primitive reference variables
|
||||
cvar.var_bool = createref_bool(0)
|
||||
if value_bool(cvar.var_bool) != 0:
|
||||
cvar.var_bool = createref_bool(False)
|
||||
if value_bool(cvar.var_bool) != False:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.var_bool = createref_bool(1)
|
||||
if value_bool(cvar.var_bool) != 1:
|
||||
cvar.var_bool = createref_bool(True)
|
||||
if value_bool(cvar.var_bool) != True:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.var_char = createref_char('w')
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ for i in range(0,len(m)):
|
|||
if m[i][j] != im[i][j]:
|
||||
raise RuntimeError, "bad getslice"
|
||||
|
||||
m = ((1,0,1),(1,1),(1,1))
|
||||
m = ((True,False,True),(True,True),(True,True))
|
||||
im = std_containers.midentb(m)
|
||||
for i in range(0,len(m)):
|
||||
for j in range(0,len(m[i])):
|
||||
|
|
|
|||
88
Examples/test-suite/ruby/overload_bool_runme.rb
Executable file
88
Examples/test-suite/ruby/overload_bool_runme.rb
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put description here
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'overload_bool'
|
||||
|
||||
include Overload_bool
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overloaded(true) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(false) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded(0) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(1) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(2) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded("1234") != "string"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
# Test bool masquerading as integer
|
||||
# Not possible
|
||||
|
||||
# Test int masquerading as bool
|
||||
if boolfunction(0) != "false"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction(1) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction(2) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
#############################################
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overloaded_ref(true) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(false) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded_ref(0) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(1) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(2) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded_ref("1234") != "string"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
# Test bool masquerading as integer
|
||||
# Not possible
|
||||
|
||||
# Test int masquerading as bool
|
||||
if boolfunction_ref(0) != "false"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction_ref(1) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction_ref(2) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
%module smart_pointer_template_defaults_overload
|
||||
|
||||
// SF Bug #1363
|
||||
// Problem with method overloading when some methods are added by %extend and others are real methods
|
||||
// and using template default parameters with smart pointers.
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Wrap::operator->;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Container::rubout;
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_map.i>
|
||||
|
||||
%inline %{
|
||||
template <typename T>
|
||||
class Wrap {
|
||||
T *ptr;
|
||||
public:
|
||||
Wrap(T *p) : ptr(p) {}
|
||||
T const* operator->(void) const { return ptr; }
|
||||
T* operator->(void) { return ptr; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(StringDoubleMap) std::map<std::string, double>; // erase is generated okay
|
||||
%template(WrappedMap) Wrap< std::map<std::string, double> >; // erase wrappers lead to compile error
|
||||
|
||||
// Above only affects some languages depending on how std::map is implemented.
|
||||
// Below is a cutdown language independent demonstration of the bug
|
||||
|
||||
%extend Container {
|
||||
void rubout(int, int) {}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
template<typename T, typename X = T> class Container {
|
||||
public:
|
||||
int rubout() { return 0; }
|
||||
void rubout(T const &element) {}
|
||||
static Container* factory() { return new Container(); }
|
||||
static Container* factory(bool b) { return new Container(); }
|
||||
static void staticstuff(bool) {}
|
||||
#ifdef SWIG
|
||||
%extend {
|
||||
void rubout(bool) {}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
%}
|
||||
|
||||
%extend Container {
|
||||
void rubout(int) {}
|
||||
}
|
||||
|
||||
%template(ContainerInt) Container<double>;
|
||||
%template(WrapContainerInt) Wrap< Container<double> >;
|
||||
|
||||
|
|
@ -7,10 +7,11 @@
|
|||
/* do nothing */
|
||||
}
|
||||
|
||||
%typemap(out) Integer1
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
#ifdef SWIGCSHARP
|
||||
%typemap(out) Integer1 { /* do nothing */ $result = 0; }
|
||||
#else
|
||||
%typemap(out) Integer1 { /* do nothing */ }
|
||||
#endif
|
||||
|
||||
%typemap(in) Integer2
|
||||
{
|
||||
|
|
@ -18,10 +19,11 @@
|
|||
/* do nothing */
|
||||
}
|
||||
|
||||
%typemap(out) Integer2
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
#ifdef SWIGCSHARP
|
||||
%typemap(out) Integer2 { /* do nothing */ $result = 0; }
|
||||
#else
|
||||
%typemap(out) Integer2 { /* do nothing */ }
|
||||
#endif
|
||||
|
||||
%{
|
||||
typedef int Integer1;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,19 @@ void foo2(Foo<short> f, const Foo<short>& ff) {}
|
|||
};
|
||||
}
|
||||
|
||||
#ifdef SWIGCSHARP
|
||||
#define TYPEMAP_OUT_INIT $result = 0;
|
||||
#else
|
||||
#define TYPEMAP_OUT_INIT
|
||||
#endif
|
||||
|
||||
// Test obscure bug where named typemaps where not being applied when symbol name contained a number
|
||||
%typemap(out) double "_typemap_for_double_no_compile_"
|
||||
%typemap(out) double ABCD::meth "$1 = 0.0;"
|
||||
%typemap(out) double ABCD::m1 "$1 = 0.0;"
|
||||
%typemap(out) double ABCD::_x2 "$1 = 0.0;"
|
||||
%typemap(out) double ABCD::y_ "$1 = 0.0;"
|
||||
%typemap(out) double ABCD::_3 "$1 = 0.0;"
|
||||
%typemap(out) double ABCD::meth {$1 = 0.0; TYPEMAP_OUT_INIT}
|
||||
%typemap(out) double ABCD::m1 {$1 = 0.0; TYPEMAP_OUT_INIT}
|
||||
%typemap(out) double ABCD::_x2 {$1 = 0.0; TYPEMAP_OUT_INIT}
|
||||
%typemap(out) double ABCD::y_ {$1 = 0.0; TYPEMAP_OUT_INIT}
|
||||
%typemap(out) double ABCD::_3 {$1 = 0.0; TYPEMAP_OUT_INIT}
|
||||
%inline %{
|
||||
struct ABCD {
|
||||
double meth() { return 0.0; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue