From: SourceForge.net <no...@so...> - 2008-11-29 17:51:14
|
Bugs item #2359417, was opened at 2008-11-29 17:51 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2359417&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: William Fulton (wsfulton) Assigned to: Nobody/Anonymous (nobody) Summary: Type system broken for pointers and the STL Initial Comment: The type system is broken when using the STL and pointers. Testcase below (li_std_vector_ptr.i - checked into svn): %module li_std_vector_ptr %include "std_vector.i" %template(IntPtrVector) std::vector<int *>; %inline %{ #include <iostream> using namespace std; int* makeIntPtr(int v) { return new int(v); } double* makeDoublePtr(double v) { return new double(v); } #if 1 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) cout << *vpi[i] << endl; } %} The following Python code fails: from li_std_vector_ptr import * ip1 = makeIntPtr(11) ip2 = makeIntPtr(22) vi = IntPtrVector((ip1, ip2)) displayVector(vi) Traceback (most recent call last): File "./li_std_vector_ptr_runme.py", line 6, in <module> vi = IntPtrVector((ip1, ip2)) File "/home/william/swig/trunk/Examples/test-suite/python/li_std_vector_ptr.py", line 122, in __init__ this = _li_std_vector_ptr.new_IntPtrVector(*args) NotImplementedError: Wrong number of arguments for overloaded function 'new_IntPtrVector'. Possible C/C++ prototypes are: std::vector< int * >() std::vector< int * >(std::vector< int * > const &) std::vector< int * >(std::vector< int * >::size_type) std::vector< int * >(std::vector< int * >::size_type,std::vector< int * >::value_type) Something to do with int ** in the type system causes it to fail, because if the makeIntIntPtr() method is removed, then it works. But I think it works by chance more than anything else as in SWIG_Python_ConvertPtrAndOwn(), swig_type_info *ty is zero, when it should contain type information for "int *". The problem was previously masked but since fixing invalid STL conversions, the problem is more visible, see svn changeset 10958. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2359417&group_id=1645 |