[C++-sig] [Py++] operators() got an unexpected keyword argument 'decl_type'

2009-06-13 Thread Werner Joergensen

Hello,
I need to exclude some operators from my wrapped python classes, but I seem not 
to be able to access the operators.

What is wrong with this code:
--8<--
from pyplusplus import module_builder
files=["test.H"]
mb = module_builder.module_builder_t(
files=files,
)
print mb.operators()
--8<--
(For completeness, test.H contains nothing but "class X{public:  int i(); };"
The following error, however, occurs independent of test.H.)

On the last line the script produces:
--8<--
 Traceback (most recent call last)
/home/wj/tmp/ in ()
/usr/lib/python2.5/site-packages/pyplusplus/module_builder/builder.py in 
operators(self, name, symbol, return_type, arg_types, decl_type, header_dir, 
header_file, recursive)
541  , header_dir=header_dir
542  , header_file=header_file
--> 543  , recursive=recursive )
544 
545 def member_function( self, name=None, function=None, 
return_type=None, arg_types=None, header_dir=None, header_file=None, 
recursive=None ):
: operators() got an unexpected keyword argument 
'decl_type'
--8<--

The installation is latest gccxml from CVS, pygccxml-1.0.0 and pyplusplus-1.0.0 
with python 2.5.2. Same result with python 2.6.

Please help. Is the use of mb.operators() wrong, or what else might be the 
problem?

Werner



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


cplusplus-sig@python.org

2009-06-13 Thread Benjamin Koerner
How can one allow Py++ to handle member functions that return a reference to an 
immutable type?

For example this X::getval function:
class X{
double xval;
public:
  double& getval(){return xval;}
}; 

I don't care about the reference. All I need is the double value, which is only 
used as an r-value. Can one use a call policy in this situation, or does one 
have to write custom wrapper code?

Regards,
Bennie

Text: GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de

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


Re: [C++-sig] [Py++] operators() got an unexpected keyword argument 'decl_type'

2009-06-13 Thread Roman Yakovenko
On Sat, Jun 13, 2009 at 11:48 AM, Werner
Joergensen wrote:
>
> Hello,
> I need to exclude some operators from my wrapped python classes, but I seem 
> not to be able to access the operators.
>
> What is wrong with this code:
> --8<--
> from pyplusplus import module_builder
> files=["test.H"]
> mb = module_builder.module_builder_t(
>        files=files,
>    )
> print mb.operators()
> --8<--
> (For completeness, test.H contains nothing but "class X{public:  int i(); };"
> The following error, however, occurs independent of test.H.)
>
> On the last line the script produces:
> --8<--
>              Traceback (most recent call last)
> /home/wj/tmp/ in ()
> /usr/lib/python2.5/site-packages/pyplusplus/module_builder/builder.py in 
> operators(self, name, symbol, return_type, arg_types, decl_type, header_dir, 
> header_file, recursive)
>    541                                          , header_dir=header_dir
>    542                                          , header_file=header_file
> --> 543                                          , recursive=recursive )
>    544
>    545     def member_function( self, name=None, function=None, 
> return_type=None, arg_types=None, header_dir=None, header_file=None, 
> recursive=None ):
> : operators() got an unexpected keyword argument 
> 'decl_type'
> --8<--
>
> The installation is latest gccxml from CVS, pygccxml-1.0.0 and 
> pyplusplus-1.0.0 with python 2.5.2. Same result with python 2.6.
>
> Please help. Is the use of mb.operators() wrong, or what else might be the 
> problem?

The version you use contains such bug. It is fixed in SVN.

If you don't want to upgrade you can use the following code:

mb.global_ns.operators() # query global namespace for all operators


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


cplusplus-sig@python.org

2009-06-13 Thread Roman Yakovenko
On Sat, Jun 13, 2009 at 9:09 PM, Benjamin Koerner wrote:
> How can one allow Py++ to handle member functions that return a reference to 
> an immutable type?
>
> For example this X::getval function:
> class X{
> double xval;
> public:
>  double& getval(){return xval;}
> };
>
> I don't care about the reference. All I need is the double value, which is 
> only used as an r-value. Can one use a call policy in this situation, or does 
> one have to write custom wrapper code?

Did you read Boost.Python manuals?
http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/copy_non_const_reference.html

from pyplusplus.module_builder import call_policies
...
mb.calldef( '::X::getval' ).call_policies =
call_policies.return_value_policy(
call_policies.copy_non_const_reference )

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