Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spectools: use a callback in EbmlCallbacks to validate the size of an element #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spectool/schema_2_kaxsemantic_cpp.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ static constexpr const MatroskaProfile VERSION_WEBM_UP_TO_V4 = {true, false, 0,
<xsl:call-template name="output-display-name">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="@name='Block' or @name='SimpleBlock' or @name='BlockVirtual'"><xsl:text>, KaxInternalBlock::SizeIsValid</xsl:text></xsl:when>
<xsl:when test="not(@length)"><xsl:text>, libebml::EbmlBinary::SizeIsValid</xsl:text></xsl:when>
<xsl:otherwise>
<xsl:text>, Kax</xsl:text>
<xsl:call-template name="get-class-name">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
<xsl:text>::SizeIsValid</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="output-minmax">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
Expand Down
12 changes: 8 additions & 4 deletions spectool/schema_2_kaxsemantic_h.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ namespace libmatroska {
</xsl:when>
<xsl:when test="@type='binary'">
<xsl:text>DECLARE_MKX_BINARY</xsl:text>
<xsl:if test="@length"><xsl:text>_LENGTH</xsl:text></xsl:if>
</xsl:when>
<xsl:when test="@type='uinteger'">
<xsl:text>DECLARE_MKX_UINTEGER</xsl:text>
Expand Down Expand Up @@ -98,16 +97,21 @@ namespace libmatroska {
<xsl:call-template name="get-class-name">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
<xsl:if test="@length">
<xsl:text>, </xsl:text><xsl:value-of select="@length"/>
</xsl:if>
<xsl:text>)&#10;</xsl:text>
<xsl:if test="@maxver='0' or @maxver='1' or @maxver='2' or @maxver='3'">
<xsl:text>public:&#10;</xsl:text>
</xsl:if>
<xsl:if test="@maxver='0' or @maxver='1' or @maxver='2' or @maxver='3'">
<xsl:text> libebml::filepos_t RenderData(libebml::IOCallback &amp; output, bool bForceRender, const ShouldWrite &amp; writeFilter) override;&#10;</xsl:text>
</xsl:if>
<xsl:if test="@length">
<xsl:text> static inline bool SizeIsValid(std::uint64_t Size) {return Size </xsl:text>
<xsl:choose>
<xsl:when test="contains(@length, '=') or contains(@length, '&lt;') or contains(@length, '&gt;')"><xsl:value-of select="@length"/></xsl:when>
<xsl:otherwise><xsl:text>== </xsl:text><xsl:value-of select="@length"/></xsl:otherwise>
</xsl:choose>
<xsl:text>;}&#10;</xsl:text>
</xsl:if>
<xsl:text>};&#10;</xsl:text>
<!-- <xsl:if test="$minVer &gt; 1 or ebml:extension[@divx='1']">#endif&#10;</xsl:if> -->
<xsl:text>&#10;</xsl:text>
Expand Down
Loading