Thread: [pygccxml-development] Finalizing a class?
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@vr...> - 2006-05-17 04:29:22
|
Is it possible to finalize a wrapped class? In the library I am wrapping there are a number of classes that I know I do not want to allow the users to extend. Thus I would like to not expose protected method or provide a wrapper to allow overriding virtuals. Is it possible to do this with pyplusplus? -Allen |
From: Roman Y. <rom...@gm...> - 2006-05-17 05:15:50
|
On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > Is it possible to finalize a wrapped class? In the library I am > wrapping there are a number of classes that I know I do not want to > allow the users to extend. Thus I would like to not expose protected > method or provide a wrapper to allow overriding virtuals. > > Is it possible to do this with pyplusplus? The short answer - may be yes. mb =3D module_builder_t( ... ) non_public =3D ~declarations.access_type_matcher_t( 'public' ) mb.calldefs( query ).exclude() mb.member_functions().virtuality =3D declarations.VIRTUALITY_TYPES.NOT_VIRT= UAL This is a hack, but it should work. The long answer is here: http://sourceforge.net/mailarchive/forum.php?forum_id=3D47898&max_rows=3D25= &style=3Dflat&viewmonth=3D200603&viewday=3D20 > -Allen --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-05-17 15:35:31
|
This seems like something that should be made easier for the user. Perhaps something like: my_ns.class_("ClassA").finalize() class_a.member_function("my_method").finalize() Is there any reason pyplusplus can't provide a more simple interface like this for the user? -Allen Roman Yakovenko wrote: > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > >> Is it possible to finalize a wrapped class? In the library I am >> wrapping there are a number of classes that I know I do not want to >> allow the users to extend. Thus I would like to not expose protected >> method or provide a wrapper to allow overriding virtuals. >> >> Is it possible to do this with pyplusplus? > > > The short answer - may be yes. > > mb = module_builder_t( ... ) > non_public = ~declarations.access_type_matcher_t( 'public' ) > mb.calldefs( query ).exclude() > > mb.member_functions().virtuality = > declarations.VIRTUALITY_TYPES.NOT_VIRTUAL > > This is a hack, but it should work. > > The long answer is here: > http://sourceforge.net/mailarchive/forum.php?forum_id=47898&max_rows=25&style=flat&viewmonth=200603&viewday=20 > > >> -Allen > > |
From: Roman Y. <rom...@gm...> - 2006-05-17 17:11:48
|
On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > This seems like something that should be made easier for the user. > > Perhaps something like: > > my_ns.class_("ClassA").finalize() > > class_a.member_function("my_method").finalize() > > Is there any reason pyplusplus can't provide a more simple interface > like this for the user? What should do pyplusplus if the only way to export declaration is to create some wrapper for it? For example class with pure virtual function: raise an error? create wrapper? try to export without wrapper and let to the user to understand what he did wrong? > -Allen > --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-05-17 18:13:38
|
On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > Roman Yakovenko wrote: > > > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > > > >> This seems like something that should be made easier for the user. > >> > >> Perhaps something like: > >> > >> my_ns.class_("ClassA").finalize() > >> > >> class_a.member_function("my_method").finalize() > >> > >> Is there any reason pyplusplus can't provide a more simple interface > >> like this for the user? > > > > > > What should do pyplusplus if the only way to export declaration is to > > create some > > wrapper for it? For example class with pure virtual function: > > raise an error? > > create wrapper? > > try to export without wrapper and let to the user to understand > > what he did > > wrong? > > I think it should raise an error and explain to the user why pyplusplus > can't honor their request. > > If it is ever possible to detect that they user is doing something that > is invalid and can be detected, then the system should tell the user and > ask them to correct it. It is not convinient, I think we should have next functionality: finalize if possible > For example I would like the option to turn on > a warning or even error message for cases where pyplusplus knows the > user should specify a calling policy but hasn't. The system already > puts a comment in the code to that effect, it may as well warn the user > as well. I will print a message to log. > -Allen > > --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-06-15 03:22:43
|
Roman: Was there ever any progress on this? I am back to wrapping my original library now and I really need the ability to finalize classes. -Allen Roman Yakovenko wrote: > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > >> Roman Yakovenko wrote: >> >> > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: >> > >> >> This seems like something that should be made easier for the user. >> >> >> >> Perhaps something like: >> >> >> >> my_ns.class_("ClassA").finalize() >> >> >> >> class_a.member_function("my_method").finalize() >> >> >> >> Is there any reason pyplusplus can't provide a more simple interface >> >> like this for the user? >> > >> > >> > What should do pyplusplus if the only way to export declaration is to >> > create some >> > wrapper for it? For example class with pure virtual function: >> > raise an error? >> > create wrapper? >> > try to export without wrapper and let to the user to understand >> > what he did >> > wrong? >> >> I think it should raise an error and explain to the user why pyplusplus >> can't honor their request. >> >> If it is ever possible to detect that they user is doing something that >> is invalid and can be detected, then the system should tell the user and >> ask them to correct it. > > > It is not convinient, I think we should have next functionality: > finalize if possible > >> For example I would like the option to turn on >> a warning or even error message for cases where pyplusplus knows the >> user should specify a calling policy but hasn't. The system already >> puts a comment in the code to that effect, it may as well warn the user >> as well. > > > I will print a message to log. > >> -Allen >> >> > > |
From: Roman Y. <rom...@gm...> - 2006-06-15 06:01:16
|
On 6/15/06, Allen Bierbaum <al...@vr...> wrote: > Roman: > > Was there ever any progress on this? I am back to wrapping my original > library now and I really need the ability to finalize classes. There is no progress, but there is pretty simple work around: set member functions virtuality to NOT_VIRTUAL. In this case py++ will generate wrappers only when it is absolutely needed: arrays bit fields member variable that has pointer or reference type may be something else Be careful with pure virtual functions. Also If you want to implement this, I will try to find time and to explain you how to do that. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |