Merge branch 'stl-vector-ptrs'
* stl-vector-ptrs: Test case warning fixes for nodejs Fix testcase causing nodejs test failure UTL STL container descriptor checks Fix std::vector of pointers which failed if a pointer to a pointer of the container element type existed (Python) Remove unused traits.swg
This commit is contained in:
commit
4ab3af90cb
32 changed files with 235 additions and 362 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 \
|
||||
|
|
@ -588,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 \
|
||||
|
|
|
|||
|
|
@ -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,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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,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