Virtual Functions with Default Implementations code sample
I can't build the "Virtual Functions with Default Implementations" code sample from the online tutorial : struct Base { virtual int f() { return 0; } }; struct BaseWrap : Base { BaseWrap(PyObject* self_) : self(self_) {} int f() { return call_method<int>(self, "f"); } int default_f() { return Base::f(); } // <<=== ***ADDED*** PyObject* self; }; ------- class_<Base, BaseWrap>("Base") .def("f", &Base::f, &BaseWrap::default_f) --> get the error "value_holder.hpp(131) : error C2661: 'BaseWrap::BaseWrap' : no overloaded function takes 2 parameters" ??? (btw I can build all the other code samples from the tutorial) ------- other newbie questions : Is there a place on the web where all the c++-sig@python mails are archived ? Does pyste can convert C++ function arguments to python keyword arguments ?
"Alex" <alex@glumol.com> writes:
I can't build the "Virtual Functions with Default Implementations" code sample from the online tutorial :
struct Base { virtual int f() { return 0; } };
struct BaseWrap : Base { BaseWrap(PyObject* self_) : self(self_) {} int f() { return call_method<int>(self, "f"); } int default_f() { return Base::f(); } // <<=== ***ADDED*** PyObject* self; };
-------
class_<Base, BaseWrap>("Base") .def("f", &Base::f, &BaseWrap::default_f)
--> get the error "value_holder.hpp(131) : error C2661: 'BaseWrap::BaseWrap' : no overloaded function takes 2 parameters"
This is a tutorial bug. We need to either: 1. Add a copying constructor: BaseWrap(PyObject* self_, Base const& rhs) : Base(rhs), self(self_) {} 2. Use noncopyable in the wrapper: class_<Base, BaseWrap, noncopyable>("Base") .def("f", &Base::f, &BaseWrap::default_f) ; [Joel, could you choose an appropriate fix?]
(btw I can build all the other code samples from the tutorial)
That's a relief!
-------
other newbie questions :
Is there a place on the web where all the c++-sig@python mails are archived ?
http://www.boost.org/more/mailing_lists.htm#cplussig lists two archives in addition to http://mail.python.org/pipermail/c++-sig/..
Does pyste can convert C++ function arguments to python keyword arguments ?
I don't think so; IIRC GCC_XML doesn't give us the declared argument names (if any). Nicodemus? -- Dave Abrahams Boost Consulting www.boost-consulting.com
David Abrahams wrote:
"Alex" <alex@glumol.com> writes:
Does pyste can convert C++ function arguments to python keyword arguments ?
I don't think so; IIRC GCC_XML doesn't give us the declared argument names (if any). Nicodemus?
That's correct, GCCXML doesn't provide this information. We could allow the user to specify the args() in the pyste file: C = Class(...) set_args(C.foo, 'arg1', 'arg2') # or just "args(C.foo, ...)"? ?
--- Nicodemus <nicodemus@globalite.com.br> wrote:
I don't think so; IIRC GCC_XML doesn't give us the declared argument names (if any). Nicodemus?
That's correct, GCCXML doesn't provide this information.
What a pitty. It is a bit unfortunate that keyword support for wrapped C++ functions isn't automatic. In practice I tend to help myself with Python wrappers for the wrapped C++ functions. Not very elegant. Is there hope that GCCXML will provide the declared arguments names at some point in the future? Ralf __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Ralf W. Grosse-Kunstleve wrote:
--- Nicodemus <nicodemus@globalite.com.br> wrote:
I don't think so; IIRC GCC_XML doesn't give us the declared argument names (if any). Nicodemus?
That's correct, GCCXML doesn't provide this information.
What a pitty. It is a bit unfortunate that keyword support for wrapped C++ functions isn't automatic. In practice I tend to help myself with Python wrappers for the wrapped C++ functions. Not very elegant. Is there hope that GCCXML will provide the declared arguments names at some point in the future?
I will ask Brad in the GCCXML list about it.
participants (4)
-
Alex -
David Abrahams -
Nicodemus -
Ralf W. Grosse-Kunstleve