From: John H. <jdh...@ac...> - 2006-04-25 20:15:55
|
>>>>> "Jouni" == Jouni K Seppanen <jk...@ik...> writes: Jouni> I hacked the load_char method to accept a "flags" keyword Jouni> parameter. I hope I didn't break anything; is it safe to Jouni> use PyArg_ParseTupleAndKeywords with the C++ interface? You shouldn't need to with the ft2font extension code, because it uses pycxx which has support for kwarg handling. Eg in the _image.cpp src Py::Object resize(const Py::Tuple& args, const Py::Dict& kwargs); Py::Object Image::resize(const Py::Tuple& args, const Py::Dict& kwargs) { _VERBOSE("Image::resize"); args.verify_length(2); int norm = 1; if ( kwargs.hasKey("norm") ) norm = Py::Int( kwargs["norm"] ); double radius = 4.0; if ( kwargs.hasKey("radius") ) radius = Py::Float( kwargs["radius"] ); //snip snip snip } so you can easily add kwarg handling by changing the declaration to accept a Py::Dict and then use the object with dictionary like semantics. In the init_type function, you'll need to declare your method as a kwarg method, eg add_keyword_method( "resize", &Image::resize, Image::resize__doc__); JDH |