MCPcopy Create free account
hub / github.com/anjo76/angelscript / ProcessScriptSection

Method ProcessScriptSection

sdk/add_on/scriptbuilder/scriptbuilder.cpp:241–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length, const char *sectionname, int lineOffset)
242{
243 vector<string> includes;
244
245 // Perform a superficial parsing of the script first to store the metadata
246 if( length )
247 modifiedScript.assign(script, length);
248 else
249 modifiedScript = script;
250
251 // First perform the checks for #if directives to exclude code that shouldn't be compiled
252 unsigned int pos = 0;
253 int nested = 0;
254 while( pos < modifiedScript.size() )
255 {
256 asUINT len = 0;
257 asETokenClass t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
258 if( t == asTC_UNKNOWN && modifiedScript[pos] == '#' && (pos + 1 < modifiedScript.size()) )
259 {
260 int start = pos++;
261
262 // Is this an #if directive?
263 t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
264
265 string token;
266 token.assign(&modifiedScript[pos], len);
267
268 pos += len;
269
270 if( token == "if" )
271 {
272 t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
273 if( t == asTC_WHITESPACE )
274 {
275 pos += len;
276 t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
277 }
278
279 if( t == asTC_IDENTIFIER )
280 {
281 string word;
282 word.assign(&modifiedScript[pos], len);
283
284 // Overwrite the #if directive with space characters to avoid compiler error
285 pos += len;
286 OverwriteCode(start, pos-start);
287
288 // Has this identifier been defined by the application or not?
289 if( definedWords.find(word) == definedWords.end() )
290 {
291 // Exclude all the code until and including the #endif
292 pos = ExcludeCode(pos);
293 }
294 else
295 {
296 nested++;
297 }
298 }

Callers

nothing calls this directly

Calls 10

findMethod · 0.80
endMethod · 0.80
WriteMessageMethod · 0.80
SetEnginePropertyMethod · 0.80
AddScriptSectionMethod · 0.80
sizeMethod · 0.45
ParseTokenMethod · 0.45
lengthMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected