summaryrefslogtreecommitdiff
path: root/src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci
diff options
context:
space:
mode:
authorpmarecha2008-06-05 08:49:05 +0000
committerpmarecha2008-06-05 08:49:05 +0000
commit42659d6cdbe63972aea27baf0289db8fcc1310fa (patch)
tree05cc1eb42b985cf657be112ae5a2e842a13c2126 /src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci
parentc4ca26eb9d2bbe224e41fc40658279cb865c48fc (diff)
downloadscilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.tar.gz
scilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.tar.bz2
scilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.zip
SVN is not FTP !
Diffstat (limited to 'src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci')
-rw-r--r--src/Scilab2C/Annotations/GetFunAnnotationsAnnFile.sci96
1 files changed, 96 insertions, 0 deletions
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