default values
This commit is contained in:
@@ -133,7 +133,7 @@ void DefinitionFile::WriteTypes(TemplateWriter& Template)
|
||||
{
|
||||
bx::snprintf(Array, sizeof(Array), "[%u]", ArraySize);
|
||||
}
|
||||
Template.Write(WriteTemplates::StructField4, Type, t.FieldNames[fieldIdx], Array, "{}");
|
||||
Template.Write(WriteTemplates::StructField4, Type, t.FieldNames[fieldIdx], Array, t.FieldVaules[fieldIdx]);
|
||||
}
|
||||
Template.Write(WriteTemplates::StructEnd);
|
||||
}
|
||||
@@ -315,9 +315,14 @@ Parser::Result Parser::HandleType()
|
||||
return Error;
|
||||
}
|
||||
Def::Type& t = Definitions.Types[Definitions.TypeCount];
|
||||
CHECK(ReadName(t.Name));
|
||||
for (int32_t i = 0; i < Def::MaxFields; ++i)
|
||||
{
|
||||
bx::strCopy(t.FieldVaules[i], sizeof(t.FieldVaules[i]), "{}");
|
||||
}
|
||||
|
||||
CHECK(ReadName(t.Name));
|
||||
CHECK(SkipWhitespace());
|
||||
|
||||
CHECK(ExpectChar("{"));
|
||||
CHECK(SkipWhitespace());
|
||||
|
||||
@@ -336,7 +341,7 @@ Parser::Result Parser::HandleType()
|
||||
bool NewLine = false;
|
||||
CHECK(SkipWhitespace(&NewLine));
|
||||
|
||||
if (!NewLine)
|
||||
while (!NewLine)
|
||||
{
|
||||
Result Res;
|
||||
if (CmpAdvance("Arr", Res, true) && Res == Result::OK)
|
||||
@@ -345,9 +350,30 @@ Parser::Result Parser::HandleType()
|
||||
CHECK(ReadUint(t.FieldArraySizes[t.FieldCount]));
|
||||
CHECK(ExpectChar(")"));
|
||||
}
|
||||
else if (CmpAdvance("Default", Res, true) && Res == OK)
|
||||
{
|
||||
CHECK(ExpectChar("("));
|
||||
CHECK(ExpectChar("\""));
|
||||
|
||||
int32_t Remaining = bx::min(GetRemaining(), (int32_t)BX_COUNTOF(Def::Type::FieldVaules[0]));
|
||||
for (int32_t i = 0; i < Remaining; ++i)
|
||||
{
|
||||
if (*ReadPtr != '\\' && CmpAdvance("\"", Res)) break;
|
||||
t.FieldVaules[t.FieldCount][i] = *ReadPtr;
|
||||
ReadPtr++;
|
||||
}
|
||||
if (Res != OK) return Res;
|
||||
CHECK(ExpectChar(")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR(Line, "Unknown token!");
|
||||
ErrorLine();
|
||||
return Error;
|
||||
}
|
||||
CHECK(SkipWhitespace(&NewLine));
|
||||
}
|
||||
|
||||
CHECK(SkipWhitespace());
|
||||
t.FieldCount++;
|
||||
}
|
||||
Definitions.TypeCount++;
|
||||
@@ -529,7 +555,6 @@ Parser::Result Parser::ReadOptionalEnumValues(Def::Enum& Enum, int32_t EntryIdx)
|
||||
int32_t Remaining = GetRemaining();
|
||||
for (int32_t i = 0; i < Remaining; ++i)
|
||||
{
|
||||
|
||||
if (CmpAdvance("\"", Res)) break;
|
||||
Enum.ExtraStringFields[extraIdx][EntryIdx][i] = *ReadPtr;
|
||||
ReadPtr++;
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace Def
|
||||
FieldType FieldTypes[MaxFields];
|
||||
char FieldNames[MaxFields][MaxNameLength];
|
||||
uint32_t FieldArraySizes[MaxFields]{0};
|
||||
char FieldVaules[MaxFields][128]{0};
|
||||
char Name[MaxNameLength]{0};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user