Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
seo young Joung
opencv
Commits
b32d914a
Commit
b32d914a
authored
7 years ago
by
Alexander Alekhin
Browse files
Options
Download
Email Patches
Plain Diff
static analyze: python dynamic_cast checks
parent
f670a992
4.x
3.4
5.x
master
next
4.5.5
4.5.4
4.5.3
4.5.3-openvino
4.5.3-openvino-2021.4.2
4.5.3-openvino-2021.4.1
4.5.2
4.5.2-openvino
4.5.1
4.5.1-openvino
4.5.0
4.5.0-openvino
4.4.0
4.4.0-openvino
4.3.0
4.3.0-openvino
4.3.0-openvino-2020.3.0
4.2.0
4.2.0-openvino
4.1.2
4.1.2-openvino
4.1.1
4.1.1-openvino
4.1.0
4.1.0-openvino
4.0.1
4.0.1-openvino
4.0.0
4.0.0-rc
4.0.0-openvino
4.0.0-beta
4.0.0-alpha
3.4.17
3.4.16
3.4.15
3.4.14
3.4.13
3.4.12
3.4.11
3.4.10
3.4.9
3.4.8
3.4.7
3.4.6
3.4.5
3.4.4
3.4.3
3.4.3-openvino
3.4.2
3.4.2-openvino
3.4.1
3.4.1-cvsdk
3.4.0
3.4.0-rc
3.3.1
3.3.1-cvsdk
3.3.0
3.3.0-cvsdk
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/python/src2/gen2.py
+19
-6
modules/python/src2/gen2.py
with
19 additions
and
6 deletions
+19
-6
modules/python/src2/gen2.py
View file @
b32d914a
...
...
@@ -11,14 +11,18 @@ else:
ignored_arg_types
=
[
"RNG*"
]
gen_template_check_self
=
Template
(
""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type))
gen_template_check_self
=
Template
(
""" $cname* _self_ = NULL;
if(PyObject_TypeCheck(self, &pyopencv_${name}_Type))
_self_ = ${amp}((pyopencv_${name}_t*)self)->v${get};
if (_self_ == NULL)
return failmsgp("Incorrect type of self (must be '${name}' or its derivative)");
$cname* _self_ = ${amp}((pyopencv_${name}_t*)self)->v${get};
"""
)
gen_template_check_self_algo
=
Template
(
""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type))
gen_template_check_self_algo
=
Template
(
""" $cname* _self_ = NULL;
if(PyObject_TypeCheck(self, &pyopencv_${name}_Type))
_self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.get());
if (_self_ == NULL)
return failmsgp("Incorrect type of self (must be '${name}' or its derivative)");
$cname* _self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.get());
"""
)
gen_template_call_constructor_prelude
=
Template
(
"""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type);
...
...
@@ -200,7 +204,10 @@ 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.get())${access}${member});
$cname* _self_ = dynamic_cast<$cname*>(p->v.get());
if (_self_ == NULL)
return failmsgp("Incorrect type of object (must be '${name}' or its derivative)");
return pyopencv_from(_self_${access}${member});
}
"""
)
...
...
@@ -224,7 +231,13 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value
PyErr_SetString(PyExc_TypeError, "Cannot delete the ${member} attribute");
return -1;
}
return pyopencv_to(value, dynamic_cast<$cname*>(p->v.get())${access}${member}) ? 0 : -1;
$cname* _self_ = dynamic_cast<$cname*>(p->v.get());
if (_self_ == NULL)
{
failmsgp("Incorrect type of object (must be '${name}' or its derivative)");
return -1;
}
return pyopencv_to(value, _self_${access}${member}) ? 0 : -1;
}
"""
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help