aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/flags/SkCommandLineFlags.h
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-09 21:25:46 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-09 21:25:46 +0000
commit604e0c249ef0e11a1b8bc41195081363fd86d892 (patch)
tree7e62c386fd9edbbba5833674ee25cd0be84a6a97 /tools/flags/SkCommandLineFlags.h
parentc53404ed1e54e564b2091c0063833f379487a2ca (diff)
SkFlags now follows proper dashing convention.
Two dashes are used for flags with multiple characters, and one dash is used for flags with single characters. In GM, changed '-wp' to '-p' (the command to choose a directory for writing SKPs) to fit with the convention. In render_pictures and bench_pictures, changed the flag for read and write path to have full names (which are consistent) and use the old single character names as their shortcuts. SkCommandLineFlags: Updated the documentation, and only allow -h or --help for help (again, to match the convention). Also enforce the single character limit for the short name, and require the full name to be at least two characters. Provide full names for skhello. BUG=https://code.google.com/p/skia/issues/detail?id=1174 Review URL: https://codereview.chromium.org/12521019 git-svn-id: http://skia.googlecode.com/svn/trunk@8582 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/flags/SkCommandLineFlags.h')
-rw-r--r--tools/flags/SkCommandLineFlags.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h
index 1d4f409fbf..c705948348 100644
--- a/tools/flags/SkCommandLineFlags.h
+++ b/tools/flags/SkCommandLineFlags.h
@@ -41,8 +41,6 @@
* "--boolean true" (where "true" can be replaced by "false", "TRUE", "FALSE",
* "1" or "0").
*
- * Single dashes are also permitted for this and other flags.
- *
* The helpString will be printed if the help flag (-h or -help) is used.
*
* Similarly, the line
@@ -149,8 +147,8 @@ static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
defaultValue, \
helpString)
-// string2 allows specifying a short name. No check is done to ensure that shortName
-// is actually shorter than name.
+// string2 allows specifying a short name. There is an assert that shortName
+// is only 1 character.
#define DEFINE_string2(name, shortName, defaultValue, helpString) \
SkTDArray<const char*> FLAGS_##name; \
static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
@@ -192,8 +190,7 @@ public:
// Create flags of the desired type, and append to the list.
static bool CreateBoolFlag(const char* name, const char* shortName, bool* pBool,
bool defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, kBool_FlagType, helpString));
- info->fShortName.set(shortName);
+ SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kBool_FlagType, helpString));
info->fBoolValue = pBool;
*info->fBoolValue = info->fDefaultBool = defaultValue;
return true;
@@ -202,8 +199,7 @@ public:
static bool CreateStringFlag(const char* name, const char* shortName,
SkTDArray<const char*>* pStrings,
const char* defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, kString_FlagType, helpString));
- info->fShortName.set(shortName);
+ SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType, helpString));
info->fDefaultString.set(defaultValue);
info->fStrings = pStrings;
@@ -217,7 +213,7 @@ public:
static bool CreateIntFlag(const char* name, int32_t* pInt,
int32_t defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, kInt_FlagType, helpString));
+ SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, NULL, kInt_FlagType, helpString));
info->fIntValue = pInt;
*info->fIntValue = info->fDefaultInt = defaultValue;
return true;
@@ -225,7 +221,7 @@ public:
static bool CreateDoubleFlag(const char* name, double* pDouble,
double defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, kDouble_FlagType, helpString));
+ SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, NULL, kDouble_FlagType, helpString));
info->fDoubleValue = pDouble;
*info->fDoubleValue = info->fDefaultDouble = defaultValue;
return true;
@@ -333,8 +329,9 @@ public:
}
private:
- SkFlagInfo(const char* name, FlagTypes type, const char* helpString)
+ SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString)
: fName(name)
+ , fShortName(shortName)
, fFlagType(type)
, fHelpString(helpString)
, fBoolValue(NULL)
@@ -346,6 +343,8 @@ private:
, fStrings(NULL) {
fNext = SkCommandLineFlags::gHead;
SkCommandLineFlags::gHead = this;
+ SkASSERT(NULL != name && strlen(name) > 1);
+ SkASSERT(NULL == shortName || 1 == strlen(shortName));
}
// Name of the flag, without initial dashes
SkString fName;