From fa075c50a1863bba8f99a64f816e11a155f93165 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Mon, 28 Apr 2014 15:43:12 +0200 Subject: [PATCH] Matlab bindings: fixed the functional template to perform an explicit cast to the type of an input option that is expected. This avoids issues with ternary operator not having the same type in rvalue and lvalue, such as in the case below: Ptr_FeatureDetector blobDetector = inputs[3].empty() ? makePtr() : inputs[3].toPtrFeatureDetector(); Which after the patch, would be: Ptr_FeatureDetector blobDetector = inputs[3].empty() ? (Ptr_FeatureDetector) makePtr() : inputs[3].toPtrFeatureDetector(); --- modules/matlab/generator/templates/functional.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/matlab/generator/templates/functional.cpp b/modules/matlab/generator/templates/functional.cpp index 9f3a995..b019a13 100644 --- a/modules/matlab/generator/templates/functional.cpp +++ b/modules/matlab/generator/templates/functional.cpp @@ -110,7 +110,7 @@ addVariant("{{ fun.name }}", {{ fun.req|inputs|length }}, {{ fun.opt|inputs|leng {{arg.tp}} {{arg.name}} = inputs[{{ loop.index0 }}].to{{arg.tp|toUpperCamelCase}}(); {% endfor %} {% for opt in fun.opt|inputs %} - {{opt.tp}} {{opt.name}} = inputs[{{loop.index0 + fun.req|inputs|length}}].empty() ? {% if opt.ref == '*' -%} {{opt.tp}}() {%- else -%} {{opt.default}} {%- endif %} : inputs[{{loop.index0 + fun.req|inputs|length}}].to{{opt.tp|toUpperCamelCase}}(); + {{opt.tp}} {{opt.name}} = inputs[{{loop.index0 + fun.req|inputs|length}}].empty() ? ({{opt.tp}}) {% if opt.ref == '*' -%} {{opt.tp}}() {%- else -%} {{opt.default}} {%- endif %} : inputs[{{loop.index0 + fun.req|inputs|length}}].to{{opt.tp|toUpperCamelCase}}(); {% endfor %} {# ----------- Outputs ------------ #} {% for arg in fun.req|only|outputs %} -- 2.7.4