Skip to content

Commit af660ef

Browse files
committed
fix for struct in cpp template
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21106 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a6b54f3 commit af660ef

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7704,11 +7704,27 @@ case CAST(__) then
77047704
let from = expTypeFromExpShort(exp)
77057705
let &preExp += 'cast_<%from%>_array_to_<%to%>(&<%expVar%>, &<%tvar%>);<%\n%>' /*test2*/
77067706
'<%tvar%>'
7707-
case T_COMPLEX(complexClassType=rec as RECORD(__)) then '(*((<%underscorePath(rec.path)%>*)&<%expVar%>))'
7708-
else
7707+
7708+
//'(*((<%underscorePath(rec.path)%>*)&<%expVar%>))'
7709+
case T_COMPLEX(varLst=vl,complexClassType=rec as RECORD(__)) then
7710+
7711+
let tvar = tempDecl(underscorePath(rec.path)+"Type", &varDecls /*BUFD*/)
7712+
let &preExp += '<%structParams(expVar,tvar,vl)%><%\n%>' /*test2*/
7713+
'<%tvar%>'
7714+
else
77097715
'(<%expVar%>) /* could not cast, using the variable as it is */'
77107716
end daeExpCast;
77117717

7718+
7719+
template structParams(String structName,String varName,list<Var> exps)
7720+
::=
7721+
let params = (exps |> e => match e
7722+
case TYPES_VAR(__) then
7723+
'<%varName%>.<%name%>=<%structName%>.<%name%>;'
7724+
;separator="\n" )
7725+
params
7726+
end structParams;
7727+
77127728
template daeExpRecord(Exp rec, Context context, Text &preExp, Text &varDecls, SimCode simCode)
77137729
::=
77147730
match rec

0 commit comments

Comments
 (0)