[C++-sig] problem exposing iterators
abhi.sri45
abhishek.srivastava at nechclst.in
Thu Jun 17 11:27:06 CEST 2010
Hi,
I am facing some problem in exposing iterator(using pyplusplus), for this I
have created a sample problem(to communicate this problem)
#include<iostream>
#include<vector>
using namespace std;
class A
{
};
typedef vector< A > vectorA;
class B
{
public:
typedef vectorA::iterator iter;
iter begin()
{
return this->aVect.begin();
}
private:
vectorA aVect;
};
B getB()
{
return B();
}
main()
{
B b(getB());
vectorA::iterator it = b.begin();
}
Here in the above example begin() function in class returns vector
::iterator and I want to expose this function but
while generating bindings it gives
WARNING: __gnu_cxx::__normal_iterator<A*, std::vector<A, std::allocator > >
[class]
> execution error W1040: The declaration is unexposed, but there are other
> declarations, which refer to it. This could cause "no to_python
> converter found" run time error. Declarations:
> __gnu_cxx::__normal_iterator<A*, std::vector<A, std::allocator > >
> B::begin() [member
> function]
Due to this it gives run time error while using this function.
I tried various methods to include it explicitly but it fails. Can you
please help, whether I have missed something in my
case.
Code generator that I used for generating bindings.
import sys
import os
from pyplusplus import module_builder
from pyplusplus.module_builder import call_policies
from pyplusplus import code_creators
from pyplusplus.module_builder.ctypes_decls_dependencies import
find_out_dependencies
sourceFile = './testIterator.cpp'
mb=module_builder.module_builder_t(
files = [sourceFile],
include_paths = './',
indexing_suite_version = 2,
#define_symbols = defines
)
i=0
depList=[]
#depList.append(a)
def getDepend():
global i
if i < len(depList):
try:
deps = find_out_dependencies ( [depList[i]] )
for dep in deps:
if dep not in depList:
depList.append(dep)
except:
print "No Dependency for class %s", x
pass
i = i + 1
getDepend()
else:
return 0
z = getDepend()
for dep in depList:
dep.include()
print dep
a = mb.free_function('getB')
depList=[a]
i = 0
z = getDepend()
for dep in depList:
dep.include()
mb.build_code_creator( module_name = 'testIterator')
mb.code_creator.license = '//Boost Software
License(http://boost.org/more/license_info.html )'
mb.write_module('bindings.cpp')
With Regards,
Abhishek Srivastava
--
View this message in context: http://old.nabble.com/problem-exposing-iterators-tp28912265p28912265.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.
More information about the Cplusplus-sig
mailing list