Merge branch 'master' into directorargout_and_java_typemaps
This commit is contained in:
commit
c7adb7901d
68 changed files with 568 additions and 462 deletions
|
|
@ -87,7 +87,6 @@ CPP_TEST_BROKEN += \
|
|||
director_nested_class \
|
||||
exception_partial_info \
|
||||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
li_boost_shared_ptr_template \
|
||||
nested_private \
|
||||
overload_complicated \
|
||||
|
|
@ -308,6 +307,7 @@ CPP_TEST_CASES += \
|
|||
nested_class \
|
||||
nested_directors \
|
||||
nested_comment \
|
||||
nested_ignore \
|
||||
nested_scope \
|
||||
nested_template_base \
|
||||
nested_workaround \
|
||||
|
|
@ -587,6 +587,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_vector \
|
||||
li_std_vector_enum \
|
||||
li_std_vector_member_var\
|
||||
li_std_vector_ptr \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
template_type_namespace \
|
||||
|
|
|
|||
|
|
@ -2,15 +2,6 @@
|
|||
|
||||
// Type aliasing seg fault : Github issue #424
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
|
||||
|
||||
%inline %{
|
||||
namespace Halide {
|
||||
|
||||
|
|
@ -53,14 +44,69 @@ public:
|
|||
|
||||
|
||||
%inline %{
|
||||
using Int = int;
|
||||
using IntRef = int&;
|
||||
using IntPtrRef = int*&;
|
||||
using IntRValueRef = int&&;
|
||||
using IntArray = int[];
|
||||
|
||||
using HalideTargetPtr1 = Halide::Target*;
|
||||
namespace Halide {
|
||||
using HalideTargetPtr2 = Target*;
|
||||
}
|
||||
%}
|
||||
|
||||
// Define some types
|
||||
|
||||
%inline %{
|
||||
using Int = int;
|
||||
using IntPtr = Int*;
|
||||
using IntRef = Int&;
|
||||
using IntPtrRef = Int*&;
|
||||
using IntRValueRef = Int&&;
|
||||
using IntArray = Int[];
|
||||
%}
|
||||
|
||||
// Test that SWIG understands these new types
|
||||
|
||||
%callback("%s_cb");
|
||||
Int mult2(Int x);
|
||||
%nocallback;
|
||||
|
||||
%inline %{
|
||||
Int mult2(Int x) { return x * 2; }
|
||||
IntPtr allocate_int() { return new Int(12); }
|
||||
void free_int(int* ptr) { delete ptr; }
|
||||
void inplace_mult2(IntRef x) { x *= 2; }
|
||||
Int read_int(IntPtr ptr) { return *ptr; }
|
||||
|
||||
template <typename T> class Pair {
|
||||
public:
|
||||
using data_t = T;
|
||||
|
||||
data_t a, b;
|
||||
|
||||
Pair() : a(), b() { }
|
||||
Pair(data_t a, data_t b) : a(a), b(b) { }
|
||||
data_t first() { return a; }
|
||||
data_t second() { return b; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(int_pair) Pair<Int>;
|
||||
|
||||
%inline %{
|
||||
using PairInt = Pair<Int>;
|
||||
|
||||
class PairSubclass : public PairInt {
|
||||
public:
|
||||
PairSubclass(data_t a, data_t b) : PairInt(a, b) { }
|
||||
|
||||
using const_ref_data_t = const data_t&;
|
||||
};
|
||||
|
||||
PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; }
|
||||
%}
|
||||
|
||||
// Test function pointers
|
||||
|
||||
%inline %{
|
||||
using callback_t = int(*)(int);
|
||||
|
||||
callback_t get_callback() { return mult2; }
|
||||
int call(callback_t func, int param) { return func(param); }
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ The primary purpose of this testcase is to ensure that enums used along with the
|
|||
|
||||
%inline %{
|
||||
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for anonymous enums */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
enum SOME_ENUM {ENUM_ONE, ENUM_TWO};
|
||||
|
||||
struct StructWithEnums {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@
|
|||
|
||||
%inline %{
|
||||
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for anonymous enums */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
enum { AnonEnum1, AnonEnum2 = 100 };
|
||||
enum { ReallyAnInteger = 200 };
|
||||
//enum { AnonEnum3, AnonEnum4 } instance;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@
|
|||
|
||||
%inline %{
|
||||
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for anonymous enums */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CSP_ITERATION_FWD,
|
||||
CSP_ITERATION_BWD = 11
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
cpp_using_type_aliasing.i:8: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
|
||||
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
|
||||
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
|
||||
|
|
@ -1,12 +1,19 @@
|
|||
package main
|
||||
|
||||
import . "./li_std_vector_ptr"
|
||||
import "fmt"
|
||||
|
||||
func check(val1 int, val2 int) {
|
||||
if val1 != val2 {
|
||||
panic(fmt.Sprintf("Values are not the same %d %d", val1, val2))
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
ip1 := MakeIntPtr(11)
|
||||
ip2 := MakeIntPtr(22)
|
||||
vi := NewIntPtrVector()
|
||||
vi.Add(ip1)
|
||||
vi.Add(ip2)
|
||||
DisplayVector(vi)
|
||||
check(GetValueFromVector(vi, 0), 11)
|
||||
check(GetValueFromVector(vi, 1), 22)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ INTEGER bar_getter(Base<INTEGER>& foo) {
|
|||
// 2nd test - templates with default template parameters
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%shared_ptr(Space::BaseDefault<short>)
|
||||
%shared_ptr(Space::BaseDefault<short, int>)
|
||||
%shared_ptr(Space::DerivedDefault<short>)
|
||||
%shared_ptr(Space::DerivedDefault2<short>)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Bug 2359417
|
||||
// SF Bug 2359417
|
||||
%module li_std_vector_ptr
|
||||
|
||||
%include "std_vector.i"
|
||||
|
|
@ -15,16 +15,76 @@ double* makeDoublePtr(double v) {
|
|||
return new double(v);
|
||||
}
|
||||
|
||||
#if 1
|
||||
// pointer to pointer in the wrappers was preventing a vector of pointers from working
|
||||
int** makeIntPtrPtr(int* v) {
|
||||
return new int*(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
void displayVector(std::vector<int *> vpi) {
|
||||
cout << "displayVector..." << endl;
|
||||
for (int i=0; i<vpi.size(); ++i)
|
||||
for (size_t i=0; i<vpi.size(); ++i)
|
||||
cout << *vpi[i] << endl;
|
||||
}
|
||||
int getValueFromVector(std::vector<int *> vpi, size_t index) {
|
||||
return *vpi[index];
|
||||
}
|
||||
%}
|
||||
|
||||
// A not exposed to wrappers
|
||||
%{
|
||||
struct A {
|
||||
int val;
|
||||
A(int val) : val(val) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(APtrVector) std::vector<A *>;
|
||||
|
||||
%inline %{
|
||||
A *makeA(int val) { return new A(val); }
|
||||
int getVal(A* a) { return a->val; }
|
||||
int getVectorValueA(std::vector<A *> vpi, size_t index) {
|
||||
return vpi[index]->val;
|
||||
}
|
||||
%}
|
||||
|
||||
// B is fully exposed to wrappers
|
||||
%inline %{
|
||||
struct B {
|
||||
int val;
|
||||
B(int val = 0) : val(val) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(BPtrVector) std::vector<B *>;
|
||||
|
||||
%inline %{
|
||||
B *makeB(int val) { return new B(val); }
|
||||
int getVal(B* b) { return b->val; }
|
||||
int getVectorValueB(std::vector<B *> vpi, size_t index) {
|
||||
return vpi[index]->val;
|
||||
}
|
||||
%}
|
||||
|
||||
// C is fully exposed to wrappers (includes code using B **)
|
||||
%inline %{
|
||||
struct C {
|
||||
int val;
|
||||
C(int val = 0) : val(val) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(CPtrVector) std::vector<C *>;
|
||||
|
||||
%inline %{
|
||||
// pointer to pointer in the wrappers was preventing a vector of pointers from working
|
||||
C** makeCIntPtrPtr(C* v) {
|
||||
return new C*(v);
|
||||
}
|
||||
C *makeC(int val) { return new C(val); }
|
||||
int getVal(C* b) { return b->val; }
|
||||
int getVectorValueC(std::vector<C *> vpi, size_t index) {
|
||||
return vpi[index]->val;
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,18 @@ Also tests reported error when a #define placed in a deeply embedded struct/unio
|
|||
%rename(InUnNamed) OuterStructNamed::Inner_union_named;
|
||||
#endif
|
||||
|
||||
#if defined(SWIG_JAVASCRIPT_V8)
|
||||
|
||||
%inline %{
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for nested C class wrappers compiled as C++ code */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
struct TestStruct {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
%module nested_extend_c
|
||||
|
||||
#if defined(SWIG_JAVASCRIPT_V8)
|
||||
|
||||
%inline %{
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for nested C class wrappers compiled as C++ code */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
|
||||
%extend hiA {
|
||||
hiA() {
|
||||
|
|
|
|||
24
Examples/test-suite/nested_ignore.i
Normal file
24
Examples/test-suite/nested_ignore.i
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
%module nested_ignore
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) B::C::D;
|
||||
|
||||
%rename($ignore) B::C;
|
||||
|
||||
%inline %{
|
||||
namespace B {
|
||||
class C {
|
||||
public:
|
||||
struct D {
|
||||
};
|
||||
};
|
||||
|
||||
class E {
|
||||
public:
|
||||
typedef C::D D;
|
||||
};
|
||||
|
||||
struct F
|
||||
{
|
||||
const E::D foo(){ return E::D(); }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
|
@ -1,5 +1,17 @@
|
|||
%module nested_structs
|
||||
|
||||
#if defined(SWIG_JAVASCRIPT_V8)
|
||||
|
||||
%inline %{
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for nested C class wrappers compiled as C++ code */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
// bug #491476
|
||||
%inline %{
|
||||
struct Outer {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,19 @@ def check(got, expected, expected_builtin=None, skip=False):
|
|||
def is_new_style_class(cls):
|
||||
return hasattr(cls, "__class__")
|
||||
|
||||
def is_fastproxy(module):
|
||||
return "new_instancemethod" in module
|
||||
|
||||
if not is_new_style_class(A):
|
||||
# Missing static methods make this hard to test... skip if -classic is
|
||||
# used!
|
||||
sys.exit(0)
|
||||
|
||||
if is_fastproxy(dir()):
|
||||
# Detect when -fastproxy is specified and skip test as it changes the function names making it
|
||||
# hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved
|
||||
sys.exit(0)
|
||||
|
||||
# skip builtin check - the autodoc is missing, but it probably should not be
|
||||
skip = True
|
||||
|
||||
|
|
|
|||
32
Examples/test-suite/python/cpp11_type_aliasing_runme.py
Normal file
32
Examples/test-suite/python/cpp11_type_aliasing_runme.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from cpp11_type_aliasing import *
|
||||
|
||||
if get_host_target().bits != 32:
|
||||
raise RuntimeError("get_host_target().bits should return 32")
|
||||
|
||||
if mult2(10) != 20:
|
||||
raise RuntimeError("mult2(10) should return 20")
|
||||
|
||||
int_ptr = allocate_int()
|
||||
inplace_mult2(int_ptr)
|
||||
if read_int(int_ptr) != 24:
|
||||
raise RuntimeError("read_int should return 24")
|
||||
free_int(int_ptr)
|
||||
|
||||
pair = PairSubclass(3, 4)
|
||||
if pair.first() != 3:
|
||||
raise RuntimeError("pair.first() should return 3")
|
||||
|
||||
if pair.second() != 4:
|
||||
raise RuntimeError("pair.second() should return 4")
|
||||
|
||||
if pair.a != 3:
|
||||
raise RuntimeError("pair.a should be 3")
|
||||
|
||||
if plus1(5) != 6:
|
||||
raise RuntimeError("plus1(5) should return 6")
|
||||
|
||||
if call(mult2_cb, 7) != 14:
|
||||
raise RuntimeError("call(mult2_cb, 7) should return 14")
|
||||
|
||||
if call(get_callback(), 7) != 14:
|
||||
raise RuntimeError("call(get_callback(), 7) should return 14")
|
||||
|
|
@ -14,4 +14,5 @@ else:
|
|||
StaticFunctionTest().static_func_2(1)
|
||||
StaticFunctionTest().static_func_3(1, 2)
|
||||
StaticMemberTest.static_int = 10
|
||||
assert StaticMemberTest.static_int == 10
|
||||
if not StaticMemberTest.static_int == 10:
|
||||
raise RuntimeError("static_int not 10")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import exception_classname
|
||||
|
||||
a = exception_classname.Exception()
|
||||
assert a.testfunc() == 42
|
||||
if a.testfunc() != 42:
|
||||
raise RuntimeError("Not 42!")
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ if d.bar() != 2:
|
|||
raise RuntimeError
|
||||
if bar_getter(b) != 1:
|
||||
raise RuntimeError
|
||||
# Fix reverted in rev 12953
|
||||
# if bar_getter(d) != 2:
|
||||
# raise RuntimeError
|
||||
if bar_getter(d) != 2:
|
||||
raise RuntimeError
|
||||
|
||||
b = BaseDefaultInt()
|
||||
d = DerivedDefaultInt()
|
||||
|
|
@ -23,8 +22,11 @@ if d2.bar2() != 4:
|
|||
raise RuntimeError
|
||||
if bar2_getter(b) != 3:
|
||||
raise RuntimeError
|
||||
# Fix reverted in rev 12953
|
||||
# if bar2_getter(d) != 4:
|
||||
# raise RuntimeError
|
||||
# if bar2_getter(d2) != 4:
|
||||
# raise RuntimeError
|
||||
# SWIG fix reverted in Subversion rev 12953
|
||||
# Testcase has now been modified to mask the problem by providing the default parameter 'int' in:
|
||||
# %shared_ptr(Space::BaseDefault<short, int>)
|
||||
# If this is not done then d fails to convert to BaseDefault<short>&
|
||||
if bar2_getter(d) != 4:
|
||||
raise RuntimeError
|
||||
if bar2_getter(d2) != 4:
|
||||
raise RuntimeError
|
||||
|
|
|
|||
|
|
@ -1,7 +1,38 @@
|
|||
from li_std_vector_ptr import *
|
||||
|
||||
def check(val1, val2):
|
||||
if val1 != val2:
|
||||
raise RuntimeError("Values are not the same %s %s" % (val1, val2))
|
||||
ip1 = makeIntPtr(11)
|
||||
ip2 = makeIntPtr(22)
|
||||
|
||||
vi = IntPtrVector((ip1, ip2))
|
||||
displayVector(vi)
|
||||
check(getValueFromVector(vi, 0), 11)
|
||||
check(getValueFromVector(vi, 1), 22)
|
||||
|
||||
vA = APtrVector([makeA(33), makeA(34)])
|
||||
check(getVectorValueA(vA, 0), 33)
|
||||
|
||||
vB = BPtrVector([makeB(133), makeB(134)])
|
||||
check(getVectorValueB(vB, 0), 133)
|
||||
|
||||
vC = CPtrVector([makeC(1133), makeC(1134)])
|
||||
check(getVectorValueC(vC, 0), 1133)
|
||||
|
||||
|
||||
vA = [makeA(233), makeA(234)]
|
||||
check(getVectorValueA(vA, 0), 233)
|
||||
|
||||
vB = [makeB(333), makeB(334)]
|
||||
check(getVectorValueB(vB, 0), 333)
|
||||
|
||||
vC = [makeC(3333), makeC(3334)]
|
||||
check(getVectorValueC(vC, 0), 3333)
|
||||
|
||||
# mixed A and B should not be accepted
|
||||
vAB = [makeA(999), makeB(999)]
|
||||
try:
|
||||
check(getVectorValueA(vAB, 0), 999)
|
||||
raise RuntimeError("missed exception")
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
import operbool
|
||||
assert not operbool.Test()
|
||||
if operbool.Test():
|
||||
raise RuntimeError("operbool failed")
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ def test1():
|
|||
sys.stderr.flush()
|
||||
sys.stderr = stderr_saved
|
||||
|
||||
assert attributeErrorOccurred
|
||||
assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1
|
||||
if not attributeErrorOccurred:
|
||||
raise RuntimeError("attributeErrorOccurred failed")
|
||||
if not buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1:
|
||||
raise RuntimeError("ClassWithThrowingDestructor dtor doing bad things failed")
|
||||
|
||||
class VectorHolder(object):
|
||||
def __init__(self, v):
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@ if sys.version_info[0:2] >= (3, 1):
|
|||
if unicode_strings.non_utf8_std_string() != test_string:
|
||||
raise ValueError('Test comparison mismatch')
|
||||
|
||||
def check(s1, s2):
|
||||
if s1 != s2:
|
||||
raise RuntimeError("{} != {}".format(s1, s2))
|
||||
|
||||
# Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C
|
||||
if sys.version_info[0:2] < (3, 0):
|
||||
assert unicode_strings.charstring("hello1") == "hello1"
|
||||
assert unicode_strings.charstring(str(u"hello2")) == "hello2"
|
||||
assert unicode_strings.charstring(u"hello3") == "hello3"
|
||||
assert unicode_strings.charstring(unicode("hello4")) == "hello4"
|
||||
check(unicode_strings.charstring("hello1"), "hello1")
|
||||
check(unicode_strings.charstring(str(u"hello2")), "hello2")
|
||||
check(unicode_strings.charstring(u"hello3"), "hello3")
|
||||
check(unicode_strings.charstring(unicode("hello4")), "hello4")
|
||||
unicode_strings.charstring(u"hell\xb05")
|
||||
unicode_strings.charstring(u"hell\u00f66")
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ top_builddir = ../@top_builddir@
|
|||
|
||||
C_TEST_CASES += \
|
||||
scilab_consts \
|
||||
scilab_enums \
|
||||
scilab_identifier_name \
|
||||
|
||||
CPP_TEST_CASES += \
|
||||
|
|
@ -21,6 +20,7 @@ CPP_TEST_CASES += \
|
|||
primitive_types \
|
||||
scilab_li_matrix \
|
||||
scilab_multivalue \
|
||||
scilab_enums \
|
||||
scilab_pointer_conversion_functions \
|
||||
|
||||
CPP_STD_TEST_CASES += \
|
||||
|
|
|
|||
|
|
@ -24,4 +24,13 @@ checkEnum(TYPEDEF_ENUM_1_2, 22);
|
|||
checkEnum(TYPEDEF_ENUM_2_1, 31);
|
||||
checkEnum(TYPEDEF_ENUM_2_2, 32);
|
||||
|
||||
checkEnum(ENUM_REF_1, 1);
|
||||
checkEnum(ENUM_REF_2, 10);
|
||||
|
||||
checkEnum(clsEnum_CLS_ENUM_1, 100);
|
||||
checkEnum(clsEnum_CLS_ENUM_2, 101);
|
||||
|
||||
checkEnum(clsEnum_CLS_ENUM_REF_1, 101);
|
||||
checkEnum(clsEnum_CLS_ENUM_REF_2, 110);
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
|
|
|||
|
|
@ -35,4 +35,21 @@ typedef enum TYPEDEF_ENUM_2 {
|
|||
TYPEDEF_ENUM_2_2 = 32
|
||||
} TYPEDEF_ENUM_2;
|
||||
|
||||
enum ENUM_REF {
|
||||
ENUM_REF_1 = 1,
|
||||
ENUM_REF_2 = ENUM_REF_1 + 9
|
||||
};
|
||||
|
||||
class clsEnum {
|
||||
public:
|
||||
enum CLS_ENUM {
|
||||
CLS_ENUM_1 = 100,
|
||||
CLS_ENUM_2 = 101
|
||||
};
|
||||
enum CLS_ENUM_REF {
|
||||
CLS_ENUM_REF_1 = 101,
|
||||
CLS_ENUM_REF_2 = CLS_ENUM_REF_1 + 9
|
||||
};
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
%module traits
|
||||
|
||||
%include typemaps/traits.swg
|
||||
|
||||
|
||||
%fragment("Traits");
|
||||
|
|
@ -1,6 +1,13 @@
|
|||
%module typedef_struct
|
||||
|
||||
%inline %{
|
||||
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
/* for anonymous enums */
|
||||
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int numpoints;
|
||||
} LineObj;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue