[C++-sig] problem exposing iterators
Hi,
I am facing some problem in exposing iterator(using pyplusplus), for this I
have created a sample problem(to communicate this problem)
#include
#include
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 >
[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 >
> 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.
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
[C++-sig] problem exposing iterators
Hi,
I am facing some problem in exposing iterator, for this I have created a sample
problem(to communicate this problem)
#include
#include
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 > >
[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 > >
> 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. .
---___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] problem exposing iterators
Although for this case I can think of a workable solution, to create some
kind of wrapper functions(only in bindings) which return *iterator by
adding:
classB = mb.class_( 'B' )
classB.add_declaration_code("A getA( B& b ){ vector< A >::iterator iter =
b.begin(); return *iter ;}")
classB.add_registration_code( 'def( "begin", &::getA )' , works_on_instance
= True)
in codeGenerator scripts.
But can I get some kind of solution where I can expose iterators(some kind
of support available for iterators).
With Regards,
Abhishek Srivastava
--
View this message in context:
http://old.nabble.com/problem-exposing-iterators-tp28912265p28922372.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
