Browse Source

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.
Brad King 13 years ago
parent
commit
0546484e4b

+ 3 - 2
Source/cmCPluginAPI.cxx

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

+ 10 - 9
Source/cmListFileCache.cxx

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

+ 11 - 6
Source/cmListFileCache.h

@@ -25,22 +25,27 @@ class cmMakefile;
 
 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):
-    Value(r.Value), Quoted(r.Quoted), FilePath(r.FilePath), Line(r.Line) {}
-  cmListFileArgument(const std::string& v, bool q, const char* file,
-                     long line): Value(v), Quoted(q),
+    Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
+  cmListFileArgument(const std::string& v, Delimiter d, const char* file,
+                     long line): Value(v), Delim(d),
                                  FilePath(file), Line(line) {}
   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
     {
     return !(*this == r);
     }
   std::string Value;
-  bool Quoted;
+  Delimiter Delim;
   const char* FilePath;
   long Line;
 };

+ 1 - 1
Source/cmMacroCommand.cxx

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

+ 1 - 1
Source/cmMakefile.cxx

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

+ 10 - 5
Source/cmVariableWatchCommand.cxx

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

+ 2 - 2
Source/cmWhileCommand.cxx

@@ -49,9 +49,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
           unsigned int 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].Quoted?"\"":"");
+            err += (this->Args[i].Delim?"\"":"");
             err += " ";
             }
           err += "(";