summaryrefslogtreecommitdiff
path: root/2.3-1/macros/CCodeGeneration/C_FinalizeCode.sci
blob: 33a1d791466580af84afd47240ecef68508dcaea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function C_FinalizeCode(FileInfo,SharedInfo)
// function C_FinalizeCode(FileInfo,SharedInfo)
// -----------------------------------------------------------------
// //NUT: add description here
//
// Input data:
// //NUT: add description here
//
// Output data:
// //NUT: add description here
//
// Status:
// 27-Oct-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------

// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),2,2);

// -----------------------
// --- Initialization. ---
// -----------------------
// --- Load File Info Structure. ---
load(FileInfoDatFile,'FileInfo');

// --- Load Shared Info Structure. ---
load(FileInfo.SharedInfoDatFile,'SharedInfo');

CPass2FileName      = FileInfo.Funct(SharedInfo.NextSCIFunNumber).CPass2FileName;
FinalCFileName      = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalCFileName;
Pass1HeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).Pass1HeaderFileName;
FinalHeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalHeaderFileName;
// #RNU_RES_B
PrintStringInfo('Generating the final C code in:'+FinalCFileName,...
   FileInfo.Funct(SharedInfo.NextSCIFunNumber).ReportFileName,'file','y');
// #RNU_RES_E
// ---------------------------
// --- End Initialization. ---
// ---------------------------

// ---------------------------------
// --- 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. ---
// -------------------------------------

[tmphdrpath,tmphdrname,tmphdrext] = fileparts(Pass1HeaderFileName);

// #RNU_RES_B
// --------------------------------------------------
// --- Copy the C code into the C code directory. ---
// --------------------------------------------------
// #RNU_RES_E
C_SCI2CHeader(FinalCFileName);
PrintStringInfo('/*',FinalCFileName,'file','y');
PrintStringInfo('** ----------------- ',FinalCFileName,'file','y');
PrintStringInfo('** --- Includes. --- ',FinalCFileName,'file','y');
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');
PrintStringInfo('** --------------------- ',FinalCFileName,'file','y');
PrintStringInfo('*/',FinalCFileName,'file','y');
PrintStringInfo(' ',FinalCFileName,'file','y');
PrintStringInfo(' ',FinalCFileName,'file','y');
PrintStringInfo(' ',FinalCFileName,'file','y');
SCI2Ccopyfile(CPass2FileName,...
   FinalCFileName,'append');
SCI2Ccopyfile(Pass1HeaderFileName,...
   FinalHeaderFileName,'append');


endfunction