Thread: [pygccxml-development] type_traits problem
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@vr...> - 2006-05-11 23:31:16
|
I just ran into an annoyance that I had seen before bug forgot to post. I am checking a return_type from a method to see if it is a const reference and the type traits are not working well. The problem is that is_const and is_reference only check the most external portion of a composed type. So if you want to check if something is really a const ref you have do write code something like this (please correct me if I am wrong). ret_type = method.return_type is_ref = True in map(declarations.is_reference, declarations.decompose_type(ret_type)) is_const = True in map(declarations.is_const, declarations.decompose_type(ret_type)) is_const_ref = (is_ref and not is_const) Boost type traits and other libraries like it automatically do the decomposition so you could check a const reference type and it will return true to both is_reference and is_const. Is there any reason that we shouldn't make pygccxml work similarly? -Allen |
From: Roman Y. <rom...@gm...> - 2006-05-12 10:25:09
|
On 5/12/06, Allen Bierbaum <al...@vr...> wrote: > I just ran into an annoyance that I had seen before bug forgot to post. > > I am checking a return_type from a method to see if it is a const > reference and the type traits are not working well. > > The problem is that is_const and is_reference only check the most > external portion of a composed type. So if you want to check if > something is really a const ref you have do write code something like > this (please correct me if I am wrong). > > ret_type =3D method.return_type > is_ref =3D True in map(declarations.is_reference, > declarations.decompose_type(ret_type)) > is_const =3D True in map(declarations.is_const, > declarations.decompose_type(ret_type)) > is_const_ref =3D (is_ref and not is_const) > > Boost type traits and other libraries like it automatically do the > decomposition so you could check a const reference type and it will > return true to both is_reference and is_const. > > Is there any reason that we shouldn't make pygccxml work similarly? Yes. I did not have test case for this. If you can send me test case I will= make sure it works as expected. > -Allen > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job ea= sier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > pygccxml-development mailing list > pyg...@li... > https://lists.sourceforge.net/lists/listinfo/pygccxml-development > --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-05-12 12:38:57
Attachments:
test_diff.patch
|
I have attached a patch that adds a test case. I think all the is_* tests suffer from a similar problem. They only seem to examine the "outside" most type information and ignore the internal data. For example, shouldn't is_float return true for a "const float" type? -Allen Roman Yakovenko wrote: > On 5/12/06, Allen Bierbaum <al...@vr...> wrote: > >> I just ran into an annoyance that I had seen before bug forgot to post. >> >> I am checking a return_type from a method to see if it is a const >> reference and the type traits are not working well. >> >> The problem is that is_const and is_reference only check the most >> external portion of a composed type. So if you want to check if >> something is really a const ref you have do write code something like >> this (please correct me if I am wrong). >> >> ret_type = method.return_type >> is_ref = True in map(declarations.is_reference, >> declarations.decompose_type(ret_type)) >> is_const = True in map(declarations.is_const, >> declarations.decompose_type(ret_type)) >> is_const_ref = (is_ref and not is_const) >> >> Boost type traits and other libraries like it automatically do the >> decomposition so you could check a const reference type and it will >> return true to both is_reference and is_const. >> >> Is there any reason that we shouldn't make pygccxml work similarly? > > > Yes. I did not have test case for this. If you can send me test case I > will make > sure it works as expected. > >> -Allen >> >> >> ------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, >> security? >> Get stuff done quickly with pre-integrated technology to make your >> job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache >> Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> pygccxml-development mailing list >> pyg...@li... >> https://lists.sourceforge.net/lists/listinfo/pygccxml-development >> > > |
From: Roman Y. <rom...@gm...> - 2006-05-12 12:52:14
|
On 5/12/06, Allen Bierbaum <al...@vr...> wrote: > I have attached a patch that adds a test case. Thanks. I will fix it. > I think all the is_* tests suffer from a similar problem. They only > seem to examine the "outside" most type information and ignore the > internal data. > > For example, shouldn't is_float return true for a "const float" type? The behaviour should be same as with boost.type_traits. It is possible I mi= ssed something. I will check it and fix. > -Allen --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-05-30 20:11:20
|
On 5/30/06, Allen Bierbaum <al...@vr...> wrote: > Did this ever get fixed? (I don't think it did) No :-(. May be I wrong with my priorities, but I wanted to create better documentation. If you want/can contribute the patch, I will apply it after all my unit tests pass. Sorry. I do have this on my to do list, but for next release, not this one. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-06-05 12:40:03
|
On 5/30/06, Roman Yakovenko <rom...@gm...> wrote: > On 5/30/06, Allen Bierbaum <al...@vr...> wrote: > > Did this ever get fixed? (I don't think it did) Yes, I am going to fix this. is_xxx will report true for "xxx" and "const xxx", for all other cases it will report false Here is a link to relevant example: http://boost.org/doc/html/boost_typetraits/reference.html#boost_typetraits.is_enum -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |