On Feb 16, 2008 4:05 AM, Norma Zimmerman <nzi...@is...> wrote:
> Hi Roman,
Good evening
> Thanks for your help with my problem using std::vector<int>. As I said in my
> last email, my ultimate goal is to wrap functions with a signature similar
> to:
> UserDefinedReturnValue getDevices(std::vector<UserDefinedClass> &
> devices)
>
>
> I am have problems with a vector of a UserDefinedClass.
>
> I have the following class:
>
> #include <string>
> #include <iostream>
> #include <vector>
>
> using namespace std;
> enum iStorReturnType {SUCCESS, FAILURE};
> class Device
> {
> public:
> Device();
> iStorReturnType setName( string );
> iStorReturnType getName( string& );
> iStorReturnType printName();
> protected:
> string m_name;
> };
>
>
>
> In another class I have two instances of the Device class. In this class I
> have a function which returns one instance of the Device class with no
> problem. I want to also have a function to return a vector of all the
> devices.
>
>
>
> iStorReturnType getDevices(std::vector<Device>& devices);
>
>
>
> In my generated file I am seeing the following error:
>
>
>
> { //scope begin
>
> typedef bp::class_< std::vector< Device > >
> vector_less__Device__grate__exposer_t;
>
> vector_less__Device__grate__exposer_t
> vector_less__Device__grate__exposer =
> vector_less__Device__grate__exposer_t("vector_less__Device__grate_");
>
> bp::scope vector_less__Device__grate__scope(
> vector_less__Device__grate__exposer );
>
> //WARNING: the next line of code will not compile, because
> "::Device" does not have operator== !
>
> vector_less__Device__grate__exposer.def( bp::vector_indexing_suite<
> ::std::vector< Device > >() );
>
> } //scope end
>
>
>
> I am hoping this is the last stumbling block to being able to implement
> these "simple" classes. I would greatly appreciate any help you can give me.
If you can add operator== to your code. You don't have to modify the class,
you can implement is as free operator.
Or you can use "indexing suite v2". See
http://language-binding.net/pyplusplus/documentation/containers.html
> I do have one other question. In the C++ code that I am trying to wrap, all
> the functions have an error code as the return value and the actual values
> you want are passed as reference parameters. Is there a way to generate the
> function transformations other than listing each function separately in the
> python script which pyplusplus uses to generate the wrappers?
I thought this is an initial reason you started to use Py++ :-)
from pyplusplus import function_transformers as FT
mb =module_builder_t(...)
my_ns = mb.namespace( 'my namespace' )
for f in my_ns.calldefs():
if f.arguments[ -1 ].type.decl_string == "type that represent error":
f.add_transformation( FT.output( len( f.arguments ) - 1 )
Is this what you want?
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|