Skip to content

Commit

Permalink
add an EbmlMaster variant of tEBML_CONTEXT
Browse files Browse the repository at this point in the history
Hopefully the compiler picks the most appropriate one ?
  • Loading branch information
robUx4 committed Feb 26, 2024
1 parent 184d3e1 commit 9e6f5b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ebml/EbmlMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
bool ProcessMandatory();
};

static inline constexpr const EbmlSemanticContextMaster & tEBML_CONTEXT(const EbmlMaster * e)
{
return e->ContextMaster();
}

///< \todo add a restriction to only elements legal in the context
template <typename Type>
Type & GetChild(EbmlMaster & Master)
Expand Down
4 changes: 4 additions & 0 deletions test/test_macros.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ int main(void)

[[maybe_unused]] const EbmlSemanticContext &ctx = EBML_CLASS_CONTEXT(EbmlHead);
[[maybe_unused]] const EbmlSemanticContextMaster &ctxMaster = EBML_CLASS_CONTEXT(EbmlHead);
EbmlHead TestHead;
[[maybe_unused]] const EbmlSemanticContextMaster & MasterContext = EBML_CONTEXT(&TestHead);
[[maybe_unused]] const EbmlSemanticContext & BasicContext = EBML_CONTEXT(&TestHead);
[[maybe_unused]] const auto & AutoContext = EBML_CONTEXT(&TestHead);

return 0;
}

0 comments on commit 9e6f5b5

Please sign in to comment.