summaryrefslogtreecommitdiff
path: root/macros/CCodeGeneration/C_IfElseBlocks.sci
blob: 92ac94f7936ab804248cd483032045f97c842e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements)
// function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements)
// -----------------------------------------------------------------
// //NUT: add description here
//
// Input data:
// //NUT: add description here
//
// Output data:
// //NUT: add description here
//
// Status:
// 27-Oct-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------

// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),3,3);

// -----------------------
// --- Initialization. ---
// -----------------------
nxtscifunname    = SharedInfo.NextSCIFunName;
nxtscifunnumber  = SharedInfo.NextSCIFunNumber;

ReportFileName   = FileInfo.Funct(nxtscifunnumber).ReportFileName;
CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName;

IndentLevel      = SharedInfo.NIndent;

// #RNU_RES_B
PrintStringInfo(' ',ReportFileName,'file','y');
PrintStringInfo('   Generate ""{"" or ""}"" code for if/else statement',ReportFileName,'file','y');
// #RNU_RES_E
CCall = '';
// ---------------------------
// --- End Initialization. ---
// ---------------------------

// #RNU_RES_B
// -----------------------------------------------------
// --- Generate the C call/Update indentation level. ---
// -----------------------------------------------------
// #RNU_RES_E
if (InOutStatements=='in')
   CCall = CCall+'{';
   PrintStringInfo('   '+CCall,ReportFileName,'file','y');
   PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y');
   IndentLevel = IndentLevel + 1;
elseif (InOutStatements=='out')
   CCall = CCall+'}';
   IndentLevel = IndentLevel - 1;
   PrintStringInfo('   '+CCall,ReportFileName,'file','y');
   PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y');
else
   error(9999, 'Unknown setting for InOutStatements: '+InOutStatements+'.');
end

// #RNU_RES_B
PrintStringInfo('   Updating indentation level to:'+string(IndentLevel),ReportFileName,'file','y');
// #RNU_RES_E
SharedInfo.NIndent = IndentLevel;

endfunction