Re: [pygccxml-development] Trying to ramp up again
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-05-11 18:26:28
|
On 5/11/06, Allen Bierbaum <al...@vr...> wrote: > Hello all. I am back at it and trying to wrap some libraries that used > to use Pyste. It is nice to read from you again :-). > Anyway, I have been out of the loop for a while and I wondered if > someone could point me in the direction of what to look at to get back > into things. I will try to do it. I re-wrote date_time tester. So may be it is a good id= ea to look at it, after tutorial example. > I see there is a tutorial on the website for a module_builder > interface. I assume that this is the high-level interface. Am I correct= ? Yes, you are. > The tutorial shows how to do some basic things but it does not explain > things like are the classes searched for recursively, mutli-matching, > and all that stuff we were talking about the last time I was here. I did not want to insert that staffs into tutorials. > What is the best way to get up to speed on this stuff? Just start working, I think that API is simple and intuitive. If you don't = mind I prefer you to use version from SVN. It is much better, then last release. > Should I be reading API documentation? Yes. In order to understand how selection API works, please read pygccxml/declarations/scopedef.py module. The short version is next: The are 2 sets of API: one set returns single object and raises exception if object not found. Another API set selects multiple objects. Lets learn member_function and member_functions api: def member_function ( self, name=3DNone, function=3DNone, return_type=3DNone, arg_types=3DNone, header_dir=3DNone, header_file=3DNone= , recursive=3DNone ): def member_functions( self, name=3DNone, function=3DNone, return_type=3DNone, arg_types=3DNone, header_dir=3DNone, header_file=3DNone= , recursive=3DNone, allow_empty=3DNone ): As you can see, they are almost identical. The only difference is "allow_em= pty" argument in "multi select" function. Now how does it works? Because those methods are defined on scopedef_t class, both class_t and namespace_t classes have them. It allows you to write next code mb =3D module_builder_t(...) my_class =3D mb.class_( "xxxx" ) my_class.member_functions( "do_smth", recursive=3DFalse ).exclude() If you just pass one argument to the "select" functions scopedef_t class wi= ll correctly find out what it is: name or custom function. my_class.member_functions( lambda decl: decl.name.endswith( '_impl' ) ) In all other cases you have to use keywords arguments. Now about defaults for recursive and allow_empty. As you can see in both functions this is None. The algorithm is simple: if allow_empty is None: use scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER else: use it as is. The same is true for recursive argument. So, you are able to redefine behaviour for the whole project in one place. Now multi select functions return instance of "mdecl_wrapper_t" class. It a= llows you to "set" some attribute or call some function on all object in one line= : my_class.member_functions( "do_smth", recursive=3DFalse ).exclude() All member functions that match the criteria will be excluded. There is no = need to travel on them using loop. >How do I generate it? If you use SVN version, then it is very simple. Install epydoc. You have to install latest version of epydoc ( 3.0 alpha 2 ). python setup.py sdist or if you want to generate documentation only python setup.py doc > Sorry for all the questions, I just want to get back up to speed as > quickly as I can and I am sure you guys can point me in the right > direction. :) I hope, that was the right direction. Any way if you need more help we can talk on some IRC channel. > Thanks, > Allen --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |