Skip to content

Commit

Permalink
factorize some macros
Browse files Browse the repository at this point in the history
So we only have to change one to make changes on all types.
  • Loading branch information
robUx4 committed Dec 29, 2023
1 parent 01eca30 commit 2707901
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,85 +72,70 @@ class EbmlElement;
const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, nullptr, global, &EBML_INFO(x)); \
constexpr EbmlCallbacks x::ClassInfos(x::Create, Id_##x, infinite, name, Context_##x); \

#define DEFINE_xxx_CLASS(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
constexpr EbmlCallbacks x::ClassInfos(x::Create, Id_##x, false, name, Context_##x); \
x::x() {}

#define DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x));

#define DEFINE_xxx_CLASS(x,id,idl,parent,name,global) \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacks x::ClassInfos(x::Create, Id_##x, false, name, Context_##x);

#define DEFINE_xxx_UINTEGER(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<std::uint64_t> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlUInteger(x::ClassInfos) {}

#define DEFINE_xxx_SINTEGER(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<std::int64_t> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlSInteger(x::ClassInfos) {}

#define DEFINE_xxx_STRING(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<const char *> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlString(x::ClassInfos) {}

#define DEFINE_xxx_UNISTRING(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<const wchar_t *> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlUnicodeString(x::ClassInfos) {}

#define DEFINE_xxx_FLOAT(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<double> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlFloat(x::ClassInfos) {}

#define DEFINE_xxx_DATE(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<std::int64_t> x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlDate(x::ClassInfos) {}

#define DEFINE_xxx_BINARY(x,id,idl,parent,name,global) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
constexpr EbmlCallbacks x::ClassInfos(x::Create, Id_##x, false, name, Context_##x); \
DEFINE_xxx_CLASS(x,id,idl,parent,name,global) \
x::x() :EbmlBinary(x::ClassInfos) {}

#define DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,global,defval) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<std::uint64_t> x::ClassInfos(x::Create, Id_##x, static_cast<std::uint64_t>(defval), name, Context_##x); \
x::x() :EbmlUInteger(x::ClassInfos) {}

#define DEFINE_xxx_SINTEGER_DEF(x,id,idl,parent,name,global,defval) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<std::int64_t> x::ClassInfos(x::Create, Id_##x, static_cast<std::int64_t>(defval), name, Context_##x); \
x::x() :EbmlSInteger(x::ClassInfos) {}

#define DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,global,defval) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<const char *> x::ClassInfos(x::Create, Id_##x, static_cast<const char *>(defval), name, Context_##x); \
x::x() :EbmlString(x::ClassInfos) {}

#define DEFINE_xxx_UNISTRING_DEF(x,id,idl,parent,name,global,defval) \
constexpr EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<const wchar_t *> x::ClassInfos(x::Create, Id_##x, static_cast<const wchar_t *>(defval), name, Context_##x); \
x::x() :EbmlUnicodeString(x::ClassInfos) {}

#define DEFINE_xxx_FLOAT_DEF(x,id,idl,parent,name,global,defval) \
constexpr EbmlId Id_##x (id, idl); \
constexpr EbmlSemanticContext Context_##x = EbmlSemanticContext(0, nullptr, &Context_##parent, global, &EBML_INFO(x)); \
DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
constexpr EbmlCallbacksDefault<double> x::ClassInfos(x::Create, Id_##x, static_cast<double>(defval), name, Context_##x); \
x::x() :EbmlFloat(x::ClassInfos) {}

Expand Down

0 comments on commit 2707901

Please sign in to comment.