[C++-sig] [pybindgen] custom selections with pybindgen and pygccxml

Gustavo Carneiro gjcarneiro at gmail.com
Fri Oct 17 18:37:24 CEST 2008


2008/10/17 Adrien Saladin <adrien.saladin at gmail.com>

> Hi,
>
> I would like to give pybindgen a try on a C++ library. I'm currently
> using Py++ (which is great) to automatically generate the correct
> interface.
> Before seriously playing with pybindgen, I need to know if it is
> possible to do a fine selection of which classes and methods has to be
> exposed to python.
> For some reasons I need to expose to python only a part of a C++
> library, but for this part I would like to do it in an automated
> fashion (ie: use pygccxml)
>
> Is it possible to do a kind of "exclude all classes and methods"
> command to the ModuleParser object (or another pybindgen/pygccxml
> object) and then only include a few classes one by one together with
> pygccxml ?  Is it possible to remove a single method from a class by
> name or argument types ?
> Are pre_scan_hook or post_scan_hook suitable for this ?


The pre_scan_hook can be used to exclude classes or methods:

from pygccxml.declarations.class_declaration import class_t

def pre_scan_hook(module_parser,
                  pygccxml_definition,
                  global_annotations,
                  parameter_annotations):
    if isinstance(pygccxml_definition, class_t):
         if pygccxml_definition.name not in ["Class1", "Class2"]:
               global_annotations['ignore'] = None


> Another question: on the features page
> (http://code.google.com/p/pybindgen/wiki/Features) it is said that
> multiple inheritance is not yet supported. What does this exactly mean
> ? It is not possible to expose a class C which publicly inherits from
> A and B ?


Correct.  That is not possible.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081017/81a5b5f4/attachment.htm>


More information about the Cplusplus-sig mailing list