From c0c57568b0756235fc17184fb8e7f421ff1a2201 Mon Sep 17 00:00:00 2001 From: jofret Date: Fri, 13 Aug 2010 09:01:22 +0000 Subject: Allow variable to have more than 2 dimensions --- .../macros/FunctionAnnotation/FA_GetFunAnn.sci | 216 +++++++++++---------- 1 file changed, 114 insertions(+), 102 deletions(-) diff --git a/scilab2c/macros/FunctionAnnotation/FA_GetFunAnn.sci b/scilab2c/macros/FunctionAnnotation/FA_GetFunAnn.sci index 7c0ed937..e5fb8ac8 100644 --- a/scilab2c/macros/FunctionAnnotation/FA_GetFunAnn.sci +++ b/scilab2c/macros/FunctionAnnotation/FA_GetFunAnn.sci @@ -1,5 +1,5 @@ function [FunTypeAnnot,FunSizeAnnot] = ... - FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo) + FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo) // function [FunTypeAnnot,FunSizeAnnot] = ... // FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo) // ----------------------------------------------------------------- @@ -62,126 +62,138 @@ FoundNIn = 0; FoundNOut = 0; line_position = 0; while ((meof(inclsfid) == 0) & (FoundNIn == 0) & (FoundNOut == 0)) - check_string = stripblanks(mgetl(inclsfid,1)); - line_position = line_position + 1; - if (~isempty(check_string)) + check_string = stripblanks(mgetl(inclsfid,1)); + line_position = line_position + 1; + if (~isempty(check_string)) - // #RNU_RES_B - // --- Search for the NIN annotation. --- - // #RNU_RES_E - if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNIN,check_string)) - FUNNINAnnot = part(check_string,length(SharedInfo.Annotations.FUNNIN)+1:length(check_string)); - // #RNU_RES_B - // --- Check NIN value. --- - // #RNU_RES_E - if (eval(FUNNINAnnot) == NInArg) - // #RNU_RES_B - PrintStringInfo(' Line '+string(line_position)+' - Function NInArg Annotation: '+' ""'+check_string+' ""',... - ReportFileName,'file','y'); - // #RNU_RES_E - FoundNIn = 1; - check_string = stripblanks(mgetl(inclsfid,1)); - line_position = line_position + 1; - if (~isempty(check_string)) +// #RNU_RES_B +// --- Search for the NIN annotation. --- +// #RNU_RES_E + if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNIN,check_string)) + FUNNINAnnot = part(check_string,length(SharedInfo.Annotations.FUNNIN)+1:length(check_string)); +// #RNU_RES_B +// --- Check NIN value. --- +// #RNU_RES_E + if (eval(FUNNINAnnot) == NInArg) +// #RNU_RES_B + PrintStringInfo(' Line '+string(line_position)+' - Function NInArg Annotation: '+' ""'+check_string+' ""',... + ReportFileName,'file','y'); +// #RNU_RES_E + FoundNIn = 1; + check_string = stripblanks(mgetl(inclsfid,1)); + line_position = line_position + 1; + if (~isempty(check_string)) - // #RNU_RES_B - // --- Search for the NOUT annotation. --- - // #RNU_RES_E - if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string)) - FUNNOUTAnnot = part(check_string,length(SharedInfo.Annotations.FUNNOUT)+1:length(check_string)); +// #RNU_RES_B +// --- Search for the NOUT annotation. --- +// #RNU_RES_E + if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string)) + FUNNOUTAnnot = part(check_string,length(SharedInfo.Annotations.FUNNOUT)+1:length(check_string)); - // #RNU_RES_B - // --- Check NOUT value. --- - // #RNU_RES_E - if (eval(FUNNOUTAnnot) == NOutArg) - // #RNU_RES_B - PrintStringInfo(' Line '+string(line_position)+' - Function NOutArg Annotation: '+' ""'+check_string+' ""',... - ReportFileName,'file','y'); - // #RNU_RES_E - FoundNOut = 1; - else - FoundNIn = 0; - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'SCI2CERROR: Incorrect format for function annotation.'); - end +// #RNU_RES_B +// --- Check NOUT value. --- +// #RNU_RES_E + if (eval(FUNNOUTAnnot) == NOutArg) +// #RNU_RES_B + PrintStringInfo(' Line '+string(line_position)+' - Function NOutArg Annotation: '+' ""'+check_string+' ""',... + ReportFileName,'file','y'); +// #RNU_RES_E + FoundNOut = 1; else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'SCI2CERROR: Incorrect format for function annotation.'); + FoundNIn = 0; end - end + else + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'SCI2CERROR: Incorrect format for function annotation.'); + end + else + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'SCI2CERROR: Incorrect format for function annotation.'); + end end - end + end + end end if (FoundNOut*FoundNIn == 0) - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Please check file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: There are two possibilities:',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 1. Syntax error in function annotations.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 2. Missing the right combination of NIN/NOUT annotations: ""'+SharedInfo.Annotations.FUNNIN+string(NInArg)+','+SharedInfo.Annotations.FUNNOUT+' '+string(NOutArg)+'"".',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'SCI2CERROR: Incorrect function annotation.'); + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Please check file: '+SCI2CClassFileName,ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Incorrect function annotation.',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: There are two possibilities:',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: 1. Syntax error in function annotations.',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: 2. Missing the right combination of NIN/NOUT annotations: ""'+SharedInfo.Annotations.FUNNIN+string(NInArg)+','+SharedInfo.Annotations.FUNNOUT+' '+string(NOutArg)+'"".',ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'SCI2CERROR: Incorrect function annotation.'); else - for cntout = 1:NOutArg - SCI2C_nout=cntout; // Useful for eval. - // #RNU_RES_B - // Read the Fun type annotation. - // #RNU_RES_E + // In case we are reading to much informations + readNewLine = %t; + + for cntout = 1:NOutArg + SCI2C_nout=cntout; // Useful for eval. + +// #RNU_RES_B +// Read the Fun type annotation. +// #RNU_RES_E + if (readNewLine == %t) check_string = stripblanks(mgetl(inclsfid,1)); line_position = line_position + 1; - if (isempty(check_string) == %F) - tmpannstring = eval(SharedInfo.Annotations.FUNTYPE); - if (SCI2Cstrncmps1size(tmpannstring,check_string)) - // #RNU_RES_B - PrintStringInfo(' Line '+string(line_position)+' - Function Type Annotation: '+' ""'+check_string+' ""',... - ReportFileName,'file','y'); - // #RNU_RES_E - FunTypeAnnot(cntout) = ... - stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName); + else + // reset state + readNewLine = %t; + end + if (isempty(check_string) == %F) + tmpannstring = eval(SharedInfo.Annotations.FUNTYPE); + if (SCI2Cstrncmps1size(tmpannstring,check_string)) +// #RNU_RES_B + PrintStringInfo(' Line '+string(line_position)+' - Function Type Annotation: '+' ""'+check_string+' ""',... + ReportFileName,'file','y'); +// #RNU_RES_E + FunTypeAnnot(cntout) = ... + stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); end + else + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName); + end - // #RNU_RES_B - // --- Read the Fun size annotation. --- - // #RNU_RES_E - SCI2C_nelem = 0; // Useful for eval. - while(SCI2C_nelem < 2 & isempty(check_string) == %F) - SCI2C_nelem = SCI2C_nelem + 1 - line_position = line_position + 1; +// #RNU_RES_B +// --- Read the Fun size annotation. --- +// #RNU_RES_E + SCI2C_nelem = 0; // Useful for eval. +// while(SCI2C_nelem < 2 & isempty(check_string) == %F) + while(SCI2C_nelem < 3 & isempty(check_string) == %F) + line_position = line_position + 1; +// #RNU_RES_B + PrintStringInfo(' Line '+string(line_position)+' - Function Size Annotation: '+' ""'+check_string+' ""',... + ReportFileName,'file','y'); if (isempty(check_string) == %F) - tmpannstring = eval(SharedInfo.Annotations.FUNSIZE); - check_string = stripblanks(mgetl(inclsfid,1)); - if (SCI2Cstrncmps1size(tmpannstring,check_string)) - // #RNU_RES_B - PrintStringInfo(' Line '+string(line_position)+' - Function Size Annotation: '+' ""'+check_string+' ""',... - ReportFileName,'file','y'); - // #RNU_RES_E - FunSizeAnnot(cntout,SCI2C_nelem) = ... - stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); - end + SCI2C_nelem = SCI2C_nelem + 1 + tmpannstring = eval(SharedInfo.Annotations.FUNSIZE); + check_string = stripblanks(mgetl(inclsfid,1)); + if (SCI2Cstrncmps1size(tmpannstring,check_string)) +// #RNU_RES_E + FunSizeAnnot(cntout,SCI2C_nelem) = ... + stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - error(9999, 'SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName); + readNewLine = %f; end + else + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName); end - end + end + end end // --- End loop over the lines of the input file. --- mclose(inclsfid); -- cgit