mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
fixed just introduced bug in Python wrapper generator
This commit is contained in:
parent
f22a3af483
commit
52ede9c84d
@ -169,6 +169,13 @@ static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *clo
|
|||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
gen_template_get_prop_algo = Template("""
|
||||||
|
static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *closure)
|
||||||
|
{
|
||||||
|
return pyopencv_from(dynamic_cast<$cname*>(p->v.obj)${access}${member});
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
gen_template_set_prop = Template("""
|
gen_template_set_prop = Template("""
|
||||||
static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value, void *closure)
|
static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value, void *closure)
|
||||||
{
|
{
|
||||||
@ -181,6 +188,19 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value
|
|||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
gen_template_set_prop_algo = Template("""
|
||||||
|
static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value, void *closure)
|
||||||
|
{
|
||||||
|
if (value == NULL)
|
||||||
|
{
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Cannot delete the ${member} attribute");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return pyopencv_to(value, dynamic_cast<$cname*>(p->v.obj)${access}${member}) ? 0 : -1;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
gen_template_prop_init = Template("""
|
gen_template_prop_init = Template("""
|
||||||
{(char*)"${member}", (getter)pyopencv_${name}_get_${member}, NULL, (char*)"${member}", NULL},""")
|
{(char*)"${member}", (getter)pyopencv_${name}_get_${member}, NULL, (char*)"${member}", NULL},""")
|
||||||
|
|
||||||
@ -267,11 +287,17 @@ class ClassInfo(object):
|
|||||||
access_op = "."
|
access_op = "."
|
||||||
|
|
||||||
for pname, p in sorted_props:
|
for pname, p in sorted_props:
|
||||||
getset_code.write(gen_template_get_prop.substitute(name=self.name, member=pname, membertype=p.tp, access=access_op))
|
if self.isalgorithm:
|
||||||
|
getset_code.write(gen_template_get_prop_algo.substitute(name=self.name, cname=self.cname, member=pname, membertype=p.tp, access=access_op))
|
||||||
|
else:
|
||||||
|
getset_code.write(gen_template_get_prop.substitute(name=self.name, member=pname, membertype=p.tp, access=access_op))
|
||||||
if p.readonly:
|
if p.readonly:
|
||||||
getset_inits.write(gen_template_prop_init.substitute(name=self.name, member=pname))
|
getset_inits.write(gen_template_prop_init.substitute(name=self.name, member=pname))
|
||||||
else:
|
else:
|
||||||
getset_code.write(gen_template_set_prop.substitute(name=self.name, member=pname, membertype=p.tp, access=access_op))
|
if self.isalgorithm:
|
||||||
|
getset_code.write(gen_template_set_prop_algo.substitute(name=self.name, cname=self.cname, member=pname, membertype=p.tp, access=access_op))
|
||||||
|
else:
|
||||||
|
getset_code.write(gen_template_set_prop.substitute(name=self.name, member=pname, membertype=p.tp, access=access_op))
|
||||||
getset_inits.write(gen_template_rw_prop_init.substitute(name=self.name, member=pname))
|
getset_inits.write(gen_template_rw_prop_init.substitute(name=self.name, member=pname))
|
||||||
|
|
||||||
methods_code = cStringIO.StringIO()
|
methods_code = cStringIO.StringIO()
|
||||||
|
Loading…
Reference in New Issue
Block a user