Re: [C++-sig] Py++ and protected destructors

2009-09-17 Thread Pertti Kellomäki

Roman Yakovenko wrote:

Before I modified the code, I suggest you to submit a small working
example which shows the problem, so we can solve the right problem.


Ok, here's a distilled code example. Running

  python dest.pypp && gcc -c -I/usr/include/python2.6 dest_bindings.cpp

yields the error message

  dest.hh:3: virhe: ”virtual A::~A()” is protected

This is with the latest svn version of py++.
--
Pertti
class A {
protected:
virtual ~A();
};

class B {
public:
  void f(A const & x);
};
import pyplusplus

mb = pyplusplus.module_builder.module_builder_t(["dest.hh"])
mb.build_code_creator( module_name="dest" )
mb.write_module("dest_bindings.cpp")
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Py++ and protected destructors

2009-09-17 Thread Roman Yakovenko
2009/9/17 Pertti Kellomäki :
> Roman Yakovenko wrote:
>>
>> Before I modified the code, I suggest you to submit a small working
>> example which shows the problem, so we can solve the right problem.
>
> Ok, here's a distilled code example. Running
>
>  python dest.pypp && gcc -c -I/usr/include/python2.6 dest_bindings.cpp
>
> yields the error message
>
>  dest.hh:3: virhe: ”virtual A::~A()” is protected
>
> This is with the latest svn version of py++.

Okey. You should use "modify_type" function transformation with
"remove_const" type traits function.

Untested:

from pygccxml import declarations
from pyplusplus import module_builder
from pyplusplus import function_transformers as FT

mb = module_builder_( ... )
f = mb.mem_fun( 'f' )
f.add_transformation( FT.modify_type(0, declarations.remove_const ) )
#0 - argument index

HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Py++ and protected destructors

2009-09-17 Thread Pertti Kellomäki

Roman Yakovenko wrote:

Okey. You should use "modify_type" function transformation with
"remove_const" type traits function.


Thanks. This does not quite solve the problem, as remove_const
will turn "const A" to "A" but leave "A const &" as it is.

I modified remove_const to convert "A const &" to "A &" and it is
only a few lines. However, I'm not sure whether this really is the
semantics you want for remove const. Maybe I should create my own
function remove_const_ref and use that as a transformation instead?
--
Pertit
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Py++ and protected destructors

2009-09-17 Thread Roman Yakovenko
2009/9/17 Pertti Kellomäki :
> Roman Yakovenko wrote:
>>
>> Okey. You should use "modify_type" function transformation with
>> "remove_const" type traits function.
>
> Thanks. This does not quite solve the problem, as remove_const
> will turn "const A" to "A" but leave "A const &" as it is.

Right, I forgot about that. Actually the type composition looks like:
ref( const( A ) )

> I modified remove_const to convert "A const &" to "A &" and it is
> only a few lines. However, I'm not sure whether this really is the
> semantics you want for remove const. Maybe I should create my own
> function remove_const_ref and use that as a transformation instead?

Yes you should create and pass your own function.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Py++ and protected destructors

2009-09-17 Thread Pertti Kellomäki

Roman Yakovenko wrote:

Yes you should create and pass your own function.


Ok. Thanks once again for your prompt help!
--
Pertti

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig