Re: [pygccxml-development] How to add a new function to an individual file?
Brought to you by:
mbaas,
roman_yakovenko
|
From: Matthias B. <ba...@ir...> - 2006-09-11 13:15:47
|
Roman Yakovenko wrote: >> or rather: *when* can it do that? > > Every function transformation consist from 2 parts: function wrapper > definition > and registration, right. Take a closer look on creator_t class. When you > create > relevant code creators you have to inject them to the right position. > In your case you will > have to add wrapper to the tree and to the associated_decl_creators. Hm, so in addition to implementing the actual mem_fun_transformed_t and mem_fun_transformed_wrapper_t classes I have to modify code at the following locations: - code_creators/__init__.py: Modify guess_mem_fun_creator_classes() so that it returns the transformed versions when appropriate. - module_creator/creator.py: Modify creator_t.visit_member_function() so that it adds the appropriate code creator object to the list of associated creators for the current class. When the option is turned on that Py++ should always create a wrapper class I also have to modify the following places: - module_creator/creator.py: Modify either creator_t.visit_class() or creator_t._is_wrapper_needed() (or both?) so that a wrapper class is created when there's a member function that has function transformers assigned to it. I think this is rather complex and what I don't like about it is that code that belongs together is scattered over several files (even from different sub-packages). I would really prefer if I could keep all my code local to the place where the member function code creators are implemented. This would simplify maintenance. For example, the visit_member_function() method could invoke an initialization method on the code creator that allows that method to do the work that would otherwise be located in visit_member_function(). Then it would be nice if it was possible to register functions that are invoked by guess_mem_fun_creator_classes() and that can check if they know how to handle a particular declaration, etc. So all in all, it would be great if everything would be a bit more extensible so that a modification like the one that I'm currently trying to do could even be done externally without having to modify internal Py++ code. Or in my case where it actually is an internal modification, everything could be kept local to one file (or at least one sub-package). - Matthias - |