diff options
author | jofret | 2008-06-06 15:49:19 +0000 |
---|---|---|
committer | jofret | 2008-06-06 15:49:19 +0000 |
commit | 24fea7774ad69b3f8d61333e2d6f31eeff54b8ec (patch) | |
tree | b0b9d9a21ff43091ec3aed71d70339ce33908dcc /src | |
parent | 4a260811a8997d249b3802a24f8333c66e0e681c (diff) | |
download | scilab2c-24fea7774ad69b3f8d61333e2d6f31eeff54b8ec.tar.gz scilab2c-24fea7774ad69b3f8d61333e2d6f31eeff54b8ec.tar.bz2 scilab2c-24fea7774ad69b3f8d61333e2d6f31eeff54b8ec.zip |
- Clean add for Raffaele.
Diffstat (limited to 'src')
6 files changed, 254 insertions, 0 deletions
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci new file mode 100644 index 00000000..95e61ffa --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci @@ -0,0 +1,73 @@ +function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName) +// function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName) +// ----------------------------------------------------------------- +// +// Status: +// 30-Oct-2007 -- Raffaele Nutricato: Author. +// 30-Oct-2007 -- Alberto Morea: Test Ok. +// +// Copyright 2007 Raffaele Nutricato & Alberto Morea. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +SCI2CNInArgCheck(argn(2),6,6); + +flagexist = %F; + + +AvailableDat = USER2CAvailableCDat; +load(AvailableDat,'Available'); +NAvail = size(Available,1); + +tmpcnt = 1; +while ((tmpcnt <=NAvail) & (flagexist == %F)) + if mtlb_strcmp(Available(tmpcnt),CFunName) + flagexist = %T; + end + tmpcnt = tmpcnt + 1; +end +clear Available + +if (flagexist == %F) + AvailableDat = SCI2CAvailableCDat; + load(AvailableDat,'Available'); + NAvail = size(Available,1); + + tmpcnt = 1; + while ((tmpcnt <=NAvail) & (flagexist == %F)) + if mtlb_strcmp(Available(tmpcnt),CFunName) + flagexist = %T; + end + tmpcnt = tmpcnt + 1; + end + clear Available +end + +if (flagexist == %F) + load(ConvertedDat,'Converted'); + NConv = size(Converted,1); + tmpcnt = 1; + while ((tmpcnt <=NConv) & (flagexist == %F)) + if mtlb_strcmp(Converted(tmpcnt),CFunName) + flagexist = %T; + end + tmpcnt = tmpcnt + 1; + end + clear Converted +end + +if (flagexist == %F) + load(ToBeConvertedDat,'ToBeConverted'); + NToBeConv = size(ToBeConverted,1); + tmpcnt = 1; + while ((tmpcnt <=NToBeConv) & (flagexist == %F)) + if mtlb_strcmp(ToBeConverted(tmpcnt).CFunctionName,CFunName) + flagexist = %T; + end + tmpcnt = tmpcnt + 1; + end + clear ToBeConverted +end + + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci new file mode 100644 index 00000000..120dc467 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci @@ -0,0 +1,37 @@ +function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName) +// function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName) +// ----------------------------------------------------------------- +// +// Status: +// 05-Jan-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + + +SCI2CNInArgCheck(argn(2),5,5); + +tmppwd = pwd(); +cd(FunctionDir); +funfiles = listfiles(); +cd(tmppwd); +NFunFiles = size(funfiles,1); + +CFuncList = ''; +NElements = 0; + +for cntfun = 1:NFunFiles + FunFileName = fullfile(FunctionDir,funfiles(cntfun)); + ClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName); + ClassFileName = fullfile(ClassDir,ClassName); + [tmpfunlist,tmpnelem] = File2StringArray(ClassFileName+ExtFLCls); + [tmppath,tmpfunname,tmpext] = fileparts(FunFileName); + tmpfunlist = FL_InOutArgs2CFunNames(tmpfunname,tmpfunlist,tmpnelem); + for cnttmpfun = 1:tmpnelem + NElements = NElements + 1; + CFuncList(NElements) = tmpfunlist(cnttmpfun); + end +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci new file mode 100644 index 00000000..373604c4 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci @@ -0,0 +1,31 @@ +function SCI2CClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName) +// function SCI2CClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName) +// ----------------------------------------------------------------- +// +// Status: +// 11-Jul-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +SCI2CNInArgCheck(argn(2),3,3); +inannfid = SCI2COpenFileRead(FunFileName); +FoundClass = 0; +if (meof(inannfid) == 0) + check_string = stripblanks(mgetl(inannfid,1)); + if (~isempty(check_string)) + if (SCI2Cstrncmps1size(SCI2CClassSpecifier,check_string)) + SCI2CClassName = part(check_string,length(SCI2CClassSpecifier)+1:length(check_string)); + FoundClass = 1; + else + SCI2CerrorFile('Could not find ""'+SCI2CClassSpecifier+'"" in '+FunFileName+'.',ReportFileName); + end + end +end +mclose(inannfid); +if (FoundClass == 0) + SCI2CerrorFile('Could not find ""'+SCI2CClassSpecifier+'"" specifier.',ReportFileName); +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci new file mode 100644 index 00000000..ce106318 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci @@ -0,0 +1,37 @@ +function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem) +// function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem) +// ----------------------------------------------------------------- +// +// Status: +// 05-Jan-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + + +SCI2CNInArgCheck(argn(2),3,3); + + +FunNameCFuncList = ''; +SepChar = ','; +for cntelem = 1:CFuncListNElem + tmptokens = tokens(CommaSepCFuncList(cntelem),SepChar); + if (size(tmptokens,1) == 0) + FunNameCFuncList(cntelem) = FunctionName; + elseif (size(tmptokens,1) == 1) + if part(tmptokens,1:1) == ',' + FunNameCFuncList(cntelem) = FunctionName+tmptokens(2); + else + FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName; + end + elseif (size(tmptokens,1) == 2) + FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName+tmptokens(2); + else + disp('Incorrect format for the function list class.'); + disp('Check the following function list class item: ""'+CommaSepCFuncList(cntelem)+'"".'); + SCI2Cerror(' '); + end +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci new file mode 100644 index 00000000..b5d36d44 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci @@ -0,0 +1,21 @@ +function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile) +// function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile) +// ----------------------------------------------------------------- +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +SCI2CNInArgCheck(argn(2),2,2); + +load(ConvertedDatFile,'Converted'); + +if (NFilesToTranslate >= 1) + NConvP1 = size(Converted,1)+1; + Converted(NConvP1) = SharedInfo.NextCFunName; +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci new file mode 100644 index 00000000..52f9cc7f --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci @@ -0,0 +1,55 @@ +function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo) +// function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +SCI2CNInArgCheck(argn(2),11,11); + +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +SCI2CAvailableCDat = FileInfo.FunctionList.SCI2CAvailableCDat; +USER2CAvailableCDat = FileInfo.FunctionList.USER2CAvailableCDat; +ConvertedDat = FileInfo.FunctionList.ConvertedDat; +ToBeConvertedDat = FileInfo.FunctionList.ToBeConvertedDat; +FunInfoDatDir = FileInfo.FunctionList.FunInfoDatDir; + + +if (SharedInfo.SkipNextFun > 0) + PrintStringInfo(' Current function will not be inserted in the Function List.',ReportFileName,'file','y'); + return; +end + +if ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & ... + (SharedInfo.SkipNextPrec == 1)) + return; +end + +if ((mtlb_strcmp(ASTFunName,'OpEqual')) & ... + (SharedInfo.SkipNextEqual == 1)) + return; +end + +flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName); + +if (flagexist == %F) + + load(ToBeConvertedDat,'ToBeConverted'); + + NToConvP1 = size(ToBeConverted,1)+1; + ToBeConverted(NToConvP1).SCIFunctionName = ASTFunName; + ToBeConverted(NToConvP1).CFunctionName = CFunName; + + save(ToBeConvertedDat,ToBeConverted); + SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate + 1; + +end + +endfunction |