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

Rework element creation #289

Open
wants to merge 5 commits 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
1 change: 0 additions & 1 deletion ebml/EbmlDummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class EBML_DLL_API EbmlDummy : public EbmlBinary {
return DummyId;
}

EbmlElement & CreateElement() const override { return Create(); }
EbmlElement * Clone() const override { return new EbmlDummy(DummyId); }

static EbmlElement & Create() { return *(new EbmlDummy()); }
Expand Down
18 changes: 9 additions & 9 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ class DllApi x : public BaseClass { \

#define EBML_CONCRETE_CLASS(Type) \
public: \
libebml::EbmlElement & CreateElement() const override {return Create();} \
libebml::EbmlElement * Clone() const override { return new Type(*this); } \
static libebml::EbmlElement & Create() {return *(new Type);} \
static constexpr const libebml::EbmlCallbacks & ClassInfo() {return ClassInfos;} \
Expand All @@ -257,6 +256,8 @@ class DllApi x : public BaseClass { \
#define EBML_CLASS_SEMCONTEXT(ref) Context_##ref
#define EBML_CONTEXT(e) tEBML_CONTEXT(e)
#define EBML_NAME(e) tEBML_NAME(e)
#define EBML_SPEC(e) tEBML_SPEC(e)
#define EBML_CREATE(e) EBML_INFO_CREATE(EBML_SPEC(e))

#define EBML_INFO_ID(cb) tEBML_INFO_ID(cb)
#define EBML_INFO_NAME(cb) tEBML_INFO_NAME(cb)
Expand All @@ -265,7 +266,7 @@ class DllApi x : public BaseClass { \

#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) tEBML_SEM_CREATE(s)
#define EBML_SEM_CREATE(s) EBML_INFO_CREATE(EBML_SEM_SPECS(s))

#define EBML_CTX_SIZE(c) tEBML_CTX_SIZE(c)
#define EBML_CTX_MASTER(c) tEBML_CTX_MASTER(c)
Expand Down Expand Up @@ -429,7 +430,6 @@ class EBML_DLL_API EbmlSemantic {

inline constexpr bool IsMandatory() const { return Mandatory; }
inline constexpr bool IsUnique() const { return Unique; }
inline EbmlElement & Create() const { return EBML_INFO_CREATE(Callbacks); }
inline constexpr EbmlCallbacks const &GetCallbacks() const { return Callbacks; }

private:
Expand All @@ -443,11 +443,6 @@ static inline constexpr const EbmlCallbacks & tEBML_SEM_SPECS(const EbmlSemantic
return s.GetCallbacks();
}

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

using _GetSemanticContext = const EbmlSemanticContextMaster &(*)();

/*!
Expand Down Expand Up @@ -601,7 +596,7 @@ class EBML_DLL_API EbmlElement {
virtual explicit operator const EbmlId &() const { return GetClassId(); }
constexpr const char *DebugName() const {return ClassInfo.GetName();}
constexpr const EbmlSemanticContext &Context() const {return ClassInfo.GetContext();}
virtual EbmlElement & CreateElement() const = 0;
EbmlElement & CreateElement() const { return EBML_INFO_CREATE(ClassInfo); }

/*!
* \brief Set whether the size is finite
Expand Down Expand Up @@ -826,6 +821,11 @@ static inline constexpr const EbmlSemanticContext & tEBML_CONTEXT(const EbmlElem
return e->Context();
}

static inline const EbmlCallbacks & tEBML_SPEC(const EbmlElement & e)
{
return e.ElementSpec();
}

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