[C++-sig] Default arguments in pyplusplus

Roman Yakovenko roman.yakovenko at gmail.com
Tue Jun 20 07:49:42 CEST 2006


On 6/20/06, Niall Douglas <s_sourceforge at nedprod.com> wrote:
# Is it an enumeration?
if isinstance( arg.type, declarations.cpptypes.declarated_t ) \
  and isinstance( arg.type.declaration,
declarations.enumeration.enumeration_t ):

You are working too hard here. pygccxml has functionality similar to
boost.type_traits
Read more here:
http://language-binding.net/pygccxml/design.html#type-traits

pygccxml.declarations.is_enum( arg.type ) will do the job

> Of course, this won't compile. Any ideas?

Obviously we need to supply different default arguments for wrapper
and for code that
actually exposes the function. The idea is simple we need new class variable on
argument_t class default_value_xxx ( I explain later why xxx, but you
will have to rename it
to something readable ). And then to generate code that in wrapper
uses original value, but
in boost.python code uses modified one, right?

I attached the solution to your problem. I made small refactoring + added new
functionality ( enum_declaration ) so you will need the latest version.

> Thanks for the enum idea. If I can get keyword parameters working I'd
> be very happy.

Hope I made you very, very happy :-).

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: default_value.py
Type: application/x-python
Size: 1396 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060620/2b88fc6d/attachment.bin>


More information about the Cplusplus-sig mailing list