Added ability to separate words by underscore in generated names

This commit is contained in:
Aruki
2018-02-18 12:16:55 -07:00
parent 366c4cd3ff
commit 6719b82077
7 changed files with 697 additions and 859 deletions

View File

@@ -130,6 +130,11 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
for (; RecalcIndex < WordCache.size(); RecalcIndex++)
{
int Index = WordCache[RecalcIndex].WordIndex;
// Add an underscore if needed
if (RecalcIndex > 0 && rkParams.UseUnderscores)
LastValidHash.Hash("_");
LastValidHash.Hash( *mWords[Index].Word );
WordCache[RecalcIndex].Hash = LastValidHash;
}
@@ -156,6 +161,12 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
for (int WordIdx = 0; WordIdx < WordCache.size(); WordIdx++)
{
int Index = WordCache[WordIdx].WordIndex;
if (WordIdx > 0 && rkParams.UseUnderscores)
{
PropertyName.Name += "_";
}
PropertyName.Name += mWords[Index].Word;
}

View File

@@ -19,6 +19,9 @@ struct SPropertyNameGenerationParameters
/** List of valid type suffixes */
std::vector<TString> TypeNames;
/** Whether to separate words with underscores */
bool UseUnderscores;
/** Whether to print the output from the generation process to the log */
bool PrintToLog;
};

View File

@@ -311,7 +311,7 @@ const char* HashablePropTypeName(EPropertyType Prop)
case eBoolProperty: return "bool";
case eLongProperty: return "int";
case eEnumProperty: return "enum";
case eBitfieldProperty: return "bitfield";
case eBitfieldProperty: return "Flags";
case eFloatProperty: return "float";
case eStringProperty: return "string";
case eColorProperty: return "Color";