summaryrefslogtreecommitdiff
path: root/2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci
diff options
context:
space:
mode:
authoryash11122017-07-07 21:20:49 +0530
committeryash11122017-07-07 21:20:49 +0530
commit9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 (patch)
treef50d6e06d8fe6bc1a9053ef10d4b4d857800ab51 /2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci
downloadScilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.gz
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.bz2
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.zip
sci2c arduino updated
Diffstat (limited to '2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci')
-rw-r--r--2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci173
1 files changed, 173 insertions, 0 deletions
diff --git a/2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci b/2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci
new file mode 100644
index 00000000..2c69f46e
--- /dev/null
+++ b/2.3-1/macros/CCodeGeneration/JoinDeclarAndCcode.sci
@@ -0,0 +1,173 @@
+function JoinDeclarAndCcode(FileInfoDatFile)
+// function JoinDeclarAndCcode(FileInfoDatFile)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 07-Nov-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ---------------------
+// --- Load section. ---
+// ---------------------
+// --- Load File Info Structure. ---
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+// -------------------------
+// --- End load section. ---
+// -------------------------
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+funnumber = SharedInfo.NextSCIFunNumber;
+
+CPass1FileName = FileInfo.Funct(funnumber).CPass1FileName;
+CPass2FileName = FileInfo.Funct(funnumber).CPass2FileName;
+CDeclarationFileName = FileInfo.Funct(funnumber).CDeclarationFileName;
+CGblDeclarFileName = FileInfo.Funct(funnumber).CGblDeclarFileName;
+CInitVarsFileName = FileInfo.Funct(funnumber).CInitVarsFileName;
+ReportFileName = FileInfo.Funct(funnumber).ReportFileName;
+
+CPass1V1FileFid = SCI2COpenFileRead(CPass1FileName);
+CDeclarationFileFid = SCI2COpenFileRead(CDeclarationFileName);
+CGblDeclarFileFid = SCI2COpenFileRead(CGblDeclarFileName);
+CInitVarsFileFid = SCI2COpenFileRead(CInitVarsFileName);
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+PrintStepInfo('Joining declaration and C-call files',ReportFileName,'file');
+
+PrintStringInfo('/*',CPass2FileName,'file','y');
+PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('** --- Global Variables Declaration. ---',CPass2FileName,'file','y');
+PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('*/',CPass2FileName,'file','y');
+// #RNU_RES_B
+// --- Copy in V2 the global declaration file. ---
+// #RNU_RES_E
+while (~meof(CGblDeclarFileFid))
+ // Read a line from C Global Declaration file.
+ tmpcline = mgetl(CGblDeclarFileFid,1);
+ if (length(tmpcline) == 0)
+ tmpcline = ' ';
+ end
+
+ noblkstmpcline = stripblanks(tmpcline);
+ PrintStringInfo(tmpcline,CPass2FileName,'file','y');
+end
+PrintStringInfo('/*',CPass2FileName,'file','y');
+PrintStringInfo('** -----------------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('** --- End Global Variables Declaration. ---',CPass2FileName,'file','y');
+PrintStringInfo('** -----------------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('*/',CPass2FileName,'file','y');
+PrintStringInfo(' ',CPass2FileName,'file','y');
+
+// #RNU_RES_B
+// --- Copy in V2 the first part of V1 up to "{". ---
+// #RNU_RES_E
+FoundCurlyBracket = 0;
+while ((~meof(CPass1V1FileFid)) & (FoundCurlyBracket == 0))
+ // Read a line from C Pass1 file.
+ tmpcline = mgetl(CPass1V1FileFid,1);
+ noblkstmpcline = stripblanks(tmpcline);
+ if (length(noblkstmpcline) > 0)
+ if (SCI2Cstrncmps1size('{',noblkstmpcline))
+ FoundCurlyBracket = 1;
+ end
+ else
+ tmpcline = ' ';
+ end
+ PrintStringInfo(tmpcline,CPass2FileName,'file','y');
+end
+
+if (FoundCurlyBracket == 0)
+ SCI2CerrorFile('""{"" char not found in:'+CPass1FileName,ReportFileName);
+end
+
+PrintStringInfo('/*',CPass2FileName,'file','y');
+PrintStringInfo('** -----------------------------',CPass2FileName,'file','y');
+PrintStringInfo('** --- Variable Declaration. ---',CPass2FileName,'file','y');
+PrintStringInfo('** -----------------------------',CPass2FileName,'file','y');
+PrintStringInfo('*/',CPass2FileName,'file','y');
+// --- Copy in V2 the declaration file. ---
+while (~meof(CDeclarationFileFid))
+ // Read a line from C Declaration file.
+ tmpcline = mgetl(CDeclarationFileFid,1);
+ if (length(tmpcline) == 0)
+ tmpcline = ' ';
+ end
+
+ noblkstmpcline = stripblanks(tmpcline);
+ PrintStringInfo(tmpcline,CPass2FileName,'file','y');
+end
+
+// #RNU_RES_B
+// --- Copy in V2 the variable initialization file. ---
+// #RNU_RES_E
+while (~meof(CInitVarsFileFid))
+ // Read a line from C Declaration file.
+ tmpcline = mgetl(CInitVarsFileFid,1);
+ if (length(tmpcline) == 0)
+ tmpcline = ' ';
+ end
+
+ noblkstmpcline = stripblanks(tmpcline);
+ PrintStringInfo(tmpcline,CPass2FileName,'file','y');
+end
+PrintStringInfo('/*',CPass2FileName,'file','y');
+PrintStringInfo('** ---------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('** --- End Variable Declaration. ---',CPass2FileName,'file','y');
+PrintStringInfo('** ---------------------------------',CPass2FileName,'file','y');
+PrintStringInfo('*/',CPass2FileName,'file','y');
+
+
+PrintStringInfo('/*',CPass2FileName,'file','y');
+PrintStringInfo('** ---------------',CPass2FileName,'file','y');
+PrintStringInfo('** --- C code. ---',CPass2FileName,'file','y');
+PrintStringInfo('** ---------------',CPass2FileName,'file','y');
+PrintStringInfo('*/',CPass2FileName,'file','y');
+
+if((SharedInfo.Target == "RPi") & (nxtscifunname == SharedInfo.SCIMainFunName))
+ //Add wiringPiSetup() function as it is required
+ PrintStringInfo('wiringPiSetup();',CPass2FileName,'file','y');
+end
+// --- Copy the remaining part of V1 in V2. ---
+while (~meof(CPass1V1FileFid))
+ // #RNU_RES_B
+ // Read a line from C Pass1 file.
+ // #RNU_RES_E
+ tmpcline = mgetl(CPass1V1FileFid,1);
+ if (length(tmpcline) == 0)
+ tmpcline = ' ';
+ end
+ PrintStringInfo(tmpcline,CPass2FileName,'file','y');
+end
+
+// --------------------
+// --- Close Files. ---
+// --------------------
+mclose(CPass1V1FileFid);
+mclose(CDeclarationFileFid);
+mclose(CGblDeclarFileFid);
+mclose(CInitVarsFileFid);
+
+endfunction