Thread: [pygccxml-development] Re: Small patch for two things
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-05-16 19:22:27
|
On 5/16/06, Allen Bierbaum <al...@vr...> wrote: > Roman: > > I have attached a patch to pyplusplus that adds to things. > > - In module_builder/builder.py > > Add decl_headers parameter to build_code_creator method. This is just > passed on directly to creator.create() to allow the user to overried the > headers used. > > - in module_t code creator > > Extended adopt_include method so it can take directory names (string's) > directly. It will check the type and automatically create an include_t > behind the scenes if it is needed. This makes it a little easier to add > includes to the code creator returned from the module_builder and makes > it so the users don't need to know about the code creator types. :-). I am a little bit ill, so I have some time to work on py++. This is exactly the problem I found and implemented an other solution. I am not sure which one is better( easier to understand, correct ). My solution is next: To module_t code creator I added new function: replace_included_headers( list of headers( =3D=3D strings ) , leave_boost_python_header=3DTrue ) So user needs to call this function. Now comparison: What is bad in my implementation: user needs to take a look on module_t code creator. What is not so good in your implementation: it is not extensibility. I am sure, that there are inconveniences or bugs in interface of code creators, that you will not be able to fix by passing argument to build_code_creator. I am not sure with what implementation to go. Thoughts? > One other note: I am a little confused by the use of the word "adopt" > in the API. For example adopt_include seems more like it should be > named add_include since it is adding an include to a module. There is > really no adopting going on as far as I can tell. adopt_include as argument takes include code creator. Every code creator has "parent" property. This is a reference to the parent code creator. Take a look on next code: ( compound_t code creator ) def adopt_creator( self, creator, index=3DNone): creator.parent =3D self if index or index =3D=3D 0: self._creators.insert( index, creator ) else: self._creators.append( creator ) Function post condition: parent code creator has new son. So I choose name "adopt". Also I understand, what are you talking about. Yesterday, I added 2 new functions to module_t code creator: def add_namespace_usage( self, namespace_name ): self.adopt_creator( namespace.namespace_using_t( 'boost' ) , self.last_include_index() + 1 ) def add_namespace_alias( self, alias, full_namespace_name ): self.adopt_creator( namespace.namespace_alias_t( alias=3Dalias , full_namespace_name=3Dfull_namespace_name= ) , self.last_include_index() + 1 ) As you can see, I use here "add". > Thanks, > Allen --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-05-16 22:44:51
|
Roman Yakovenko wrote: > On 5/16/06, Allen Bierbaum <al...@vr...> wrote: > >> Roman: >> >> I have attached a patch to pyplusplus that adds to things. >> >> - In module_builder/builder.py >> >> Add decl_headers parameter to build_code_creator method. This is just >> passed on directly to creator.create() to allow the user to overried the >> headers used. >> >> - in module_t code creator >> >> Extended adopt_include method so it can take directory names (string's) >> directly. It will check the type and automatically create an include_t >> behind the scenes if it is needed. This makes it a little easier to add >> includes to the code creator returned from the module_builder and makes >> it so the users don't need to know about the code creator types. > > > :-). I am a little bit ill, so I have some time to work on py++. > This is exactly the problem I found and implemented an other solution. > > I am not sure which one is better( easier to understand, correct ). > My solution is next: > To module_t code creator I added new function: > replace_included_headers( list of headers( == strings ) > , > leave_boost_python_header=True ) > > So user needs to call this function. > Now comparison: > > What is bad in my implementation: user needs to take a look on module_t > code creator. > > What is not so good in your implementation: it is not extensibility. I > am sure, that > there are inconveniences or bugs in interface of code creators, that > you will not > be able to fix by passing argument to build_code_creator. > > I am not sure with what implementation to go. Thoughts? I am fine with either. They really do the same thing behind the scenes. Mine could be easier to understand since the user sees it as part of their method call, but I am not going to argue it either way. What about the other patch, the one that allows adopt_include to take a string as an argument? -Allen |
From: Roman Y. <rom...@gm...> - 2006-05-17 04:44:47
|
On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > I am fine with either. They really do the same thing behind the > scenes. Mine could be easier to understand since the user sees it as > part of their method call, but I am not going to argue it either way. Thanks > What about the other patch, the one that allows adopt_include to take a > string as an argument? I forgot aboit it. I will add it, but function name will be add_include. Is it fine with you? > -Allen > > --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-05-17 04:50:28
|
Roman Yakovenko wrote: > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > >> I am fine with either. They really do the same thing behind the >> scenes. Mine could be easier to understand since the user sees it as >> part of their method call, but I am not going to argue it either way. > > > Thanks > >> What about the other patch, the one that allows adopt_include to take a >> string as an argument? > > > I forgot aboit it. I will add it, but function name will be > add_include. Is it fine with you? Sure, I am fine with whatever function name you like. Now that you explained what adopt_include means it makes sense to me. Thanks. -Allen |