List Info

Thread: Py++ and 'using' declarations




Py++ and 'using' declarations
country flaguser name
Finland
2007-06-19 04:16:46
Is there a way in Py++ to deal with overloaded member
functions
introduced by 'using' declarations?

For example, for the following declarations, Py++ creates
the code below.

-----------------------------------------------------
class B {
public:
     void f();
};

class D : public B {
public:
     void f(int i);
     using B::f;
};
-----------------------------------------------------
// This file has been generated by Py++.
#include "boost/python.hpp"
#include "killme.hh"
namespace bp = boost::python;

BOOST_PYTHON_MODULE(killme){
     bp::class_< B >( "B" )
         .def("f", &::B::f );
     bp::class_< D, bp::bases< B > >(
"D" )
         .def("f", &:::f, (
bp::arg("i") ) );
}
-----------------------------------------------------

Compiling this with g++ results in an "unresolved
overloaded
function type" error, because g++ cannot choose
between
D::f() and D::f(int).
-- 
Pertti


_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: Py++ and 'using' declarations
user name
2007-06-19 04:20:54
On 6/19/07, Pertti Kellomäki <pkcs.tut.fi> wrote:
> Is there a way in Py++ to deal with overloaded member
functions
> introduced by 'using' declarations?
>
> For example, for the following declarations, Py++
creates
> the code below.
>
> -----------------------------------------------------
> class B {
> public:
>      void f();
> };
>
> class D : public B {
> public:
>      void f(int i);
>      using B::f;
> };
> -----------------------------------------------------
> // This file has been generated by Py++.
> #include "boost/python.hpp"
> #include "killme.hh"
> namespace bp = boost::python;
>
> BOOST_PYTHON_MODULE(killme){
>      bp::class_< B >( "B" )
>          .def("f", &::B::f );
>      bp::class_< D, bp::bases< B > >(
"D" )
>          .def("f", &:::f, (
bp::arg("i") ) );
> }
> -----------------------------------------------------
>
> Compiling this with g++ results in an "unresolved
overloaded
> function type" error, because g++ cannot choose
between
> D::f() and D::f(int).

You don't need "using":

mb = module_builder_t( ... )
D = mb.class_( 'D' )
D.mem_fun( 'f' ).create_with_signature = True
#or:
mb.calldefs().create_with_signature = True #for all
functions

You can read more in documentation about the property:
http://language-binding.net/
pyplusplus/documentation/apidocs/pyplusplus.decl_wrappers.ca
lldef_wrapper.calldef_t-class.html#create_with_signature


P.S. I will tweak Py++ to be aware to such use case, and it
will guess
right the default value of the property.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: Py++ and 'using' declarations
country flaguser name
Finland
2007-06-19 05:15:04
Roman,

Thanks again for a very speedy answer!
-- 
Pertti
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )