Skip to content

Commit ed61035

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Remove obsolete separate initialization of external objects
1 parent 5e4878f commit ed61035

File tree

3 files changed

+14
-90
lines changed

3 files changed

+14
-90
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 14 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ template translateModel(SimCode simCode)
6666
else
6767
""
6868

69-
let()= textFile(simulationInitExtVarsCppFile(simCode, &extraFuncsInit, &extraFuncsDeclInit, '<%className%>Initialize', stateDerVectorName, false),'OMCpp<%fileNamePrefix%>InitializeExtVars.cpp')
7069
let()= textFile(simulationInitHeaderFile(simCode , &extraFuncsInit , &extraFuncsDeclInit, '<%className%>Initialize'), 'OMCpp<%fileNamePrefix%>Initialize.h')
7170

7271
let &jacobianVarsInit = buffer "" /*BUFD*/
@@ -173,7 +172,7 @@ let initparameqs = generateEquationMemberFuncDecls(parameterEquations,"initParam
173172
private:
174173
<%initeqs%>
175174
<%initparameqs%>
176-
<%initExtVarsDecl(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, false)%>
175+
<%destructExtObjsDecl(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, false)%>
177176

178177
void InitializeDummyTypeElems();
179178

@@ -552,6 +551,10 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
552551
<%setIntialStatus(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace)%>
553552

554553
<%init(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation, complexStartExpressions)%>
554+
555+
<%destructExtObjs(simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)%>
556+
557+
<%extraFuncs%>
555558
>>
556559
end simulationInitCppFile;
557560

@@ -624,13 +627,6 @@ case modelInfo as MODELINFO(vars=SIMVARS(__)) then
624627
end simulationInitAlgVarsCppFile;
625628

626629

627-
template simulationInitExtVarsCppFile(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
628-
"Generates code for main cpp file for simulation target."
629-
::=
630-
initExtVars(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
631-
end simulationInitExtVarsCppFile;
632-
633-
634630
template simulationJacobianCppFile(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text &jacobianVarsInit, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
635631
"Generates code for main cpp file for simulation target."
636632
::=
@@ -2767,7 +2763,6 @@ template calcHelperMainfile(SimCode simCode ,Text& extraFuncs,Text& extraFuncsDe
27672763
#include "OMCpp<%fileNamePrefix%>InitializeAlgVars.cpp"
27682764
>>
27692765
%>
2770-
#include "OMCpp<%fileNamePrefix%>InitializeExtVars.cpp"
27712766
#include "OMCpp<%fileNamePrefix%>Initialize.cpp"
27722767
#include "OMCpp<%fileNamePrefix%>WriteOutput.cpp"
27732768
#include "OMCpp<%fileNamePrefix%>Jacobian.cpp"
@@ -5689,34 +5684,28 @@ template funStatement(list<DAE.Statement> statementLst, Text &varDecls, SimCode
56895684
statementLst |> stmt => algStatement(stmt, contextFunction, &varDecls /*BUFD*/,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation) ; separator="\n"
56905685
end funStatement;
56915686

5692-
template initExtVars(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
5687+
template destructExtObjs(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
56935688
::=
56945689
match simCode
56955690
case SIMCODE(modelInfo = MODELINFO(__)) then
5696-
let externalvarfuncs = functionCallExternalObjectsConstruct('<%lastIdentOfPath(modelInfo.name)%>Initialize', extObjInfo, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
5697-
let externalvarsfunccalls = functionCallExternalObjectsCall('<%lastIdentOfPath(modelInfo.name)%>Initialize', extObjInfo, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, useFlatArrayNotation)
5691+
let externalObjsFuncs = functionExternalObjects('<%lastIdentOfPath(modelInfo.name)%>Initialize', extObjInfo, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, useFlatArrayNotation)
56985692
<<
5699-
<%externalvarfuncs%>
5700-
<%externalvarsfunccalls%>
5701-
<%extraFuncs%>
5693+
<%externalObjsFuncs%>
57025694
>>
57035695
end match
5704-
end initExtVars;
5696+
end destructExtObjs;
57055697

5706-
template initExtVarsDecl(SimCode simCode ,Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace, Boolean useFlatArrayNotation)
5698+
template destructExtObjsDecl(SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Boolean useFlatArrayNotation)
57075699
::=
57085700
match simCode
57095701
case SIMCODE(modelInfo = MODELINFO(__)) then
5710-
let externalobjsdecl = functionCallExternalObjectsDecl(extObjInfo, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, useFlatArrayNotation)
57115702
<<
5712-
<%externalobjsdecl%>
57135703

5714-
void constructExternalObjects();
57155704
void destructExternalObjects();
57165705
bool _constructedExternalObjects;
57175706
>>
57185707
end match
5719-
end initExtVarsDecl;
5708+
end destructExtObjsDecl;
57205709

57215710

57225711
template init(SimCode simCode ,Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation, Text& complexStartExpressions)
@@ -5917,87 +5906,24 @@ case modelInfo as MODELINFO(vars=SIMVARS(__)) then
59175906
end init2;
59185907

59195908

5920-
template functionCallExternalObjectsConstruct(Text className, ExtObjInfo extObjInfo, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
5921-
"Generates function in simulation file."
5922-
::=
5923-
match extObjInfo
5924-
case EXTOBJINFO(__) then
5925-
let tors = (vars |> var as SIMVAR(initialValue=SOME(exp)) hasindex idx =>
5926-
let &preExp = buffer "" /*BUFD*/
5927-
let &varDecls = buffer "" /*BUFD*/
5928-
let arg = daeExp(exp, contextOther, &preExp, &varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
5929-
<<
5930-
void <%className%>::constructExternalObject_<%idx%>()
5931-
{
5932-
<%varDecls%>
5933-
<%preExp%>
5934-
<%cref(var.name, useFlatArrayNotation)%> = <%arg%>;
5935-
}
5936-
5937-
>>
5938-
;separator="")
5939-
tors
5940-
end match
5941-
end functionCallExternalObjectsConstruct;
5942-
5943-
5944-
template functionCallExternalObjectsCall(Text className, ExtObjInfo extObjInfo, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Boolean useFlatArrayNotation)
5945-
"Generates function in simulation file."
5909+
template functionExternalObjects(Text className, ExtObjInfo extObjInfo, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Boolean useFlatArrayNotation)
5910+
"Generates the method destructExternalObjects."
59465911
::=
59475912
match extObjInfo
59485913
case EXTOBJINFO(__) then
5949-
let &funDecls = buffer "" /*BUFD*/
5950-
let &varDecls = buffer "" /*BUFD*/
5951-
let ctorCalls = (vars |> var as SIMVAR(initialValue=SOME(exp)) hasindex idx =>
5952-
<<
5953-
constructExternalObject_<%idx%>();
5954-
>>
5955-
;separator="\n")
59565914
let dtorCalls = (vars |> var as SIMVAR(varKind=ext as EXTOBJ(), initialValue=SOME(exp)) hasindex idx =>
59575915
<<
59585916
_functions-><%underscorePath(ext.fullClassName)%>_destructor(<%cref(var.name, useFlatArrayNotation)%>);
59595917
>>
59605918
;separator="\n")
59615919
<<
5962-
void <%className%>::constructExternalObjects()
5963-
{
5964-
<%ctorCalls%>
5965-
<%aliases |> (var1, var2) => '<%cref(var1,useFlatArrayNotation)%> = <%cref(var2,useFlatArrayNotation)%>;' ;separator="\n"%>
5966-
}
5967-
59685920
void <%className%>::destructExternalObjects()
59695921
{
59705922
<%dtorCalls%>
59715923
}
5972-
59735924
>>
59745925
end match
5975-
end functionCallExternalObjectsCall;
5976-
5977-
5978-
template functionCallExternalObjectsDecl(ExtObjInfo extObjInfo, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Boolean useFlatArrayNotation)
5979-
"Generates function in simulation file."
5980-
::=
5981-
match extObjInfo
5982-
case EXTOBJINFO(__) then
5983-
let &funDecls = buffer "" /*BUFD*/
5984-
let &varDecls = buffer "" /*BUFD*/
5985-
let ctorCallsDecl = (vars |> var as SIMVAR(initialValue=SOME(exp)) hasindex idx =>
5986-
<<
5987-
void constructExternalObject_<%idx%>();
5988-
>>
5989-
;separator="\n")
5990-
let dtorCallsDecl = (vars |> var as SIMVAR(initialValue=SOME(exp)) hasindex idx =>
5991-
<<
5992-
void destructExternalObject_<%idx%>();
5993-
>>
5994-
;separator="\n")
5995-
<<
5996-
<%ctorCallsDecl%>
5997-
<%dtorCallsDecl%>
5998-
>>
5999-
end match
6000-
end functionCallExternalObjectsDecl;
5926+
end functionExternalObjects;
60015927

60025928

60035929
template functionInitialEquations(list<SimEqSystem> initalEquations, Text methodName, SimCode simCode ,Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation, Boolean createMeasureTime, Boolean assignToStartValues, Boolean overwriteOldStartValues)

Compiler/Template/CodegenCppHpcom.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ template translateModel(SimCode simCode)
7878
else
7979
""
8080

81-
let()= textFile(simulationInitExtVarsCppFile(simCode, &extraFuncsInit, &extraFuncsDeclInit, '<%className%>Initialize', stateDerVectorName, false),'OMCpp<%fileNamePrefix%>InitializeExtVars.cpp')
8281
let() = textFile(simulationInitHeaderFile(simCode, &extraFuncsInit, &extraFuncsDeclInit, ""), 'OMCpp<%fileNamePrefix%>Initialize.h')
8382

8483
let &jacobianVarsInit = buffer "" /*BUFD*/

Compiler/Template/CodegenFMUCpp.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ template fmuCalcHelperMainfile(SimCode simCode)
126126
#include "OMCpp<%fileNamePrefix%>InitializeAlgVars.cpp"
127127
>>
128128
%>
129-
#include "OMCpp<%fileNamePrefix%>InitializeExtVars.cpp"
130129
#include "OMCpp<%fileNamePrefix%>Initialize.cpp"
131130
#include "OMCpp<%fileNamePrefix%>Jacobian.cpp"
132131
#include "OMCpp<%fileNamePrefix%>StateSelection.cpp"

0 commit comments

Comments
 (0)