diff options
21 files changed, 58 insertions, 33 deletions
@@ -821,7 +821,6 @@ static_library("fxcrt") { "core/fxcrt/cfx_fixedbufgrow.h", "core/fxcrt/cfx_memorystream.cpp", "core/fxcrt/cfx_memorystream.h", - "core/fxcrt/cfx_string_pool_template.h", "core/fxcrt/cfx_unowned_ptr.h", "core/fxcrt/cfx_utf8decoder.cpp", "core/fxcrt/cfx_utf8decoder.h", @@ -857,6 +856,7 @@ static_library("fxcrt") { "core/fxcrt/retain_ptr.h", "core/fxcrt/shared_copy_on_write.h", "core/fxcrt/string_data_template.h", + "core/fxcrt/string_pool_template.h", "core/fxcrt/string_view_template.h", "core/fxcrt/widestring.cpp", "core/fxcrt/widestring.h", @@ -1920,7 +1920,6 @@ test("pdfium_unittests") { "core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp", "core/fxcodec/jbig2/JBig2_Image_unittest.cpp", "core/fxcrt/bytestring_unittest.cpp", - "core/fxcrt/cfx_string_pool_template_unittest.cpp", "core/fxcrt/cfx_unowned_ptr_unittest.cpp", "core/fxcrt/cfx_weak_ptr_unittest.cpp", "core/fxcrt/fx_bidi_unittest.cpp", @@ -1934,6 +1933,7 @@ test("pdfium_unittests") { "core/fxcrt/observable_unittest.cpp", "core/fxcrt/retain_ptr_unittest.cpp", "core/fxcrt/shared_copy_on_write_unittest.cpp", + "core/fxcrt/string_pool_template_unittest.cpp", "core/fxcrt/widestring_unittest.cpp", "core/fxge/dib/cstretchengine_unittest.cpp", "fpdfsdk/fpdfdoc_unittest.cpp", diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h index 075cc04c7c..d96f787da1 100644 --- a/core/fpdfapi/font/cpdf_fontencoding.h +++ b/core/fpdfapi/font/cpdf_fontencoding.h @@ -9,9 +9,9 @@ #include <memory> -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/string_pool_template.h" #define PDFFONT_ENCODING_BUILTIN 0 #define PDFFONT_ENCODING_WINANSI 1 diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h index 32001a8b6e..53d5dfd135 100644 --- a/core/fpdfapi/page/cpdf_streamparser.h +++ b/core/fpdfapi/page/cpdf_streamparser.h @@ -14,8 +14,8 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/parser/cpdf_object.h" #include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" +#include "core/fxcrt/string_pool_template.h" class CPDF_StreamParser { public: diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h index 93c00c8c10..a9ff353fbe 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.h +++ b/core/fpdfapi/parser/cpdf_dictionary.h @@ -13,10 +13,10 @@ #include <utility> #include "core/fpdfapi/parser/cpdf_object.h" -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/string_pool_template.h" #include "third_party/base/ptr_util.h" class CPDF_IndirectObjectHolder; diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h index ab99dd5fcc..ea70c4a351 100644 --- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h +++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h @@ -14,9 +14,9 @@ #include <vector> #include "core/fpdfapi/parser/cpdf_object.h" -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/string_pool_template.h" #include "third_party/base/ptr_util.h" class CPDF_IndirectObjectHolder { diff --git a/core/fpdfapi/parser/cpdf_name.h b/core/fpdfapi/parser/cpdf_name.h index 72a72a3a66..8a1cf2b63b 100644 --- a/core/fpdfapi/parser/cpdf_name.h +++ b/core/fpdfapi/parser/cpdf_name.h @@ -10,8 +10,8 @@ #include <memory> #include "core/fpdfapi/parser/cpdf_object.h" -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" +#include "core/fxcrt/string_pool_template.h" class CPDF_Name : public CPDF_Object { public: diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h index 9fd3e6ae8a..6f762ae27b 100644 --- a/core/fpdfapi/parser/cpdf_string.h +++ b/core/fpdfapi/parser/cpdf_string.h @@ -10,10 +10,10 @@ #include <memory> #include "core/fpdfapi/parser/cpdf_object.h" -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/string_pool_template.h" class CPDF_String : public CPDF_Object { public: diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 78d5345001..cb266837dc 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -10,8 +10,8 @@ #include <algorithm> #include <memory> -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_weak_ptr.h" +#include "core/fxcrt/string_pool_template.h" class CPDF_CryptoHandler; class CPDF_Dictionary; diff --git a/core/fpdfdoc/cpdf_filespec.h b/core/fpdfdoc/cpdf_filespec.h index 2cbbc15977..131dfbe7ca 100644 --- a/core/fpdfdoc/cpdf_filespec.h +++ b/core/fpdfdoc/cpdf_filespec.h @@ -7,10 +7,10 @@ #ifndef CORE_FPDFDOC_CPDF_FILESPEC_H_ #define CORE_FPDFDOC_CPDF_FILESPEC_H_ -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/cfx_weak_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/string_pool_template.h" class CPDF_Dictionary; class CPDF_Object; diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index a78020bae4..aa1fb57775 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -12,17 +12,17 @@ #include <cctype> #include <string> -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_utf8decoder.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/string_pool_template.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/stl_util.h" template class fxcrt::StringDataTemplate<char>; template class fxcrt::StringViewTemplate<char>; -template class CFX_StringPoolTemplate<ByteString>; +template class fxcrt::StringPoolTemplate<ByteString>; template struct std::hash<ByteString>; namespace { diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index c2c41e8c47..eba9744402 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -18,11 +18,10 @@ #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" -class ByteString_Concat_Test; -class fxcrt_ByteStringPool_Test; - namespace fxcrt { +class ByteString_Concat_Test; +class StringPool_ByteString_Test; class WideString; // A mutable string with shared buffers using copy-on-write semantics that @@ -198,7 +197,7 @@ class ByteString { RetainPtr<StringData> m_pData; friend ByteString_Concat_Test; - friend fxcrt_ByteStringPool_Test; + friend class StringPool_ByteString_Test; }; inline bool operator==(const char* lhs, const ByteString& rhs) { diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 06ba1f42fd..e1c832e114 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -11,6 +11,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/stl_util.h" +namespace fxcrt { + TEST(ByteString, ElementAccess) { const ByteString abc("abc"); EXPECT_EQ('a', abc[0]); @@ -1640,3 +1642,5 @@ TEST(ByteString, FormatInteger) { EXPECT_EQ("2147483647", ByteString::FormatInteger(INT_MAX)); EXPECT_EQ("-2147483648", ByteString::FormatInteger(INT_MIN)); } + +} // namespace fxcrt diff --git a/core/fxcrt/maybe_owned_unittest.cpp b/core/fxcrt/maybe_owned_unittest.cpp index 686fa6ffd2..7182647207 100644 --- a/core/fxcrt/maybe_owned_unittest.cpp +++ b/core/fxcrt/maybe_owned_unittest.cpp @@ -12,7 +12,6 @@ #include "third_party/base/ptr_util.h" namespace fxcrt { - namespace { class PseudoDeletable { diff --git a/core/fxcrt/observable_unittest.cpp b/core/fxcrt/observable_unittest.cpp index 8edc58f613..5e64743d86 100644 --- a/core/fxcrt/observable_unittest.cpp +++ b/core/fxcrt/observable_unittest.cpp @@ -9,6 +9,7 @@ #include "testing/gtest/include/gtest/gtest.h" +namespace fxcrt { namespace { class PseudoObservable : public Observable<PseudoObservable> { @@ -183,3 +184,5 @@ TEST(ObservePtr, Bool) { EXPECT_FALSE(null_bool); EXPECT_TRUE(obj1_bool); } + +} // namespace fxcrt diff --git a/core/fxcrt/retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp index 3e14478dbf..f4b2994eae 100644 --- a/core/fxcrt/retain_ptr_unittest.cpp +++ b/core/fxcrt/retain_ptr_unittest.cpp @@ -9,6 +9,7 @@ #include "testing/gtest/include/gtest/gtest.h" +namespace fxcrt { namespace { class PseudoRetainable { @@ -298,3 +299,5 @@ TEST(RetainPtr, VectorMove) { EXPECT_EQ(1, obj.retain_count()); EXPECT_EQ(1, obj.release_count()); } + +} // namespace fxcrt diff --git a/core/fxcrt/shared_copy_on_write_unittest.cpp b/core/fxcrt/shared_copy_on_write_unittest.cpp index a683767054..01cc09468c 100644 --- a/core/fxcrt/shared_copy_on_write_unittest.cpp +++ b/core/fxcrt/shared_copy_on_write_unittest.cpp @@ -9,6 +9,7 @@ #include "testing/gtest/include/gtest/gtest.h" +namespace fxcrt { namespace { class Observer { @@ -126,3 +127,5 @@ TEST(SharedCopyOnWrite, GetModify) { } EXPECT_EQ(2, observer.GetDestructionCount("one")); } + +} // namespace fxcrt diff --git a/core/fxcrt/cfx_string_pool_template.h b/core/fxcrt/string_pool_template.h index b170a84127..2f9fb09a9f 100644 --- a/core/fxcrt/cfx_string_pool_template.h +++ b/core/fxcrt/string_pool_template.h @@ -4,15 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_ -#define CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_ +#ifndef CORE_FXCRT_STRING_POOL_TEMPLATE_H_ +#define CORE_FXCRT_STRING_POOL_TEMPLATE_H_ #include <unordered_set> #include "core/fxcrt/fx_string.h" +namespace fxcrt { + template <typename StringType> -class CFX_StringPoolTemplate { +class StringPoolTemplate { public: StringType Intern(const StringType& str) { return *m_Pool.insert(str).first; } void Clear() { m_Pool.clear(); } @@ -21,10 +23,14 @@ class CFX_StringPoolTemplate { std::unordered_set<StringType> m_Pool; }; -using ByteStringPool = CFX_StringPoolTemplate<ByteString>; -using WideStringPool = CFX_StringPoolTemplate<WideString>; +extern template class StringPoolTemplate<ByteString>; +extern template class StringPoolTemplate<WideString>; + +} // namespace fxcrt + +using fxcrt::StringPoolTemplate; -extern template class CFX_StringPoolTemplate<ByteString>; -extern template class CFX_StringPoolTemplate<WideString>; +using ByteStringPool = StringPoolTemplate<ByteString>; +using WideStringPool = StringPoolTemplate<WideString>; -#endif // CORE_FXCRT_CFX_STRING_POOL_TEMPLATE_H_ +#endif // CORE_FXCRT_STRING_POOL_TEMPLATE_H_ diff --git a/core/fxcrt/cfx_string_pool_template_unittest.cpp b/core/fxcrt/string_pool_template_unittest.cpp index 9a5ac5d3ed..717e33d919 100644 --- a/core/fxcrt/cfx_string_pool_template_unittest.cpp +++ b/core/fxcrt/string_pool_template_unittest.cpp @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/fxcrt/cfx_string_pool_template.h" +#include "core/fxcrt/string_pool_template.h" #include "core/fxcrt/fx_string.h" #include "testing/gtest/include/gtest/gtest.h" -TEST(fxcrt, ByteStringPool) { +namespace fxcrt { + +TEST(StringPool, ByteString) { ByteStringPool pool; ByteString null1; @@ -49,7 +51,7 @@ TEST(fxcrt, ByteStringPool) { EXPECT_EQ(goats2.m_pData, reinterned_goats2.m_pData); } -TEST(fxcrt, WideStringPool) { +TEST(StringPool, WideString) { WideStringPool pool; WideString null1; @@ -91,3 +93,5 @@ TEST(fxcrt, WideStringPool) { EXPECT_EQ(goats2.m_pData, reinterned_goats1.m_pData); EXPECT_EQ(goats2.m_pData, reinterned_goats2.m_pData); } + +} // namespace fxcrt diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index e5925845be..5fe7ee4777 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -12,17 +12,17 @@ #include <cctype> #include <cwctype> -#include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/cfx_utf8decoder.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/string_pool_template.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/stl_util.h" template class fxcrt::StringDataTemplate<wchar_t>; template class fxcrt::StringViewTemplate<wchar_t>; -template class CFX_StringPoolTemplate<WideString>; +template class fxcrt::StringPoolTemplate<WideString>; template struct std::hash<WideString>; #define FORCE_ANSI 0x10000 diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index df7d95fc6f..f56703f1ab 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -18,12 +18,12 @@ #include "core/fxcrt/string_view_template.h" #include "third_party/base/optional.h" -class WideString_ConcatInPlace_Test; -class fxcrt_WideStringPool_Test; namespace fxcrt { class ByteString; +class StringPool_WideString_Test; +class WideString_ConcatInPlace_Test; // A mutable string with shared buffers using copy-on-write semantics that // avoids the cost of std::string's iterator stability guarantees. @@ -195,7 +195,7 @@ class WideString { RetainPtr<StringData> m_pData; friend WideString_ConcatInPlace_Test; - friend fxcrt_WideStringPool_Test; + friend StringPool_WideString_Test; }; inline WideString operator+(const WideStringView& str1, diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index 949827f6f1..5eba72eea7 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -10,6 +10,8 @@ #include "core/fxcrt/fx_string.h" #include "testing/gtest/include/gtest/gtest.h" +namespace fxcrt { + TEST(WideString, ElementAccess) { const WideString abc(L"abc"); EXPECT_EQ(L'a', abc[0]); @@ -1603,3 +1605,5 @@ TEST(WideStringView, WideOStreamOverload) { EXPECT_EQ(L"abcdef", stream.str()); } } + +} // namespace fxcrt |