[C++-sig] pyplusplus tutorials & GUI wizard

Matthias Baas baas at ira.uka.de
Tue Feb 7 17:18:48 CET 2006


Roman Yakovenko wrote:
> On 2/7/06, Matthias Baas <baas at ira.uka.de> wrote:
>> I saw the mail, but after I updated from cvs I still got the same
>> behavior as above, i.e. my filter still returns False on all class
>> methods but the methods are included in the output nevertheless, so I
>> was under the impression that the bug hasn't been fixed yet.
>> What exactly is/was the bug you were referring to? (maybe we have
>> different understandings of what the bug actually is...)
> 
> module_creator.creator_t class.
> When it comes to create code creators for class member function/variables it
> did not take into account filtered out declarations. I fixed that bug.
> 
> May be there is an other bug. Could you create simple usecase?

Below is a simple header and a pyplusplus script that creates 
Boost.Python code for the header. Even though the filter function 
returns False on the spam() method, the method is included in the output.

- Matthias -


///////////////////////////////////////////////////////
// File: class.h
class Foo
{
   public:
   Foo();
   void spam();
};
///////////////////////////////////////////////////////

##########################################################
# pyplusplus script
import os, os.path
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import code_creators
from pyplusplus import module_creator
from pyplusplus import file_writers

def declfilter(decl):
     """Only return True when the name is 'Foo'."""
     res = decl.name in ["Foo"]
     print decl.name,"...",res
     return res

parser_config = parser.config_t(working_directory = "tmp")
decls_all = parser.parse(["class.h"], parser_config )
decls = declarations.filtering.user_defined( decls_all, declfilter )
creator = module_creator.creator_t(
     decls = decls,
     module_name = "_api",
     recursive = True,
)
extmodule = creator.create()
file_writers.write_file( extmodule, 'bindings.cpp' )
##########################################################






More information about the Cplusplus-sig mailing list