diff options
author | dfilimon@google.com <dfilimon@google.com@672e30a5-4c29-85ac-ac6d-611c735e0a51> | 2011-09-16 01:24:51 +0000 |
---|---|---|
committer | dfilimon@google.com <dfilimon@google.com@672e30a5-4c29-85ac-ac6d-611c735e0a51> | 2011-09-16 01:24:51 +0000 |
commit | 79fe62d80f2ab09a217c5948a9adbcd019f4455d (patch) | |
tree | 728fcd3cdb72ac58785a98fc0983eb04bfb84525 | |
parent | ba91573e890c0871c6949e480a365bc85d408e77 (diff) | |
download | src-79fe62d80f2ab09a217c5948a9adbcd019f4455d.tar.gz |
Minor cleanup.
git-svn-id: http://sfntly.googlecode.com/svn/trunk/cpp/src@82 672e30a5-4c29-85ac-ac6d-611c735e0a51
-rw-r--r-- | sfntly/table/core/cmap_table.cc | 25 | ||||
-rw-r--r-- | sfntly/table/core/cmap_table.h | 48 | ||||
-rw-r--r-- | sfntly/table/table.cc | 4 | ||||
-rw-r--r-- | test/autogenerated/cmap_basic_test.cc | 4 |
4 files changed, 42 insertions, 39 deletions
diff --git a/sfntly/table/core/cmap_table.cc b/sfntly/table/core/cmap_table.cc index 0f907b7..9df1158 100644 --- a/sfntly/table/core/cmap_table.cc +++ b/sfntly/table/core/cmap_table.cc @@ -14,8 +14,11 @@ * limitations under the License. */ -#include "sfntly/table/core/cmap_table.h" +// type.h needs to be included first because of building issues on Windows +// Type aliases we delcare are defined in other headers and make the build +// fail otherwise. #include "sfntly/port/type.h" +#include "sfntly/table/core/cmap_table.h" #include <stdio.h> #include <stdlib.h> @@ -75,7 +78,7 @@ CALLER_ATTACH CMapTable::CMap* CMapTable::GetCMap(const int32_t index) { return NULL; #endif } - return reinterpret_cast<CMapTable::CMap*>(cmap_builder->Build()); + return down_cast<CMapTable::CMap*>(cmap_builder->Build()); } CALLER_ATTACH CMapTable::CMap* CMapTable::GetCMap(const int32_t platform_id, @@ -359,9 +362,8 @@ CMapTable::CMapFormat0::CMapFormat0(ReadableFontData* data, : CMap(data, CMapFormat::kFormat0, cmap_id) { } -void -CMapTable::CMapFormat0::Iterator(CMapTable::CMap::CharacterIterator* output) { - output = new CMapTable::CMapFormat0::CharacterIterator(0, 0xff); +CMapTable::CMap::CharacterIterator* CMapTable::CMapFormat0::Iterator() { + return new CMapTable::CMapFormat0::CharacterIterator(0, 0xff); } @@ -442,8 +444,7 @@ CMapTable::CMapFormat0::Builder::Builder( UNREFERENCED_PARAMETER(offset); } -CMapTable::CMapFormat0::Builder:: -Builder(const CMapId& cmap_id) +CMapTable::CMapFormat0::Builder::Builder(const CMapId& cmap_id) : CMap::Builder(reinterpret_cast<ReadableFontData*>(NULL), CMapFormat::kFormat0, cmap_id) { @@ -554,6 +555,11 @@ int32_t CMapTable::CMapFormat2::IdDelta(int32_t sub_header_index) { Offset::kFormat2SubHeader_idDelta); } +CMapTable::CMap::CharacterIterator* CMapTable::CMapFormat2::Iterator() { + // UNIMPLEMENTED + return NULL; +} + /****************************************************************************** * CMapTable::CMapFormat2::Builder ******************************************************************************/ @@ -712,13 +718,10 @@ int32_t CMapTable::Builder::NumCMaps() { void CMapTable::Builder::Initialize(ReadableFontData* data) { int32_t num_cmaps = NumCMaps(data); for (int32_t i = 0; i < num_cmaps; ++i) { - Ptr<CMapTable::CMap::Builder> cmap_builder; - cmap_builder.Attach(CMapBuilder(data, i)); + CMapTable::CMap::Builder* cmap_builder = CMapBuilder(data, i); if (!cmap_builder) continue; cmap_builders_[cmap_builder->cmap_id()] = cmap_builder; - cmap_builders_.insert(std::make_pair(cmap_builder->cmap_id(), - cmap_builder)); } } diff --git a/sfntly/table/core/cmap_table.h b/sfntly/table/core/cmap_table.h index 8ff9706..bbdc7b5 100644 --- a/sfntly/table/core/cmap_table.h +++ b/sfntly/table/core/cmap_table.h @@ -17,8 +17,10 @@ #ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_CMAP_TABLE_H_ #define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_CMAP_TABLE_H_ +// type.h needs to be included first because of building issues on Windows +// Type aliases we delcare are defined in other headers and make the build +// fail otherwise. #include "sfntly/port/type.h" - #include <vector> #include <map> @@ -89,7 +91,6 @@ public: ~CMapIdFilter() {} virtual bool accept(const CMapId& cmap_id) const; private: - CMapIdFilter& operator=(const CMapIdFilter& that); const CMapId wanted_id_; const CMapIdComparator *comparator_; }; @@ -160,18 +161,22 @@ public: // The fully qualified name is CMapTable::CMap::CharacterIterator class CharacterIterator { public: - CharacterIterator() {} virtual ~CharacterIterator() {} virtual bool HasNext() = 0; // Returns -1 if there are no more characters to iterate through // and exceptions are turned off virtual int32_t Next() = 0; + + protected: + // Use the CMap::Iterator method below instead of directly requesting + // a CharacterIterator. + CharacterIterator() {} }; CMap(ReadableFontData* data, int32_t format, const CMapId& cmap_id); virtual ~CMap(); - virtual void Iterator(CMapTable::CMap::CharacterIterator* output) = 0; + virtual CMap::CharacterIterator* Iterator() = 0; virtual int32_t format() { return format_; } virtual CMapId cmap_id() { return cmap_id_; } @@ -213,16 +218,13 @@ public: class Builder : public CMap::Builder, public RefCounted<Builder> { public: - CALLER_ATTACH static Builder* NewInstance( - ReadableFontData* data, - int32_t offset, - const CMapId& cmap_id); - CALLER_ATTACH static Builder* NewInstance( - WritableFontData* data, - int32_t offset, - const CMapId& cmap_id); - CALLER_ATTACH static Builder* NewInstance( - const CMapId& cmap_id); + CALLER_ATTACH static Builder* NewInstance(ReadableFontData* data, + int32_t offset, + const CMapId& cmap_id); + CALLER_ATTACH static Builder* NewInstance(WritableFontData* data, + int32_t offset, + const CMapId& cmap_id); + CALLER_ATTACH static Builder* NewInstance(const CMapId& cmap_id); virtual ~Builder(); protected: @@ -232,14 +234,9 @@ public: private: // When creating a new CMapFormat0 Builder, use NewInstance instead of // the constructors! This avoids a memory leak when slicing the FontData. - Builder(ReadableFontData* data, - int32_t offset, - const CMapId& cmap_id); - Builder(WritableFontData* data, - int32_t offset, - const CMapId& cmap_id); - Builder( - const CMapId& cmap_id); + Builder(ReadableFontData* data, int32_t offset, const CMapId& cmap_id); + Builder(WritableFontData* data, int32_t offset, const CMapId& cmap_id); + Builder(const CMapId& cmap_id); }; // The fully qualified name is CMapTable::CMapFormat0::CharacterIterator @@ -258,7 +255,7 @@ public: virtual ~CMapFormat0(); virtual int32_t Language(); virtual int32_t GlyphId(int32_t character); - virtual void Iterator(CMap::CharacterIterator* output); + CMap::CharacterIterator* Iterator(); private: CMapFormat0(ReadableFontData* data, const CMapId& cmap_id); @@ -315,9 +312,7 @@ public: int32_t EntryCount(int32_t sub_header_index); int32_t IdRangeOffset(int32_t sub_header_index); int32_t IdDelta(int32_t sub_header_index); - void Iterator(CMapTable::CMap::CharacterIterator* output) { - UNREFERENCED_PARAMETER(output); - } + CMap::CharacterIterator* Iterator(); }; // CMapTable::Builder @@ -531,7 +526,6 @@ public: }; typedef std::vector<CMapTable::CMapId> CMapIdList; typedef Ptr<CMapTable> CMapTablePtr; - } // namespace sfntly #endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_CMAP_TABLE_H_ diff --git a/sfntly/table/table.cc b/sfntly/table/table.cc index 02f13e7..8f4571e 100644 --- a/sfntly/table/table.cc +++ b/sfntly/table/table.cc @@ -14,6 +14,10 @@ * limitations under the License. */ +// type.h needs to be included first because of building issues on Windows +// Type aliases we delcare are defined in other headers and make the build +// fail otherwise. +#include "sfntly/port/type.h" #include "sfntly/table/table.h" #include "sfntly/font.h" diff --git a/test/autogenerated/cmap_basic_test.cc b/test/autogenerated/cmap_basic_test.cc index 119906d..0c09199 100644 --- a/test/autogenerated/cmap_basic_test.cc +++ b/test/autogenerated/cmap_basic_test.cc @@ -14,8 +14,10 @@ * limitations under the License. */ +// type.h needs to be included first because of building issues on Windows +// Type aliases we delcare are defined in other headers and make the build +// fail otherwise. #include "sfntly/port/type.h" - #include <assert.h> #include <stdio.h> #include <unicode/ucnv.h> |