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

Turn main EBML macros into static inlines #264

Merged
merged 1 commit into from
Feb 25, 2024
Merged
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
86 changes: 74 additions & 12 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,22 @@ class DllApi x : public BaseClass { \
#define EBML_ID(ref) EBML_INFO_ID(EBML_INFO(ref))
#define EBML_CLASS_SEMCONTEXT(ref) Context_##ref
#define EBML_CLASS_CONTEXT(ref) EBML_INFO_CONTEXT(EBML_INFO(ref))
#define EBML_CONTEXT(e) (e)->Context()
#define EBML_NAME(e) (e)->DebugName()
#define EBML_CONTEXT(e) tEBML_CONTEXT(e)
#define EBML_NAME(e) tEBML_NAME(e)

#define EBML_INFO_ID(cb) (cb).ClassId()
#define EBML_INFO_NAME(cb) (cb).GetName()
#define EBML_INFO_CREATE(cb) (cb).NewElement()
#define EBML_INFO_CONTEXT(cb) (cb).GetContext()
#define EBML_INFO_ID(cb) tEBML_INFO_ID(cb)
#define EBML_INFO_NAME(cb) tEBML_INFO_NAME(cb)
#define EBML_INFO_CREATE(cb) tEBML_INFO_CREATE(cb)
#define EBML_INFO_CONTEXT(cb) tEBML_INFO_CONTEXT(cb)

#define EBML_SEM_SPECS(s) (s).GetCallbacks()
#define EBML_SEM_SPECS(s) tEBML_SEM_SPECS(s)
#define EBML_SEM_CONTEXT(s) EBML_INFO_CONTEXT(EBML_SEM_SPECS(s))
#define EBML_SEM_CREATE(s) (s).Create()
#define EBML_SEM_CREATE(s) tEBML_SEM_CREATE(s)

#define EBML_CTX_SIZE(c) (c).GetSize()
#define EBML_CTX_MASTER(c) (c).GetMaster()
#define EBML_CTX_PARENT(c) (c).Parent()
#define EBML_CTX_IDX(c,i) (c).GetSemantic(i)
#define EBML_CTX_SIZE(c) tEBML_CTX_SIZE(c)
#define EBML_CTX_MASTER(c) tEBML_CTX_MASTER(c)
#define EBML_CTX_PARENT(c) tEBML_CTX_PARENT(c)
#define EBML_CTX_IDX(c,i) tEBML_CTX_IDX(c,i)
#define EBML_CTX_IDX_INFO(c,i) EBML_SEM_SPECS(EBML_CTX_IDX(c,i))
#define EBML_CTX_IDX_ID(c,i) EBML_INFO_ID(EBML_CTX_IDX_INFO(c,i))

Expand Down Expand Up @@ -380,6 +380,26 @@ class EBML_DLL_API EbmlCallbacksWithDefault : public EbmlCallbacksDefault<T> {
const T defaultValue;
};

static inline constexpr const EbmlId & tEBML_INFO_ID(const EbmlCallbacks & cb)
{
return cb.ClassId();
}

static inline constexpr const char * tEBML_INFO_NAME(const EbmlCallbacks & cb)
{
return cb.GetName();
}

static inline EbmlElement & tEBML_INFO_CREATE(const EbmlCallbacks & cb)
{
return cb.NewElement();
}

static inline constexpr const EbmlSemanticContext & tEBML_INFO_CONTEXT(const EbmlCallbacks & cb)
{
return cb.GetContext();
}

/*!
\brief contains the semantic informations for a given level and all sublevels
\todo move the ID in the element class
Expand All @@ -400,6 +420,16 @@ class EBML_DLL_API EbmlSemantic {
const EbmlCallbacks & Callbacks;
};

static inline constexpr const EbmlCallbacks & tEBML_SEM_SPECS(const EbmlSemantic & s)
{
return s.GetCallbacks();
}

static inline EbmlElement & tEBML_SEM_CREATE(const EbmlSemantic & s)
{
return s.Create();
}

using _GetSemanticContext = const class EbmlSemanticContext &(*)();

/*!
Expand Down Expand Up @@ -437,6 +467,26 @@ class EBML_DLL_API EbmlSemanticContext {
const EbmlCallbacks *MasterElt;
};

static inline constexpr size_t tEBML_CTX_SIZE(const EbmlSemanticContext & c)
{
return c.GetSize();
}

static inline constexpr const EbmlCallbacks * tEBML_CTX_MASTER(const EbmlSemanticContext & c)
{
return c.GetMaster();
}

static inline constexpr const EbmlSemanticContext * tEBML_CTX_PARENT(const EbmlSemanticContext & c)
{
return c.Parent();
}

static inline const EbmlSemantic & tEBML_CTX_IDX(const EbmlSemanticContext & c, std::size_t i)
{
return c.GetSemantic(i);
}

/*!
\class EbmlElement
\brief Hold basic informations about an EBML element (ID + length)
Expand Down Expand Up @@ -706,6 +756,18 @@ class EBML_DLL_API EbmlElementDefaultStorage : public EbmlElementDefault<T> {
S Value;
};


static inline constexpr const EbmlSemanticContext & tEBML_CONTEXT(const EbmlElement * e)
{
return e->Context();
}

static inline constexpr const char * tEBML_NAME(const EbmlElement * e)
{
return e->DebugName();
}


} // namespace libebml

#define EBML_WRITE_FILTER 1
Expand Down
Loading