Re: [pygccxml-development] code_repository package
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-09-20 09:28:09
|
Roman Yakovenko wrote: >>>> How do I influence whether a file is considered a system header or not? >>> In creator_t, you add your header file using add_system_header API >> I suppose the header should only be created when it is required, right? > > file_writers package will do that for you. How does it do that? >> I want to use it for the class that can acquire/release the Python GIL >> (as you have suggested earlier). >> So the actual decision whether the header is required or not is done by >> the code creator (mem_fun_v_transformed_wrapper_t). What is your >> recommendation how the code in creator_t (this is >> visit_member_function(), right?) will know about this decision? > > It can search for "thread safe" transformer. The better idea to > introduce next class: > > class ftransformer_t: > keeps a list of all transformations that should be applied on the > function at once > > provides some additional functionality: > function signature > has_thread_safe_transformer > ... > > Than > 1. Creator will use it to ask the right question > 2. It will be possible to have more than 1 "f" transformation applied > on the same > function: for example "status as exception" > > struct status{}; > void do_smth( status& ) > > In some cases it makes sence to expose "do_smth" function as is and to > expose some convinience function that will raise an exception. I'm sorry, obviously I got misunderstood as this doesn't answer my question. My question was actually related to the code repository package and its usage, the function transformers and thread safety stuff was just an example. Sorry for any confusion. Maybe I should rephrase my question: 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? >> Just to see if the file gets written or not I called add_system_header() >> and adopt_creator() on every call to visit_member_function(), but then I >> get a huge list of identical include statements in the generated files. > > I don't fully understand what you are doing here. I was just doing what you were suggesting earlier, i.e. to call add_system_header() to have Py++ write a particular header from the code repository package. This did work but the file was nowhere included, so I added an "include" code creator using adopt_creator() on the root node (I was peeking at the array_1 stuff to see how it is done). But as I was doing that in every call to visit_member_function() the file got included again each time resulting in a lot of duplicate lines. >> What I would actually like to do is to add the "include" code creator to >> the associated_decl_creators list of the corresponding class so that the >> include only shows up in the file where it is needed. But how can I >> check whether the file was already included or not? > > If we talk about system header than you can ask module_t code creator > ( creator_t.__extmodule ) is_system_header. ok, this is what I'm doing now and which does work for now. But this makes the include file a "project wide" include file. How should I do this check if I would only like to add the include code creator to the associated_decl_creators list? (so that it only gets included where it is required?) >> I wonder why there is no specific API for managing include files that >> handles all those stuff? It appears to me that this would be quite a >> useful thing to have. > > Lack of time and low priority. Users learned to leave with "non > optimal" generated > code. I mean that all include appears in all header files. But they don't like > Py++, when it does not support the functionality they needed. That's not what I meant. I mean, even when the current functionality is exactly preserved, I would rather like to have an (internal) API that handles the details of how an include file is added to the output files. This is required at several places and it's not easy to understand how it is properly done. An additional benefit would be that it would pave the way for improving the handling of include files so that they could be set on a file-by-file basis. - Matthias - |