diff options
Diffstat (limited to 'macros/CCodeGeneration')
-rw-r--r-- | macros/CCodeGeneration/C_FinalizeCode.sci | 29 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_Funcall.sci | 281 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenDeclarations.sci | 28 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenDeclarations_Dup.sci | 194 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenerateFunName.sci | 40 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenerateMakefile.sci | 103 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenerateMakefile_msvc.sci | 57 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_GenerateMkfle_arduino.sci | 26 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_IfExpression.sci | 32 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_InitHeader.sci | 13 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_Type.sci | 27 | ||||
-rw-r--r-- | macros/CCodeGeneration/C_WhileExpression.sci | 29 | ||||
-rw-r--r-- | macros/CCodeGeneration/GetClsFileName.sci | 5 | ||||
-rw-r--r-- | macros/CCodeGeneration/JoinDeclarAndCcode.sci | 5 | ||||
-rw-r--r-- | macros/CCodeGeneration/names | 25 |
15 files changed, 702 insertions, 192 deletions
diff --git a/macros/CCodeGeneration/C_FinalizeCode.sci b/macros/CCodeGeneration/C_FinalizeCode.sci index 5c26dd85..33a1d791 100644 --- a/macros/CCodeGeneration/C_FinalizeCode.sci +++ b/macros/CCodeGeneration/C_FinalizeCode.sci @@ -45,11 +45,22 @@ PrintStringInfo('Generating the final C code in:'+FinalCFileName,... // --------------------------------- // --- Finalize the header file. --- // --------------------------------- +if(SharedInfo.OpenCVUsed) + PrintStringInfo('#include ""cvcore.hpp""',Pass1HeaderFileName,'file','y'); + PrintStringInfo('#include ""int_cvcore.hpp""',Pass1HeaderFileName,'file','y'); + PrintStringInfo('#include ""cvhighgui.hpp""',Pass1HeaderFileName,'file','y'); + PrintStringInfo('#include ""int_cvhighgui.hpp""',Pass1HeaderFileName,'file','y'); + PrintStringInfo('#include ""cvimgproc.hpp""',Pass1HeaderFileName,'file','y'); + PrintStringInfo('#include ""int_cvimgproc.hpp""',Pass1HeaderFileName,'file','y'); +end PrintStringInfo('/*',Pass1HeaderFileName,'file','y'); PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('** --- End USER2C Includes. --- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('*/',Pass1HeaderFileName,'file','y'); +//PrintStringInfo('#ifdef __cplusplus',Pass1HeaderFileName,'file','y'); +//PrintStringInfo('} /* extern ""C"" */',Pass1HeaderFileName,'file','y'); +//PrintStringInfo('#endif',Pass1HeaderFileName,'file','y'); PrintStringInfo('#endif',Pass1HeaderFileName,'file','y'); // ------------------------------------- // --- End Finalize the header file. --- @@ -70,6 +81,24 @@ PrintStringInfo('** ----------------- ',FinalCFileName,'file','y'); PrintStringInfo('*/',FinalCFileName,'file','y'); PrintStringInfo('#include ""'+tmphdrname+tmphdrext+'""',... FinalCFileName,'file','y'); +//If current file is main C file, include header files corresponding to ODE +//functions, if any. +if(SharedInfo.NextSCIFunName == SharedInfo.SCIMainFunName) + if(size(SharedInfo.Includelist) <> 0) //check if list is empty + //If not empty, add those header files here. + for cntlist = 1:size(SharedInfo.Includelist) + PrintStringInfo('#include ""'+SharedInfo.Includelist(cntlist)+'.h""',... + FinalCFileName,'file','y'); + end + + end +end + +//If current function contains ODEs, add gsl/gsl_errno.h. +if (mtlb_strcmp(part(SharedInfo.CurrentFunInfo.CFunctionName,1:5),'odefn') == %T) + PrintStringInfo('#include <gsl/gsl_errno.h>',... + FinalCFileName,'file','y'); +end PrintStringInfo('/*',FinalCFileName,'file','y'); PrintStringInfo('** --------------------- ',FinalCFileName,'file','y'); PrintStringInfo('** --- End Includes. --- ',FinalCFileName,'file','y'); diff --git a/macros/CCodeGeneration/C_Funcall.sci b/macros/CCodeGeneration/C_Funcall.sci index b130a622..450ad088 100644 --- a/macros/CCodeGeneration/C_Funcall.sci +++ b/macros/CCodeGeneration/C_Funcall.sci @@ -35,7 +35,7 @@ CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; CInitVarsFileName = FileInfo.Funct(nxtscifunnumber).CInitVarsFileName; IndentLevel = SharedInfo.NIndent; CCall = ''; - +Target = SharedInfo.Target; // --- Extract Function Info. --- FunctionName = FunInfo.SCIFunctionName; CFunName = FunInfo.CFunctionName; @@ -174,144 +174,205 @@ end // --- Generate the C call. --- // ---------------------------- CCall =''; -if (FunInfo.CFunctionName == SharedInfo.CMainFunName) - if (FlagCall == 1) - error(9999, 'main function called in a source code!'); - else - CCall =CCall+'int '; - end -else - if (PosFirstOutScalar >= 1) +if(mtlb_strcmp(part(CFunName,1:9),'PI_thread') == %T) +//Functions that are to be ru in separate thread in case of RPi target, +//need to have specific name which is PI_THREAD(functionname) + +CCall = CCall + 'PI_THREAD('+CFunName+')' +else + + if (FunInfo.CFunctionName == SharedInfo.CMainFunName) if (FlagCall == 1) - CCall = CCall+OutArg(PosFirstOutScalar).Name+' = '; + error(9999, 'main function called in a source code!'); else - CCall = CCall+C_Type(OutArg(PosFirstOutScalar).Type)+' '; + CCall =CCall+'int '; end + elseif ((mtlb_strcmp(part(CFunName,1:5),'odefn') == %T)) + //Return type of function containing ODEs must be int. + CCall = CCall + 'int '; else - if (FlagCall == 0) - CCall = CCall+'void '; + if (PosFirstOutScalar >= 1) + if (FlagCall == 1) + CCall = CCall+OutArg(PosFirstOutScalar).Name+' = '; + else + CCall = CCall+C_Type(OutArg(PosFirstOutScalar).Type)+' '; + end + else + if (FlagCall == 0) + CCall = CCall+'void '; + end end end -end -// FIXME : Wrap library function call with prefixed name + // FIXME : Wrap library function call with prefixed name -//if CFunName == "main" - CCall = CCall + CFunName + "("; -//else -// CCall = CCall+"SCI2C("+CFunName+")("; -//end + //if CFunName == "main" + CCall = CCall + CFunName + "("; + //else + // CCall = CCall+"SCI2C("+CFunName+")("; + //end -// #RNU_RES_B -PrintStringInfo(' C call after output scalar args check: '+CCall,ReportFileName,'file','y'); -// #RNU_RES_E -clear counterin -for counterin = 1:NInArg - - if (InArg(counterin).Type == 'g' & InArg(counterin).Scope == 'String') - TmpInArgName = '""'+InArg(counterin).Name+'""'; - elseif (InArg(counterin).Type == 'z' & (InArg(counterin).Scope == 'Number')) - TmpInArgName = 'DoubleComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; - elseif (InArg(counterin).Type == 'c' & (InArg(counterin).Scope == 'Number')) - TmpInArgName = 'FloatComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; - else - TmpInArgName = InArg(counterin).Name; - end + // #RNU_RES_B + PrintStringInfo(' C call after output scalar args check: '+CCall,ReportFileName,'file','y'); + // #RNU_RES_E + clear counterin + if(mtlb_strcmp(part(CFunName,1:5),'odefn') == %F) + for counterin = 1:NInArg - TmpInArgType = C_Type(InArg(counterin).Type); + if (InArg(counterin).Type == 'g' & InArg(counterin).Scope == 'String') + TmpInArgName = '""'+InArg(counterin).Name+'""'; + elseif (InArg(counterin).Type == 'z' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'DoubleComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + elseif (InArg(counterin).Type == 'c' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'FloatComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + else + TmpInArgName = InArg(counterin).Name; + end + TmpInArgType = C_Type(InArg(counterin).Type); - //if (FunctionName == 'OpEqual') - // TmpInArgSizeVar = '__'+OutArg(counterin).Name+'Size'; - // else - TmpInArgSizeVar = '__'+InArg(counterin).Name+'Size'; - //end + //if (FunctionName == 'OpEqual') + // TmpInArgSizeVar = '__'+OutArg(counterin).Name+'Size'; + // else + TmpInArgSizeVar = '__'+InArg(counterin).Name+'Size'; + //end - if (InArg(counterin).Dimension == 0) - if (FlagCall == 0) - CCall = CCall+TmpInArgType+' '; + if (InArg(counterin).Dimension == 0) + if (FlagCall == 0) + CCall = CCall+TmpInArgType+' '; + end + CCall = CCall+TmpInArgName+','; + else + if (FlagCall == 0) + CCall = CCall+TmpInArgType+'* '+TmpInArgName+', int* __'+TmpInArgName+'Size,'; + else + CCall = CCall+TmpInArgName+', '+TmpInArgSizeVar+','; + end + end end - CCall = CCall+TmpInArgName+','; else - if (FlagCall == 0) - CCall = CCall+TmpInArgType+'* '+TmpInArgName+', int* __'+TmpInArgName+'Size,'; - else - CCall = CCall+TmpInArgName+', '+TmpInArgSizeVar+','; + //If current function contains 'odefn' at the beginning, then it contains + //differnetial equations and its function call need to be differnt than + //other function call. GSL library being used for solving ODEs, requires + //function containing odes in specific format which is differnt than generated + //above. + for counterin = 1:NInArg + + //if((NInArg == 4 & counterin <> 3) | (NInArg == 5 & counterin <> 4)) //Skip third argument + if (InArg(counterin).Type == 'g' & InArg(counterin).Scope == 'String') + TmpInArgName = '""'+InArg(counterin).Name+'""'; + elseif (InArg(counterin).Type == 'z' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'DoubleComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + elseif (InArg(counterin).Type == 'c' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'FloatComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + else + TmpInArgName = InArg(counterin).Name; + end + + TmpInArgType = C_Type(InArg(counterin).Type); + + //if (FunctionName == 'OpEqual') + // TmpInArgSizeVar = '__'+OutArg(counterin).Name+'Size'; + // else + TmpInArgSizeVar = '__'+InArg(counterin).Name+'Size'; + //end + + if (InArg(counterin).Dimension == 0) + if (FlagCall == 0) + CCall = CCall+TmpInArgType+' '; + end + CCall = CCall+TmpInArgName+','; + else + if (FlagCall == 0) + CCall = CCall+TmpInArgType+'* '+TmpInArgName+', ';//int* __'+TmpInArgName+'Size,'; + else + CCall = CCall+TmpInArgName+', ';//+TmpInArgSizeVar+','; + end + end + //end end + end -end -// #RNU_RES_B -PrintStringInfo(' C call after input args analysis: '+CCall,ReportFileName,'file','y'); -// #RNU_RES_E -for counterout = 1:NOutArg - TmpOutArgName = OutArg(counterout).Name; - TmpOutArgType = C_Type(OutArg(counterout).Type); - if (counterout == PosFirstOutScalar) - if (FlagCall == 0) - // #RNU_RES_B - // --- Write in the declaration file the returned output scalar (if any). --- - // #RNU_RES_E - outscalardeclaration = TmpOutArgType+' '+TmpOutArgName+';'; - // #RNU_RES_B - PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); - // #RNU_RES_E - PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); - PrintStringInfo(' ',CDeclarationFileName,'file','y'); - end - else - if (OutArg(counterout).Dimension == 0) + + // #RNU_RES_B + PrintStringInfo(' C call after input args analysis: '+CCall,ReportFileName,'file','y'); + // #RNU_RES_E + for counterout = 1:NOutArg + TmpOutArgName = OutArg(counterout).Name; + TmpOutArgType = C_Type(OutArg(counterout).Type); + if (counterout == PosFirstOutScalar) if (FlagCall == 0) + // #RNU_RES_B // --- Write in the declaration file the returned output scalar (if any). --- + // #RNU_RES_E outscalardeclaration = TmpOutArgType+' '+TmpOutArgName+';'; + // #RNU_RES_B PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + // #RNU_RES_E PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); PrintStringInfo(' ',CDeclarationFileName,'file','y'); - CCall = CCall+TmpOutArgType+'* __ptr'+TmpOutArgName+', '; - else - CCall = CCall+'&'+TmpOutArgName+', ';//NUT: verifica se ci vuole l'& end else - if (FlagCall == 0) - CCall = CCall+TmpOutArgType+'* '+TmpOutArgName+','; - if (OutArg(counterout).FindLike == 1) - CCall = CCall+'int* __'+TmpOutArgName+'Size'+','; + if (OutArg(counterout).Dimension == 0) + if (FlagCall == 0) + // --- Write in the declaration file the returned output scalar (if any). --- + outscalardeclaration = TmpOutArgType+' '+TmpOutArgName+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); + PrintStringInfo(' ',CDeclarationFileName,'file','y'); + CCall = CCall+TmpOutArgType+'* __ptr'+TmpOutArgName+', '; + else + CCall = CCall+'&'+TmpOutArgName+', ';//NUT: verifica se ci vuole l'& end - // #RNU_RES_B - //NUT prova a sostituire le variabili strutture con variabili dichiarate all'inizio del codice. - // --- Declare the size of the output arguments. --- - // #RNU_RES_E - outscalardeclaration = 'int __'+TmpOutArgName+'Size[2];'; - PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); - PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); - outscalardeclaration = '__'+TmpOutArgName+'Size[0] = '+(OutArg(counterout).Size(1))+';'; - PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); - PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); - outscalardeclaration = '__'+TmpOutArgName+'Size[1] = '+(OutArg(counterout).Size(2))+';'; - PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); - PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); - PrintStringInfo(' ',CInitVarsFileName,'file','y'); else - CCall = CCall+OutArg(counterout).Name+','; - if (OutArg(counterout).FindLike == 1) - CCall = CCall+'(int* ) __'+TmpOutArgName+'Size'+','; + if (FlagCall == 0) + CCall = CCall+TmpOutArgType+'* '+TmpOutArgName+','; + if (OutArg(counterout).FindLike == 1) + CCall = CCall+'int* __'+TmpOutArgName+'Size'+','; + end + // #RNU_RES_B + //NUT prova a sostituire le variabili strutture con variabili dichiarate all'inizio del codice. + // --- Declare the size of the output arguments. --- + // #RNU_RES_E + outscalardeclaration = 'int __'+TmpOutArgName+'Size[2];'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); + outscalardeclaration = '__'+TmpOutArgName+'Size[0] = '+(OutArg(counterout).Size(1))+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); + outscalardeclaration = '__'+TmpOutArgName+'Size[1] = '+(OutArg(counterout).Size(2))+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); + PrintStringInfo(' ',CInitVarsFileName,'file','y'); + else + CCall = CCall+OutArg(counterout).Name+','; + if (OutArg(counterout).FindLike == 1) + CCall = CCall+'(int* ) __'+TmpOutArgName+'Size'+','; + end end end end end -end -PrintStringInfo(' C call after output args analysis: '+CCall,ReportFileName,'file','y'); -// Remove the last " " and "," -if (part(CCall,length(CCall):length(CCall)) == ' ') - CCall = part(CCall,1:length(CCall)-1); -end -if (part(CCall,length(CCall):length(CCall)) == ',') - CCall = part(CCall,1:length(CCall)-1); -end + PrintStringInfo(' C call after output args analysis: '+CCall,ReportFileName,'file','y'); + // Remove the last " " and "," + if (part(CCall,length(CCall):length(CCall)) == ' ') + CCall = part(CCall,1:length(CCall)-1); + end + if (part(CCall,length(CCall):length(CCall)) == ',') + CCall = part(CCall,1:length(CCall)-1); + end -CCall = CCall+')'; -if (FlagCall == 1) - CCall = CCall+';'; -end + //__ysize is added to input arguments at last to comply with form required by GSL + if(mtlb_strcmp(part(CFunName,1:5),'odefn') == %T) + CCall = CCall + ', int* '+TmpInArgSizeVar; + end + + CCall = CCall+')'; + if (FlagCall == 1) + CCall = CCall+';'; + end + +end //NUT: la parte di generazione della C call va inserita in una funzione a parte. //NUT: tale funzione deve avere anche uno switch che consenta di generare differenti versioni //NUT: delle chiamate C in accordo con la libreria disponibile, fermo restando che @@ -352,8 +413,12 @@ if mtlb_strcmp(FunctionName,'return') PrintStringInfo(' return function of the AST is skipped.',ReportFileName,'file','y'); //RN provo a non skippare e a mettere la return. // #RNU_RES_E + if (SharedInfo.CurrentFunInfo.CFunctionName == SharedInfo.CMainFunName) CCall = CCall+'return(0);'; + elseif (mtlb_strcmp(part(SharedInfo.CurrentFunInfo.CFunctionName,1:5),'odefn') == %T) + //For GSL library, function containing ODEs must return GSL_SUCCESS + CCall = CCall + 'return GSL_SUCCESS;' else if (SharedInfo.CurrentFunInfo.PosFirstOutScalar > 0) CCall = CCall+'return('+SharedInfo.CurrentFunInfo.OutArg(SharedInfo.CurrentFunInfo.PosFirstOutScalar).Name+');' @@ -371,7 +436,7 @@ else if (FlagCall == 0) // Add prototype to the header file - C_InitHeader(CCall+';',HeaderFileName,SharedInfo.Sci2CLibMainHeaderFName); + C_InitHeader(CCall+';',HeaderFileName,SharedInfo.Sci2CLibMainHeaderFName,Target,SharedInfo.OpenCVUsed); // Add { at the beginning of the function. PrintStringInfo(' {',ReportFileName,'file','y'); diff --git a/macros/CCodeGeneration/C_GenDeclarations.sci b/macros/CCodeGeneration/C_GenDeclarations.sci index 7a6565ec..41ba3a91 100644 --- a/macros/CCodeGeneration/C_GenDeclarations.sci +++ b/macros/CCodeGeneration/C_GenDeclarations.sci @@ -92,24 +92,28 @@ if (ArgStruct.Dimension > 0) Cdeclaration(2) = Cdeclaration(2)+';'; end else - if (FlagExt == 1) - Cdeclaration(1) = 'extern '; + if (ArgStruct.Type == 'fn') + //do nothing. This is a function name. Will be declared in header file. else - Cdeclaration(1) = ''; - end - Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name; - if (~isnan(ArgStruct.Value) & (FlagExt == 0)) - if isreal(ArgStruct.Value) - Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value); + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; else - if (ArgStruct.Type == 'z') - Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + Cdeclaration(1) = ''; + end + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name; + if (~isnan(ArgStruct.Value) & (FlagExt == 0)) + if isreal(ArgStruct.Value) + Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value); else - Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + if (ArgStruct.Type == 'z') + Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + else + Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + end end end + Cdeclaration(1) = Cdeclaration(1)+';'; end - Cdeclaration(1) = Cdeclaration(1)+';'; end diff --git a/macros/CCodeGeneration/C_GenDeclarations_Dup.sci b/macros/CCodeGeneration/C_GenDeclarations_Dup.sci new file mode 100644 index 00000000..bdaf9c0e --- /dev/null +++ b/macros/CCodeGeneration/C_GenDeclarations_Dup.sci @@ -0,0 +1,194 @@ +function Cdeclaration = C_GenDeclarations_Dup(InArg,NInArg,com_type,ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// 25-June-2017 -- Ukasha Noor: Modified it. +// This function is called for array declaration in C. +// +// 10-Jun-2008 -- Raffaele Nutricato: adapted to work with realloc function. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// Generate C corresponding declaration given some information in ArgStruct +// + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),9,9); +// #RNU_RES_B +//NUT: ilnome di questa funzione va cambiato perche' le dichiarazioni le fanno anche i for e i while. + +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C declaration***',ReportFileName,'file','y'); +// #RNU_RES_E + +Cdeclaration = ''; +if (ArgStruct.Dimension > 0) + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + Cdeclaration(2) = 'extern '; + else + Cdeclaration(1) = ''; + Cdeclaration(2) = ''; + end +// #RNU_RES_B +//NUT: vedi Mem_Alloc_Out per maggiori info sulla rimozione della temp nella if +// if ((ArgStruct.Scope=='Temp') | (ArgStruct.FindLike == -1) | (isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F)) +// #RNU_RES_E + if (ArgStruct.Type=='g') +// if (isnan(ArgStruct.Value) ) + if ((isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F) ) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' * '+ArgStruct.Name+';'; + else + if ((FlagExt == 1) | (isnan(ArgStruct.Value))) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'] = {'+ArgStruct.Value+'};'; + end + end + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};'; + elseif ((ArgStruct.FindLike == -1) | ... + (isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F) | ... + (ResizeApproach=='REALLOC_ALL_RESIZE_ALL' & ArgStruct.Type~='g')) +// #RNU_RES_B +//RNU sulle stringhe non ho ancora deciso se applicare la realloc. +// Generate only the pointer that will be used by the malloc function. +// #RNU_RES_E + if (FlagExt == 1) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+';'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+' = NULL;'; + end +// Declare the Size array + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];'; + else +// Declare the array with its size. + computedSize = ArgStruct.Size(1); + computedSizeLength = size(ArgStruct.Size, '*'); + computedSizeField = ArgStruct.Size(1); + for sizeIterator = 2:computedSizeLength; + computedSize = computedSize + ' * ' + ArgStruct.Size(sizeIterator); + computedSizeField = computedSizeField + ', ' + ArgStruct.Size(sizeIterator); + end +// Modified Changes: row tells number of rows and col is number of columns in array. +// col_type tells whether it is floatComplex or doubleComplex or real. +// and accordingly it declares the array. + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name+'['+computedSize+']={'; + row = eval(ArgStruct.Size(1)) + col = eval(ArgStruct.Size(2)) + if row == 1 + if com_type == 0 + for i = 1:NInArg-1 + Cdeclaration(1) = Cdeclaration(1)+InArg(i).Name+','; + end + Cdeclaration(1) = Cdeclaration(1)+InArg(NInArg).Name+'};'; + else + for i=1:NInArg-1 + if InArg(i).Type <> 'z' & InArg(i).Type <> 'c' + Cdeclaration(1) = Cdeclaration(1)+InArg(i).Name+',0,'; + else + Cdeclaration(1) = Cdeclaration(1)+InArg(i).Name+','; + end + end + if InArg(NInArg).Type <> 'z' & InArg(NInArg).Type <> 'c' + Cdeclaration(1) = Cdeclaration(1) + InArg(NInArg).Name + ',0};' + else + Cdeclaration(1) = Cdeclaration(1) + InArg(NInArg).Name + '};' + end + end + else + if com_type == 0 + for i = 1:col + for j = 0:row-1 + if (j*col)+i ~= row*col + Cdeclaration(1) = Cdeclaration(1) + InArg(((j*col)+i)).Name + ','; + end + end + end + Cdeclaration(1) = Cdeclaration(1) + InArg(NInArg).Name + '};'; + else + for i = 1:col + for j = 0:row-1 + if (j*col)+i ~= row*col + if InArg(((j*col)+i)).Type <> 'z' & InArg(((j*col)+i)).Type <> 'c' + Cdeclaration(1) = Cdeclaration(1) + InArg(((j*col)+i)).Name + ',0,'; + else + Cdeclaration(1) = Cdeclaration(1) + InArg(((j*col)+i)).Name + ','; + end + end + end + end + if InArg(NInArg).Type <> 'z' & InArg(NInArg).Type <> 'c' + Cdeclaration(1) = Cdeclaration(1) + InArg(NInArg).Name + ',0};'; + else + Cdeclaration(1) = Cdeclaration(1) + InArg(NInArg).Name + '};'; + end + end + end + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size['+string(computedSizeLength)+']'; + if (FlagExt <> 1) + Cdeclaration(2) = Cdeclaration(2)+' = {'+computedSizeField+'}'; + end + Cdeclaration(2) = Cdeclaration(2)+';'; + end +else + if (ArgStruct.Type == 'fn') + //do nothing. This is a function name. Will be declared in header file. + else + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + else + Cdeclaration(1) = ''; + end + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name; + if (~isnan(ArgStruct.Value) & (FlagExt == 0)) + if isreal(ArgStruct.Value) + Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value); + else + if (ArgStruct.Type == 'z') + Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + else + Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + end + end + end + Cdeclaration(1) = Cdeclaration(1)+';'; + end +end + + +// -------------------------------------------- +// --- Write C declaration into the C file. --- +// -------------------------------------------- +PrintStringInfo(' ',CDeclarationFileName,'file','y'); +for cntdecl = 1:size(Cdeclaration, '*') + PrintStringInfo(' '+Cdeclaration(cntdecl),ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(IndentLevel)+Cdeclaration(cntdecl),CDeclarationFileName,'file','y'); +end + +PrintStringInfo(' Writing C declaration in: '+CDeclarationFileName,ReportFileName,'file','y'); +PrintStringInfo(' ',CDeclarationFileName,'file','y'); + +endfunction +// #RNU_RES_B +//NUT: dove sta il controllo che verifica se dopo aver dichiarato una local A[10] essa viene utilizzata +//NUT: per memorizzare un A = sin(B) dove B[11]?? +// #RNU_RES_E diff --git a/macros/CCodeGeneration/C_GenerateFunName.sci b/macros/CCodeGeneration/C_GenerateFunName.sci index 9d40d2b9..a1373ded 100644 --- a/macros/CCodeGeneration/C_GenerateFunName.sci +++ b/macros/CCodeGeneration/C_GenerateFunName.sci @@ -23,22 +23,34 @@ function CFunName = C_GenerateFunName(FunctionName,InArg,NInArg,OutArg,NOutArg) // ------------------------------ SCI2CNInArgCheck(argn(2),5,5); CFunName = ''; +if((IsAVRSupportFunction(FunctionName)) | (IsRPISupportFunction(FunctionName)) | ... + (mtlb_strcmp(part(FunctionName,1:5),'odefn') == %T) |... + (mtlb_strcmp(part(FunctionName,1:9),'PI_thread') == %T)| ... + (mtlb_strcmp(part(FunctionName,1:4),'ISR_') == %T)) +//If current function is an AVR or RPi function, then function name can be just +//plain function name without any input/output arguments types +//Slimilarly for functions conataining ode functions and functions to be called in +//separate thread in RPi + CFunName = CFunName+FunctionName; -for tmpcnt = 1:NInArg - if (InArg(tmpcnt).Dimension == 1) - CFunName = CFunName+InArg(tmpcnt).Type+'2'; - else - CFunName = CFunName+InArg(tmpcnt).Type+SCI2Cstring(InArg(tmpcnt).Dimension); - end -end +else + for tmpcnt = 1:NInArg + if (InArg(tmpcnt).Dimension == 1) + CFunName = CFunName+InArg(tmpcnt).Type+'2'; + else + CFunName = CFunName+InArg(tmpcnt).Type+SCI2Cstring(InArg(tmpcnt).Dimension); + end + end + + CFunName = CFunName+FunctionName; -CFunName = CFunName+FunctionName; + for tmpcnt = 1:NOutArg + if (OutArg(tmpcnt).Dimension == 1) + CFunName = CFunName+OutArg(tmpcnt).Type+'2'; + else + CFunName = CFunName+OutArg(tmpcnt).Type+SCI2Cstring(OutArg(tmpcnt).Dimension); + end + end -for tmpcnt = 1:NOutArg - if (OutArg(tmpcnt).Dimension == 1) - CFunName = CFunName+OutArg(tmpcnt).Type+'2'; - else - CFunName = CFunName+OutArg(tmpcnt).Type+SCI2Cstring(OutArg(tmpcnt).Dimension); - end end endfunction diff --git a/macros/CCodeGeneration/C_GenerateMakefile.sci b/macros/CCodeGeneration/C_GenerateMakefile.sci index 8956d51d..dbdae9d3 100644 --- a/macros/CCodeGeneration/C_GenerateMakefile.sci +++ b/macros/CCodeGeneration/C_GenerateMakefile.sci @@ -1,3 +1,5 @@ +//Removed 4 lines code from end that causes ot generate the Makefile.mak file that is not needed with cygwin +//Changed at line 52 function C_GenerateMakefile(FileInfo,SharedInfo) // function C_GenerateMakefile(FileInfo,SharedInfo) // ----------------------------------------------------------------- @@ -26,6 +28,8 @@ SCI2CNInArgCheck(argn(2),2,2); // ----------------------- PrintStepInfo('Generating Builder '+FileInfo.MakefileFilename,... FileInfo.GeneralReport,'both'); + +target = SharedInfo.Target; // --------------------------- // --- End Initialization. --- // --------------------------- @@ -41,53 +45,103 @@ PrintStringInfo('# --- DIRECTORIES AND FILES ---',FileInfo.MakefileFilename,'fil makecsrcdir = pathconvert('src/c', %f, %f, 'u'); makehsrcdir = pathconvert('includes', %f, %f, 'u'); makeisrcdir = pathconvert('interfaces', %f, %f, 'u'); +makelibdir = pathconvert('libraries', %f, %f, 'u'); makesci2cdir = FileInfo.CStyleOutCCCodeDir; PrintStringInfo('CSRCDIR = '+makecsrcdir,FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('HSRCDIR = '+makehsrcdir,FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('ISRCDIR = '+makeisrcdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('LIBDIR = '+makelibdir,FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('SCI2CDIR = .',FileInfo.MakefileFilename,'file','y','y'); -// Compiler definition -PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('CFLAGS = -Wall -pedantic -I $(HSRCDIR) -I $(ISRCDIR)',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('LDFLAGS = -lblas -llapack -lm',FileInfo.MakefileFilename,'file','y','y'); +if getos() == 'Windows' then + + // Compiler definition + PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXX = g++',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXXFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS = -L./ -lblasplus -llapack -lm',FileInfo.MakefileFilename,'file','y','y'); //Added -L./ and -lblasplus(previously it was -lblas) + +else + if (target == 'RPi') + PrintStringInfo('CC = arm-linux-gnueabihf-gcc ',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXX = arm-linux-gnueabihf-g++ ',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR) -L $(LIBDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXXFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR) -L $(LIBDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS = -llapack -lrefblas -lgfortran -lwiringPi -lwiringPiDev -lrt -lpthread -lRPIwfi',FileInfo.MakefileFilename,'file','y','y'); + else + PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXX = g++',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR) -L $(LIBDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('CXXFLAGS = -Wall -pedantic -g -I $(HSRCDIR) -I $(ISRCDIR) -L $(LIBDIR)',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS = -lblas -llapack -lm ',FileInfo.MakefileFilename,'file','y','y'); + end + + //If ode function is used, add libgsl. + if(size(SharedInfo.Includelist) <> 0) + if((mtlb_strcmp(part(SharedInfo.Includelist(1),1:5),'odefn') == %T)) + if(target == 'RPi') + PrintStringInfo('LDFLAGS = -lgsl -lcblas',FileInfo.MakefileFilename,'file','y','y'); + else + PrintStringInfo('LDFLAGS = -lgsl',FileInfo.MakefileFilename,'file','y','y'); + end + + end + end + + if (target == 'RPi') + PrintStringInfo('LDFLAGS += -llapack -lrefblas -lgfortran -lwiringPi',FileInfo.MakefileFilename,'file','y','y'); + else + PrintStringInfo('LDFLAGS += -lblas -llapack -lm ',FileInfo.MakefileFilename,'file','y','y'); + end + + if(SharedInfo.OpenCVUsed == %T) + PrintStringInfo('LDFLAGS += -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS += -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS += -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS += -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_core -lrt -lpthread -lm -ldl', FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('LDFLAGS += -lIlmImf -ljpeg -ljasper -ltiff -lpng -lzlib -lstdc++',FileInfo.MakefileFilename,'file','y','y'); + end +end +//If ode function is used, add libgsl. +if(size(SharedInfo.Includelist) <> 0) + if((mtlb_strcmp(part(SharedInfo.Includelist(1),1:5),'odefn') == %T)) + PrintStringInfo('LDFLAGS += -lgsl',FileInfo.MakefileFilename,'file','y','y'); + end +end // Binary definition -PrintStringInfo('EXEFILENAME = mytest.exe',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILENAME = '+SharedInfo.SCIMainFunName,FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)', FileInfo.MakefileFilename,'file','y','y'); // Sources -PrintStringInfo('SRC = \\', FileInfo.MakefileFilename,'file','y','y'); -allSources = getAllSources(); -nbSources = size(allSources); -for i = 1:(nbSources(1) - 1) - [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); - PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', FileInfo.MakefileFilename,'file','y','y'); -end -[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); -PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, FileInfo.MakefileFilename,'file','y','y'); +//Check the output format selected and insert files according to it +PrintStringInfo('SRC = $(wildcard $(CSRCDIR)/*.c)', FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('SRCC = $(wildcard $(CSRCDIR)/*.cpp)', FileInfo.MakefileFilename,'file','y','y'); // Objects PrintStringInfo('OBJ = $(SRC:.c=.o)', FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('OBJC = $(SRCC:.cpp=.o)', FileInfo.MakefileFilename,'file','y','y'); // Rules PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('# --- TARGETS ---',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('compileexecute: $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('compileexecute: $(OBJ) $(OBJC)',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""Generation of the executable""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('\t$(CC) $(CFLAGS) $(OBJ) *.c $(LDFLAGS) -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(CXX) $(CFLAGS) $(OBJ) $(OBJC) *.c $(LDFLAGS) -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); -PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); - +if(target == "StandAlone") + PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +end PrintStringInfo('clean:',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); @@ -95,6 +149,7 @@ PrintStringInfo('\t@echo ""Removing only exe + obj files""',FileInfo.MakefileFil PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\trm -rf $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(OBJC)',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('distclean: clean',FileInfo.MakefileFilename,'file','y','y'); @@ -105,8 +160,6 @@ PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilena PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); -if getos() == 'Windows' then - C_GenerateMakefile_msvc(FileInfo,SharedInfo); -end -endfunction
\ No newline at end of file + +endfunction diff --git a/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci b/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci index b49a2c31..00ffb63c 100644 --- a/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci +++ b/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci @@ -24,6 +24,8 @@ MakefileFilename = FileInfo.MakefileFilename + '.mak'; PrintStepInfo('Generating Builder '+MakefileFilename,... FileInfo.GeneralReport,'both'); +target = SharedInfo.Target; + PrintStringInfo('# SCI2C Makefile (Visual Studio 2008)',MakefileFilename,'file','y','y'); PrintStringInfo('# hArtes EU Project.',MakefileFilename,'file','y','y'); PrintStringInfo('# Authors: PoliBa & Inria & DIGITEO',MakefileFilename,'file','y','y'); @@ -35,37 +37,54 @@ PrintStringInfo('# --- DIRECTORIES AND FILES ---',MakefileFilename,'file','y','y makecsrcdir = pathconvert('src/c', %f, %f, 'u'); makehsrcdir = pathconvert('includes', %f, %f, 'u'); makeisrcdir = pathconvert('interfaces', %f, %f, 'u'); +makelibdir = pathconvert('libraries', %f, %f, 'u'); makesci2cdir = FileInfo.CStyleOutCCCodeDir; + PrintStringInfo('CSRCDIR = '+makecsrcdir,MakefileFilename,'file','y','y'); PrintStringInfo('HSRCDIR = '+makehsrcdir,MakefileFilename,'file','y','y'); PrintStringInfo('ISRCDIR = '+makeisrcdir,MakefileFilename,'file','y','y'); PrintStringInfo('SCI2CDIR = .',MakefileFilename,'file','y','y'); PrintStringInfo('DIR_OBJ=Release',MakefileFilename,'file','y','y'); -PrintStringInfo('LAPACK_LIB =$(SCI2CDIR)/external-libs/lapack.lib',MakefileFilename,'file','y','y'); -PrintStringInfo('BLAS_LIB = $(SCI2CDIR)/external-libs/blasplus.lib',MakefileFilename,'file','y','y'); +//PrintStringInfo('LAPACK_LIB =$(SCI2CDIR)/libraries/lapack.lib',MakefileFilename,'file','y','y'); +//PrintStringInfo('BLAS_LIB = $(SCI2CDIR)/libraries/blasplus.lib',MakefileFilename,'file','y','y'); +PrintStringInfo('LIB_PATH = $(SCI2CDIR)/libraries',MakefileFilename,'file','y','y'); +PrintStringInfo('LIBS = lapack.lib blasplus.lib',MakefileFilename,'file','y','y'); +PrintStringInfo('LIBS = $(LIBS) kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib',MakefileFilename,'file','y','y'); PrintStringInfo('CC = cl',MakefileFilename,'file','y','y'); PrintStringInfo('LINKER = link',MakefileFilename,'file','y','y'); PrintStringInfo('LINKER_OPTIMISATION_MODE=/RELEASE ',MakefileFilename,'file','y','y'); -PrintStringInfo('CC__OPTIMISATION_MODE=-Z7 -O2 -MD',MakefileFilename,'file','y','y'); +PrintStringInfo('CC__OPTIMISATION_MODE=-Z7 -O2 -MT',MakefileFilename,'file','y','y'); PrintStringInfo('CC_OPTIONS = $(CC_COMMON) -W3 -Gd $(CC__OPTIMISATION_MODE) /Fo""$(DIR_OBJ)/"" /Fd""$(DIR_OBJ)/"" ',MakefileFilename,'file','y','y'); PrintStringInfo('CFLAGS = $(CC_OPTIONS) -I""$(HSRCDIR)"" -I""$(ISRCDIR)"" /EHsc /TP ',MakefileFilename,'file','y','y'); -PrintStringInfo('EXEFILENAME = mytest',MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILENAME = '+SharedInfo.SCIMainFunName,MakefileFilename,'file','y','y'); PrintStringInfo('EXEFILE = $(SCI2CDIR)\\$(EXEFILENAME)',MakefileFilename,'file','y','y'); PrintStringInfo('MAIN_SRC = $(SCI2CDIR)/main.c',MakefileFilename,'file','y','y'); -// Sources -PrintStringInfo('SRC = \\', MakefileFilename,'file','y','y'); -allSources = getAllSources(); -nbSources = size(allSources); -for i = 1:(nbSources(1) - 1) - [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); - PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', MakefileFilename,'file','y','y'); +if(SharedInfo.OpenCVUsed == %T) + PrintStringInfo('LIBS = $(LIBS) opencv_calib3d2413.lib opencv_contrib2413.lib opencv_features2d2413.lib',MakefileFilename,'file','y','y'); + PrintStringInfo('LIBS = $(LIBS) opencv_flann2413.lib opencv_gpu2413.lib opencv_highgui2413.lib ',MakefileFilename,'file','y','y'); + PrintStringInfo('LIBS = $(LIBS) opencv_imgproc2413.lib opencv_legacy2413.lib opencv_ml2413.lib opencv_nonfree2413.lib',MakefileFilename,'file','y','y'); + PrintStringInfo('LIBS = $(LIBS) opencv_objdetect2413.lib opencv_ocl2413.lib opencv_photo2413.lib opencv_stitching2413.lib',MakefileFilename,'file','y','y'); + PrintStringInfo('LIBS = $(LIBS) opencv_superres2413.lib opencv_ts2413.lib opencv_video2413.lib opencv_videostab2413.lib opencv_core2413.lib',MakefileFilename,'file','y','y'); + PrintStringInfo('LIBS = $(LIBS) IlmImf.lib libjpeg.lib libjasper.lib libtiff.lib libpng.lib zlib.lib',MakefileFilename,'file','y','y'); end -[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); -PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, MakefileFilename,'file','y','y'); +// Sources +PrintStringInfo('SRC = $(CSRCDIR)/*.c', MakefileFilename,'file','y','y'); +PrintStringInfo('SRCC = $(CSRCDIR)/*.cpp', MakefileFilename,'file','y','y'); + +//PrintStringInfo('SRC = \\', MakefileFilename,'file','y','y'); +//allSources = getAllSources(); +//nbSources = size(allSources); +//for i = 1:(nbSources(1) - 1) +// [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); +// PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', MakefileFilename,'file','y','y'); +//end +//[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); +//PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, MakefileFilename,'file','y','y'); PrintStringInfo('OBJ = $(SRC:.c=.obj) $(MAIN_SRC:.c=.obj)',MakefileFilename,'file','y','y'); +PrintStringInfo('OBJC = $(SRCC:.cpp=.o)', MakefileFilename,'file','y','y'); PrintStringInfo('# ---------------',MakefileFilename,'file','y','y'); PrintStringInfo('# --- TARGETS ---',MakefileFilename,'file','y','y'); PrintStringInfo('# ---------------',MakefileFilename,'file','y','y'); @@ -75,12 +94,14 @@ PrintStringInfo('\t@echo ""============================""',MakefileFilename,'fil PrintStringInfo('\t@echo ""Generation of the executable""',MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""============================""',MakefileFilename,'file','y','y'); PrintStringInfo('\t-IF NOT EXIST $(DIR_OBJ) mkdir $(DIR_OBJ)',MakefileFilename,'file','y','y'); -PrintStringInfo('\t$(CC) $(CFLAGS) $(SRC) $(MAIN_SRC) /link $(LAPACK_LIB) $(BLAS_LIB) /out:$(EXEFILE).exe',MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(CC) $(CFLAGS) $(SRC) $(SRCC) $(MAIN_SRC) /link /LIBPATH:$(LIB_PATH) $(LIBS) /out:$(EXEFILE).exe',MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""Executing code""',MakefileFilename,'file','y','y'); -PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); -PrintStringInfo('\t$(EXEFILE).exe',MakefileFilename,'file','y','y'); +if(target == "StandAlone") + PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); + PrintStringInfo('\t@echo ""Executing code""',MakefileFilename,'file','y','y'); + PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); + PrintStringInfo('\t$(EXEFILE).exe',MakefileFilename,'file','y','y'); +end PrintStringInfo('clean:',MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); PrintStringInfo('\t@echo ""=============================""',MakefileFilename,'file','y','y'); diff --git a/macros/CCodeGeneration/C_GenerateMkfle_arduino.sci b/macros/CCodeGeneration/C_GenerateMkfle_arduino.sci new file mode 100644 index 00000000..8b890f97 --- /dev/null +++ b/macros/CCodeGeneration/C_GenerateMkfle_arduino.sci @@ -0,0 +1,26 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE + +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author: Yash Pratap Singh Tomar +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + + + +function C_GenerateMkfle_arduino(FileInfo,SharedInfo) + + PrintStringInfo('ARDUINO_DIR = /usr/share/arduino',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('ARDMK_DIR = /usr/share/arduino',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('AVR_TOOLS_DIR = /usr',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('BOARD_TAG = ' + SharedInfo.Board_name ,FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('USER_LIB_PATH = ../',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('ARDUINO_LIBS = ../src/c ../includes ../interfaces ../ Wire',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('ARDUINO_PORT = /dev/ttyACM0',FileInfo.MakefileFilename,'file','y','y'); + PrintStringInfo('include /usr/share/arduino/Arduino.mk',FileInfo.MakefileFilename,'file','y','y'); + +endfunction diff --git a/macros/CCodeGeneration/C_IfExpression.sci b/macros/CCodeGeneration/C_IfExpression.sci index 48a05383..630134e1 100644 --- a/macros/CCodeGeneration/C_IfExpression.sci +++ b/macros/CCodeGeneration/C_IfExpression.sci @@ -1,4 +1,4 @@ -function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) +function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,Op,NOp,ASTIfExpType,FileInfo,SharedInfo) // function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) // ----------------------------------------------------------------- // //NUT: add description here @@ -11,6 +11,7 @@ function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo, // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. +// 28-June-2017 -- Ukasha Noor: Modified By // // Copyright 2007 Raffaele Nutricato. // Contact: raffaele.nutricato@tiscali.it @@ -19,12 +20,16 @@ function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo, // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),5,5); +SCI2CNInArgCheck(argn(2),7,7); + +//global SCI2CSTACK +//global StackPosition; +//global STACKDEDUG // --- Check NIfCondArg value. --- -if ((NIfCondArg ~= 1) & (ASTIfExpType~='else')) - error(9999, 'Cannot manage ""if/elseif"" with a number of condition variables not equal to 1.'); -end +//if ((NIfCondArg ~= 1) & (ASTIfExpType~='else')) + // error(9999, 'Cannot manage ""if/elseif"" with a number of condition variables not equal to 1.'); +//end // ----------------------- // --- Initialization. --- @@ -37,7 +42,7 @@ CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; // #RNU_RES_B PrintStringInfo(' ',ReportFileName,'file','y'); -PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***'+ string(NIfCondArg),ReportFileName,'file','y'); // #RNU_RES_E // --------------------------- // --- End Initialization. --- @@ -66,10 +71,23 @@ if SCI2Cstrncmps1size(ASTIfExpType,'else') SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,'out'); end +i=1; +k=1; CCall =''; CCall = CCall+CFunName; if (ASTIfExpType~='else') - CCall = CCall+'('+IfCondArg(1)+')'; + CCall = CCall+'('; + while i <= NIfCondArg + CCall = CCall + IfCondArg(i) + ' '; + //d = modulo(i,3); + //PrintStringInfo(' '+string(i)+string(d),'file','y'); + if (modulo(i,3)==0 & i<>NIfCondArg) + CCall = CCall + Op(k) + ' '; + k = k + 1; + end + i = i + 1; + end + CCall = CCall+')'; end PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); diff --git a/macros/CCodeGeneration/C_InitHeader.sci b/macros/CCodeGeneration/C_InitHeader.sci index 7d794127..97dcf0d6 100644 --- a/macros/CCodeGeneration/C_InitHeader.sci +++ b/macros/CCodeGeneration/C_InitHeader.sci @@ -1,4 +1,4 @@ -function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) +function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName,Target,OpenCVUsed) // function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) // ----------------------------------------------------------------- // //NUT: add description here @@ -19,7 +19,7 @@ function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),3,3); +SCI2CNInArgCheck(argn(2),5,5); // ----------------------- // --- Initialization. --- @@ -34,6 +34,12 @@ C_SCI2CHeader(HeaderFileName); PrintStringInfo('#ifndef '+tmpfname+'_h',HeaderFileName,'file','y'); PrintStringInfo('#define '+tmpfname+'_h',HeaderFileName,'file','y'); PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('** ----- Target ------ ',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); +PrintStringInfo('#define ' + Target + '1 1' ,HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); PrintStringInfo('** --- SCI2C Includes. --- ',HeaderFileName,'file','y'); PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); @@ -46,6 +52,9 @@ PrintStringInfo('** --------------------------- ',HeaderFileName,'file','y'); PrintStringInfo('*/',HeaderFileName,'file','y'); PrintStringInfo(' ',HeaderFileName,'file','y'); PrintStringInfo(' ',HeaderFileName,'file','y'); +//PrintStringInfo('#ifdef __cplusplus',HeaderFileName,'file','y'); +//PrintStringInfo('extern ""C"" {',HeaderFileName,'file','y'); +//PrintStringInfo('#endif',HeaderFileName,'file','y'); PrintStringInfo('/*',HeaderFileName,'file','y'); PrintStringInfo('** ------------------- ',HeaderFileName,'file','y'); PrintStringInfo('** --- Prototypes. --- ',HeaderFileName,'file','y'); diff --git a/macros/CCodeGeneration/C_Type.sci b/macros/CCodeGeneration/C_Type.sci index 21d83a7d..d296c5c6 100644 --- a/macros/CCodeGeneration/C_Type.sci +++ b/macros/CCodeGeneration/C_Type.sci @@ -34,7 +34,32 @@ elseif (ArgType == 'i') elseif (ArgType == 'g') OutC_Type = 'char'; elseif (ArgType == 'f') - OutC_Type = 'SCI2CFILEID'; + OutC_Type = 'FILE *'; +elseif (ArgType == 'u8') + OutC_Type = 'uint8'; +elseif (ArgType == 'i8') + OutC_Type = 'int8'; +elseif (ArgType == 'u16') + OutC_Type = 'uint16'; +elseif (ArgType == 'i16') + OutC_Type = 'int16'; +elseif (ArgType == 'u32') + OutC_Type = 'uint32'; +elseif (ArgType == 'i32') + OutC_Type = 'int32'; +elseif (ArgType == 'fn') //This type introduced for ODE function, + // as it's one of the inout argument is name of the other function + OutC_Type = ''; +elseif (ArgType == 'mt') + OutC_Type = 'Mat' +elseif (ArgType == 'ss') + OutC_Type = 'double' + //This type is introduced for storing state space systems. + //It is a matrix of size (n+k)*(n+m+1), for n states, m inputs, + //k outputs. It stores matrices A,B,C,D and initial state in following form + // | A B X0 | + // | C D 0 | + else error(9999, 'Unknown Argument Type: ""'+ArgType+'"".'); end diff --git a/macros/CCodeGeneration/C_WhileExpression.sci b/macros/CCodeGeneration/C_WhileExpression.sci index edd2830e..36fcc4f2 100644 --- a/macros/CCodeGeneration/C_WhileExpression.sci +++ b/macros/CCodeGeneration/C_WhileExpression.sci @@ -1,4 +1,4 @@ -function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) +function SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo) // function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // ----------------------------------------------------------------- // //NUT: add description here @@ -11,6 +11,7 @@ function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // // Status: // 15-Nov-2007 -- Raffaele Nutricato: Author. +// 27-June-2017 -- Ukasha Noor: Modified by // // Copyright 2007 Raffaele Nutricato. // Contact: raffaele.nutricato@tiscali.it @@ -19,7 +20,7 @@ function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); +SCI2CNInArgCheck(argn(2),6,6); // ----------------------- // --- Initialization. --- @@ -63,7 +64,7 @@ for cntstr = 1:NumCStrings // Epilogue if (length(C_Strings(cntstr)) == 0) C_Strings(cntstr) = ' '; // RNU for Bruno: If I don't do that I get a PrintStringInfo error related to mputstr. - // Function not defined for given argument type(s),
+ // Function not defined for given argument type(s), // check arguments or define function %0_mputstr for overloading. end PrintStringInfo(C_Strings(cntstr),CPass1WhileEpilFileName ,'file','y','n'); @@ -76,7 +77,27 @@ PrintStringInfo('}',CPass1WhileEpilFileName ,'file','y'); // ------------------------------ // --- Insert for expression. --- // ------------------------------ -CCall = 'while('+SharedInfo.WhileExpr.CondVar+')'; +//CCall = 'while('+SharedInfo.WhileExpr.CondVar+')'; +//PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + +i=1; +k=1; +CCall =''; +CCall = CCall+'while'; + CCall = CCall+'('; + while i <= NIfCondArg + CCall = CCall + IfCondArg(i) + ' '; + //d = modulo(i,3); + //PrintStringInfo(' '+string(i)+string(d),'file','y'); + if (modulo(i,3)==0 & i<>NIfCondArg) + CCall = CCall + Op(k) + ' '; + k = k + 1; + end + i = i + 1; + end + CCall = CCall+')'; + +PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); // ------------------- diff --git a/macros/CCodeGeneration/GetClsFileName.sci b/macros/CCodeGeneration/GetClsFileName.sci index 46f08201..42204108 100644 --- a/macros/CCodeGeneration/GetClsFileName.sci +++ b/macros/CCodeGeneration/GetClsFileName.sci @@ -45,6 +45,7 @@ if SCI2Cfileexist(FileInfo.USER2CLibCAnnFun,tmpannfilename) // #RNU_RES_B // It is a C function of the USER2C library. // #RNU_RES_E + PrintStringInfo('cUser2c',ReportFileName,'file','y'); FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.USER2CLibCAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); @@ -53,6 +54,7 @@ elseif SCI2Cfileexist(FileInfo.USER2CLibSCIAnnFun,tmpannfilename) // #RNU_RES_B // It is a scilab function of the USER2C library. // #RNU_RES_E + PrintStringInfo('fUser2c',ReportFileName,'file','y'); FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.USER2CLibSCIAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); @@ -61,6 +63,7 @@ elseif (SCI2Cfileexist(FileInfo.SCI2CLibCAnnFun,tmpannfilename)) // #RNU_RES_B // It is a C function of the SCI2C library. // #RNU_RES_E + PrintStringInfo('csci2c',ReportFileName,'file','y'); FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.SCI2CLibCAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); @@ -69,12 +72,12 @@ elseif (SCI2Cfileexist(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename)) // #RNU_RES_B // It is a scilab function of the SCI2C library. // #RNU_RES_E + PrintStringInfo('fsci2c',ReportFileName,'file','y'); FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); SCI2CClassFileName = fullfile(FileInfo.SCI2CLibSCIAnnCls,SCI2CClassName+'.acls'); end - if (FlagFoundAnnFile == 0) [FlagFoundAnnFile,fullpathscifilename] = SCI2CFindFile(FileInfo.UserSciFilesPaths,FunName+'.sci'); if (FlagFoundAnnFile == 0) diff --git a/macros/CCodeGeneration/JoinDeclarAndCcode.sci b/macros/CCodeGeneration/JoinDeclarAndCcode.sci index ebbf0023..35607f6d 100644 --- a/macros/CCodeGeneration/JoinDeclarAndCcode.sci +++ b/macros/CCodeGeneration/JoinDeclarAndCcode.sci @@ -145,6 +145,11 @@ 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 diff --git a/macros/CCodeGeneration/names b/macros/CCodeGeneration/names new file mode 100644 index 00000000..56caa81d --- /dev/null +++ b/macros/CCodeGeneration/names @@ -0,0 +1,25 @@ +C_FinalizeCode +C_ForExpression +C_Funcall +C_GenDeclarations +C_GenDeclarations_Dup +C_GenerateFunName +C_GenerateLaunchScript +C_GenerateMakefile +C_GenerateMakefile_msvc +C_GenerateMkfle_arduino +C_GenerateSCI2CHeader +C_IfElseBlocks +C_IfExpression +C_IndentBlanks +C_InitHeader +C_MemAllocOutTempVars +C_SCI2CHeader +C_Type +C_WhileExpression +GenCFunDatFiles +GetClsFileName +GetSymbolDimension +GetWhileCondVariable +JoinDeclarAndCcode +Sci2AnnotationFile |