Skip to content

Commit

Permalink
- The boxptr_-function is now only generated if not all of the functi…
Browse files Browse the repository at this point in the history
…on in/outputs are boxed (meaning the wrapper is only generated if needed; otherwise it's a preprocessor macro)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7558 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 23, 2010
1 parent fe21650 commit 04a4bd7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -2825,12 +2825,12 @@ template functionHeader(Function fn, Boolean inFunc)
case FUNCTION(__) then
<<
<%functionHeaderNormal(underscorePath(name), functionArguments, outVars, inFunc)%>
<%functionHeaderBoxed(underscorePath(name), functionArguments, outVars)%>
<%functionHeaderBoxed(underscorePath(name), functionArguments, outVars, isBoxedFunction(fn))%>
>>
case EXTERNAL_FUNCTION(__) then
<<
<%functionHeaderNormal(underscorePath(name), funArgs, outVars, inFunc)%>
<%functionHeaderBoxed(underscorePath(name), funArgs, outVars)%>
<%functionHeaderBoxed(underscorePath(name), funArgs, outVars, isBoxedFunction(fn))%>

<%extFunDef(fn)%>
>>
Expand Down Expand Up @@ -2929,8 +2929,9 @@ template functionHeaderNormal(String fname, list<Variable> fargs, list<Variable>
::= functionHeaderImpl(fname, fargs, outVars, inFunc, false)
end functionHeaderNormal;

template functionHeaderBoxed(String fname, list<Variable> fargs, list<Variable> outVars)
::= if acceptMetaModelicaGrammar() then functionHeaderImpl(fname, fargs, outVars, false, true)
template functionHeaderBoxed(String fname, list<Variable> fargs, list<Variable> outVars, Boolean isBoxed)
::= if acceptMetaModelicaGrammar() then
if isBoxed then '#define boxptr_<%fname%> _<%fname%><%\n%>' else functionHeaderImpl(fname, fargs, outVars, false, true)
end functionHeaderBoxed;

template functionHeaderImpl(String fname, list<Variable> fargs, list<Variable> outVars, Boolean inFunc, Boolean boxed)
Expand Down Expand Up @@ -3261,10 +3262,10 @@ template functionBodyBoxed(Function fn)
"Generates code for a boxed version of a function. Extracts the needed data
from a function and calls functionBodyBoxedImpl"
::=
match fn
case FUNCTION(__) then functionBodyBoxedImpl(name, functionArguments, outVars)
case EXTERNAL_FUNCTION(__) then functionBodyBoxedImpl(name, funArgs, outVars)
case RECORD_CONSTRUCTOR(__) then boxRecordConstructor(fn)
match fn
case FUNCTION(__) then if not isBoxedFunction(fn) then functionBodyBoxedImpl(name, functionArguments, outVars)
case EXTERNAL_FUNCTION(__) then if not isBoxedFunction(fn) then functionBodyBoxedImpl(name, funArgs, outVars)
case RECORD_CONSTRUCTOR(__) then boxRecordConstructor(fn)
end functionBodyBoxed;

template functionBodyBoxedImpl(Absyn.Path name, list<Variable> funargs, list<Variable> outvars)
Expand Down
5 changes: 5 additions & 0 deletions Compiler/susan_codegen/SimCode/SimCodeTV.mo
Expand Up @@ -418,6 +418,11 @@ package SimCode
output DAE.Exp outExp;
end hackMatrixReverseToCref;

function isBoxedFunction
input Function fn;
output Boolean b;
end isBoxedFunction;

end SimCode;


Expand Down

0 comments on commit 04a4bd7

Please sign in to comment.