-
Notifications
You must be signed in to change notification settings - Fork 3
/
MummyGenerator.cxx
182 lines (146 loc) · 4.96 KB
/
MummyGenerator.cxx
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//----------------------------------------------------------------------------
//
// $Id: MummyGenerator.cxx 2 2007-12-17 18:15:56Z david.cole $
//
// $Author: david.cole $
// $Date: 2007-12-17 13:15:56 -0500 (Mon, 17 Dec 2007) $
// $Revision: 2 $
//
// Copyright (C) 2006-2007 Kitware, Inc.
//
//----------------------------------------------------------------------------
#include "MummyGenerator.h"
#include "MummyLineOrientedTextFileReader.h"
#include "MummyLog.h"
#include "MummySettings.h"
#include "cableClass.h"
#include "gxsys/RegularExpression.hxx"
//----------------------------------------------------------------------------
MummyGenerator::MummyGenerator()
{
this->Settings = 0;
this->TargetClass = 0;
this->HeaderFileReader = 0;
}
//----------------------------------------------------------------------------
MummyGenerator::~MummyGenerator()
{
if (this->HeaderFileReader)
{
delete this->HeaderFileReader;
this->HeaderFileReader = 0;
}
}
//----------------------------------------------------------------------------
MummySettings* MummyGenerator::GetSettings()
{
return this->Settings;
}
//----------------------------------------------------------------------------
void MummyGenerator::SetSettings(MummySettings* settings)
{
this->Settings = settings;
}
//----------------------------------------------------------------------------
const cable::Class* MummyGenerator::GetTargetClass()
{
return this->TargetClass;
}
//----------------------------------------------------------------------------
void MummyGenerator::SetTargetClass(const cable::Class *c)
{
this->TargetClass = c;
}
//----------------------------------------------------------------------------
bool MummyGenerator::FundamentalTypeIsWrappable(const cable::Type*)
{
return false;
}
//----------------------------------------------------------------------------
bool MummyGenerator::TypeIsWrappable(const cable::Type*)
{
return false;
}
//----------------------------------------------------------------------------
bool MummyGenerator::FunctionTypeIsWrappable(const cable::FunctionType*)
{
return false;
}
//----------------------------------------------------------------------------
bool MummyGenerator::MethodIsWrappable(const cable::Method*, const cable::Context::Access&)
{
return false;
}
//----------------------------------------------------------------------------
bool MummyGenerator::ClassIsWrappable(const cable::Class* c)
{
MummySettings* settings = this->GetSettings();
if (settings)
{
return settings->ClassIsWrappable(c);
}
return false;
}
//----------------------------------------------------------------------------
MummyLineOrientedTextFileReader* MummyGenerator::GetHeaderFileReader(const cable::Class* c)
{
if (0 == this->HeaderFileReader)
{
this->HeaderFileReader = new MummyLineOrientedTextFileReader;
MummySettings* settings = this->GetSettings();
if (settings)
{
ClassWrappingSettings cws;
if (settings->FindClassWrappingSettings(GetFullyQualifiedNameForCPlusPlus(c).c_str(), &cws))
{
this->HeaderFileReader->SetExcludeMarkedLines(cws.excludeMarkedLines);
this->HeaderFileReader->SetBeginExcludeRegex(cws.beginExcludeRegex);
this->HeaderFileReader->SetEndExcludeRegex(cws.endExcludeRegex);
}
else
{
LogError(me_NoClassWrappingSettings,
<< "Could not find class wrapping settings for class '" << GetFullyQualifiedNameForCPlusPlus(c).c_str() << "'");
}
}
this->HeaderFileReader->SetFileName(c->GetFile());
}
else
{
if (this->HeaderFileReader->GetFileName() != c->GetFile())
{
LogError(me_InternalError,
<< "Trying to open a different file for HeaderFileReader..." << gxsys_stl::endl
<< " class: " << GetFullyQualifiedNameForCPlusPlus(c).c_str() << gxsys_stl::endl
<< " c->GetFile(): " << c->GetFile() << gxsys_stl::endl
<< " this->HeaderFileReader->GetFileName(): " << this->HeaderFileReader->GetFileName() << gxsys_stl::endl
);
}
}
return this->HeaderFileReader;
}
//----------------------------------------------------------------------------
void MummyGenerator::EmitMummyVersionComments(gxsys_ios::ostream &os, const char *lineCommentString)
{
gxsys_stl::string mummy_version(this->GetSettings()->GetMummyVersion());
if (!lineCommentString)
{
lineCommentString = "//";
}
Emit(os, lineCommentString);
Emit(os, "----------------------------------------------------------------------------\n");
Emit(os, lineCommentString);
Emit(os, "\n");
Emit(os, lineCommentString);
Emit(os, " This file was machine generated by:\n");
Emit(os, lineCommentString);
Emit(os, " ");
Emit(os, mummy_version.c_str());
Emit(os, "\n");
Emit(os, lineCommentString);
Emit(os, "\n");
Emit(os, lineCommentString);
Emit(os, " Manual changes to this file may be overwritten by the next build.\n");
Emit(os, lineCommentString);
Emit(os, "\n");
}