From 7ef3be34296b453e819c71e5d070960a14d20b24 Mon Sep 17 00:00:00 2001 From: hbristow Date: Wed, 7 Aug 2013 00:14:13 +1000 Subject: [PATCH] By default, all function now export at least one return value back into the Matlab workspace, even if none are requested. This is in line with Matlab's calling convention, where functions called without an lvalue or a semicolon have their first output printed to the terminal --- modules/matlab/CMakeLists.txt | 5 +++-- .../matlab/generator/templates/template_function_base.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt index 3e415e20d..f9f869051 100644 --- a/modules/matlab/CMakeLists.txt +++ b/modules/matlab/CMakeLists.txt @@ -73,8 +73,9 @@ ocv_add_module(matlab BINDINGS opencv_nonfree ) -# set the path to the C++ header parser -set(HDR_PARSER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../python/src2) +# set the path to the C++ header and doc parser +set(HDR_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/python/src2) +set(RST_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/java/generator) # set mex compiler options prepend("-I" MEX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/modules/matlab/generator/templates/template_function_base.cpp b/modules/matlab/generator/templates/template_function_base.cpp index 5089455df..7a6ad4b07 100644 --- a/modules/matlab/generator/templates/template_function_base.cpp +++ b/modules/matlab/generator/templates/template_function_base.cpp @@ -50,7 +50,7 @@ void mexFunction(int nlhs, mxArray*{% if fun|noutputs %} plhs[]{% else %}*{% end {% if fun|noutputs %} // push the outputs back to matlab - for (size_t n = 0; n < static_cast(nlhs); ++n) { + for (size_t n = 0; n < static_cast(std::max(nlhs,1)); ++n) { plhs[n] = outputs[n].toMxArray().releaseOwnership(); } {% endif %}