Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#5 inner classes produce wrong data representation

v1.0 (example)
closed-invalid
Roman
None
9
2006-11-12
2006-11-11
Gaetan Lehmann
No

inner classes are wrongly parsed by pygccxml, and
produce wrong data representation: the methods and
constructors of the inner class are put in the main
class. For example, something like:

class Main {
public:
Main();
void main_method();

class Inner {
public:
Inner( int );
inner_method();
}
}

is seen as:

class Main {
public:
Main();
Main( int );
main_method():
inner_method();
}

which is definitively wrong :-(
Some help with that problem would be highly
appreciated - I'm afraid I'm not able to provide a
patch this time

Discussion

  • Roman
    Roman
    2006-11-12

    Logged In: YES
    user_id=1084190

    Good morning. I was not able to reproduce the bug you
    described :-(. I tried to do
    this with Py++ 0.8.2 and on-going versions. Here is relevant
    links to unit test:
    http://tinyurl.com/wshzh - Py++ script
    http://tinyurl.com/vhp7w - C++ source file

    I also attach a generated file. May be you didn't reproduce
    exactly the use case you
    have?

     
  • Roman
    Roman
    2006-11-12

    • priority: 5 --> 9
    • assigned_to: nobody --> roman_yakovenko
     
  • Roman
    Roman
    2006-11-12

     
    Attachments
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    Logged In: YES
    user_id=931523

    Hi,

    I'm not using py++: my goal is to wrap ITK for several languages including at least python,
    tcl, java and perl. I'm using pygccxml to generate an interface file for swig - wig doesn't
    have a good enough c++ parser to parse the ITK classes which can be quite complex.

    I'm attaching 2 files:
    (1) the modified c++ file to fit my needs (a __cable__::wrappers namespace with a typedef
    in it). Only the typedef in that namespace are wrapped.
    (2) the program used to produce the interface

    The interface I'm generating is:

    class main_t {
    public:
    main_t(inner_classes::main_t::inner_t const & _ctor_arg);
    main_t(int arg0);
    main_t(main_t const & _ctor_arg);
    main_t();
    void inner_method();
    virtual void inner_method2();
    virtual void inner_method3() = 0;
    void main_method();
    virtual void main_method2();
    virtual void main_method3() = 0;
    protected:
    private:
    ~main_t();
    };

    Perhaps I have said too quickly that there is a bug, but really, I can't found where I have
    made a mistake if that's not the case.
    For example, the code used to generate the constructors is constructed as follow:

    for constructor in typedef.type.declaration.constructors() :
    args = []
    for arg in constructor.arguments:
    # fill the args list
    print >> outputFile, " %s(%s);" % (typedef.name, ", ".join( args) )

    Where typedef is the typedef in the __cable__::wrappers namespace as provided by pygccxml.

    Perhaps a problem with the typedef ?
    Or can you see something else ?

     
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    • milestone: --> v1.0 (example)
     
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    the swig interface generator

     
    Attachments
  • Roman
    Roman
    2006-11-12

    Logged In: YES
    user_id=1084190

    Hi. I think I understand your problem.
    Please read next article one more time:
    http://language-binding.net/pygccxml/query_interface.html

    In general the problem is simple: by default Py++ tries to
    find\select declarations
    recursively. You can override this behavior for the whole
    project:

    pygccxml.declarations.scopedef_t.RECURSIVE_DEFAULT = False

    You can achieve same effect for allow_empty argument too:

    pygccxml.declarations.scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER =
    True

    P.S. Can we switch to discuss such thing to the mailing
    list? I find gmail interface
    much user friendly.

     
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    Logged In: YES
    user_id=931523

    ok, it works :-)
    that's my mistake: I've missed the recursive feature.

    Thanks a lot for your help !

     
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    • status: open --> open-invalid
     
  • Gaetan Lehmann
    Gaetan Lehmann
    2006-11-12

    • status: open-invalid --> closed-invalid