Re: [pygccxml-development] Printing declarations...
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-03-21 17:03:26
|
Roman Yakovenko wrote: >>>> Almost, the signature is there but the actual method name is missing. >>> Okay, I give up :-). I understand what you want, but I don't >>> understand the format. >> The more it resembles the original source code the better. I'm dumping >> the declarations into a log file that the user can inspect. For example, >> he could just grep for a particular function name to find out what >> decorations have been applied to that function. > >>> Also, why do you need this from framework. You have all tools to >>> create almost any format by your own? >> Well, yes, but it seems that recreating the source code doesn't look >> that easy to me (and I don't know how much of the original source code >> (which could be reused here) has survived in the output from gccxml). >> When I have some time left I can have a look at it. Would you like the >> idea to add __str__() methods to the declaration_t classes? (then a user >> could just print a declaration and see exactly what it is) > > 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] 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. > 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> > 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. > 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. - Matthias - |