Merge pull request #12622 from cv3d:fix/js_property

pull/12631/merge
Alexander Alekhin 6 years ago
commit efca746d36
  1. 6
      modules/js/src/core_bindings.cpp
  2. 3
      modules/js/src/embindgen.py
  3. 3
      modules/js/src/templates.py

@ -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…
Cancel
Save