Commit 79acac7b authored by Ludovic L'Hours's avatar Ludovic L'Hours Committed by Tomeu Vizoso

Proper handling of null-ok in virtual methods

https://bugzilla.gnome.org/show_bug.cgi?id=589253
parent 259a4b08
......@@ -615,6 +615,7 @@ class Wrapper:
handler, props = argtypes.matcher.get_reverse(
param.ptype)
props["direction"] = param.pdir
props["nullok"] = param.pnull
wrapper.add_parameter(handler(wrapper,
param.pname, **props))
buf = reversewrapper.MemoryCodeSink()
......@@ -1168,6 +1169,7 @@ class GInterfaceWrapper(GObjectWrapper):
handler, props = argtypes.matcher.get_reverse(
param.ptype)
props["direction"] = param.pdir
props["nullok"] = param.pnull
wrapper.add_parameter(
handler(wrapper, param.pname, **props))
buf = reversewrapper.MemoryCodeSink()
......
......@@ -408,10 +408,22 @@ class StringParam(Parameter):
% (self.name, self.name, self.name)),
cleanup=("Py_XDECREF(py_%s);" % self.name))
self.wrapper.add_pyargv_item("py_%s" % self.name, optional=True)
else:
elif self.props.get('nullok', False):
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
self.wrapper.write_code(code=("py_%s = PyString_FromString(%s);" %
(self.name, self.name)),
self.wrapper.write_code(code=("if (%s)\n"
" py_%s = PyString_FromString(%s);\n"
"else {\n"
" Py_INCREF(Py_None);\n"
" py_%s = Py_None;\n"
"}\n"
% (self.name, self.name, self.name, self.name)),
cleanup=("Py_DECREF(py_%s);" % self.name))
self.wrapper.add_pyargv_item("py_%s" % self.name)
else:
self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
self.wrapper.write_code(code=("if (%s)\n"
" py_%s = PyString_FromString(%s);\n" %
(self.name, self.name, self.name)),
cleanup=("Py_DECREF(py_%s);" % self.name),
failure_expression=("!py_%s" % self.name))
self.wrapper.add_pyargv_item("py_%s" % self.name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment