diff options
author | nutricato | 2007-07-13 10:03:51 +0000 |
---|---|---|
committer | nutricato | 2007-07-13 10:03:51 +0000 |
commit | c25b43cf50da3a1e2bbbc459448e6b80806df51c (patch) | |
tree | ad8f2656b2378314a492a7e5e27c588072fc9834 | |
parent | 5e99f6ee73b31f683d5b4fb5f88e1bb0b683a9e8 (diff) | |
download | scilab2c-c25b43cf50da3a1e2bbbc459448e6b80806df51c.tar.gz scilab2c-c25b43cf50da3a1e2bbbc459448e6b80806df51c.tar.bz2 scilab2c-c25b43cf50da3a1e2bbbc459448e6b80806df51c.zip |
-rw-r--r-- | src/Scilab2C/Annotations/GenAnnotationFile.sci | 66 | ||||
-rw-r--r-- | src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci | 96 | ||||
-rw-r--r-- | src/Scilab2C/Annotations/GetVarAnnotationsSciFile.sci | 115 | ||||
-rw-r--r-- | src/Scilab2C/Annotations/GetVarTypeAnnotation.sci | 23 | ||||
-rw-r--r-- | src/Scilab2C/Annotations/InitializeLibraryAnnotations.sci | 253 | ||||
-rw-r--r-- | src/Scilab2C/Annotations/Sci2AnnotationFile.sci | 73 |
6 files changed, 626 insertions, 0 deletions
diff --git a/src/Scilab2C/Annotations/GenAnnotationFile.sci b/src/Scilab2C/Annotations/GenAnnotationFile.sci new file mode 100644 index 00000000..cba33f53 --- /dev/null +++ b/src/Scilab2C/Annotations/GenAnnotationFile.sci @@ -0,0 +1,66 @@ +function GenAnnotationFile(AnnStyle,FunName,OutDir) +// function GenAnnotationFile(AnnStyle,FunName,OutDir)
+// -----------------------------------------------------------------
+// Generates the annotation for the function "FunName" according to +// the style specified by AnnStyle. +// The annotation file will be stored into the OutDir. +// Examples of annotation styles: +// AnnStyle = 'I1O1' -> input and output have the same size and type. +// AnnStyle = 'I2O1' -> inputs and output have the same size and type.
+//
+// Input data:
+//
+// Output data:
+//
+// Status:
+// 17-Jun-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+ + +// ---------------------------
+// --- Open the .ann file. ---
+// --------------------------- +annotationfilename = fullfile(OutDir,FunName+'.ann');
+[inannfid,inannerr] = mopen(annotationfilename,'w+');
+if (inannerr < 0)
+ SCI2Cerror(['Cannot open: '+annotationfilename]);
+end
+ +// ------------------------------ +// --- Write annotation file. --- +// ------------------------------ +if (AnnStyle=='I1O1') + fprintf(inannfid,'//_SCI2C_NOUT: 1\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); +elseif (AnnStyle=='I2O1') + fprintf(inannfid,'//_SCI2C_NOUT: 1\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); +elseif (AnnStyle=='INON') + // Cosa si puo' fare per la equal che puo' avere anche N input e N output? + fprintf(inannfid,'//_SCI2C_NOUT: 1\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); + + fprintf(inannfid,'//_SCI2C_NOUT: 2\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(2).Size = InArg(2).Size\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(2).Type = InArg(2).Type\n'); +elseif (AnnStyle=='DET') + // Cosa si puo' fare per la equal che puo' avere anche N input e N output? + fprintf(inannfid,'//_SCI2C_NOUT: 1\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = [1,1]\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); +elseif (AnnStyle=='TRANS') + // Cosa si puo' fare per la equal che puo' avere anche N input e N output? + fprintf(inannfid,'//_SCI2C_NOUT: 1\n'); + fprintf(inannfid,'//_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size.''\n'); + fprintf(inannfid,'//_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type\n'); +else + SCI2Cerror('Unknown Annotation style: '+AnnStyle); +end + +mclose(inannfid); +endfunction diff --git a/src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci b/src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci new file mode 100644 index 00000000..d1981ff3 --- /dev/null +++ b/src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci @@ -0,0 +1,96 @@ +function [FunTypeAnnot,FunSizeAnnot] = ...
+ GetFunAnnotationsAnnFile(SharedInfo_Annotations,NOut,AnnFileName,ReportFileName);
+// function [FunTypeAnnot,FunSizeAnnot] = ...
+// GetFunAnnotationsAnnFile(SharedInfo_Annotations,NOut,AnnFileName,ReportFileName);
+// -----------------------------------------------------------------
+// This function extracts the FUN TYPE and SIZE annotations from the
+// input .ann file.
+// Example of annotation:
+// //_SCI2C_NOUT: 1
+// //_SCI2C_FUNSIZE: OutArg(1).Size = InArg(1).Size
+// //_SCI2C_FUNTYPE: OutArg(1).Type = InArg(1).Type
+// No blank lines are allowed between function annotations.
+//
+// Input data:
+//
+// Output data:
+//
+// Status:
+// 11-Jul-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+if (argn(2) ~= 4)
+ SCI2Cerror('Incorrect number of input arguments.');
+end
+
+// ---------------------------------------
+// --- Open the .sci file (read only). ---
+// ---------------------------------------
+[inscifid,inscierr] = mopen(AnnFileName,'r');
+if (inscierr < 0)
+ SCI2Cerror(['Cannot open: '+AnnFileName])
+end
+
+// ----------------------------------------------
+// --- Loop over the lines of the input file. ---
+// ----------------------------------------------
+// Position file pointer to the desired NOUT section,
+// and read the NOUT annotation.
+FoundNout = 0;
+line_position = 0;
+while ((meof(inscifid) == 0) & (FoundNout == 0))
+ check_string = stripblanks(mgetl(inscifid,1));
+ line_position = line_position + 1;
+ if (~isempty(check_string))
+ if (SCI2Cstrncmps1size(SharedInfo_Annotations.FUNNOUT,check_string))
+ FunNOutAnnot = part(check_string,length(SharedInfo_Annotations.FUNNOUT)+1:length(check_string));
+ if (eval(FunNOutAnnot) == NOut)
+ PrintStringInfo('Line '+string(line_position)+' - Function NOut Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ FoundNout = 1;
+ end
+ end
+ end
+end
+
+if (FoundNout == 0)
+ disp('Please check file: '+AnnFileName);
+ SCI2Cerror('Could not find ""'+SharedInfo_Annotations.FUNNOUT+' '+string(NOut)+'"" annotation.');
+else
+ for cntout = 1:NOut
+ // Read the Fun size annotation.
+ check_string = stripblanks(mgetl(inscifid,1));
+ line_position = line_position + 1;
+ if (isempty(check_string) == %F)
+ if (SCI2Cstrncmps1size(SharedInfo_Annotations.FUNSIZE,check_string))
+ PrintStringInfo('Line '+string(line_position)+' - Function Size Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ FunSizeAnnot(cntout) = ...
+ stripblanks(part(check_string,length(SharedInfo_Annotations.FUNSIZE)+1:length(check_string)));
+ else
+ SCI2Cerror('Line '+string(line_position)+' Function type annotation (//_SCI2C_FUNSIZE:) not found in file: '+AnnFileName,...
+ ReportFileName,'file','y');
+ end
+ // Read the Fun type annotation.
+ check_string = stripblanks(mgetl(inscifid,1));
+ line_position = line_position + 1;
+ if (SCI2Cstrncmps1size(SharedInfo_Annotations.FUNTYPE,check_string))
+ PrintStringInfo('Line '+string(line_position)+' - Function Type Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ FunTypeAnnot(cntout) = ...
+ stripblanks(part(check_string,length(SharedInfo_Annotations.FUNTYPE)+1:length(check_string)));
+ else
+ SCI2Cerror('Line '+string(line_position)+' Function type annotation (//_SCI2C_FUNTYPE:) not found in file: '+AnnFileName,...
+ ReportFileName,'file','y');
+ end
+ end
+ end
+end
+// --------------------------------------------------
+// --- End loop over the lines of the input file. ---
+// --------------------------------------------------
+mclose(inscifid);
+endfunction
diff --git a/src/Scilab2C/Annotations/GetVarAnnotationsSciFile.sci b/src/Scilab2C/Annotations/GetVarAnnotationsSciFile.sci new file mode 100644 index 00000000..9fafce8b --- /dev/null +++ b/src/Scilab2C/Annotations/GetVarAnnotationsSciFile.sci @@ -0,0 +1,115 @@ +function GetVarAnnotationsSciFile(FileInfoDatFile);
+// function GetVarAnnotationsSciFile(FileInfoDatFile);
+// --------------------------------------------------------------------------------
+// This function reads the .sci input file and returns all the variable annotations
+// found in that file.
+//
+// Input data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+// SharedInfoDatFile: it is a buffer containing parameters that are exchanged by the
+// functions of the SCI2C tool.
+//
+// Output data:
+//
+// Status:
+// 21-Jun-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+// ---------------------
+// --- Load section. ---
+// ---------------------
+// --- Load File Info Structure. ---
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+
+// --- Extraction of the function name and number. ---
+funname = SharedInfo.Next(1).SCIFunName;
+funnumber = SharedInfo.NextSCIFunNumber;
+
+// --- Load GlobalVars Structure. ---
+load(FileInfo.GlobalVarFileName,'GlobalVars');
+
+// --- Load LocalVars Structure. ---
+load(FileInfo.Funct(funnumber).LocalVarFileName,'LocalVars');
+// -------------------------
+// --- End load section. ---
+// -------------------------
+
+SciFileName = FileInfo.Funct(funnumber).SCIFileName;
+
+PrintStepInfo('Get annotations from '+SciFileName,...
+ FileInfo.GeneralReport,'both');
+
+// ---------------------------------------
+// --- Open the .sci file (read only). ---
+// ---------------------------------------
+[inscifid,inscierr] = mopen(SciFileName,'r');
+if (inscierr < 0)
+ SCI2Cerror(['Cannot open: '+SciFileName])
+end
+
+
+// --- Loop Initialization. ---
+GlobalVarNames = [];
+
+// ----------------------------------------------
+// --- Loop over the lines of the input file. ---
+// ----------------------------------------------
+line_position = 0;
+while (meof(inscifid) == 0)
+ check_string = stripblanks(mgetl(inscifid,1));
+ line_position = line_position + 1;
+ if (length(check_string) >= 1)
+ if (SCI2Cstrncmps1size(SharedInfo.Annotations.GBLVAR,check_string))
+ PrintStringInfo('Line '+string(line_position)+' - Global Variables: '+' ""'+check_string+' ""',...
+ FileInfo.GeneralReport,'both','y');
+ TmpGlobalAnn = stripblanks(tokens(check_string,' '));
+ GlobalVarNames = [GlobalVarNames,TmpGlobalAnn(2:max(size(TmpGlobalAnn)))];
+ clear TmpGlobalAnn
+ elseif (SCI2Cstrncmps1size(SharedInfo.Annotations.VARTYPE,check_string))
+ // Assuming the following annotation:
+ // //_SCI2C_VARTYPE: name | type | size
+ // Ex.:
+ // //_SCI2C_VARTYPE: myvar | z | [10,4]
+ TmpVarAnn = GetVarTypeAnnotation(check_string);
+ PrintStringInfo('Line '+string(line_position)+' - VARTYPE annotation: '+' ""'+check_string+' ""',...
+ FileInfo.GeneralReport,'file','y');
+ // Check if the variable is global or local
+ if length(find(GlobalVarNames==TmpVarAnn(2))) > 0
+ //RN Qui manca un check per verificare se sto ridefinendo una global gia definita
+ GlobalVarsNum = size(GlobalVars,1) + 1;
+ GlobalVars(GlobalVarsNum).Name = TmpVarAnn(2);
+ GlobalVars(GlobalVarsNum).CName = TmpVarAnn(2);
+ GlobalVars(GlobalVarsNum).Type = TmpVarAnn(3);
+ GlobalVars(GlobalVarsNum).Size = eval(TmpVarAnn(4));
+ else
+ //RN Qui manca un check per verificare se sto ridefinendo una local gia definita
+ LocalVarsNum = size(LocalVars,1) + 1;
+ LocalVars(LocalVarsNum).Name = TmpVarAnn(2);
+ LocalVars(LocalVarsNum).CName = TmpVarAnn(2);
+ LocalVars(LocalVarsNum).Type = TmpVarAnn(3);
+ LocalVars(LocalVarsNum).Size = eval(TmpVarAnn(4));
+ end
+ clear TmpVarAnn
+ end
+ end
+end
+// --------------------------------------------------
+// --- End loop over the lines of the input file. ---
+// --------------------------------------------------
+
+mclose(inscifid);
+
+// ---------------------
+// --- Save section. ---
+// ---------------------
+// --- Save File Info Structure. ---
+save(FileInfoDatFile,FileInfo);
+
+// Save Global and Local variables info into .dat files.
+save(FileInfo.GlobalVarFileName,GlobalVars);
+save(FileInfo.Funct(funnumber).LocalVarFileName,LocalVars);
+
+endfunction
diff --git a/src/Scilab2C/Annotations/GetVarTypeAnnotation.sci b/src/Scilab2C/Annotations/GetVarTypeAnnotation.sci new file mode 100644 index 00000000..b362fdfd --- /dev/null +++ b/src/Scilab2C/Annotations/GetVarTypeAnnotation.sci @@ -0,0 +1,23 @@ +
+function VarTypeAnnotation = GetVarTypeAnnotation(InputString);
+// function VarTypeAnnotation = GetVarTypeAnnotation(InputString);
+// --------------------------------------------------------------------------------
+// This function extracts the VAR TYPE annotation from the input string.
+//
+// Input data:
+//
+// Output data:
+//
+// Status:
+// 11-Jul-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+tmp1 = stripblanks(tokens(InputString,'|'));
+tmp2 = stripblanks(tokens(tmp1(1),' '));
+tmp1(1) = [];
+VarTypeAnnotation = [tmp2; tmp1];
+
+if ((max(size(VarTypeAnnotation))) ~= 4)
+ SCI2Cerror('Incorrect VARTYPE ANNOTATION in string ""'+InputString+'"".');
+end
+endfunction
diff --git a/src/Scilab2C/Annotations/InitializeLibraryAnnotations.sci b/src/Scilab2C/Annotations/InitializeLibraryAnnotations.sci new file mode 100644 index 00000000..742bf5e0 --- /dev/null +++ b/src/Scilab2C/Annotations/InitializeLibraryAnnotations.sci @@ -0,0 +1,253 @@ +function InitializeLibraryAnnotations(FileInfoDatFile)
+// function InitializeLibraryAnnotations(FileInfoDatFile)
+// -----------------------------------------------------------------
+// This function initializes the SCI2C and USER library annotation
+// files.
+// For each Scilab function a .ann file is created where the function
+// annotations are listed into it.
+//
+// Input data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+//
+// Output data:
+//
+// Status:
+// 12-Jun-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+// ---------------------
+// --- Load section. ---
+// ---------------------
+// --- Load File Info Structure. ---
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+// -------------------------
+// --- End load section. ---
+// -------------------------
+
+
+PrintStepInfo('Initialize Library Annotation Files.',...
+ FileInfo.GeneralReport,'both');
+
+OutDir = FileInfo.SCI2CLibAnnDirName;
+SCI2CCreateDir(OutDir);
+
+// ------------------------------------------------------
+// --- Add elementary functions to the SCI2C library. ---
+// ------------------------------------------------------
+PrintStringInfo('Adding elementary functions to the SCI2C library.',...
+ FileInfo.GeneralReport,'both','y');
+
+//RN non so comet trattare la equal
+AnnStyle = 'INON';
+
+//RN equal funziona come le sin ma occorre fare diversi controlli per capire se l'output
+//e' compatibile con l'input. Per ora la lascio cosi'.
+NewFunctionName = 'Equal';
+PrintStringInfo(' Adding function ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+ // ----------------------
+ // --- Style: 'I1O1'. ---
+ // ----------------------
+AnnStyle = 'I1O1';
+
+NewFunctionName = 'sin';
+PrintStringInfo(' Adding function ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+NewFunctionName = 'cos';
+PrintStringInfo(' Adding function ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+// SCI2CLib = AddElementaryFunction("tan",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("cotg",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("asin",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("acos",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("sinh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("cosh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("tanh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("asinh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("acosh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("atanh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("exp",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("log",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("log10",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("abs",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("inv",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("sqrtR",SCI2CLib);
+
+ // ----------------------
+ // --- Style: 'DET'. ---
+ // ----------------------
+AnnStyle = 'DET';
+
+NewFunctionName = 'det';
+PrintStringInfo(' Adding function ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+// ----------------------------------------------------------
+// --- End add elementary functions to the SCI2C library. ---
+// ----------------------------------------------------------
+
+
+// ----------------------------------------------------
+// --- Add operator functions to the SCI2C library. ---
+// ----------------------------------------------------
+PrintStringInfo('Adding operator functions to the SCI2C library.',...
+ FileInfo.GeneralReport,'both','y');
+
+ // ----------------------
+ // --- Style: 'I2O1'. ---
+ // ----------------------
+AnnStyle = 'I2O1';
+
+NewFunctionName = 'OpPlus';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+NewFunctionName = 'OpMinus';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+NewFunctionName = 'OpMul';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+NewFunctionName = 'OpDiv';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+ // -----------------------
+ // --- Style: 'TRANS'. ---
+ // -----------------------
+AnnStyle = 'TRANS';
+
+NewFunctionName = 'OpTrans';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+NewFunctionName = 'OpTransConj';
+PrintStringInfo(' Adding operator ""'+NewFunctionName+'"".',FileInfo.GeneralReport,'both','y');
+GenAnnotationFile(AnnStyle,NewFunctionName,OutDir);
+
+// --------------------------------------------------------
+// --- End add operator functions to the SCI2C library. ---
+// --------------------------------------------------------
+
+
+
+if (1==2)
+// determinant function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDet("det");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// sqrt function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafSqrt("sqrt");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// I add the function with 2 Input
+
+// dot function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("DotAdd");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("DotSub");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("DotMul");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("DotDiv");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// op function
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("OpAdd");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("OpSub");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("OpMul");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafDotOp("OpDiv");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// atan function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafAtan("atan");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// convol function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafConvol("convol");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// fft function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafFFT("fft");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+
+// ifft function
+
+
+ [FuncStruct, CINFO, NumFunc] = AddLeafIFFT("ifft");
+
+ for ind = 1 : NumFunc,
+ SCI2CLib = AddBranch(SCI2CLib, FuncStruct(ind), CINFO(ind) );
+ end
+end // end if (1==2)
+
+endfunction
diff --git a/src/Scilab2C/Annotations/Sci2AnnotationFile.sci b/src/Scilab2C/Annotations/Sci2AnnotationFile.sci new file mode 100644 index 00000000..a7046543 --- /dev/null +++ b/src/Scilab2C/Annotations/Sci2AnnotationFile.sci @@ -0,0 +1,73 @@ +function Sci2AnnotationFile(FileInfoDatFile,SciFileName)
+// function Sci2AnnotationFile(FileInfoDatFile,SciFileName)
+// --------------------------------------------------------------------------------
+// This function reads the .sci input file and generates the correspondig .ann
+// file.
+//
+// Input data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+//
+// Output data:
+//
+// Status:
+// 25-Jun-2007 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+// ---------------------
+// --- Load section. ---
+// ---------------------
+// --- Load File Info Structure. ---
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+
+// --- Extraction of the function name and number. ---
+funname = SharedInfo.Next(1).SCIFunName;
+funnumber = SharedInfo.NextSCIFunNumber;
+// -------------------------
+// --- End load section. ---
+// -------------------------
+
+// --- File names initialization. ---
+[tmppath,tmpname,tmpext] = fileparts(SciFileName);
+AnnFileName = fullfile(FileInfo.USER2CLibAnnDirName,tmpname+'.ann');
+
+PrintStepInfo('Generate annotations file: '+AnnFileName,...
+ FileInfo.GeneralReport,'both');
+
+// ---------------------------------------
+// --- Open the .sci file (read only). ---
+// ---------------------------------------
+[inscifid,inscierr] = mopen(SciFileName,'r');
+if (inscierr < 0)
+ SCI2Cerror(['Cannot open (in read mode): '+SciFileName]);
+end
+
+// ----------------------------------------------
+// --- Loop over the lines of the input file. ---
+// ----------------------------------------------
+line_position = 0;
+while (meof(inscifid) == 0)
+ check_string = stripblanks(mgetl(inscifid,1));
+ line_position = line_position + 1;
+ if (length(check_string) >= 1)
+ if ((SCI2Cstrncmps1size(SharedInfo.Annotations.GBLVAR,check_string)) | ...
+ (SCI2Cstrncmps1size(SharedInfo.Annotations.VARTYPE,check_string)) | ...
+ (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string)) | ...
+ (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNSIZE,check_string)) | ...
+ (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNTYPE,check_string)))
+ PrintStringInfo('Line '+string(line_position)+' - Found Annotation:: '+' ""'+check_string+' ""',...
+ FileInfo.GeneralReport,'file','y');
+ PrintStringInfo(check_string,...
+ AnnFileName,'file','y');
+
+ end
+ end
+end
+// --------------------------------------------------
+// --- End loop over the lines of the input file. ---
+// --------------------------------------------------
+
+mclose(inscifid);
+endfunction
|