Commit 2482cf1d authored by Steve Lhomme's avatar Steve Lhomme

v2: set the default value if bDefaultIsSet is set in the Core-C class PostCreate

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@112 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent e12010e1
......@@ -286,8 +286,24 @@ static filepos_t UpdateSizeInt(ebml_integer *Element, bool_t bKeepIntact, bool_t
static void PostCreateInt(ebml_element *Element)
{
INHERITED(Element,ebml_element_vmt,EBML_INTEGER_CLASS)->PostCreate(Element);
INHERITED(Element,ebml_element_vmt,Node_ClassId(Element))->PostCreate(Element);
Element->DefaultSize = 1;
if (Element->bDefaultIsSet)
{
Element->bValueIsSet = 1;
((ebml_integer*)Element)->Value = Element->Context->DefaultValue;
}
}
static void PostCreateFloat(ebml_element *Element)
{
INHERITED(Element,ebml_element_vmt,EBML_FLOAT_CLASS)->PostCreate(Element);
Element->DefaultSize = 1;
if (Element->bDefaultIsSet)
{
Element->bValueIsSet = 1;
((ebml_float*)Element)->Value = Element->Context->DefaultValue;
}
}
......@@ -312,6 +328,7 @@ META_VMT(TYPE_FUNC,ebml_element_vmt,ReadData,ReadDataSignedInt)
META_VMT(TYPE_FUNC,ebml_element_vmt,RenderData,RenderDataSignedInt)
#endif
META_VMT(TYPE_FUNC,ebml_element_vmt,UpdateSize,UpdateSizeSignedInt)
META_VMT(TYPE_FUNC,ebml_element_vmt,PostCreate,PostCreateInt)
META_END_CONTINUE(EBML_ELEMENT_CLASS)
META_START_CONTINUE(EBML_BOOLEAN_CLASS)
......@@ -322,4 +339,5 @@ META_CLASS(SIZE,sizeof(ebml_float))
META_VMT(TYPE_FUNC,ebml_element_vmt,IsDefaultValue,IsDefaultValueFloat)
META_VMT(TYPE_FUNC,ebml_element_vmt,ValidateSize,ValidateSizeFloat)
META_VMT(TYPE_FUNC,ebml_element_vmt,ReadData,ReadDataFloat)
META_VMT(TYPE_FUNC,ebml_element_vmt,PostCreate,PostCreateFloat)
META_END(EBML_ELEMENT_CLASS)
......@@ -161,6 +161,16 @@ static bool_t IsDefaultValue(const ebml_string *Element)
return Element->Base.Context->HasDefault && (!Element->Base.bValueIsSet || strcmp(Element->Buffer,(const char*)Element->Base.Context->DefaultValue)==0);
}
static void PostCreateString(ebml_element *Element)
{
INHERITED(Element,ebml_element_vmt,Node_ClassId(Element))->PostCreate(Element);
if (Element->bDefaultIsSet)
{
Element->bValueIsSet = 1;
((ebml_string*)Element)->Buffer = strdup((const char *)Element->Context->DefaultValue);
}
}
META_START(EBMLString_Class,EBML_STRING_CLASS)
META_CLASS(SIZE,sizeof(ebml_string))
META_CLASS(DELETE,Delete)
......@@ -170,6 +180,7 @@ META_VMT(TYPE_FUNC,ebml_element_vmt,UpdateSize,UpdateSize)
#if defined(CONFIG_EBML_WRITING)
META_VMT(TYPE_FUNC,ebml_element_vmt,RenderData,RenderData)
#endif
META_VMT(TYPE_FUNC,ebml_element_vmt,PostCreate,PostCreateString)
META_END_CONTINUE(EBML_ELEMENT_CLASS)
META_START_CONTINUE(EBML_UNISTRING_CLASS)
......@@ -181,4 +192,5 @@ META_VMT(TYPE_FUNC,ebml_element_vmt,UpdateSize,UpdateSize)
#if defined(CONFIG_EBML_WRITING)
META_VMT(TYPE_FUNC,ebml_element_vmt,RenderData,RenderData)
#endif
META_VMT(TYPE_FUNC,ebml_element_vmt,PostCreate,PostCreateString)
META_END(EBML_ELEMENT_CLASS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment