use DECLARE_EBML_*** in the legacy code too

add a EBML_CTX_IDX() macro to avoid direct access to MyTable

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@92 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-04-08 16:36:43 +00:00
parent d0c70fd901
commit 66ccb761d8
3 changed files with 544 additions and 533 deletions

View File

@ -201,6 +201,7 @@ extern const EbmlSemanticContext Context_EbmlGlobal;
#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)
#else
#define EBML_CONCRETE_CLASS(Type) \
public: \
@ -231,6 +232,7 @@ extern const EbmlSemanticContext Context_EbmlGlobal;
#define EBML_CTX_SIZE(c) (c).Size
#define EBML_CTX_MASTER(c) (c).MasterElt
#define EBML_CTX_PARENT(c) (c).UpTable
#define EBML_CTX_IDX(c,i) (c).MyTable[(i)]
#endif
// functions for generic handling of data (should be static to all classes)
@ -302,13 +304,14 @@ class EBML_DLL_API EbmlSemanticContext {
inline size_t GetSize() const { return Size; }
inline const EbmlCallbacks* GetMaster() const { return MasterElt; }
inline const EbmlSemanticContext* Parent() const { return UpTable; }
const EbmlSemantic & GetSemantic(size_t i) const;
const EbmlSemantic *MyTable; ///< First element in the table
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
#if defined(EBML_STRICT_API)
private:
#endif
const EbmlSemantic *MyTable; ///< First element in the table
size_t Size; ///< number of elements in the table
const EbmlSemanticContext *UpTable; ///< Parent element
/// \todo replace with the global context directly

View File

@ -212,6 +212,14 @@ EbmlCallbacks::EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalI
assert((Create!=NULL) || !strcmp(aDebugName, "DummyElement"));
}
const EbmlSemantic & EbmlSemanticContext::GetSemantic(size_t i) const
{
assert(i<Size);
if (i<Size)
return MyTable[i];
else
return *(EbmlSemantic*)NULL;
}
EbmlElement::EbmlElement(uint64 aDefaultSize, bool bValueSet)
@ -484,9 +492,9 @@ EbmlElement * EbmlElement::SkipData(EbmlStream & DataStream, const EbmlSemanticC
unsigned int EltIndex;
// data known in this Master's context
for (EltIndex = 0; EltIndex < EBML_CTX_SIZE(Context); EltIndex++) {
if (EbmlId(*Result) == EBML_SEM_ID(Context.MyTable[EltIndex])) {
if (EbmlId(*Result) == EBML_SEM_ID(EBML_CTX_IDX(Context,EltIndex))) {
// skip the data with its own context
Result = Result->SkipData(DataStream, EBML_SEM_CONTEXT(Context.MyTable[EltIndex]), NULL);
Result = Result->SkipData(DataStream, EBML_SEM_CONTEXT(EBML_CTX_IDX(Context,EltIndex)), NULL);
break; // let's go to the next ID
}
}
@ -519,8 +527,8 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb
// elements at the current level
for (ContextIndex = 0; ContextIndex < EBML_CTX_SIZE(Context); ContextIndex++) {
if (aID == EBML_SEM_ID(Context.MyTable[ContextIndex])) {
return &Context.MyTable[ContextIndex].Create();
if (aID == EBML_SEM_ID(EBML_CTX_IDX(Context,ContextIndex))) {
return &EBML_CTX_IDX(Context,ContextIndex).Create();
}
}

File diff suppressed because it is too large Load Diff