Matlab bindings now only building once rather than every call to make, via the use of some proxies. Matlab build currently only happens in one thread, so it can be pretty slow

This commit is contained in:
hbristow
2013-06-22 23:26:27 -07:00
parent 3b4814a52e
commit 755ce9d654
6 changed files with 159 additions and 38 deletions

View File

@@ -43,12 +43,15 @@ def noutputs(args):
'''Counts the number of output arguments in the input list'''
return len(outputs(args))
def toUpperCamelCase(text):
def capitalizeFirst(text):
return text[0].upper() + text[1:]
def toUpperCamelCase(text):
return ''.join([capitalizeFirst(word) for word in text.split('_')])
def toLowerCamelCase(text):
return text[0].lower() + text[1:]
upper_camel = toUpperCamelCase(test)
return upper_camel[0].lower() + upper_camel[1:]
def toUnderCase(text):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)

View File

@@ -8,7 +8,7 @@
{% macro compose(fun) %}
{# ----------- Return type ------------- #}
{%- if not fun.rtp|void -%} retval = {% endif -%}
{%- if fun.clss -%}inst.{%- else -%} cv:: {% endif -%}
{%- if fun.clss -%}inst.{%- else -%} cv:: {%- endif -%}
{{fun.name}}(
{#- ----------- Required ------------- -#}
{%- for arg in fun.req -%}
@@ -32,10 +32,10 @@
// unpack the arguments
{# ----------- Inputs ------------- #}
{% for arg in fun.req|inputs %}
{{arg.tp}} {{arg.name}} = inputs[{{ loop.index0 }}];
{{arg.tp}} {{arg.name}} = inputs[{{ loop.index0 }}].to{{arg.tp|toUpperCamelCase}}();
{% endfor %}
{% for opt in fun.opt|inputs %}
{{opt.tp}} {{opt.name}} = (nrhs > {{loop.index0 + fun.req|inputs|length}}) ? ({{opt.tp}})inputs[{{loop.index0 + fun.req|inputs|length}}] : {{opt.default}};
{{opt.tp}} {{opt.name}} = (nrhs > {{loop.index0 + fun.req|inputs|length}}) ? inputs[{{loop.index0 + fun.req|inputs|length}}].to{{opt.tp|toUpperCamelCase}}() : {% if opt.ref == '*' -%} {{opt.tp}}() {%- else -%} {{opt.default}} {%- endif %};
{% endfor %}
{# ----------- Outputs ------------ #}
{% for arg in fun.req|only|outputs %}

View File

@@ -42,8 +42,10 @@ void mexFunction(int nlhs, mxArray* plhs[],
{{ functional.generate(fun) }}
{%- if noutputs %}
// push the outputs back to matlab
for (size_t n = 0; n < nlhs; ++n) {
plhs[n] = outputs[n].mxArray();
plhs[n] = outputs[n].toMxArray();
}
{% endif %}
}