[C++-sig] problem exposing iterators

Abhishek Srivastava abhishek.srivastava at nechclst.in
Thu Jun 17 11:24:37 CEST 2010


Hi,

I am facing some problem in exposing iterator, 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<A>::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<A> > > [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<A> > > 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







DISCLAIMER: 
----------------------------------------------------------------------------------------------------------------------- 
The contents of this e-mail and any attachment(s) are confidential and
intended 
for the named recipient(s) only.  
It shall not attach any liability on the originator or NECHCL or its 
affiliates. Any views or opinions presented in  
this email are solely those of the author and may not necessarily reflect the 
opinions of NECHCL or its affiliates.  
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of  
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have  
received this email in error please delete it and notify the sender 
immediately. . 
-----------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100617/54f2d00b/attachment.html>


More information about the Cplusplus-sig mailing list