Thread: [pygccxml-development] FT - recent changes
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-10-24 21:15:40
|
Hi. I committed few small changes to FT feature. The main one is the interface change: Now in order to add new transformation user have to write: f.add_transformation( output(1), output(2) ) f.transformations property provides access to all function transformations that should be applied. The change was necessary because I want the way to apply few function transformations on a single function. For example: struct error_t{}; void do_smth( ..., error_t& ); I want to expose do_smth in 2 ways: 1. as is: def( "do_smth_no_raise", &do_smth ); 2. error status is converted by Py++ to exception: void do_smth_raise(){ error_t x; do_smth( x ); if x contains error: throw actual error; } def( "do_smth", &do_smth_raise ); do_smth.add_transformation() #<- use Py++ default behaviour do_smth.add_transformation( raise_on_error( 0, ... ) ) -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <ba...@ir...> - 2006-10-25 18:43:28
|
Roman Yakovenko wrote: > For example: > > struct error_t{}; > > void do_smth( ..., error_t& ); > > I want to expose do_smth in 2 ways: > > 1. as is: def( "do_smth_no_raise", &do_smth ); > 2. error status is converted by Py++ to exception: > > void do_smth_raise(){ > error_t x; > do_smth( x ); > if x contains error: > throw actual error; > } > > def( "do_smth", &do_smth_raise ); > > > do_smth.add_transformation() #<- use Py++ default behaviour > do_smth.add_transformation( raise_on_error( 0, ... ) ) How do you rename the first version to "do_smth_no_raise" (without renaming the other one)? - Matthias - |
From: Roman Y. <rom...@gm...> - 2006-10-25 18:55:35
|
On 10/25/06, Matthias Baas <ba...@ir...> wrote: > Roman Yakovenko wrote: > > For example: > > > > struct error_t{}; > > > > void do_smth( ..., error_t& ); > > > > I want to expose do_smth in 2 ways: > > > > 1. as is: def( "do_smth_no_raise", &do_smth ); > > 2. error status is converted by Py++ to exception: > > > > void do_smth_raise(){ > > error_t x; > > do_smth( x ); > > if x contains error: > > throw actual error; > > } > > > > def( "do_smth", &do_smth_raise ); > > > > > > do_smth.add_transformation() #<- use Py++ default behaviour > > do_smth.add_transformation( raise_on_error( 0, ... ) ) > > How do you rename the first version to "do_smth_no_raise" (without > renaming the other one)? do_smth.add_transformation( "do_smth_no_raise", raise_on_error( 0, ... ) ) I want to make it clear: this functionality is disabled now. But in future function_transformation_t class will get new property - alias. add_transformation method will change: def add_transformation( *args ): alias = self.alias if args and isinstance( args[0], str ): alias = args[0] args = args[1:] .... So it should be pretty simple to add it. I just want to concentrate my attention on small refactoring steps. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Matthias B. <ba...@ir...> - 2006-10-25 19:30:10
|
Roman Yakovenko wrote: >> > do_smth.add_transformation() #<- use Py++ default behaviour >> > do_smth.add_transformation( raise_on_error( 0, ... ) ) >> >> How do you rename the first version to "do_smth_no_raise" (without >> renaming the other one)? > > do_smth.add_transformation( "do_smth_no_raise", raise_on_error( 0, ... ) ) What about other decoration operations (such as assigning call policies, assigning a doc string, etc.)? Why isn't the existing interface used? The user could obtain a handle to a "clone" of the original declaration (either returned by add_transformation() or maybe even by a dedicated clone() method) that provides the same interface as the regular declarations. Then the user could do to the clone whatever he could do to every other declaration using an interface that he knows already. - Matthias - |
From: Roman Y. <rom...@gm...> - 2006-10-25 20:25:53
|
On 10/25/06, Matthias Baas <ba...@ir...> wrote: > Roman Yakovenko wrote: > >> > do_smth.add_transformation() #<- use Py++ default behaviour > >> > do_smth.add_transformation( raise_on_error( 0, ... ) ) > >> > >> How do you rename the first version to "do_smth_no_raise" (without > >> renaming the other one)? > > > > do_smth.add_transformation( "do_smth_no_raise", raise_on_error( 0, ... ) ) > > What about other decoration operations (such as assigning call policies, > assigning a doc string, etc.)? This is exactly function_transformation_t class for. add_transformation is just a convenience method. > Why isn't the existing interface used? The user could obtain a handle to > a "clone" of the original declaration (either returned by > add_transformation() or maybe even by a dedicated clone() method) that > provides the same interface as the regular declarations. Then the user > could do to the clone whatever he could do to every other declaration > using an interface that he knows already. In general asking a user to modify his data is a bad idea. Py++ should not change the declarations tree, but work with it as is. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |