cmListFileArgument: Generalize 'Quoted' bool to 'Delimeter' enum

Replace the boolean value that indicates whether an argument is unquoted
or quoted with a generalized enumeration of possible argument types.
For now "Quoted" and "Unquoted" remain the only types.
This commit is contained in:
Brad King 2012-08-06 10:07:58 -04:00
parent 28685ade7a
commit 0546484e4b
7 changed files with 38 additions and 26 deletions

View File

@ -422,7 +422,8 @@ int CCONV cmExecuteCommand(void *arg, const char *name,
for(int i = 0; i < numArgs; ++i) for(int i = 0; i < numArgs; ++i)
{ {
// Assume all arguments are quoted. // Assume all arguments are quoted.
lff.Arguments.push_back(cmListFileArgument(args[i], true, lff.Arguments.push_back(
cmListFileArgument(args[i], cmListFileArgument::Quoted,
"[CMake-Plugin]", 0)); "[CMake-Plugin]", 0));
} }
cmExecutionStatus status; cmExecutionStatus status;

View File

@ -196,7 +196,8 @@ bool cmListFile::ParseFile(const char* filename,
{ {
cmListFileFunction project; cmListFileFunction project;
project.Name = "PROJECT"; project.Name = "PROJECT";
cmListFileArgument prj("Project", false, filename, 0); cmListFileArgument prj("Project", cmListFileArgument::Unquoted,
filename, 0);
project.Arguments.push_back(prj); project.Arguments.push_back(prj);
this->Functions.insert(this->Functions.begin(),project); this->Functions.insert(this->Functions.begin(),project);
} }
@ -243,8 +244,8 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
if(token->type == cmListFileLexer_Token_ParenLeft) if(token->type == cmListFileLexer_Token_ParenLeft)
{ {
parenDepth++; parenDepth++;
cmListFileArgument a("(", cmListFileArgument a("(", cmListFileArgument::Unquoted,
false, filename, token->line); filename, token->line);
function.Arguments.push_back(a); function.Arguments.push_back(a);
} }
else if(token->type == cmListFileLexer_Token_ParenRight) else if(token->type == cmListFileLexer_Token_ParenRight)
@ -254,21 +255,21 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
return true; return true;
} }
parenDepth--; parenDepth--;
cmListFileArgument a(")", cmListFileArgument a(")", cmListFileArgument::Unquoted,
false, filename, token->line); filename, token->line);
function.Arguments.push_back(a); function.Arguments.push_back(a);
} }
else if(token->type == cmListFileLexer_Token_Identifier || else if(token->type == cmListFileLexer_Token_Identifier ||
token->type == cmListFileLexer_Token_ArgumentUnquoted) token->type == cmListFileLexer_Token_ArgumentUnquoted)
{ {
cmListFileArgument a(token->text, cmListFileArgument a(token->text, cmListFileArgument::Unquoted,
false, filename, token->line); filename, token->line);
function.Arguments.push_back(a); function.Arguments.push_back(a);
} }
else if(token->type == cmListFileLexer_Token_ArgumentQuoted) else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
{ {
cmListFileArgument a(token->text, cmListFileArgument a(token->text, cmListFileArgument::Quoted,
true, filename, token->line); filename, token->line);
function.Arguments.push_back(a); function.Arguments.push_back(a);
} }
else if(token->type != cmListFileLexer_Token_Newline) else if(token->type != cmListFileLexer_Token_Newline)

View File

@ -25,22 +25,27 @@ class cmMakefile;
struct cmListFileArgument struct cmListFileArgument
{ {
cmListFileArgument(): Value(), Quoted(false), FilePath(0), Line(0) {} enum Delimiter
{
Unquoted,
Quoted
};
cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
cmListFileArgument(const cmListFileArgument& r): cmListFileArgument(const cmListFileArgument& r):
Value(r.Value), Quoted(r.Quoted), FilePath(r.FilePath), Line(r.Line) {} Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
cmListFileArgument(const std::string& v, bool q, const char* file, cmListFileArgument(const std::string& v, Delimiter d, const char* file,
long line): Value(v), Quoted(q), long line): Value(v), Delim(d),
FilePath(file), Line(line) {} FilePath(file), Line(line) {}
bool operator == (const cmListFileArgument& r) const bool operator == (const cmListFileArgument& r) const
{ {
return (this->Value == r.Value) && (this->Quoted == r.Quoted); return (this->Value == r.Value) && (this->Delim == r.Delim);
} }
bool operator != (const cmListFileArgument& r) const bool operator != (const cmListFileArgument& r) const
{ {
return !(*this == r); return !(*this == r);
} }
std::string Value; std::string Value;
bool Quoted; Delimiter Delim;
const char* FilePath; const char* FilePath;
long Line; long Line;
}; };

View File

@ -227,7 +227,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
} }
arg.Value = tmps; arg.Value = tmps;
arg.Quoted = k->Quoted; arg.Delim = k->Delim;
arg.FilePath = k->FilePath; arg.FilePath = k->FilePath;
arg.Line = k->Line; arg.Line = k->Line;
newLFF.Arguments.push_back(arg); newLFF.Arguments.push_back(arg);

View File

@ -2799,7 +2799,7 @@ bool cmMakefile::ExpandArguments(
// If the argument is quoted, it should be one argument. // If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments. // Otherwise, it may be a list of arguments.
if(i->Quoted) if(i->Delim == cmListFileArgument::Quoted)
{ {
outArgs.push_back(value); outArgs.push_back(value);
} }

View File

@ -86,15 +86,20 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable,
std::string command = *it; std::string command = *it;
newLFF.Arguments.clear(); newLFF.Arguments.clear();
newLFF.Arguments.push_back( newLFF.Arguments.push_back(
cmListFileArgument(variable, true, "unknown", 9999)); cmListFileArgument(variable, cmListFileArgument::Quoted,
"unknown", 9999));
newLFF.Arguments.push_back( newLFF.Arguments.push_back(
cmListFileArgument(accessString, true, "unknown", 9999)); cmListFileArgument(accessString, cmListFileArgument::Quoted,
"unknown", 9999));
newLFF.Arguments.push_back( newLFF.Arguments.push_back(
cmListFileArgument(newValue?newValue:"", true, "unknown", 9999)); cmListFileArgument(newValue?newValue:"", cmListFileArgument::Quoted,
"unknown", 9999));
newLFF.Arguments.push_back( newLFF.Arguments.push_back(
cmListFileArgument(currentListFile, true, "unknown", 9999)); cmListFileArgument(currentListFile, cmListFileArgument::Quoted,
"unknown", 9999));
newLFF.Arguments.push_back( newLFF.Arguments.push_back(
cmListFileArgument(stack, true, "unknown", 9999)); cmListFileArgument(stack, cmListFileArgument::Quoted,
"unknown", 9999));
newLFF.Name = command; newLFF.Name = command;
newLFF.FilePath = "Some weird path"; newLFF.FilePath = "Some weird path";
newLFF.Line = 9999; newLFF.Line = 9999;

View File

@ -49,9 +49,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
unsigned int i; unsigned int i;
for(i =0; i < this->Args.size(); ++i) for(i =0; i < this->Args.size(); ++i)
{ {
err += (this->Args[i].Quoted?"\"":""); err += (this->Args[i].Delim?"\"":"");
err += this->Args[i].Value; err += this->Args[i].Value;
err += (this->Args[i].Quoted?"\"":""); err += (this->Args[i].Delim?"\"":"");
err += " "; err += " ";
} }
err += "("; err += "(";