[C++-sig] Default arguments in pyplusplus
s_sourceforge at nedprod.com
Wed Jun 21 03:37:59 CEST 2006
On 20 Jun 2006 at 8:49, Roman Yakovenko wrote:
> > 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.
Cool, thanks for that. I've committed it to the TnFOX SVN repository.
> > Thanks for the enum idea. If I can get keyword parameters working I'd
> > be very happy.
> Hope I made you very, very happy :-).
Well, nearly ...
Unfortunately, because I am now including all the patch code into
every source file, I'm getting compiler limit: internal structure
overflow error on some of the more complex files. So I came up with a
In file_writers/multiple_files.py create_source(), I added the
answer = 
answer.append( self.extmodule.license.create() )
answer.append( '#define PYPP_BUILDING_'+file_name.replace(
'.', '_').upper() )
answer.append( '#include "%s%s"' % ( file_name,
self.HEADER_EXT ) )
# Include all 'global' include files...
Now I have a common.h which is the precompiled header and then a
patches.cpp.h which uses a series of #ifdef's to decide which patch
code to include based on the macro defined above. Achieves what I
wanted originally of inserting custom code just to where it's needed.
One other thing: I've just discovered you can't do a #pragma hdrstop
if it's enclosed by an #if. So that code of:
answer.append( '#ifdef _MSC_VER' )
answer.append( self.indent( '#pragma hdrstop' ) )
answer.append( '#endif //_MSC_VER' )
... I originally suggested is useless. Sorry about that. If you just
plain remove it, you can specify on the command where to stop
precompiled header inclusion.
More information about the Cplusplus-sig