mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 06:10:02 +08:00
JS: Support enum properties
This commit is contained in:
parent
475c775b25
commit
0739d1c2eb
@ -78,6 +78,12 @@ using namespace dnn;
|
||||
|
||||
namespace binding_utils
|
||||
{
|
||||
template<typename classT, typename enumT>
|
||||
static inline typename std::underlying_type<enumT>::type classT::* underlying_ptr(enumT classT::* enum_ptr)
|
||||
{
|
||||
return reinterpret_cast<typename std::underlying_type<enumT>::type classT::*>(enum_ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
emscripten::val matData(const cv::Mat& mat)
|
||||
{
|
||||
|
@ -856,7 +856,8 @@ class JSWrapperGenerator(object):
|
||||
|
||||
# Generate bindings for properties
|
||||
for property in class_info.props:
|
||||
class_bindings.append(class_property_template.substitute(js_name=property.name, cpp_name='::'.join(
|
||||
_class_property = class_property_enum_template if property.tp in type_dict else class_property_template
|
||||
class_bindings.append(_class_property.substitute(js_name=property.name, cpp_name='::'.join(
|
||||
[class_info.cname, property.name])))
|
||||
|
||||
dv = ''
|
||||
|
@ -153,6 +153,9 @@ overload_class_static_function_template = Template("""
|
||||
class_property_template = Template("""
|
||||
.property("$js_name", &$cpp_name)""")
|
||||
|
||||
class_property_enum_template = Template("""
|
||||
.property("$js_name", binding_utils::underlying_ptr(&$cpp_name))""")
|
||||
|
||||
ctr_template = Template("""
|
||||
.constructor(select_overload<$ret($args)$const>(&$cpp_name)$optional)""")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user