[C++-sig] Re: make_constructor & keyword arguments?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Aug 9 23:31:32 CEST 2004


--- David Abrahams <dave at boost-consulting.com> wrote:
> > Could it be that my list of arg's is not actually used in
> make_constructor.hpp?
> 
> I don't think that's the problem.

I am afraid you have to change your mind. :-)
Here is the critical patch:

Index: make_constructor.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/make_constructor.hpp,v
retrieving revision 1.3
diff -u -r1.3 make_constructor.hpp
--- make_constructor.hpp        5 Jan 2004 11:46:29 -0000       1.3
+++ make_constructor.hpp        9 Aug 2004 21:19:02 -0000
@@ -184,6 +184,7 @@
               detail::caller<F,inner_policy,Sig>(f, inner_policy(p))
             , outer_signature()
           )
+          , kw
       );
   }
   // }

> Try changing (in make_constructor.hpp):
> 
>       enum { arity = mpl::size<Sig>::value - 1 };
>       
> to:
> 
>       enum { arity = mpl::size<Sig>::value };
>       
> Then add back the "self" keyword and let me know if it works.

With my "critical" patch it works both ways. With "- 1" and without arg("self")
the traceback shows:

    __init__(boost::python::api::object, int a, int b, int c)

Without the  "- 1" and with arg("self"):

    __init__(boost::python::api::object self, int a, int b, int c)

The latter is inconsistent with the traceback resulting from wrapping
constructors the regular way (e.g. .def(init<int>((arg("x"))) ). I also find it
inconvenient having to provide arg("self") all the time. Therefore I am leaning
towards keeping the "- 1" in make_constructor.hpp. What do you think?

While poking around I discovered that the keywords are also not used correctly
in this situation:

    class_<X>("X", init<int>((arg("x"))))

Where would I be looking for missing ", kw" to fix this?

Ralf



		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail



More information about the Cplusplus-sig mailing list