From 19ae0bb4183b3efe7567f25d906e4eb9b53a6ce0 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 15 Apr 2010 14:59:25 +0000 Subject: [PATCH] v1/v2: clean the access of EbmlId data git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@124 a6f86f6d-0131-4f8e-9e7b-e335508773d5 --- ebml/EbmlElement.h | 2 +- ebml/EbmlId.h | 8 ++++---- ebml/EbmlMaster.h | 2 +- src/EbmlElement.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index 95dadb9..a1e7de1 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -407,7 +407,7 @@ class EBML_DLL_API EbmlElement { virtual bool IsMaster() const {return false;} uint8 HeadSize() const { - return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); + return EBML_ID_LENGTH((const EbmlId&)*this) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); } /// return the size of the head, on reading/writing /*! diff --git a/ebml/EbmlId.h b/ebml/EbmlId.h index 4de3c7e..b15bd74 100644 --- a/ebml/EbmlId.h +++ b/ebml/EbmlId.h @@ -42,11 +42,11 @@ START_LIBEBML_NAMESPACE #if defined(EBML_STRICT_API) -#define EBML_ID_VALUE(id) id.GetValue() -#define EBML_ID_LENGTH(id) id.GetLength() +#define EBML_ID_VALUE(id) (id).GetValue() +#define EBML_ID_LENGTH(id) (id).GetLength() #else -#define EBML_ID_VALUE(id) id.Value -#define EBML_ID_LENGTH(id) id.Length +#define EBML_ID_VALUE(id) (id).Value +#define EBML_ID_LENGTH(id) (id).Length #endif /*! diff --git a/ebml/EbmlMaster.h b/ebml/EbmlMaster.h index 4ad3c4f..0063464 100644 --- a/ebml/EbmlMaster.h +++ b/ebml/EbmlMaster.h @@ -81,7 +81,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement { } uint64 GetDataStart() const { - return GetElementPosition() + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()); + return GetElementPosition() + EBML_ID_LENGTH((const EbmlId&)*this) + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()); } /*! diff --git a/src/EbmlElement.cpp b/src/EbmlElement.cpp index 22f33d0..f037b05 100644 --- a/src/EbmlElement.cpp +++ b/src/EbmlElement.cpp @@ -605,7 +605,7 @@ filepos_t EbmlElement::Render(IOCallback & output, bool bWithDefault, bool bKeep */ filepos_t EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bWithDefault, bool bKeepPosition) { - if (EBML_ID_LENGTH(EbmlId(*this)) <= 0 || EBML_ID_LENGTH(EbmlId(*this)) > 4) + if (EBML_ID_LENGTH((const EbmlId&)*this) <= 0 || EBML_ID_LENGTH((const EbmlId&)*this) > 4) return 0; UpdateSize(bWithDefault, bForceRender); @@ -618,7 +618,7 @@ filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition) binary FinalHead[4+8]; // Class D + 64 bits coded size unsigned int FinalHeadSize; - FinalHeadSize = EBML_ID_LENGTH(EbmlId(*this)); + FinalHeadSize = EBML_ID_LENGTH((const EbmlId&)*this); EbmlId(*this).Fill(FinalHead); int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite); @@ -628,7 +628,7 @@ filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition) output.writeFully(FinalHead, FinalHeadSize); if (!bKeepPosition) { ElementPosition = output.getFilePointer() - FinalHeadSize; - SizePosition = ElementPosition + EBML_ID_LENGTH(EbmlId(*this)); + SizePosition = ElementPosition + EBML_ID_LENGTH((const EbmlId&)*this); } return FinalHeadSize; @@ -638,7 +638,7 @@ uint64 EbmlElement::ElementSize(bool bWithDefault) const { if (!bWithDefault && IsDefaultValue()) return 0; // won't be saved - return Size + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); + return Size + EBML_ID_LENGTH((const EbmlId&)*this) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); } bool EbmlElement::IsSmallerThan(const EbmlElement *Cmp) const