Re: [pygccxml-development] Printing declarations...
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-03-21 18:49:17
|
On 3/21/06, Matthias Baas <ba...@ir...> wrote: > > Before you do it, please ask your self next questions: > > 1. What is the difference between output of decl_printer_t? > > decl_printer_t is a more advanced way to output a declaration (or an > entire tree) whereas I'd expect the __str__ method to return a concise > version of the declaration (preferably in one line) so that it can be > uniquely identified by the user. > > For example, I have a method that the decl_printer_t outputs like this: > > member_function_t: 'selectByName' > Signature: [u'::MStatus', [u'::MString const &', > u'::MGlobal::ListAdjustment']] > > The __str__ method could instead return something like: > > MStatus MGlobal::selectByName(MString const &, MGlobal::ListAdjustment) > [member_function] Okay > That is, it is almost C++ source code. > The advantage of having only one line is that you can use 'grep' to find > a particular declaration in a log file. > > By the way, in the case of a class, I don't expect the entire class to > be printed (including members) but only the class name. > If I really want to inspect the contents of the class I can still use > the decl_printer. Okay > > 2. Why we need 2 implementation of __str__ methods > > I don't understand. So far, there is no __str__ method. When I print a > declaration I get something like: > > <pyplusplus.decl_wrappers.calldef_wrapper.member_function_t object at > 0xb75b826c> I meant why we need decl_printer_t and __str__. In answer to first question you explained this. > > 3. is decl_printer_t should be implemented in terms of __str__ method, = or may be > > __str__ method should be implemented in terms of decl_printer_t > > I think they serve different purposes. __str__ should yield a short but > unique human-readable representation of the object (like an id so that > the user knows where to find this declaration in his source code) > whereas decl_printer_t can be used to inspect an entire declaration > tree. The decl_printer can be used by a new user to find out how > pyplusplus works and how it stores its data. Clear. Can you put this paragraph somewhere in documentation? > > 4. How you configure the a amount of printed information. > > It's ok to be able to configure decl_printer_t, but in my opinion > __str__ doesn't need to be configured. Right Thanks. I understand what you want/need. I think that this is a good functionality. Can you add it to pygccxml.declarations class hierarchy? I will add some te= st code for it. Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |