[C++-sig] How to use functionality of list.
vishal bayskar
vishal.bayskar at nechclst.in
Wed May 5 13:20:28 CEST 2010
>There is no need to expose std containers directly. Instead, expose
>declarations that are using them and Py++ will do the rest.
>mb.free_function( 'getDummyAlist' ).include()
>This topic is covered in the following document:
>http://language-binding.net/pyplusplus/documentation/containers.html
Yes I tried like as you suggested.
but I am not able to use the functionality of list from python.
Like suppose I need to use push_back etc from python.
>>> import testModule
>>> alistobj = testModule.Alist()
>>> aobj=testModule.A(5)
>>> alistobj.push_back(aobj)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'Alist' object has no attribute 'push_back'
>>>
>>> dummyList =testModule.getDummyAlist()
>>> dummyList.push_back(aobj)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'Alist' object has no attribute 'push_back'
Generated wrapper code : testModule.cpp
===============================
// This file has been generated by Py++.
#include "boost/python.hpp"
#include "listP.cpp"
namespace bp = boost::python;
BOOST_PYTHON_MODULE(testModule){
{ //::A
typedef bp::class_< A > A_exposer_t;
A_exposer_t A_exposer = A_exposer_t( "A", bp::init< int >((
bp::arg("num") )) );
bp::scope A_scope( A_exposer );
bp::implicitly_convertible< int, A >();
}
bp::class_< Alist >( "Alist" )
.def(
"a"
, (void (*)( ))( &::Alist::a ) )
.staticmethod( "a" );
{ //::getDummyAlist
typedef ::Alist ( *getDummyAlist_function_type )( );
bp::def(
"getDummyAlist"
, getDummyAlist_function_type( &::getDummyAlist ) );
}
{ //::main
typedef int ( *main_function_type )( );
bp::def(
"main"
, main_function_type( &::main ) );
}
}
--
View this message in context: http://old.nabble.com/How-to-use-functionality-of-list.-tp28459066p28459555.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.
More information about the Cplusplus-sig
mailing list