Re: [pygccxml-development] [FT] small issue
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-09-24 20:50:48
|
Roman Yakovenko wrote: > Hi Matthias. Next code is cut-and-paste from creator_t.visit_member_function > > required_headers = getattr(fwrapper, "get_required_headers", lambda : [])() > > This code is problematic for next reasons: > > 1. When we talked about [FT], we thought that user will be able to add > custom > function transformation, without understanding of code creators, right? > I think, that putting "get_required_headers" on code creator is a > little bit problematic. (This point didn't contain any reason why the above code is problematic, you just say that you think it is problematic...?) > 2. There is small design violation: creator_t should not talk to code > creators. > creator_t is a factory. As such it should ask for required headers from > function transformation. I was asking about that in an earlier mail: Roman Yakovenko wrote: >> The responsibility of a code creator object is to create a piece of C++ >> source code that will be written into one or more output files, right? >> Now my actual question probably boils down to the following question: >> Whose responsibility is it to make sure that the code that was generated >> by a particular code creator object can also be compiled without errors? > > File writer + code creator. File writer answer the question: where to > put the > code, while code creator "what code to put". creator_t defines > "logical" place of the code creator, by placing it in the right place > within the tree. File writers insure that the "logical" > place of code creator is preserved. I interpret this as it is the code creator's responsibility to make sure that the code it generates can be compiled. This means that if the code creator generates code that requires a particular header file it must make sure that this header file gets included. And because there's no way for a code creator to do that directly, I did it indirectly by providing a method that returns the required header files (which then have to be added by whoever is in the position to do so, I decided for the visit_member_function method). Your suggestion to have a transformation group object that returns a list of header files would be less flexible than the above. The transformers only add code to a function but they do not know the entire function and as such they cannot know about the requirements of code that was not added by themselves. Have a look at the current code, the code creator for transformed virtual functions requests the gil guard header file because it may create code that uses this header. This code is not handled by a function transformer, so a transformer group couldn't know about that. So how does the current design deal with the problem that a code creator might generate code that requires a particular header file? - Matthias - |