Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 814
Functions: -% 0 / 1 / 1
Branches: 0.0% 0 / 0 / 26

build_cmake/OMCompiler/Compiler/generated-mo/Template/GenerateAPIFunctionsTpl.mo
Line Branch Exec Source
1 encapsulated package GenerateAPIFunctionsTpl
2 "
3 file: GenerateAPIFunctionsTpl.mo
4 package: GenerateAPIFunctionsTpl
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import SimCodeVar;
11 public import HashTableCrefSimVar;
12 public import SimCode;
13 public import SimCodeFunction;
14 public import SimCodeCodegenUtil;
15 public import SimCodeFunctionUtil;
16 public import BackendDAE;
17 public import System;
18 public import Autoconf;
19 protected import Absyn;
20 protected import AbsynUtil;
21 public import MMath;
22 public import DAE;
23 public import ClassInf;
24 public import ClassInfUtil;
25 protected import SCode;
26 protected import SCodeDump;
27 public import StringUtil;
28 public import Util;
29 public import List;
30 public import ComponentReferenceBasics;
31 public import ComponentReference;
32 public import Expression;
33 protected import ExpressionDump;
34 public import ExpressionBasics;
35 public import Config;
36 public import Testsuite;
37 public import Flags;
38 public import FlagsUtil;
39 public import Settings;
40 public import Patternm;
41 public import Error;
42 public import Values;
43 public import ValuesUtil;
44 public import DAEDump;
45 public import Algorithm;
46 protected import ElementSource;
47 public import DAEUtil;
48 public import TypesDump;
49 public import Types;
50 public import HashTableCrIListArray;
51 public import CodegenUtil;
52
53 protected function lm_44
54 input output Tpl.Text txt;
55 input list<DAE.Type> items;
56 algorithm
57 ✗ for lstElt_44 in items loop
58 txt := match lstElt_44
59 local
60 DAE.Type i_ty_funcResultType;
61 list<DAE.FuncArg> i_ty_funcArg;
62 Absyn.Path i_path;
63 String ret_0;
64
65 case DAE.T_FUNCTION(path = i_path, funcArg = i_ty_funcArg, funcResultType = i_ty_funcResultType)
66 algorithm
67 ✗ ret_0 := AbsynUtil.pathLastIdent(i_path);
68 ✗ txt := getCevalScriptInterfaceFunc(txt, ret_0, i_ty_funcArg, i_ty_funcResultType);
69 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
70 then txt;
71
72 case _
73 then txt;
74 end match;
75 end for;
76 end lm_44;
77
78 public function getCevalScriptInterface
79 input Tpl.Text txt;
80 input list<DAE.Type> a_tys;
81
82 output Tpl.Text out_txt;
83 protected
84 Tpl.Text l_funcs;
85 algorithm
86 ✗ l_funcs := lm_44(Tpl.emptyTxt, a_tys);
87 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
88 "import Absyn;\n",
89 "import AbsynUtil;\n",
90 "import CevalScript;\n",
91 "import Parser;\n",
92 "\n",
93 "protected\n",
94 "\n",
95 "import Values;\n",
96 "import ValuesMake;\n",
97 "import ValuesUtil;\n",
98 "constant Absyn.Msg dummyMsg = Absyn.MSG(SOURCEINFO(\"<interactive>\",false,1,1,1,1,0.0));\n",
99 "\n",
100 "public\n",
101 "\n"
102 }, true));
103 ✗ out_txt := Tpl.writeText(out_txt, l_funcs);
104 end getCevalScriptInterface;
105
106 public function getInType
107 input Tpl.Text in_txt;
108 input DAE.Type in_a_ty;
109
110 output Tpl.Text out_txt;
111 algorithm
112 out_txt :=
113 match(in_txt, in_a_ty)
114 local
115 Tpl.Text txt;
116 DAE.Type i_ty;
117 DAE.Type i_aty_ty;
118 Tpl.Text txt_0;
119 String ret_0;
120
121 case ( txt,
122 DAE.T_STRING(varLst = _) )
123 algorithm
124 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("String"));
125 then txt;
126
127 case ( txt,
128 DAE.T_INTEGER(varLst = _) )
129 algorithm
130 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Integer"));
131 then txt;
132
133 case ( txt,
134 DAE.T_BOOL(varLst = _) )
135 algorithm
136 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Boolean"));
137 then txt;
138
139 case ( txt,
140 DAE.T_REAL(varLst = _) )
141 algorithm
142 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Real"));
143 then txt;
144
145 case ( txt,
146 DAE.T_ARRAY(ty = i_aty_ty) )
147 algorithm
148 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("list<"));
149 ✗ txt := getInType(txt, i_aty_ty);
150 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
151 then txt;
152
153 case ( txt,
154 DAE.T_CODE(ty = DAE.C_TYPENAME()) )
155 algorithm
156 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("String"));
157 then txt;
158
159 case ( txt,
160 i_ty )
161 algorithm
162 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getInType failed for "));
163 ✗ ret_0 := TypesDump.unparseType(i_ty);
164 ✗ txt_0 := Tpl.writeStr(txt_0, ret_0);
165 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 72, 16), Tpl.textString(txt_0));
166 then txt;
167 end match;
168 end getInType;
169
170 protected function fun_47
171 input Tpl.Text in_txt;
172 input DAE.Type in_a_ty;
173 input Tpl.Text in_a_name;
174
175 output Tpl.Text out_txt;
176 algorithm
177 out_txt :=
178 match(in_txt, in_a_ty, in_a_name)
179 local
180 Tpl.Text txt;
181 Tpl.Text a_name;
182 DAE.Type i_ty;
183 DAE.Type i_aty_ty;
184 Tpl.Text txt_1;
185 String ret_1;
186 Tpl.Text txt_0;
187
188 case ( txt,
189 DAE.T_STRING(varLst = _),
190 a_name )
191 algorithm
192 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.STRING("));
193 ✗ txt := Tpl.writeText(txt, a_name);
194 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
195 then txt;
196
197 case ( txt,
198 DAE.T_INTEGER(varLst = _),
199 a_name )
200 algorithm
201 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.INTEGER("));
202 ✗ txt := Tpl.writeText(txt, a_name);
203 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
204 then txt;
205
206 case ( txt,
207 DAE.T_BOOL(varLst = _),
208 a_name )
209 algorithm
210 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.BOOL("));
211 ✗ txt := Tpl.writeText(txt, a_name);
212 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
213 then txt;
214
215 case ( txt,
216 DAE.T_REAL(varLst = _),
217 a_name )
218 algorithm
219 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.REAL("));
220 ✗ txt := Tpl.writeText(txt, a_name);
221 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
222 then txt;
223
224 case ( txt,
225 DAE.T_ARRAY(ty = i_aty_ty),
226 a_name )
227 algorithm
228 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ValuesMake.makeArray(list("));
229 ✗ txt_0 := Tpl.writeText(Tpl.emptyTxt, a_name);
230 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_iter"));
231 ✗ (txt, txt_0) := getInValue(txt, txt_0, i_aty_ty);
232 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" for "));
233 ✗ txt := Tpl.writeText(txt, a_name);
234 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_iter in "));
235 ✗ txt := Tpl.writeText(txt, a_name);
236 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("))"));
237 then txt;
238
239 case ( txt,
240 DAE.T_CODE(ty = DAE.C_TYPENAME()),
241 a_name )
242 algorithm
243 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.CODE(Absyn.C_TYPENAME(Parser.stringPath("));
244 ✗ txt := Tpl.writeText(txt, a_name);
245 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")))"));
246 then txt;
247
248 case ( txt,
249 i_ty,
250 _ )
251 algorithm
252 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getInValue failed for "));
253 ✗ ret_1 := TypesDump.unparseType(i_ty);
254 ✗ txt_1 := Tpl.writeStr(txt_1, ret_1);
255 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 84, 16), Tpl.textString(txt_1));
256 then txt;
257 end match;
258 end fun_47;
259
260 public function getInValue
261 input Tpl.Text txt;
262 input Tpl.Text a_name;
263 input DAE.Type a_ty;
264
265 output Tpl.Text out_txt;
266 output Tpl.Text out_a_name;
267 algorithm
268 ✗ out_txt := fun_47(txt, a_ty, a_name);
269 out_a_name := a_name;
270 end getInValue;
271
272 protected function fun_49
273 input Tpl.Text in_txt;
274 input DAE.Type in_a_ty;
275 input Tpl.Text in_a_name;
276 input Tpl.Text in_a_varDecl;
277 input Tpl.Text in_a_postMatch;
278
279 output Tpl.Text out_txt;
280 output Tpl.Text out_a_varDecl;
281 output Tpl.Text out_a_postMatch;
282 algorithm
283 (out_txt, out_a_varDecl, out_a_postMatch) :=
284 match(in_txt, in_a_ty, in_a_name, in_a_varDecl, in_a_postMatch)
285 local
286 Tpl.Text txt;
287 Tpl.Text a_name;
288 Tpl.Text a_varDecl;
289 Tpl.Text a_postMatch;
290 DAE.Type i_ty;
291 DAE.Type i_aty;
292 Tpl.Text txt_1;
293 String ret_1;
294 Tpl.Text txt_0;
295
296 case ( txt,
297 DAE.T_STRING(varLst = _),
298 a_name,
299 a_varDecl,
300 a_postMatch )
301 algorithm
302 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.STRING("));
303 ✗ txt := Tpl.writeText(txt, a_name);
304 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
305 then (txt, a_varDecl, a_postMatch);
306
307 case ( txt,
308 DAE.T_INTEGER(varLst = _),
309 a_name,
310 a_varDecl,
311 a_postMatch )
312 algorithm
313 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.INTEGER("));
314 ✗ txt := Tpl.writeText(txt, a_name);
315 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
316 then (txt, a_varDecl, a_postMatch);
317
318 case ( txt,
319 DAE.T_BOOL(varLst = _),
320 a_name,
321 a_varDecl,
322 a_postMatch )
323 algorithm
324 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.BOOL("));
325 ✗ txt := Tpl.writeText(txt, a_name);
326 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
327 then (txt, a_varDecl, a_postMatch);
328
329 case ( txt,
330 DAE.T_REAL(varLst = _),
331 a_name,
332 a_varDecl,
333 a_postMatch )
334 algorithm
335 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.REAL("));
336 ✗ txt := Tpl.writeText(txt, a_name);
337 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
338 then (txt, a_varDecl, a_postMatch);
339
340 case ( txt,
341 (i_aty as DAE.T_ARRAY(ty = _)),
342 a_name,
343 a_varDecl,
344 a_postMatch )
345 algorithm
346 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("Values.Value "));
347 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
348 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_arr;"));
349 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
350 ✗ a_postMatch := Tpl.writeText(a_postMatch, a_name);
351 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_STRING(" := "));
352 ✗ txt_0 := Tpl.writeText(Tpl.emptyTxt, a_name);
353 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_arr"));
354 ✗ (a_postMatch, txt_0) := getOutValueArray(a_postMatch, txt_0, i_aty);
355 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_STRING(";"));
356 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_NEW_LINE());
357 ✗ txt := Tpl.writeText(txt, a_name);
358 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_arr"));
359 then (txt, a_varDecl, a_postMatch);
360
361 case ( txt,
362 DAE.T_CODE(ty = DAE.C_TYPENAME()),
363 a_name,
364 a_varDecl,
365 a_postMatch )
366 algorithm
367 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("Absyn.Path "));
368 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
369 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_path;"));
370 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
371 ✗ a_postMatch := Tpl.writeText(a_postMatch, a_name);
372 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_STRING(" := AbsynUtil.pathString("));
373 ✗ a_postMatch := Tpl.writeText(a_postMatch, a_name);
374 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_STRING("_path);"));
375 ✗ a_postMatch := Tpl.writeTok(a_postMatch, Tpl.ST_NEW_LINE());
376 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.CODE(Absyn.C_TYPENAME(path="));
377 ✗ txt := Tpl.writeText(txt, a_name);
378 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_path))"));
379 then (txt, a_varDecl, a_postMatch);
380
381 case ( txt,
382 i_ty,
383 _,
384 a_varDecl,
385 a_postMatch )
386 algorithm
387 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getOutValue failed for "));
388 ✗ ret_1 := TypesDump.unparseType(i_ty);
389 ✗ txt_1 := Tpl.writeStr(txt_1, ret_1);
390 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 103, 16), Tpl.textString(txt_1));
391 then (txt, a_varDecl, a_postMatch);
392 end match;
393 end fun_49;
394
395 public function getOutValue
396 input Tpl.Text txt;
397 input Tpl.Text a_name;
398 input DAE.Type a_ty;
399 input Tpl.Text a_varDecl;
400 input Tpl.Text a_postMatch;
401
402 output Tpl.Text out_txt;
403 output Tpl.Text out_a_name;
404 output Tpl.Text out_a_varDecl;
405 output Tpl.Text out_a_postMatch;
406 algorithm
407 ✗ (out_txt, out_a_varDecl, out_a_postMatch) := fun_49(txt, a_ty, a_name, a_varDecl, a_postMatch);
408 out_a_name := a_name;
409 end getOutValue;
410
411 protected function fun_51
412 input Tpl.Text in_txt;
413 input DAE.Type in_a_ty;
414 input Tpl.Text in_a_name;
415
416 output Tpl.Text out_txt;
417 algorithm
418 out_txt :=
419 match(in_txt, in_a_ty, in_a_name)
420 local
421 Tpl.Text txt;
422 Tpl.Text a_name;
423 DAE.Type i_ty;
424 DAE.Type i_aty_ty;
425 Tpl.Text txt_1;
426 String ret_1;
427 Tpl.Text txt_0;
428
429 case ( txt,
430 DAE.T_STRING(varLst = _),
431 a_name )
432 algorithm
433 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("match "));
434 ✗ txt := Tpl.writeText(txt, a_name);
435 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" case Values.STRING() then "));
436 ✗ txt := Tpl.writeText(txt, a_name);
437 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".string; end match"));
438 then txt;
439
440 case ( txt,
441 DAE.T_INTEGER(varLst = _),
442 a_name )
443 algorithm
444 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("match "));
445 ✗ txt := Tpl.writeText(txt, a_name);
446 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" case Values.INTEGER() then "));
447 ✗ txt := Tpl.writeText(txt, a_name);
448 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".integer; end match"));
449 then txt;
450
451 case ( txt,
452 DAE.T_BOOL(varLst = _),
453 a_name )
454 algorithm
455 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("match "));
456 ✗ txt := Tpl.writeText(txt, a_name);
457 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" case Values.BOOL() then "));
458 ✗ txt := Tpl.writeText(txt, a_name);
459 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".boolean; end match"));
460 then txt;
461
462 case ( txt,
463 DAE.T_REAL(varLst = _),
464 a_name )
465 algorithm
466 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("match "));
467 ✗ txt := Tpl.writeText(txt, a_name);
468 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" case Values.REAL() then "));
469 ✗ txt := Tpl.writeText(txt, a_name);
470 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".real; end match"));
471 then txt;
472
473 case ( txt,
474 DAE.T_ARRAY(ty = i_aty_ty),
475 a_name )
476 algorithm
477 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("list("));
478 ✗ txt_0 := Tpl.writeText(Tpl.emptyTxt, a_name);
479 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_iter"));
480 ✗ (txt, txt_0) := getOutValueArray(txt, txt_0, i_aty_ty);
481 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" for "));
482 ✗ txt := Tpl.writeText(txt, a_name);
483 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_iter in ValuesUtil.arrayValues("));
484 ✗ txt := Tpl.writeText(txt, a_name);
485 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("))"));
486 then txt;
487
488 case ( txt,
489 DAE.T_CODE(ty = DAE.C_TYPENAME()),
490 a_name )
491 algorithm
492 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ValuesUtil.valString("));
493 ✗ txt := Tpl.writeText(txt, a_name);
494 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
495 then txt;
496
497 case ( txt,
498 i_ty,
499 _ )
500 algorithm
501 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getOutValueArray failed for "));
502 ✗ ret_1 := TypesDump.unparseType(i_ty);
503 ✗ txt_1 := Tpl.writeStr(txt_1, ret_1);
504 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 117, 16), Tpl.textString(txt_1));
505 then txt;
506 end match;
507 end fun_51;
508
509 public function getOutValueArray
510 input Tpl.Text txt;
511 input Tpl.Text a_name;
512 input DAE.Type a_ty;
513
514 output Tpl.Text out_txt;
515 output Tpl.Text out_a_name;
516 algorithm
517 ✗ out_txt := fun_51(txt, a_ty, a_name);
518 out_a_name := a_name;
519 end getOutValueArray;
520
521 protected function lm_53
522 input output Tpl.Text txt;
523 input list<DAE.FuncArg> items;
524 algorithm
525 ✗ for lstElt_53 in items loop
526 txt := match lstElt_53
527 local
528 DAE.Type i_arg_ty;
529 String i_arg_name;
530
531 case DAE.FUNCARG(name = i_arg_name, ty = i_arg_ty)
532 algorithm
533 ✗ (txt, _) := getInValue(txt, Tpl.stringText(i_arg_name), i_arg_ty);
534 ✗ txt := Tpl.nextIter(txt);
535 then txt;
536
537 case _
538 then txt;
539 end match;
540 end for;
541 end lm_53;
542
543 protected function lm_54
544 input output Tpl.Text txt;
545 input list<DAE.Type> items;
546 input output Tpl.Text a_postMatch;
547 input output Tpl.Text a_varDecl;
548 algorithm
549 ✗ for lstElt_54 in items loop
550 (txt, a_postMatch, a_varDecl) := match lstElt_54
551 local
552 Integer x_i;
553 DAE.Type i_ty;
554 Tpl.Text txt_0;
555
556 case i_ty
557 algorithm
558 ✗ x_i := Tpl.getIteri_i0(txt);
559 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("res"));
560 ✗ txt_0 := Tpl.writeStr(txt_0, intString(x_i));
561 ✗ (txt, txt_0, a_varDecl, a_postMatch) := getOutValue(txt, txt_0, i_ty, a_varDecl, a_postMatch);
562 ✗ txt := Tpl.nextIter(txt);
563 then (txt, a_postMatch, a_varDecl);
564 end match;
565 end for;
566 end lm_54;
567
568 protected function fun_55
569 input Tpl.Text in_txt;
570 input DAE.Type in_a_res;
571 input Tpl.Text in_a_postMatch;
572 input Tpl.Text in_a_varDecl;
573
574 output Tpl.Text out_txt;
575 output Tpl.Text out_a_postMatch;
576 output Tpl.Text out_a_varDecl;
577 algorithm
578 (out_txt, out_a_postMatch, out_a_varDecl) :=
579 match(in_txt, in_a_res, in_a_postMatch, in_a_varDecl)
580 local
581 Tpl.Text txt;
582 Tpl.Text a_postMatch;
583 Tpl.Text a_varDecl;
584 DAE.Type i_res;
585 list<DAE.Type> i_types;
586
587 case ( txt,
588 DAE.T_TUPLE(types = i_types),
589 a_postMatch,
590 a_varDecl )
591 algorithm
592 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.TUPLE({"));
593 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
594 ✗ (txt, a_postMatch, a_varDecl) := lm_54(txt, i_types, a_postMatch, a_varDecl);
595 ✗ txt := Tpl.popIter(txt);
596 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("})"));
597 ✗ then (txt, a_postMatch, a_varDecl);
598
599 case ( txt,
600 DAE.T_NORETCALL(),
601 a_postMatch,
602 a_varDecl )
603 algorithm
604 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Values.NORETCALL()"));
605 ✗ then (txt, a_postMatch, a_varDecl);
606
607 case ( txt,
608 i_res,
609 a_postMatch,
610 a_varDecl )
611 algorithm
612 ✗ (txt, _, a_varDecl, a_postMatch) := getOutValue(txt, Tpl.strTokText(Tpl.ST_STRING("res")), i_res, a_varDecl, a_postMatch);
613 ✗ then (txt, a_postMatch, a_varDecl);
614 end match;
615 end fun_55;
616
617 protected function lm_56
618 input output Tpl.Text txt;
619 input list<DAE.FuncArg> items;
620 algorithm
621 ✗ for lstElt_56 in items loop
622 txt := match lstElt_56
623 local
624 String i_arg_name;
625 DAE.Type i_arg_ty;
626
627 case DAE.FUNCARG(ty = i_arg_ty, name = i_arg_name)
628 algorithm
629 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("input "));
630 ✗ txt := getInType(txt, i_arg_ty);
631 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
632 ✗ txt := Tpl.writeStr(txt, i_arg_name);
633 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
634 ✗ txt := Tpl.nextIter(txt);
635 then txt;
636
637 case _
638 then txt;
639 end match;
640 end for;
641 end lm_56;
642
643 protected function lm_57
644 input output Tpl.Text txt;
645 input list<DAE.Type> items;
646 algorithm
647 ✗ for lstElt_57 in items loop
648 txt := match lstElt_57
649 local
650 Integer x_i;
651 DAE.Type i_ty;
652
653 case i_ty
654 algorithm
655 ✗ x_i := Tpl.getIteri_i0(txt);
656 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("output "));
657 ✗ txt := getInType(txt, i_ty);
658 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" res"));
659 ✗ txt := Tpl.writeStr(txt, intString(x_i));
660 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
661 ✗ txt := Tpl.nextIter(txt);
662 then txt;
663 end match;
664 end for;
665 end lm_57;
666
667 protected function fun_58
668 input Tpl.Text in_txt;
669 input DAE.Type in_a_res;
670
671 output Tpl.Text out_txt;
672 algorithm
673 out_txt :=
674 match(in_txt, in_a_res)
675 local
676 Tpl.Text txt;
677 DAE.Type i_res;
678 list<DAE.Type> i_types;
679
680 case ( txt,
681 DAE.T_TUPLE(types = i_types) )
682 algorithm
683 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
684 ✗ txt := lm_57(txt, i_types);
685 ✗ txt := Tpl.popIter(txt);
686 then txt;
687
688 case ( txt,
689 DAE.T_NORETCALL() )
690 then txt;
691
692 case ( txt,
693 i_res )
694 algorithm
695 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("output "));
696 ✗ txt := getInType(txt, i_res);
697 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" res;"));
698 then txt;
699 end match;
700 end fun_58;
701
702 protected function fun_59
703 input Tpl.Text in_txt;
704 input Boolean in_mArg;
705 input Tpl.Text in_a_varDecl;
706
707 output Tpl.Text out_txt;
708 algorithm
709 out_txt :=
710 match(in_txt, in_mArg, in_a_varDecl)
711 local
712 Tpl.Text txt;
713 Tpl.Text a_varDecl;
714
715 case ( txt,
716 true,
717 _ )
718 then txt;
719
720 case ( txt,
721 _,
722 a_varDecl )
723 algorithm
724 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("protected\n"));
725 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
726 ✗ txt := Tpl.writeText(txt, a_varDecl);
727 ✗ txt := Tpl.popBlock(txt);
728 then txt;
729 end match;
730 end fun_59;
731
732 public function getCevalScriptInterfaceFunc
733 input Tpl.Text txt;
734 input String a_name;
735 input list<DAE.FuncArg> a_args;
736 input DAE.Type a_res;
737
738 output Tpl.Text out_txt;
739 protected
740 Boolean ret_4;
741 Tpl.Text l_outVals;
742 Tpl.Text l_inVals;
743 Tpl.Text l_postMatch;
744 Tpl.Text l_varDecl;
745 algorithm
746 ✗ l_varDecl := Tpl.emptyTxt;
747 ✗ l_postMatch := Tpl.emptyTxt;
748 ✗ l_inVals := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
749 ✗ l_inVals := lm_53(l_inVals, a_args);
750 ✗ l_inVals := Tpl.popIter(l_inVals);
751 ✗ (l_outVals, l_postMatch, l_varDecl) := fun_55(Tpl.emptyTxt, a_res, l_postMatch, l_varDecl);
752 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("function "));
753 ✗ out_txt := Tpl.writeStr(out_txt, a_name);
754 ✗ out_txt := Tpl.softNewLine(out_txt);
755 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
756 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
757 ✗ out_txt := lm_56(out_txt, a_args);
758 ✗ out_txt := Tpl.popIter(out_txt);
759 ✗ out_txt := Tpl.softNewLine(out_txt);
760 ✗ out_txt := fun_58(out_txt, a_res);
761 ✗ out_txt := Tpl.softNewLine(out_txt);
762 ✗ out_txt := Tpl.popBlock(out_txt);
763 ✗ ret_4 := Tpl.isEmpty(l_varDecl);
764 ✗ out_txt := fun_59(out_txt, ret_4, l_varDecl);
765 ✗ out_txt := Tpl.softNewLine(out_txt);
766 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("algorithm\n"));
767 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
768 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("(_,"));
769 ✗ out_txt := Tpl.writeText(out_txt, l_outVals);
770 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(") := CevalScript.cevalInteractiveFunctions2(FCore.emptyCache(), FGraph.empty(), \""));
771 ✗ out_txt := Tpl.writeStr(out_txt, a_name);
772 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\", {"));
773 ✗ out_txt := Tpl.writeText(out_txt, l_inVals);
774 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("}, dummyMsg);\n"));
775 ✗ out_txt := Tpl.writeText(out_txt, l_postMatch);
776 ✗ out_txt := Tpl.softNewLine(out_txt);
777 ✗ out_txt := Tpl.popBlock(out_txt);
778 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("end "));
779 ✗ out_txt := Tpl.writeStr(out_txt, a_name);
780 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(";"));
781 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
782 end getCevalScriptInterfaceFunc;
783
784 protected function lm_61
785 input output Tpl.Text txt;
786 input list<DAE.Type> items;
787 input String a_classNameWithColons;
788 algorithm
789 ✗ for lstElt_61 in items loop
790 txt := match lstElt_61
791 local
792 DAE.Type i_ty_funcResultType;
793 list<DAE.FuncArg> i_ty_funcArg;
794 Absyn.Path i_path;
795 String ret_0;
796
797 case DAE.T_FUNCTION(path = i_path, funcArg = i_ty_funcArg, funcResultType = i_ty_funcResultType)
798 algorithm
799 ✗ ret_0 := AbsynUtil.pathLastIdent(i_path);
800 ✗ txt := getQtInterfaceFunc(txt, ret_0, i_ty_funcArg, i_ty_funcResultType, a_classNameWithColons);
801 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
802 then txt;
803
804 case _
805 then txt;
806 end match;
807 end for;
808 end lm_61;
809
810 public function getQtInterface
811 input Tpl.Text txt;
812 input list<DAE.Type> a_tys;
813 input String a_classNameWithColons;
814 input String a_className;
815
816 output Tpl.Text out_txt;
817 protected
818 Tpl.Text l_funcs;
819 algorithm
820 ✗ l_funcs := lm_61(Tpl.emptyTxt, a_tys, a_classNameWithColons);
821 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
822 "/* generated by OpenModelica */\n",
823 "\n",
824 "#include <stdexcept>\n",
825 "#include \"OpenModelicaScriptingAPIQt.h\"\n",
826 "\n"
827 }, true));
828 ✗ out_txt := Tpl.writeStr(out_txt, a_classNameWithColons);
829 ✗ out_txt := Tpl.writeStr(out_txt, a_className);
830 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
831 "(threadData_t *td)\n",
832 " : threadData(td)\n",
833 "{\n",
834 "}\n"
835 }, true));
836 ✗ out_txt := Tpl.writeText(out_txt, l_funcs);
837 ✗ out_txt := Tpl.softNewLine(out_txt);
838 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
839 end getQtInterface;
840
841 protected function lm_63
842 input output Tpl.Text txt;
843 input list<DAE.Type> items;
844 input String a_className;
845 algorithm
846 ✗ for lstElt_63 in items loop
847 txt := match lstElt_63
848 local
849 DAE.Type i_ty_funcResultType;
850 list<DAE.FuncArg> i_ty_funcArg;
851 Absyn.Path i_path;
852 String ret_0;
853
854 case DAE.T_FUNCTION(path = i_path, funcArg = i_ty_funcArg, funcResultType = i_ty_funcResultType)
855 algorithm
856 ✗ ret_0 := AbsynUtil.pathLastIdent(i_path);
857 ✗ txt := getQtInterfaceHeader(txt, ret_0, "", i_ty_funcArg, i_ty_funcResultType, a_className, true);
858 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
859 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
860 then txt;
861
862 case _
863 then txt;
864 end match;
865 end for;
866 end lm_63;
867
868 public function getQtInterfaceHeaders
869 input Tpl.Text txt;
870 input list<DAE.Type> a_tys;
871 input String a_className;
872
873 output Tpl.Text out_txt;
874 protected
875 Tpl.Text l_heads;
876 algorithm
877 ✗ l_heads := lm_63(Tpl.emptyTxt, a_tys, a_className);
878 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
879 "/* generated by OpenModelica */\n",
880 "#ifndef OpenModelicaScriptingAPIQt__H\n",
881 "#define OpenModelicaScriptingAPIQt__H\n",
882 "\n",
883 "#include <QOpenGLContext> // must be first include to fix undefined GLDEBUGPROC\n",
884 "#include <QtCore>\n",
885 "/* import the scripting here */\n",
886 "#define IMPORT_INTO\n",
887 "#include \"OpenModelicaScriptingAPI.h\"\n",
888 "\n",
889 "class "
890 }, false));
891 ✗ out_txt := Tpl.writeStr(out_txt, a_className);
892 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
893 " : public QObject\n",
894 "{\n",
895 " Q_OBJECT\n",
896 "public:\n",
897 " threadData_t *threadData;\n"
898 }, true));
899 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
900 ✗ out_txt := Tpl.writeStr(out_txt, a_className);
901 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("(threadData_t *td);\n"));
902 ✗ out_txt := Tpl.writeText(out_txt, l_heads);
903 ✗ out_txt := Tpl.softNewLine(out_txt);
904 ✗ out_txt := Tpl.popBlock(out_txt);
905 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
906 "signals:\n",
907 " void logCommand(QString command);\n",
908 " // elapsed time in seconds\n",
909 " void logResponse(QString command, QString response, double elapsed);\n",
910 " void throwException(QString exception);\n",
911 "};\n",
912 "\n",
913 "#endif /* OpenModelicaScriptingAPIQt__H */"
914 }, false));
915 end getQtInterfaceHeaders;
916
917 public function getQtType
918 input Tpl.Text in_txt;
919 input DAE.Type in_a_ty;
920
921 output Tpl.Text out_txt;
922 algorithm
923 out_txt :=
924 match(in_txt, in_a_ty)
925 local
926 Tpl.Text txt;
927 DAE.Type i_ty;
928 DAE.Type i_aty_ty;
929 Tpl.Text txt_0;
930 String ret_0;
931
932 case ( txt,
933 DAE.T_STRING(varLst = _) )
934 algorithm
935 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("QString"));
936 then txt;
937
938 case ( txt,
939 DAE.T_INTEGER(varLst = _) )
940 algorithm
941 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_integer"));
942 then txt;
943
944 case ( txt,
945 DAE.T_BOOL(varLst = _) )
946 algorithm
947 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean"));
948 then txt;
949
950 case ( txt,
951 DAE.T_REAL(varLst = _) )
952 algorithm
953 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_real"));
954 then txt;
955
956 case ( txt,
957 DAE.T_ARRAY(ty = i_aty_ty) )
958 algorithm
959 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("QList<"));
960 ✗ txt := getQtType(txt, i_aty_ty);
961 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >"));
962 then txt;
963
964 case ( txt,
965 DAE.T_CODE(ty = DAE.C_TYPENAME()) )
966 algorithm
967 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("QString"));
968 then txt;
969
970 case ( txt,
971 i_ty )
972 algorithm
973 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtType failed for "));
974 ✗ ret_0 := TypesDump.unparseType(i_ty);
975 ✗ txt_0 := Tpl.writeStr(txt_0, ret_0);
976 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 211, 16), Tpl.textString(txt_0));
977 then txt;
978 end match;
979 end getQtType;
980
981 public function getQtTupleTypeOutputNameHelper
982 input Tpl.Text in_txt;
983 input Option<list<String>> in_a_names;
984 input Integer in_a_index;
985
986 output Tpl.Text out_txt;
987 algorithm
988 out_txt :=
989 match(in_txt, in_a_names, in_a_index)
990 local
991 Tpl.Text txt;
992 Integer a_index;
993 list<String> i_lst;
994 String ret_0;
995
996 case ( txt,
997 SOME(i_lst),
998 a_index )
999 algorithm
1000 ✗ ret_0 := listGet(i_lst, a_index);
1001 ✗ txt := Tpl.writeStr(txt, ret_0);
1002 then txt;
1003
1004 case ( txt,
1005 _,
1006 a_index )
1007 algorithm
1008 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("res"));
1009 ✗ txt := Tpl.writeStr(txt, intString(a_index));
1010 then txt;
1011 end match;
1012 end getQtTupleTypeOutputNameHelper;
1013
1014 public function getQtTupleTypeOutputName
1015 input Tpl.Text in_txt;
1016 input DAE.Type in_a_ty;
1017 input Integer in_a_index;
1018
1019 output Tpl.Text out_txt;
1020 algorithm
1021 out_txt :=
1022 match(in_txt, in_a_ty, in_a_index)
1023 local
1024 Tpl.Text txt;
1025 Integer a_index;
1026 Option<list<String>> i_names;
1027
1028 case ( txt,
1029 DAE.T_TUPLE(names = i_names),
1030 a_index )
1031 algorithm
1032 ✗ txt := getQtTupleTypeOutputNameHelper(txt, i_names, a_index);
1033 then txt;
1034
1035 case ( txt,
1036 _,
1037 a_index )
1038 algorithm
1039 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("res"));
1040 ✗ txt := Tpl.writeStr(txt, intString(a_index));
1041 then txt;
1042 end match;
1043 end getQtTupleTypeOutputName;
1044
1045 protected function fun_68
1046 input Tpl.Text in_txt;
1047 input DAE.Type in_a_ty;
1048 input DAE.Type in_a_res;
1049 input Integer in_a_index;
1050 input Tpl.Text in_a_name;
1051
1052 output Tpl.Text out_txt;
1053 output Tpl.Text out_a_name;
1054 algorithm
1055 (out_txt, out_a_name) :=
1056 match(in_txt, in_a_ty, in_a_res, in_a_index, in_a_name)
1057 local
1058 Tpl.Text txt;
1059 DAE.Type a_res;
1060 Integer a_index;
1061 Tpl.Text a_name;
1062 DAE.Type i_ty;
1063 DAE.Type i_aty_ty;
1064 Tpl.Text txt_3;
1065 String ret_3;
1066 Tpl.Text l_counter;
1067 Tpl.Text l_elt;
1068 Tpl.Text l_varName;
1069
1070 case ( txt,
1071 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1072 a_res,
1073 a_index,
1074 a_name )
1075 algorithm
1076 ✗ txt := Tpl.writeText(txt, a_name);
1077 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
1078 ✗ txt := getQtTupleTypeOutputName(txt, a_res, a_index);
1079 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
1080 ✗ then (txt, a_name);
1081
1082 case ( txt,
1083 DAE.T_STRING(varLst = _),
1084 a_res,
1085 a_index,
1086 a_name )
1087 algorithm
1088 ✗ txt := Tpl.writeText(txt, a_name);
1089 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"\\\"\" + "));
1090 ✗ txt := getQtTupleTypeOutputName(txt, a_res, a_index);
1091 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + \"\\\"\");"));
1092 ✗ then (txt, a_name);
1093
1094 case ( txt,
1095 DAE.T_INTEGER(varLst = _),
1096 a_res,
1097 a_index,
1098 a_name )
1099 algorithm
1100 ✗ txt := Tpl.writeText(txt, a_name);
1101 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
1102 ✗ txt := getQtTupleTypeOutputName(txt, a_res, a_index);
1103 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
1104 ✗ then (txt, a_name);
1105
1106 case ( txt,
1107 DAE.T_REAL(varLst = _),
1108 a_res,
1109 a_index,
1110 a_name )
1111 algorithm
1112 ✗ txt := Tpl.writeText(txt, a_name);
1113 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
1114 ✗ txt := getQtTupleTypeOutputName(txt, a_res, a_index);
1115 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
1116 ✗ then (txt, a_name);
1117
1118 case ( txt,
1119 DAE.T_BOOL(varLst = _),
1120 a_res,
1121 a_index,
1122 a_name )
1123 algorithm
1124 ✗ txt := Tpl.writeText(txt, a_name);
1125 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
1126 ✗ txt := getQtTupleTypeOutputName(txt, a_res, a_index);
1127 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ? \"true\" : \"false\");"));
1128 ✗ then (txt, a_name);
1129
1130 case ( txt,
1131 DAE.T_ARRAY(ty = i_aty_ty),
1132 a_res,
1133 a_index,
1134 a_name )
1135 algorithm
1136 ✗ l_varName := getQtTupleTypeOutputName(Tpl.emptyTxt, a_res, a_index);
1137 ✗ l_elt := Tpl.writeText(Tpl.emptyTxt, l_varName);
1138 ✗ l_elt := Tpl.writeTok(l_elt, Tpl.ST_STRING("_elt"));
1139 ✗ l_counter := Tpl.writeText(Tpl.emptyTxt, l_varName);
1140 ✗ l_counter := Tpl.writeTok(l_counter, Tpl.ST_STRING("_i"));
1141 ✗ txt := Tpl.writeText(txt, a_name);
1142 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1143 ".append(\"{\");\n",
1144 "int "
1145 }, false));
1146 ✗ txt := Tpl.writeText(txt, l_counter);
1147 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1148 " = 0;\n",
1149 "foreach("
1150 }, false));
1151 ✗ txt := getQtType(txt, i_aty_ty);
1152 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1153 ✗ txt := Tpl.writeText(txt, l_elt);
1154 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
1155 ✗ txt := Tpl.writeText(txt, l_varName);
1156 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1157 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1158 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if ("));
1159 ✗ txt := Tpl.writeText(txt, l_counter);
1160 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1161 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1162 ✗ txt := Tpl.writeText(txt, a_name);
1163 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(".append(\",\");\n"));
1164 ✗ txt := Tpl.popBlock(txt);
1165 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
1166 ✗ (txt, l_elt, a_name) := getQtResponseLogText(txt, l_elt, i_aty_ty, a_name);
1167 ✗ txt := Tpl.softNewLine(txt);
1168 ✗ txt := Tpl.writeText(txt, l_counter);
1169 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("++;\n"));
1170 ✗ txt := Tpl.popBlock(txt);
1171 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
1172 ✗ txt := Tpl.writeText(txt, a_name);
1173 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"}\");"));
1174 ✗ then (txt, a_name);
1175
1176 case ( txt,
1177 i_ty,
1178 _,
1179 _,
1180 a_name )
1181 algorithm
1182 ✗ txt_3 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("structToString failed for "));
1183 ✗ ret_3 := TypesDump.unparseType(i_ty);
1184 ✗ txt_3 := Tpl.writeStr(txt_3, ret_3);
1185 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 256, 16), Tpl.textString(txt_3));
1186 ✗ then (txt, a_name);
1187 end match;
1188 end fun_68;
1189
1190 public function structToString
1191 input Tpl.Text txt;
1192 input DAE.Type a_res;
1193 input DAE.Type a_ty;
1194 input Integer a_index;
1195 input Tpl.Text a_name;
1196
1197 output Tpl.Text out_txt;
1198 output Tpl.Text out_a_name;
1199 algorithm
1200 ✗ (out_txt, out_a_name) := fun_68(txt, a_ty, a_res, a_index, a_name);
1201 end structToString;
1202
1203 protected function lm_70
1204 input output Tpl.Text txt;
1205 input list<DAE.FuncArg> items;
1206 algorithm
1207 ✗ for lstElt_70 in items loop
1208 txt := match lstElt_70
1209 local
1210 String i_arg_name;
1211 DAE.Type i_arg_ty;
1212
1213 case DAE.FUNCARG(ty = i_arg_ty, name = i_arg_name)
1214 algorithm
1215 ✗ txt := getQtType(txt, i_arg_ty);
1216 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1217 ✗ txt := Tpl.writeStr(txt, i_arg_name);
1218 ✗ txt := Tpl.nextIter(txt);
1219 then txt;
1220
1221 case _
1222 then txt;
1223 end match;
1224 end for;
1225 end lm_70;
1226
1227 protected function lm_71
1228 input output Tpl.Text txt;
1229 input list<DAE.Type> items;
1230 input DAE.Type a_res;
1231 algorithm
1232 ✗ for lstElt_71 in items loop
1233 txt := match lstElt_71
1234 local
1235 Integer x_i;
1236 DAE.Type i_ty;
1237
1238 case i_ty
1239 algorithm
1240 ✗ x_i := Tpl.getIteri_i0(txt);
1241 ✗ txt := getQtType(txt, i_ty);
1242 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1243 ✗ txt := getQtTupleTypeOutputName(txt, a_res, x_i);
1244 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1245 ✗ txt := Tpl.nextIter(txt);
1246 then txt;
1247 end match;
1248 end for;
1249 end lm_71;
1250
1251 protected function lm_72
1252 input output Tpl.Text txt;
1253 input list<DAE.Type> items;
1254 input DAE.Type a_res;
1255 algorithm
1256 ✗ for lstElt_72 in items loop
1257 txt := match lstElt_72
1258 local
1259 Integer x_i;
1260 DAE.Type i_ty;
1261
1262 case i_ty
1263 algorithm
1264 ✗ x_i := Tpl.getIteri_i0(txt);
1265 ✗ (txt, _) := structToString(txt, a_res, i_ty, x_i, Tpl.strTokText(Tpl.ST_STRING("resultBuffer")));
1266 ✗ txt := Tpl.nextIter(txt);
1267 then txt;
1268 end match;
1269 end for;
1270 end lm_72;
1271
1272 protected function fun_73
1273 input Tpl.Text in_txt;
1274 input Boolean in_a_addStructs;
1275 input DAE.Type in_a_res;
1276 input list<DAE.Type> in_a_types;
1277 input String in_a_name;
1278 input String in_a_prefix;
1279
1280 output Tpl.Text out_txt;
1281 algorithm
1282 out_txt :=
1283 match(in_txt, in_a_addStructs, in_a_res, in_a_types, in_a_name, in_a_prefix)
1284 local
1285 Tpl.Text txt;
1286 DAE.Type a_res;
1287 list<DAE.Type> a_types;
1288 String a_name;
1289 String a_prefix;
1290 Tpl.StringToken ret_1;
1291 Tpl.Text txt_0;
1292
1293 case ( txt,
1294 false,
1295 _,
1296 _,
1297 a_name,
1298 a_prefix )
1299 algorithm
1300 ✗ txt := Tpl.writeStr(txt, a_prefix);
1301 ✗ txt := Tpl.writeStr(txt, a_name);
1302 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_res"));
1303 then txt;
1304
1305 case ( txt,
1306 _,
1307 a_res,
1308 a_types,
1309 a_name,
1310 _ )
1311 algorithm
1312 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("typedef struct "));
1313 ✗ txt := Tpl.writeStr(txt, a_name);
1314 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("_res {\n"));
1315 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1316 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1317 ✗ txt := lm_71(txt, a_types, a_res);
1318 ✗ txt := Tpl.popIter(txt);
1319 ✗ txt := Tpl.softNewLine(txt);
1320 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1321 "QString toString() {\n",
1322 " QString resultBuffer = \"(\";\n"
1323 }, true));
1324 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1325 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_NEW_LINE());
1326 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("resultBuffer.append(\",\");"));
1327 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_NEW_LINE());
1328 ✗ ret_1 := Tpl.textStrTok(txt_0);
1329 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(1, NONE(), SOME(ret_1), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1330 ✗ txt := lm_72(txt, a_types, a_res);
1331 ✗ txt := Tpl.popIter(txt);
1332 ✗ txt := Tpl.softNewLine(txt);
1333 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1334 "resultBuffer.append(\")\");\n",
1335 "return resultBuffer;\n"
1336 }, true));
1337 ✗ txt := Tpl.popBlock(txt);
1338 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
1339 ✗ txt := Tpl.popBlock(txt);
1340 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("} "));
1341 ✗ txt := Tpl.writeStr(txt, a_name);
1342 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("_res;\n"));
1343 ✗ txt := Tpl.writeStr(txt, a_name);
1344 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_res"));
1345 then txt;
1346 end match;
1347 end fun_73;
1348
1349 protected function fun_74
1350 input Tpl.Text in_txt;
1351 input DAE.Type in_a_res;
1352 input String in_a_name;
1353 input String in_a_prefix;
1354 input Boolean in_a_addStructs;
1355
1356 output Tpl.Text out_txt;
1357 algorithm
1358 out_txt :=
1359 match(in_txt, in_a_res, in_a_name, in_a_prefix, in_a_addStructs)
1360 local
1361 Tpl.Text txt;
1362 String a_name;
1363 String a_prefix;
1364 Boolean a_addStructs;
1365 DAE.Type i_res;
1366 list<DAE.Type> i_types;
1367
1368 case ( txt,
1369 (i_res as DAE.T_TUPLE(types = i_types)),
1370 a_name,
1371 a_prefix,
1372 a_addStructs )
1373 algorithm
1374 ✗ txt := fun_73(txt, a_addStructs, i_res, i_types, a_name, a_prefix);
1375 then txt;
1376
1377 case ( txt,
1378 DAE.T_NORETCALL(),
1379 _,
1380 _,
1381 _ )
1382 algorithm
1383 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void"));
1384 then txt;
1385
1386 case ( txt,
1387 i_res,
1388 _,
1389 _,
1390 _ )
1391 algorithm
1392 ✗ txt := getQtType(txt, i_res);
1393 then txt;
1394 end match;
1395 end fun_74;
1396
1397 public function getQtInterfaceHeader
1398 input Tpl.Text txt;
1399 input String a_name;
1400 input String a_prefix;
1401 input list<DAE.FuncArg> a_args;
1402 input DAE.Type a_res;
1403 input String a_className;
1404 input Boolean a_addStructs;
1405
1406 output Tpl.Text out_txt;
1407 protected
1408 Tpl.Text l_outType;
1409 Tpl.Text l_inTypes;
1410 algorithm
1411 ✗ l_inTypes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1412 ✗ l_inTypes := lm_70(l_inTypes, a_args);
1413 ✗ l_inTypes := Tpl.popIter(l_inTypes);
1414 ✗ l_outType := fun_74(Tpl.emptyTxt, a_res, a_name, a_prefix, a_addStructs);
1415 ✗ out_txt := Tpl.writeText(txt, l_outType);
1416 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" "));
1417 ✗ out_txt := Tpl.writeStr(out_txt, a_prefix);
1418 ✗ out_txt := Tpl.writeStr(out_txt, a_name);
1419 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("("));
1420 ✗ out_txt := Tpl.writeText(out_txt, l_inTypes);
1421 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(")"));
1422 end getQtInterfaceHeader;
1423
1424 protected function fun_76
1425 input Tpl.Text in_txt;
1426 input DAE.Type in_a_ty;
1427 input Tpl.Text in_a_name;
1428 input Tpl.Text in_a_varDecl;
1429
1430 output Tpl.Text out_txt;
1431 output Tpl.Text out_a_varDecl;
1432 algorithm
1433 (out_txt, out_a_varDecl) :=
1434 match(in_txt, in_a_ty, in_a_name, in_a_varDecl)
1435 local
1436 Tpl.Text txt;
1437 Tpl.Text a_name;
1438 Tpl.Text a_varDecl;
1439 DAE.Type i_ty;
1440 DAE.Type i_aty_ty;
1441 Tpl.Text txt_5;
1442 String ret_5;
1443 Tpl.Text l_i;
1444 Tpl.Text txt_3;
1445 Tpl.Text l_body;
1446 Tpl.Text l_elt;
1447 Tpl.Text l_varDecl2;
1448
1449 case ( txt,
1450 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1451 a_name,
1452 a_varDecl )
1453 algorithm
1454 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("QByteArray "));
1455 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1456 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_utf8 = "));
1457 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1458 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(".toUtf8();"));
1459 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1460 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_scon("));
1461 ✗ txt := Tpl.writeText(txt, a_name);
1462 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_utf8.constData())"));
1463 then (txt, a_varDecl);
1464
1465 case ( txt,
1466 DAE.T_STRING(varLst = _),
1467 a_name,
1468 a_varDecl )
1469 algorithm
1470 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("QByteArray "));
1471 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1472 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_utf8 = "));
1473 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1474 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(".toUtf8();"));
1475 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1476 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_scon("));
1477 ✗ txt := Tpl.writeText(txt, a_name);
1478 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_utf8.constData())"));
1479 then (txt, a_varDecl);
1480
1481 case ( txt,
1482 DAE.T_INTEGER(varLst = _),
1483 a_name,
1484 a_varDecl )
1485 algorithm
1486 ✗ txt := Tpl.writeText(txt, a_name);
1487 then (txt, a_varDecl);
1488
1489 case ( txt,
1490 DAE.T_BOOL(varLst = _),
1491 a_name,
1492 a_varDecl )
1493 algorithm
1494 ✗ txt := Tpl.writeText(txt, a_name);
1495 then (txt, a_varDecl);
1496
1497 case ( txt,
1498 DAE.T_REAL(varLst = _),
1499 a_name,
1500 a_varDecl )
1501 algorithm
1502 ✗ txt := Tpl.writeText(txt, a_name);
1503 then (txt, a_varDecl);
1504
1505 case ( txt,
1506 DAE.T_ARRAY(ty = i_aty_ty),
1507 a_name,
1508 a_varDecl )
1509 algorithm
1510 ✗ l_varDecl2 := Tpl.emptyTxt;
1511 ✗ l_elt := Tpl.writeText(Tpl.emptyTxt, a_name);
1512 ✗ l_elt := Tpl.writeTok(l_elt, Tpl.ST_STRING("_elt"));
1513 ✗ (txt_3, l_elt, l_varDecl2) := getQtInArg(Tpl.emptyTxt, l_elt, i_aty_ty, l_varDecl2);
1514 ✗ (l_body, txt_3) := getQtInArgBoxed(Tpl.emptyTxt, txt_3, i_aty_ty);
1515 ✗ l_i := Tpl.writeText(Tpl.emptyTxt, a_name);
1516 ✗ l_i := Tpl.writeTok(l_i, Tpl.ST_STRING("_i"));
1517 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("void *"));
1518 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1519 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING_LIST({
1520 "_lst = mmc_mk_nil();\n",
1521 "for (int "
1522 }, false));
1523 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_i);
1524 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(" = "));
1525 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1526 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(".size()-1; "));
1527 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_i);
1528 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(">=0; "));
1529 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_i);
1530 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_LINE("--) {\n"));
1531 ✗ a_varDecl := Tpl.pushBlock(a_varDecl, Tpl.BT_INDENT(2));
1532 ✗ a_varDecl := getQtType(a_varDecl, i_aty_ty);
1533 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(" "));
1534 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_elt);
1535 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(" = "));
1536 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1537 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("["));
1538 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_i);
1539 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_LINE("];\n"));
1540 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_varDecl2);
1541 ✗ a_varDecl := Tpl.softNewLine(a_varDecl);
1542 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1543 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_lst = mmc_mk_cons("));
1544 ✗ a_varDecl := Tpl.writeText(a_varDecl, l_body);
1545 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(", "));
1546 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_name);
1547 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_LINE("_lst);\n"));
1548 ✗ a_varDecl := Tpl.popBlock(a_varDecl);
1549 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("}"));
1550 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1551 ✗ txt := Tpl.writeText(txt, a_name);
1552 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_lst"));
1553 then (txt, a_varDecl);
1554
1555 case ( txt,
1556 i_ty,
1557 _,
1558 a_varDecl )
1559 algorithm
1560 ✗ txt_5 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtInArg failed for "));
1561 ✗ ret_5 := TypesDump.unparseType(i_ty);
1562 ✗ txt_5 := Tpl.writeStr(txt_5, ret_5);
1563 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 311, 16), Tpl.textString(txt_5));
1564 then (txt, a_varDecl);
1565 end match;
1566 end fun_76;
1567
1568 public function getQtInArg
1569 input Tpl.Text txt;
1570 input Tpl.Text a_name;
1571 input DAE.Type a_ty;
1572 input Tpl.Text a_varDecl;
1573
1574 output Tpl.Text out_txt;
1575 output Tpl.Text out_a_name;
1576 output Tpl.Text out_a_varDecl;
1577 algorithm
1578 ✗ (out_txt, out_a_varDecl) := fun_76(txt, a_ty, a_name, a_varDecl);
1579 out_a_name := a_name;
1580 end getQtInArg;
1581
1582 protected function fun_78
1583 input Tpl.Text in_txt;
1584 input DAE.Type in_a_ty;
1585 input Tpl.Text in_a_name;
1586
1587 output Tpl.Text out_txt;
1588 algorithm
1589 out_txt :=
1590 match(in_txt, in_a_ty, in_a_name)
1591 local
1592 Tpl.Text txt;
1593 Tpl.Text a_name;
1594 DAE.Type i_ty;
1595 Tpl.Text txt_0;
1596 String ret_0;
1597
1598 case ( txt,
1599 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1600 a_name )
1601 algorithm
1602 ✗ txt := Tpl.writeText(txt, a_name);
1603 then txt;
1604
1605 case ( txt,
1606 DAE.T_STRING(varLst = _),
1607 a_name )
1608 algorithm
1609 ✗ txt := Tpl.writeText(txt, a_name);
1610 then txt;
1611
1612 case ( txt,
1613 DAE.T_ARRAY(ty = _),
1614 a_name )
1615 algorithm
1616 ✗ txt := Tpl.writeText(txt, a_name);
1617 then txt;
1618
1619 case ( txt,
1620 DAE.T_INTEGER(varLst = _),
1621 a_name )
1622 algorithm
1623 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_icon("));
1624 ✗ txt := Tpl.writeText(txt, a_name);
1625 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1626 then txt;
1627
1628 case ( txt,
1629 DAE.T_BOOL(varLst = _),
1630 a_name )
1631 algorithm
1632 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_icon("));
1633 ✗ txt := Tpl.writeText(txt, a_name);
1634 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1635 then txt;
1636
1637 case ( txt,
1638 DAE.T_REAL(varLst = _),
1639 a_name )
1640 algorithm
1641 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_rcon("));
1642 ✗ txt := Tpl.writeText(txt, a_name);
1643 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1644 then txt;
1645
1646 case ( txt,
1647 i_ty,
1648 _ )
1649 algorithm
1650 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtInArgBoxed failed for "));
1651 ✗ ret_0 := TypesDump.unparseType(i_ty);
1652 ✗ txt_0 := Tpl.writeStr(txt_0, ret_0);
1653 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 323, 16), Tpl.textString(txt_0));
1654 then txt;
1655 end match;
1656 end fun_78;
1657
1658 public function getQtInArgBoxed
1659 input Tpl.Text txt;
1660 input Tpl.Text a_name;
1661 input DAE.Type a_ty;
1662
1663 output Tpl.Text out_txt;
1664 output Tpl.Text out_a_name;
1665 algorithm
1666 ✗ out_txt := fun_78(txt, a_ty, a_name);
1667 out_a_name := a_name;
1668 end getQtInArgBoxed;
1669
1670 protected function fun_80
1671 input Tpl.Text in_txt;
1672 input DAE.Type in_a_ty;
1673 input Tpl.Text in_a_name;
1674 input Tpl.Text in_a_commandLog;
1675
1676 output Tpl.Text out_txt;
1677 output Tpl.Text out_a_commandLog;
1678 algorithm
1679 (out_txt, out_a_commandLog) :=
1680 match(in_txt, in_a_ty, in_a_name, in_a_commandLog)
1681 local
1682 Tpl.Text txt;
1683 Tpl.Text a_name;
1684 Tpl.Text a_commandLog;
1685 DAE.Type i_ty;
1686 DAE.Type i_aty_ty;
1687 Tpl.Text txt_2;
1688 String ret_2;
1689 Tpl.Text l_counter;
1690 Tpl.Text l_elt;
1691
1692 case ( txt,
1693 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1694 a_name,
1695 a_commandLog )
1696 algorithm
1697 ✗ txt := Tpl.writeText(txt, a_commandLog);
1698 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
1699 ✗ txt := Tpl.writeText(txt, a_name);
1700 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
1701 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1702 ✗ then (txt, a_commandLog);
1703
1704 case ( txt,
1705 DAE.T_STRING(varLst = _),
1706 a_name,
1707 a_commandLog )
1708 algorithm
1709 ✗ txt := Tpl.writeText(txt, a_commandLog);
1710 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"\\\"\" + "));
1711 ✗ txt := Tpl.writeText(txt, a_name);
1712 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + \"\\\"\");"));
1713 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1714 ✗ then (txt, a_commandLog);
1715
1716 case ( txt,
1717 DAE.T_INTEGER(varLst = _),
1718 a_name,
1719 a_commandLog )
1720 algorithm
1721 ✗ txt := Tpl.writeText(txt, a_commandLog);
1722 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
1723 ✗ txt := Tpl.writeText(txt, a_name);
1724 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
1725 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1726 ✗ then (txt, a_commandLog);
1727
1728 case ( txt,
1729 DAE.T_REAL(varLst = _),
1730 a_name,
1731 a_commandLog )
1732 algorithm
1733 ✗ txt := Tpl.writeText(txt, a_commandLog);
1734 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
1735 ✗ txt := Tpl.writeText(txt, a_name);
1736 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
1737 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1738 ✗ then (txt, a_commandLog);
1739
1740 case ( txt,
1741 DAE.T_BOOL(varLst = _),
1742 a_name,
1743 a_commandLog )
1744 algorithm
1745 ✗ txt := Tpl.writeText(txt, a_commandLog);
1746 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
1747 ✗ txt := Tpl.writeText(txt, a_name);
1748 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ? \"true\" : \"false\");"));
1749 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1750 ✗ then (txt, a_commandLog);
1751
1752 case ( txt,
1753 DAE.T_ARRAY(ty = i_aty_ty),
1754 a_name,
1755 a_commandLog )
1756 algorithm
1757 ✗ l_elt := Tpl.writeText(Tpl.emptyTxt, a_name);
1758 ✗ l_elt := Tpl.writeTok(l_elt, Tpl.ST_STRING("_elt"));
1759 ✗ l_counter := Tpl.writeText(Tpl.emptyTxt, a_name);
1760 ✗ l_counter := Tpl.writeTok(l_counter, Tpl.ST_STRING("_i"));
1761 ✗ txt := Tpl.writeText(txt, a_commandLog);
1762 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1763 ".append(\"{\");\n",
1764 "int "
1765 }, false));
1766 ✗ txt := Tpl.writeText(txt, l_counter);
1767 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1768 " = 0;\n",
1769 "foreach("
1770 }, false));
1771 ✗ txt := getQtType(txt, i_aty_ty);
1772 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1773 ✗ txt := Tpl.writeText(txt, l_elt);
1774 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
1775 ✗ txt := Tpl.writeText(txt, a_name);
1776 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1777 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1778 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if ("));
1779 ✗ txt := Tpl.writeText(txt, l_counter);
1780 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1781 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1782 ✗ txt := Tpl.writeText(txt, a_commandLog);
1783 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(".append(\",\");\n"));
1784 ✗ txt := Tpl.popBlock(txt);
1785 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
1786 ✗ (txt, l_elt, a_commandLog) := getQtCommandLogText(txt, l_elt, i_aty_ty, a_commandLog);
1787 ✗ txt := Tpl.softNewLine(txt);
1788 ✗ txt := Tpl.writeText(txt, l_counter);
1789 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("++;\n"));
1790 ✗ txt := Tpl.popBlock(txt);
1791 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
1792 ✗ txt := Tpl.writeText(txt, a_commandLog);
1793 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"}\");"));
1794 ✗ then (txt, a_commandLog);
1795
1796 case ( txt,
1797 i_ty,
1798 _,
1799 a_commandLog )
1800 algorithm
1801 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtCommandLogText failed for "));
1802 ✗ ret_2 := TypesDump.unparseType(i_ty);
1803 ✗ txt_2 := Tpl.writeStr(txt_2, ret_2);
1804 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 349, 16), Tpl.textString(txt_2));
1805 ✗ then (txt, a_commandLog);
1806 end match;
1807 end fun_80;
1808
1809 public function getQtCommandLogText
1810 input Tpl.Text txt;
1811 input Tpl.Text a_name;
1812 input DAE.Type a_ty;
1813 input Tpl.Text a_commandLog;
1814
1815 output Tpl.Text out_txt;
1816 output Tpl.Text out_a_name;
1817 output Tpl.Text out_a_commandLog;
1818 algorithm
1819 ✗ (out_txt, out_a_commandLog) := fun_80(txt, a_ty, a_name, a_commandLog);
1820 out_a_name := a_name;
1821 end getQtCommandLogText;
1822
1823 protected function fun_82
1824 input Tpl.Text in_txt;
1825 input DAE.Type in_a_ty;
1826 input Tpl.Text in_a_name;
1827 input Tpl.Text in_a_shortName;
1828 input Tpl.Text in_a_varDecl;
1829 input Tpl.Text in_a_postCall;
1830
1831 output Tpl.Text out_txt;
1832 output Tpl.Text out_a_name;
1833 output Tpl.Text out_a_shortName;
1834 output Tpl.Text out_a_varDecl;
1835 output Tpl.Text out_a_postCall;
1836 algorithm
1837 (out_txt, out_a_name, out_a_shortName, out_a_varDecl, out_a_postCall) :=
1838 match(in_txt, in_a_ty, in_a_name, in_a_shortName, in_a_varDecl, in_a_postCall)
1839 local
1840 Tpl.Text txt;
1841 Tpl.Text a_name;
1842 Tpl.Text a_shortName;
1843 Tpl.Text a_varDecl;
1844 Tpl.Text a_postCall;
1845 DAE.Type i_ty;
1846 DAE.Type i_aty;
1847 Tpl.Text txt_1;
1848 String ret_1;
1849 Tpl.Text txt_0;
1850
1851 case ( txt,
1852 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1853 a_name,
1854 a_shortName,
1855 a_varDecl,
1856 a_postCall )
1857 algorithm
1858 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("void *"));
1859 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_shortName);
1860 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_mm = NULL;"));
1861 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1862 ✗ a_postCall := Tpl.writeText(a_postCall, a_name);
1863 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_STRING(" = QString::fromUtf8((char*)MMC_STRINGDATA("));
1864 ✗ a_postCall := Tpl.writeText(a_postCall, a_shortName);
1865 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_STRING("_mm));"));
1866 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_NEW_LINE());
1867 ✗ txt := Tpl.writeText(txt, a_shortName);
1868 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_mm"));
1869 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1870
1871 case ( txt,
1872 DAE.T_STRING(varLst = _),
1873 a_name,
1874 a_shortName,
1875 a_varDecl,
1876 a_postCall )
1877 algorithm
1878 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("void *"));
1879 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_shortName);
1880 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_mm = NULL;"));
1881 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1882 ✗ a_postCall := Tpl.writeText(a_postCall, a_name);
1883 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_STRING(" = QString::fromUtf8((char*)MMC_STRINGDATA("));
1884 ✗ a_postCall := Tpl.writeText(a_postCall, a_shortName);
1885 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_STRING("_mm));"));
1886 ✗ a_postCall := Tpl.writeTok(a_postCall, Tpl.ST_NEW_LINE());
1887 ✗ txt := Tpl.writeText(txt, a_shortName);
1888 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_mm"));
1889 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1890
1891 case ( txt,
1892 DAE.T_INTEGER(varLst = _),
1893 a_name,
1894 a_shortName,
1895 a_varDecl,
1896 a_postCall )
1897 algorithm
1898 ✗ txt := Tpl.writeText(txt, a_name);
1899 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1900
1901 case ( txt,
1902 DAE.T_BOOL(varLst = _),
1903 a_name,
1904 a_shortName,
1905 a_varDecl,
1906 a_postCall )
1907 algorithm
1908 ✗ txt := Tpl.writeText(txt, a_name);
1909 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1910
1911 case ( txt,
1912 DAE.T_REAL(varLst = _),
1913 a_name,
1914 a_shortName,
1915 a_varDecl,
1916 a_postCall )
1917 algorithm
1918 ✗ txt := Tpl.writeText(txt, a_name);
1919 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1920
1921 case ( txt,
1922 (i_aty as DAE.T_ARRAY(ty = _)),
1923 a_name,
1924 a_shortName,
1925 a_varDecl,
1926 a_postCall )
1927 algorithm
1928 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("void *"));
1929 ✗ a_varDecl := Tpl.writeText(a_varDecl, a_shortName);
1930 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_mm = NULL;"));
1931 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
1932 ✗ txt_0 := Tpl.writeText(Tpl.emptyTxt, a_shortName);
1933 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_mm"));
1934 ✗ (a_postCall, a_name, a_shortName, txt_0) := getQtOutArgArray(a_postCall, a_name, a_shortName, txt_0, i_aty);
1935 ✗ txt := Tpl.writeText(txt, a_shortName);
1936 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_mm"));
1937 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1938
1939 case ( txt,
1940 i_ty,
1941 a_name,
1942 a_shortName,
1943 a_varDecl,
1944 a_postCall )
1945 algorithm
1946 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtOutArg failed for "));
1947 ✗ ret_1 := TypesDump.unparseType(i_ty);
1948 ✗ txt_1 := Tpl.writeStr(txt_1, ret_1);
1949 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 367, 16), Tpl.textString(txt_1));
1950 ✗ then (txt, a_name, a_shortName, a_varDecl, a_postCall);
1951 end match;
1952 end fun_82;
1953
1954 public function getQtOutArg
1955 input Tpl.Text txt;
1956 input Tpl.Text a_name;
1957 input Tpl.Text a_shortName;
1958 input DAE.Type a_ty;
1959 input Tpl.Text a_varDecl;
1960 input Tpl.Text a_postCall;
1961
1962 output Tpl.Text out_txt;
1963 output Tpl.Text out_a_name;
1964 output Tpl.Text out_a_shortName;
1965 output Tpl.Text out_a_varDecl;
1966 output Tpl.Text out_a_postCall;
1967 algorithm
1968 ✗ (out_txt, out_a_name, out_a_shortName, out_a_varDecl, out_a_postCall) := fun_82(txt, a_ty, a_name, a_shortName, a_varDecl, a_postCall);
1969 end getQtOutArg;
1970
1971 protected function fun_84
1972 input Tpl.Text in_txt;
1973 input DAE.Type in_a_ty;
1974 input Tpl.Text in_a_name;
1975 input Tpl.Text in_a_shortName;
1976 input Tpl.Text in_a_mm;
1977
1978 output Tpl.Text out_txt;
1979 algorithm
1980 out_txt :=
1981 match(in_txt, in_a_ty, in_a_name, in_a_shortName, in_a_mm)
1982 local
1983 Tpl.Text txt;
1984 Tpl.Text a_name;
1985 Tpl.Text a_shortName;
1986 Tpl.Text a_mm;
1987 DAE.Type i_ty;
1988 DAE.Type i_aty_ty;
1989 Tpl.Text txt_2;
1990 String ret_2;
1991 Tpl.Text txt_1;
1992 Tpl.Text l_elt;
1993
1994 case ( txt,
1995 DAE.T_CODE(ty = DAE.C_TYPENAME()),
1996 a_name,
1997 _,
1998 a_mm )
1999 algorithm
2000 ✗ txt := Tpl.writeText(txt, a_name);
2001 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MMC_STRINGDATA("));
2002 ✗ txt := Tpl.writeText(txt, a_mm);
2003 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2004 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2005 then txt;
2006
2007 case ( txt,
2008 DAE.T_STRING(varLst = _),
2009 a_name,
2010 _,
2011 a_mm )
2012 algorithm
2013 ✗ txt := Tpl.writeText(txt, a_name);
2014 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MMC_STRINGDATA("));
2015 ✗ txt := Tpl.writeText(txt, a_mm);
2016 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2017 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2018 then txt;
2019
2020 case ( txt,
2021 DAE.T_INTEGER(varLst = _),
2022 a_name,
2023 _,
2024 a_mm )
2025 algorithm
2026 ✗ txt := Tpl.writeText(txt, a_name);
2027 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_unbox_integer("));
2028 ✗ txt := Tpl.writeText(txt, a_mm);
2029 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2030 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2031 then txt;
2032
2033 case ( txt,
2034 DAE.T_BOOL(varLst = _),
2035 a_name,
2036 _,
2037 a_mm )
2038 algorithm
2039 ✗ txt := Tpl.writeText(txt, a_name);
2040 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_unbox_boolean("));
2041 ✗ txt := Tpl.writeText(txt, a_mm);
2042 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2043 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2044 then txt;
2045
2046 case ( txt,
2047 DAE.T_REAL(varLst = _),
2048 a_name,
2049 _,
2050 a_mm )
2051 algorithm
2052 ✗ txt := Tpl.writeText(txt, a_name);
2053 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_unbox_real("));
2054 ✗ txt := Tpl.writeText(txt, a_mm);
2055 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2056 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2057 then txt;
2058
2059 case ( txt,
2060 DAE.T_ARRAY(ty = i_aty_ty),
2061 a_name,
2062 a_shortName,
2063 a_mm )
2064 algorithm
2065 ✗ l_elt := Tpl.writeText(Tpl.emptyTxt, a_shortName);
2066 ✗ l_elt := Tpl.writeTok(l_elt, Tpl.ST_STRING("_elt"));
2067 ✗ txt := Tpl.writeText(txt, a_name);
2068 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2069 ".clear();\n",
2070 "while (!listEmpty("
2071 }, false));
2072 ✗ txt := Tpl.writeText(txt, a_mm);
2073 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(")) {\n"));
2074 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2075 ✗ txt := getQtType(txt, i_aty_ty);
2076 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2077 ✗ txt := Tpl.writeText(txt, l_elt);
2078 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
2079 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("MMC_CAR("));
2080 ✗ txt_1 := Tpl.writeText(txt_1, a_mm);
2081 ✗ txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(")"));
2082 ✗ (txt, _, l_elt, txt_1) := getQtOutArgArray(txt, l_elt, l_elt, txt_1, i_aty_ty);
2083 ✗ txt := Tpl.softNewLine(txt);
2084 ✗ txt := Tpl.writeText(txt, a_name);
2085 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
2086 ✗ txt := Tpl.writeText(txt, l_elt);
2087 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
2088 ✗ txt := Tpl.writeText(txt, a_mm);
2089 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MMC_CDR("));
2090 ✗ txt := Tpl.writeText(txt, a_mm);
2091 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
2092 ✗ txt := Tpl.popBlock(txt);
2093 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
2094 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2095 then txt;
2096
2097 case ( txt,
2098 i_ty,
2099 _,
2100 _,
2101 _ )
2102 algorithm
2103 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getOutValueArray failed for "));
2104 ✗ ret_2 := TypesDump.unparseType(i_ty);
2105 ✗ txt_2 := Tpl.writeStr(txt_2, ret_2);
2106 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 389, 16), Tpl.textString(txt_2));
2107 then txt;
2108 end match;
2109 end fun_84;
2110
2111 public function getQtOutArgArray
2112 input Tpl.Text txt;
2113 input Tpl.Text a_name;
2114 input Tpl.Text a_shortName;
2115 input Tpl.Text a_mm;
2116 input DAE.Type a_ty;
2117
2118 output Tpl.Text out_txt;
2119 output Tpl.Text out_a_name;
2120 output Tpl.Text out_a_shortName;
2121 output Tpl.Text out_a_mm;
2122 algorithm
2123 ✗ out_txt := fun_84(txt, a_ty, a_name, a_shortName, a_mm);
2124 out_a_name := a_name;
2125 out_a_shortName := a_shortName;
2126 out_a_mm := a_mm;
2127 end getQtOutArgArray;
2128
2129 protected function fun_86
2130 input Tpl.Text in_txt;
2131 input DAE.Type in_a_ty;
2132 input Tpl.Text in_a_name;
2133 input Tpl.Text in_a_responseLog;
2134
2135 output Tpl.Text out_txt;
2136 output Tpl.Text out_a_responseLog;
2137 algorithm
2138 (out_txt, out_a_responseLog) :=
2139 match(in_txt, in_a_ty, in_a_name, in_a_responseLog)
2140 local
2141 Tpl.Text txt;
2142 Tpl.Text a_name;
2143 Tpl.Text a_responseLog;
2144 DAE.Type i_ty;
2145 DAE.Type i_aty_ty;
2146 Tpl.Text txt_2;
2147 String ret_2;
2148 Tpl.Text l_counter;
2149 Tpl.Text l_elt;
2150
2151 case ( txt,
2152 DAE.T_CODE(ty = DAE.C_TYPENAME()),
2153 a_name,
2154 a_responseLog )
2155 algorithm
2156 ✗ txt := Tpl.writeText(txt, a_responseLog);
2157 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
2158 ✗ txt := Tpl.writeText(txt, a_name);
2159 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
2160 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2161 ✗ then (txt, a_responseLog);
2162
2163 case ( txt,
2164 DAE.T_STRING(varLst = _),
2165 a_name,
2166 a_responseLog )
2167 algorithm
2168 ✗ txt := Tpl.writeText(txt, a_responseLog);
2169 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"\\\"\" + "));
2170 ✗ txt := Tpl.writeText(txt, a_name);
2171 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + \"\\\"\");"));
2172 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2173 ✗ then (txt, a_responseLog);
2174
2175 case ( txt,
2176 DAE.T_INTEGER(varLst = _),
2177 a_name,
2178 a_responseLog )
2179 algorithm
2180 ✗ txt := Tpl.writeText(txt, a_responseLog);
2181 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
2182 ✗ txt := Tpl.writeText(txt, a_name);
2183 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
2184 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2185 ✗ then (txt, a_responseLog);
2186
2187 case ( txt,
2188 DAE.T_REAL(varLst = _),
2189 a_name,
2190 a_responseLog )
2191 algorithm
2192 ✗ txt := Tpl.writeText(txt, a_responseLog);
2193 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(QString::number("));
2194 ✗ txt := Tpl.writeText(txt, a_name);
2195 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("));"));
2196 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2197 ✗ then (txt, a_responseLog);
2198
2199 case ( txt,
2200 DAE.T_BOOL(varLst = _),
2201 a_name,
2202 a_responseLog )
2203 algorithm
2204 ✗ txt := Tpl.writeText(txt, a_responseLog);
2205 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
2206 ✗ txt := Tpl.writeText(txt, a_name);
2207 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ? \"true\" : \"false\");"));
2208 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2209 ✗ then (txt, a_responseLog);
2210
2211 case ( txt,
2212 DAE.T_TUPLE(types = _),
2213 a_name,
2214 a_responseLog )
2215 algorithm
2216 ✗ txt := Tpl.writeText(txt, a_responseLog);
2217 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
2218 ✗ txt := Tpl.writeText(txt, a_name);
2219 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".toString());"));
2220 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2221 ✗ then (txt, a_responseLog);
2222
2223 case ( txt,
2224 DAE.T_ARRAY(ty = i_aty_ty),
2225 a_name,
2226 a_responseLog )
2227 algorithm
2228 ✗ l_elt := Tpl.writeText(Tpl.emptyTxt, a_name);
2229 ✗ l_elt := Tpl.writeTok(l_elt, Tpl.ST_STRING("_elt"));
2230 ✗ l_counter := Tpl.writeText(Tpl.emptyTxt, a_name);
2231 ✗ l_counter := Tpl.writeTok(l_counter, Tpl.ST_STRING("_i"));
2232 ✗ txt := Tpl.writeText(txt, a_responseLog);
2233 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2234 ".append(\"{\");\n",
2235 "int "
2236 }, false));
2237 ✗ txt := Tpl.writeText(txt, l_counter);
2238 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2239 " = 0;\n",
2240 "foreach("
2241 }, false));
2242 ✗ txt := getQtType(txt, i_aty_ty);
2243 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2244 ✗ txt := Tpl.writeText(txt, l_elt);
2245 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
2246 ✗ txt := Tpl.writeText(txt, a_name);
2247 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
2248 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2249 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if ("));
2250 ✗ txt := Tpl.writeText(txt, l_counter);
2251 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
2252 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2253 ✗ txt := Tpl.writeText(txt, a_responseLog);
2254 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(".append(\",\");\n"));
2255 ✗ txt := Tpl.popBlock(txt);
2256 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
2257 ✗ (txt, l_elt, a_responseLog) := getQtResponseLogText(txt, l_elt, i_aty_ty, a_responseLog);
2258 ✗ txt := Tpl.softNewLine(txt);
2259 ✗ txt := Tpl.writeText(txt, l_counter);
2260 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("++;\n"));
2261 ✗ txt := Tpl.popBlock(txt);
2262 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
2263 ✗ txt := Tpl.writeText(txt, a_responseLog);
2264 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append(\"}\");"));
2265 ✗ then (txt, a_responseLog);
2266
2267 case ( txt,
2268 i_ty,
2269 _,
2270 a_responseLog )
2271 algorithm
2272 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("getQtResponseLogText failed for "));
2273 ✗ ret_2 := TypesDump.unparseType(i_ty);
2274 ✗ txt_2 := Tpl.writeStr(txt_2, ret_2);
2275 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("GenerateAPIFunctionsTpl.tpl", 416, 16), Tpl.textString(txt_2));
2276 ✗ then (txt, a_responseLog);
2277 end match;
2278 end fun_86;
2279
2280 public function getQtResponseLogText
2281 input Tpl.Text txt;
2282 input Tpl.Text a_name;
2283 input DAE.Type a_ty;
2284 input Tpl.Text a_responseLog;
2285
2286 output Tpl.Text out_txt;
2287 output Tpl.Text out_a_name;
2288 output Tpl.Text out_a_responseLog;
2289 algorithm
2290 ✗ (out_txt, out_a_responseLog) := fun_86(txt, a_ty, a_name, a_responseLog);
2291 out_a_name := a_name;
2292 end getQtResponseLogText;
2293
2294 protected function lm_88
2295 input output Tpl.Text txt;
2296 input list<DAE.FuncArg> items;
2297 input output Tpl.Text a_varDecl;
2298 algorithm
2299 ✗ for lstElt_88 in items loop
2300 (txt, a_varDecl) := match lstElt_88
2301 local
2302 DAE.Type i_arg_ty;
2303 String i_arg_name;
2304
2305 case DAE.FUNCARG(name = i_arg_name, ty = i_arg_ty)
2306 algorithm
2307 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
2308 ✗ (txt, _, a_varDecl) := getQtInArg(txt, Tpl.stringText(i_arg_name), i_arg_ty, a_varDecl);
2309 ✗ then (txt, a_varDecl);
2310
2311 case _
2312 ✗ then (txt, a_varDecl);
2313 end match;
2314 end for;
2315 end lm_88;
2316
2317 protected function lm_89
2318 input output Tpl.Text txt;
2319 input list<DAE.FuncArg> items;
2320 algorithm
2321 ✗ for lstElt_89 in items loop
2322 txt := match lstElt_89
2323 local
2324 DAE.Type i_arg_ty;
2325 String i_arg_name;
2326
2327 case DAE.FUNCARG(name = i_arg_name, ty = i_arg_ty)
2328 algorithm
2329 ✗ (txt, _, _) := getQtCommandLogText(txt, Tpl.stringText(i_arg_name), i_arg_ty, Tpl.strTokText(Tpl.ST_STRING("commandLog")));
2330 ✗ txt := Tpl.nextIter(txt);
2331 then txt;
2332
2333 case _
2334 then txt;
2335 end match;
2336 end for;
2337 end lm_89;
2338
2339 protected function lm_90
2340 input output Tpl.Text txt;
2341 input list<DAE.Type> items;
2342 input output Tpl.Text a_postCall;
2343 input output Tpl.Text a_varDecl;
2344 input DAE.Type a_res;
2345 algorithm
2346 ✗ for lstElt_90 in items loop
2347 (txt, a_postCall, a_varDecl) := match lstElt_90
2348 local
2349 Integer x_i1;
2350 DAE.Type i_t;
2351 Tpl.Text txt_1;
2352 Tpl.Text txt_0;
2353
2354 case i_t
2355 algorithm
2356 ✗ x_i1 := Tpl.getIteri_i0(txt);
2357 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", &"));
2358 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("result."));
2359 ✗ txt_0 := getQtTupleTypeOutputName(txt_0, a_res, x_i1);
2360 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("out"));
2361 ✗ txt_1 := Tpl.writeStr(txt_1, intString(x_i1));
2362 ✗ (txt, txt_0, txt_1, a_varDecl, a_postCall) := getQtOutArg(txt, txt_0, txt_1, i_t, a_varDecl, a_postCall);
2363 ✗ txt := Tpl.nextIter(txt);
2364 then (txt, a_postCall, a_varDecl);
2365 end match;
2366 end for;
2367 end lm_90;
2368
2369 protected function fun_91
2370 input Tpl.Text in_txt;
2371 input DAE.Type in_a_res;
2372 input Tpl.Text in_a_postCall;
2373 input Tpl.Text in_a_outArg;
2374 input Tpl.Text in_a_responseLog;
2375 input String in_a_name;
2376 input Tpl.Text in_a_varDecl;
2377
2378 output Tpl.Text out_txt;
2379 output Tpl.Text out_a_postCall;
2380 output Tpl.Text out_a_outArg;
2381 output Tpl.Text out_a_responseLog;
2382 output Tpl.Text out_a_varDecl;
2383 algorithm
2384 (out_txt, out_a_postCall, out_a_outArg, out_a_responseLog, out_a_varDecl) :=
2385 match(in_txt, in_a_res, in_a_postCall, in_a_outArg, in_a_responseLog, in_a_name, in_a_varDecl)
2386 local
2387 Tpl.Text txt;
2388 Tpl.Text a_postCall;
2389 Tpl.Text a_outArg;
2390 Tpl.Text a_responseLog;
2391 String a_name;
2392 Tpl.Text a_varDecl;
2393 DAE.Type i_res;
2394 list<DAE.Type> i_types2;
2395 DAE.Type i_type1;
2396 DAE.Type i_t;
2397 Tpl.Text txt_0;
2398
2399 case ( txt,
2400 DAE.T_NORETCALL(),
2401 a_postCall,
2402 a_outArg,
2403 a_responseLog,
2404 _,
2405 a_varDecl )
2406 then (txt, a_postCall, a_outArg, a_responseLog, a_varDecl);
2407
2408 case ( txt,
2409 (i_t as DAE.T_TUPLE(types = i_type1 :: i_types2)),
2410 a_postCall,
2411 a_outArg,
2412 a_responseLog,
2413 a_name,
2414 a_varDecl )
2415 algorithm
2416 ✗ a_varDecl := Tpl.writeStr(a_varDecl, a_name);
2417 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING("_res result;"));
2418 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
2419 ✗ (a_responseLog, _, _) := getQtResponseLogText(a_responseLog, Tpl.strTokText(Tpl.ST_STRING("result")), i_t, Tpl.strTokText(Tpl.ST_STRING("responseLog")));
2420 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("result."));
2421 ✗ txt_0 := getQtTupleTypeOutputName(txt_0, i_t, 1);
2422 ✗ (a_outArg, txt_0, _, a_varDecl, a_postCall) := getQtOutArg(a_outArg, txt_0, Tpl.strTokText(Tpl.ST_STRING("out1")), i_type1, a_varDecl, a_postCall);
2423 ✗ a_outArg := Tpl.writeTok(a_outArg, Tpl.ST_STRING(" = "));
2424 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(2, NONE(), NONE(), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2425 ✗ (txt, a_postCall, a_varDecl) := lm_90(txt, i_types2, a_postCall, a_varDecl, i_t);
2426 ✗ txt := Tpl.popIter(txt);
2427 ✗ then (txt, a_postCall, a_outArg, a_responseLog, a_varDecl);
2428
2429 case ( txt,
2430 i_res,
2431 a_postCall,
2432 a_outArg,
2433 a_responseLog,
2434 _,
2435 a_varDecl )
2436 algorithm
2437 ✗ a_varDecl := getQtType(a_varDecl, i_res);
2438 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_STRING(" result;"));
2439 ✗ a_varDecl := Tpl.writeTok(a_varDecl, Tpl.ST_NEW_LINE());
2440 ✗ (a_responseLog, _, _) := getQtResponseLogText(a_responseLog, Tpl.strTokText(Tpl.ST_STRING("result")), i_res, Tpl.strTokText(Tpl.ST_STRING("responseLog")));
2441 ✗ (a_outArg, _, _, a_varDecl, a_postCall) := getQtOutArg(a_outArg, Tpl.strTokText(Tpl.ST_STRING("result")), Tpl.strTokText(Tpl.ST_STRING("result")), i_res, a_varDecl, a_postCall);
2442 ✗ a_outArg := Tpl.writeTok(a_outArg, Tpl.ST_STRING(" = "));
2443 ✗ then (txt, a_postCall, a_outArg, a_responseLog, a_varDecl);
2444 end match;
2445 end fun_91;
2446
2447 protected function fun_92
2448 input Tpl.Text in_txt;
2449 input Boolean in_mArg;
2450 input Tpl.Text in_a_commandLog;
2451 input String in_a_name;
2452
2453 output Tpl.Text out_txt;
2454 algorithm
2455 out_txt :=
2456 match(in_txt, in_mArg, in_a_commandLog, in_a_name)
2457 local
2458 Tpl.Text txt;
2459 Tpl.Text a_commandLog;
2460 String a_name;
2461
2462 case ( txt,
2463 false,
2464 _,
2465 a_name )
2466 algorithm
2467 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("emit logCommand(\""));
2468 ✗ txt := CodegenUtil.replaceDotAndUnderscore(txt, a_name);
2469 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("()\");"));
2470 then txt;
2471
2472 case ( txt,
2473 _,
2474 a_commandLog,
2475 a_name )
2476 algorithm
2477 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("QString commandLog;\n"));
2478 ✗ txt := Tpl.writeText(txt, a_commandLog);
2479 ✗ txt := Tpl.softNewLine(txt);
2480 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("emit logCommand(\""));
2481 ✗ txt := CodegenUtil.replaceDotAndUnderscore(txt, a_name);
2482 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(\"+commandLog+\")\");"));
2483 then txt;
2484 end match;
2485 end fun_92;
2486
2487 protected function fun_93
2488 input Tpl.Text in_txt;
2489 input Boolean in_mArg;
2490 input String in_a_name;
2491
2492 output Tpl.Text out_txt;
2493 algorithm
2494 out_txt :=
2495 match(in_txt, in_mArg, in_a_name)
2496 local
2497 Tpl.Text txt;
2498 String a_name;
2499
2500 case ( txt,
2501 false,
2502 a_name )
2503 algorithm
2504 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("emit logResponse(\""));
2505 ✗ txt := CodegenUtil.replaceDotAndUnderscore(txt, a_name);
2506 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("()\", responseLog, elapsed);"));
2507 then txt;
2508
2509 case ( txt,
2510 _,
2511 a_name )
2512 algorithm
2513 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("emit logResponse(\""));
2514 ✗ txt := CodegenUtil.replaceDotAndUnderscore(txt, a_name);
2515 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(\"+commandLog+\")\", responseLog, elapsed);"));
2516 then txt;
2517 end match;
2518 end fun_93;
2519
2520 protected function fun_94
2521 input Tpl.Text in_txt;
2522 input Boolean in_mArg;
2523
2524 output Tpl.Text out_txt;
2525 algorithm
2526 out_txt :=
2527 match(in_txt, in_mArg)
2528 local
2529 Tpl.Text txt;
2530
2531 case ( txt,
2532 true )
2533 then txt;
2534
2535 case ( txt,
2536 _ )
2537 algorithm
2538 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return result;"));
2539 then txt;
2540 end match;
2541 end fun_94;
2542
2543 public function getQtInterfaceFunc
2544 input Tpl.Text txt;
2545 input String a_name;
2546 input list<DAE.FuncArg> a_args;
2547 input DAE.Type a_res;
2548 input String a_className;
2549
2550 output Tpl.Text out_txt;
2551 protected
2552 Boolean ret_13;
2553 Boolean ret_12;
2554 Integer ret_11;
2555 Boolean ret_10;
2556 Integer ret_9;
2557 Tpl.Text l_outArgs;
2558 Tpl.Text l_outArg;
2559 Tpl.StringToken ret_6;
2560 Tpl.Text txt_5;
2561 Tpl.Text l_commandLog;
2562 Tpl.Text l_inArgs;
2563 Tpl.Text l_postCall;
2564 Tpl.Text l_responseLog;
2565 Tpl.Text l_varDecl;
2566 algorithm
2567 ✗ l_varDecl := Tpl.emptyTxt;
2568 ✗ l_responseLog := Tpl.emptyTxt;
2569 ✗ l_postCall := Tpl.emptyTxt;
2570 ✗ (l_inArgs, l_varDecl) := lm_88(Tpl.emptyTxt, a_args, l_varDecl);
2571 l_commandLog := Tpl.emptyTxt;
2572 ✗ txt_5 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("commandLog.append(\",\");"));
2573 ✗ txt_5 := Tpl.writeTok(txt_5, Tpl.ST_NEW_LINE());
2574 ✗ ret_6 := Tpl.textStrTok(txt_5);
2575 ✗ l_commandLog := Tpl.pushIter(l_commandLog, Tpl.ITER_OPTIONS(0, NONE(), SOME(ret_6), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2576 ✗ l_commandLog := lm_89(l_commandLog, a_args);
2577 ✗ l_commandLog := Tpl.popIter(l_commandLog);
2578 ✗ l_outArg := Tpl.emptyTxt;
2579 ✗ (l_outArgs, l_postCall, l_outArg, l_responseLog, l_varDecl) := fun_91(Tpl.emptyTxt, a_res, l_postCall, l_outArg, l_responseLog, a_name, l_varDecl);
2580 ✗ out_txt := getQtInterfaceHeader(txt, a_name, a_className, a_args, a_res, a_className, false);
2581 ✗ out_txt := Tpl.softNewLine(out_txt);
2582 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
2583 "{\n",
2584 " QElapsedTimer commandTime;\n",
2585 " commandTime.start();\n"
2586 }, true));
2587 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
2588 ✗ ret_9 := listLength(a_args);
2589 ✗ ret_10 := intGt(ret_9, 0);
2590 ✗ out_txt := fun_92(out_txt, ret_10, l_commandLog, a_name);
2591 ✗ out_txt := Tpl.softNewLine(out_txt);
2592 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
2593 ✗ out_txt := Tpl.writeText(out_txt, l_varDecl);
2594 ✗ out_txt := Tpl.softNewLine(out_txt);
2595 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
2596 "\n",
2597 "try {\n",
2598 " MMC_TRY_TOP_INTERNAL()\n",
2599 "\n"
2600 }, true));
2601 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
2602 ✗ out_txt := Tpl.writeText(out_txt, l_outArg);
2603 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("omc_OpenModelicaScriptingAPI_"));
2604 ✗ out_txt := CodegenUtil.replaceDotAndUnderscore(out_txt, a_name);
2605 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("(threadData"));
2606 ✗ out_txt := Tpl.writeText(out_txt, l_inArgs);
2607 ✗ out_txt := Tpl.writeText(out_txt, l_outArgs);
2608 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(");\n"));
2609 ✗ out_txt := Tpl.writeText(out_txt, l_postCall);
2610 ✗ out_txt := Tpl.softNewLine(out_txt);
2611 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
2612 "\n",
2613 "MMC_CATCH_TOP()\n"
2614 }, true));
2615 ✗ out_txt := Tpl.popBlock(out_txt);
2616 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("} catch(std::exception &exception) {\n"));
2617 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
2618 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("emit throwException(QString(\""));
2619 ✗ out_txt := CodegenUtil.replaceDotAndUnderscore(out_txt, a_name);
2620 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(" failed. %1\").arg(exception.what()));\n"));
2621 ✗ out_txt := Tpl.popBlock(out_txt);
2622 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
2623 "}\n",
2624 "\n",
2625 "QString responseLog;\n"
2626 }, true));
2627 ✗ out_txt := Tpl.writeText(out_txt, l_responseLog);
2628 ✗ out_txt := Tpl.softNewLine(out_txt);
2629 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("double elapsed = (double)commandTime.elapsed() / 1000.0;\n"));
2630 ✗ ret_11 := listLength(a_args);
2631 ✗ ret_12 := intGt(ret_11, 0);
2632 ✗ out_txt := fun_93(out_txt, ret_12, a_name);
2633 ✗ out_txt := Tpl.softNewLine(out_txt);
2634 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
2635 ✗ ret_13 := Tpl.isEmpty(l_outArg);
2636 ✗ out_txt := fun_94(out_txt, ret_13);
2637 ✗ out_txt := Tpl.softNewLine(out_txt);
2638 ✗ out_txt := Tpl.popBlock(out_txt);
2639 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("}"));
2640 end getQtInterfaceFunc;
2641
2642 annotation(__OpenModelica_Interface="backend_tools");
2643 end GenerateAPIFunctionsTpl;
2644