Commit 538dbfe5 authored by hbristow's avatar hbristow

Now compiling under much more strigent warnings, with Clang and optional C++11 support

parent 53a7fbf7
......@@ -32,6 +32,11 @@ set(OPENCV_EXTRA_EXE_LINKER_FLAGS "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")
# if Apple and Clang, enable C++11 support :)
if(APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(OPENCV_EXTRA_CXX_FLAGS "-std=c++11 -stdlib=libc++")
endif()
macro(add_extra_compiler_option option)
if(CMAKE_BUILD_TYPE)
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
......
......@@ -58,7 +58,7 @@ set(HDR_PARSER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../python/src2)
prepend("-I" MEX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
prepend("-L" MEX_LIB_DIR ${CMAKE_BINARY_DIR}/lib)
prepend("-l" MEX_LIBS opencv_core)
set(MEX_OPTS "-largeArrayDims")
set(MEX_OPTS -largeArrayDims)
if (ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_module} PROPERTIES FOLDER "Matlab bindings")
......@@ -118,7 +118,7 @@ if (NOT MEX_WORKS)
${CMAKE_CURRENT_SOURCE_DIR}/test/test_compiler.cpp
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/junk
ERROR_VARIABLE MEX_ERROR
OUTPUT_QUIET
#OUTPUT_QUIET
)
if (MEX_ERROR)
......
......@@ -12,9 +12,9 @@ def inputs(args):
except:
return [arg for arg in args if arg.I]
def ninputs(args):
def ninputs(fun):
'''Counts the number of input arguments in the input list'''
return len(inputs(args))
return len(inputs(fun.req)) + len(inputs(fun.opt))
def outputs(args):
'''Determines whether any of the given arguments is an output
......@@ -39,9 +39,9 @@ def void(arg):
def flip(arg):
return not arg
def noutputs(args):
def noutputs(fun):
'''Counts the number of output arguments in the input list'''
return len(outputs(args))
return int(not void(fun.rtp)) + len(outputs(fun.req)) + len(outputs(fun.opt))
def convertibleToInt(string):
salt = '1+'
......
......@@ -29,6 +29,7 @@
// create a full function invocation
{%- macro generate(fun) -%}
{% if fun|ninputs or fun|noutputs %}
// unpack the arguments
{# ----------- Inputs ------------- #}
{% for arg in fun.req|inputs %}
......@@ -47,6 +48,7 @@
{% if not fun.rtp|void %}
{{fun.rtp}} retval;
{% endif %}
{% endif %}
// call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
......@@ -60,6 +62,7 @@
mexErrMsgTxt("Uncaught exception occurred in {{fun.name}}");
}
{% if fun|noutputs %}
// assign the outputs into the bridge
{% if not fun.rtp|void %}
outputs[0] = retval;
......@@ -70,5 +73,6 @@
{% for opt in fun.opt|outputs %}
outputs[{{loop.index0 + fun.rtp|void|not + fun.req|outputs|length}}] = {{opt.name}};
{% endfor %}
{% endif %}
{% endmacro %}
......@@ -26,26 +26,29 @@ using namespace cv;
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
void mexFunction(int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[]) {
void mexFunction(int nlhs, mxArray*{% if fun|noutputs %} plhs[]{% else %}*{% endif %},
int nrhs, const mxArray*{% if fun|ninputs %} prhs[]{% else %}*{% endif %}) {
// assertions
conditionalError(nrhs >= {{fun.req|length - fun.req|only|outputs|length}}, "Too few required input arguments specified");
conditionalError(nrhs <= {{fun.req|length + fun.opt|length - fun.req|only|outputs|length - fun.opt|only|outputs|length}}, "Too many input arguments specified");
conditionalError(nlhs <= {{ fun.rtp|void|not + fun.req|outputs|length + fun.opt|outputs|length}}, "Too many output arguments specified");
{% if fun|ninputs or fun|noutputs %}
// setup
{% if fun|ninputs %}
std::vector<Bridge> inputs(prhs, prhs+nrhs);
{% set noutputs = fun.rtp|void|not + fun.req|outputs|length + fun.opt|outputs|length %}
{%- if noutputs %}
std::vector<Bridge> outputs({{noutputs}});
{% endif -%}
{%- if fun|noutputs %}
std::vector<Bridge> outputs({{fun|noutputs}});
{% endif %}
{% endif %}
{{ functional.generate(fun) }}
{%- if noutputs %}
{%- if fun|noutputs %}
// push the outputs back to matlab
for (size_t n = 0; n < nlhs; ++n) {
for (size_t n = 0; n < static_cast<size_t>(nlhs); ++n) {
plhs[n] = outputs[n].toMxArray().releaseOwnership();
}
{% endif %}
......
This diff is collapsed.
......@@ -8,7 +8,6 @@
* Copyright 2013 The OpenCV Foundation
*/
#include "mex.h"
#include "bridge.hpp"
#include <vector>
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment