Update to Angelscript 2.35.1
This commit is contained in:
@@ -302,7 +302,7 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
declaration.reserve(100);
|
||||
#endif
|
||||
|
||||
// Then check for meta data and #include directives
|
||||
// Then check for meta data and pre-processor directives
|
||||
pos = 0;
|
||||
while( pos < modifiedScript.size() )
|
||||
{
|
||||
@@ -313,10 +313,19 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
pos += len;
|
||||
continue;
|
||||
}
|
||||
string token;
|
||||
token.assign(&modifiedScript[pos], len);
|
||||
|
||||
#if AS_PROCESS_METADATA == 1
|
||||
// Check if class
|
||||
if( currentClass == "" && modifiedScript.substr(pos,len) == "class" )
|
||||
// Skip possible decorators before class and interface declarations
|
||||
if (token == "shared" || token == "abstract" || token == "mixin" || token == "external")
|
||||
{
|
||||
pos += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if class or interface so the metadata for members can be gathered
|
||||
if( currentClass == "" && (token == "class" || token == "interface") )
|
||||
{
|
||||
// Get the identifier after "class"
|
||||
do
|
||||
@@ -362,15 +371,15 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
}
|
||||
|
||||
// Check if end of class
|
||||
if( currentClass != "" && modifiedScript[pos] == '}' )
|
||||
if( currentClass != "" && token == "}" )
|
||||
{
|
||||
currentClass = "";
|
||||
pos += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if namespace
|
||||
if( modifiedScript.substr(pos,len) == "namespace" )
|
||||
// Check if namespace so the metadata for members can be gathered
|
||||
if( token == "namespace" )
|
||||
{
|
||||
// Get the identifier after "namespace"
|
||||
do
|
||||
@@ -403,7 +412,7 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
}
|
||||
|
||||
// Check if end of namespace
|
||||
if( currentNamespace != "" && modifiedScript[pos] == '}' )
|
||||
if( currentNamespace != "" && token == "}" )
|
||||
{
|
||||
size_t found = currentNamespace.rfind( "::" );
|
||||
if( found != string::npos )
|
||||
@@ -419,7 +428,7 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
}
|
||||
|
||||
// Is this the start of metadata?
|
||||
if( modifiedScript[pos] == '[' )
|
||||
if( token == "[" )
|
||||
{
|
||||
// Get the metadata string
|
||||
pos = ExtractMetadata(pos, metadata);
|
||||
@@ -438,37 +447,36 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
else
|
||||
#endif
|
||||
// Is this a preprocessor directive?
|
||||
if( modifiedScript[pos] == '#' && (pos + 1 < modifiedScript.size()) )
|
||||
if( token == "#" && (pos + 1 < modifiedScript.size()) )
|
||||
{
|
||||
int start = pos++;
|
||||
|
||||
t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
|
||||
if( t == asTC_IDENTIFIER )
|
||||
if (t == asTC_IDENTIFIER)
|
||||
{
|
||||
string token;
|
||||
token.assign(&modifiedScript[pos], len);
|
||||
if( token == "include" )
|
||||
if (token == "include")
|
||||
{
|
||||
pos += len;
|
||||
t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
|
||||
if( t == asTC_WHITESPACE )
|
||||
if (t == asTC_WHITESPACE)
|
||||
{
|
||||
pos += len;
|
||||
t = engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
|
||||
}
|
||||
|
||||
if( t == asTC_VALUE && len > 2 && (modifiedScript[pos] == '"' || modifiedScript[pos] == '\'') )
|
||||
if (t == asTC_VALUE && len > 2 && (modifiedScript[pos] == '"' || modifiedScript[pos] == '\''))
|
||||
{
|
||||
// Get the include file
|
||||
string includefile;
|
||||
includefile.assign(&modifiedScript[pos+1], len-2);
|
||||
includefile.assign(&modifiedScript[pos + 1], len - 2);
|
||||
pos += len;
|
||||
|
||||
// Store it for later processing
|
||||
includes.push_back(includefile);
|
||||
|
||||
// Overwrite the include directive with space characters to avoid compiler error
|
||||
OverwriteCode(start, pos-start);
|
||||
OverwriteCode(start, pos - start);
|
||||
}
|
||||
}
|
||||
else if (token == "pragma")
|
||||
@@ -491,6 +499,19 @@ int CScriptBuilder::ProcessScriptSection(const char *script, unsigned int length
|
||||
OverwriteCode(start, pos - start);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check for lines starting with #!, e.g. shebang interpreter directive. These will be treated as comments and removed by the preprocessor
|
||||
if (modifiedScript[pos] == '!')
|
||||
{
|
||||
// Read until the end of the line
|
||||
pos += len;
|
||||
for (; pos < modifiedScript.size() && modifiedScript[pos] != '\n'; pos++);
|
||||
|
||||
// Overwrite the directive with space characters to avoid compiler error
|
||||
OverwriteCode(start, pos - start);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Don't search for metadata/includes within statement blocks or between tokens in statements
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user