From 0263727b530b51f81121022aab160b010f152bc5 Mon Sep 17 00:00:00 2001 From: hbristow Date: Fri, 21 Jun 2013 23:39:28 -0700 Subject: [PATCH] Function templates now include the full skeleton, from input to output. Class templates need work --- modules/matlab/generator/templates/functional.cpp | 4 ++-- .../generator/templates/template_function_base.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/matlab/generator/templates/functional.cpp b/modules/matlab/generator/templates/functional.cpp index 143783358e..fac3cce6ba 100644 --- a/modules/matlab/generator/templates/functional.cpp +++ b/modules/matlab/generator/templates/functional.cpp @@ -66,5 +66,5 @@ {% for opt in fun.opt|outputs %} outputs[{{loop.index0 + fun.rtp|void|not + fun.req|outputs|length}}] = {{opt.name}}; {% endfor %} - -{%- endmacro -%} + +{% endmacro %} diff --git a/modules/matlab/generator/templates/template_function_base.cpp b/modules/matlab/generator/templates/template_function_base.cpp index 8ec5703f6a..9f3bb7643d 100644 --- a/modules/matlab/generator/templates/template_function_base.cpp +++ b/modules/matlab/generator/templates/template_function_base.cpp @@ -36,9 +36,15 @@ void mexFunction(int nlhs, mxArray* plhs[], // setup std::vector inputs(plhs, plhs+nrhs); - std::vector outputs(nlhs); + {% set noutputs = fun.rtp|void|not + fun.req|outputs|length + fun.opt|outputs|length %} + {%- if noutputs %} + std::vector outputs({{noutputs}}); + {% endif %} {{ functional.generate(fun) }} - // setdown + // push the outputs back to matlab + for (size_t n = 0; n < nlhs; ++n) { + plhs[n] = outputs[n].mxArray(); + } }