From 3da71d51e04f99a531d4aced9d43035398ab8e85 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 21 Mar 2018 07:50:59 -0700 Subject: [PATCH] Move source files to the src directory --- CMakeLists.txt | 6 ++-- include/fmt/{format.cc => format-inl.h} | 46 ++++--------------------- include/fmt/format.h | 2 +- {include/fmt => src}/posix.cc | 2 +- test/CMakeLists.txt | 8 ++--- test/format-impl-test.cc | 2 +- test/format-test.cc | 3 +- test/posix-mock-test.cc | 2 +- 8 files changed, 19 insertions(+), 52 deletions(-) rename include/fmt/{format.cc => format-inl.h} (90%) rename {include/fmt => src}/posix.cc (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 663b8ab5..045004a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,12 +95,12 @@ function(add_headers VAR) endfunction() # Define the fmt library, its includes and the needed defines. -# format.cc is added to FMT_HEADERS for the header-only configuration. -add_headers(FMT_HEADERS core.h format.h format.cc locale.h ostream.h printf.h +add_headers(FMT_HEADERS core.h format.h format-inl.h locale.h ostream.h printf.h time.h) +set(FMT_SOURCES src/format.cc) if (HAVE_OPEN) add_headers(FMT_HEADERS posix.h) - add_headers(FMT_SOURCES posix.cc) + set(FMT_SOURCES ${FMT_SOURCES} src/posix.cc) endif () add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst) diff --git a/include/fmt/format.cc b/include/fmt/format-inl.h similarity index 90% rename from include/fmt/format.cc rename to include/fmt/format-inl.h index 0b4f2d80..f5958732 100644 --- a/include/fmt/format.cc +++ b/include/fmt/format-inl.h @@ -5,6 +5,9 @@ // // For the license information refer to format.h. +#ifndef FMT_FORMAT_INL_H_ +#define FMT_FORMAT_INL_H_ + #include "format.h" #include "locale.h" @@ -69,7 +72,7 @@ inline fmt::internal::null<> strerror_s(char *, std::size_t, ...) { namespace fmt { FMT_FUNC format_error::~format_error() throw() {} -FMT_FUNC system_error::~system_error() throw() {} +FMT_FUNC system_error::~system_error() FMT_DTOR_NOEXCEPT {} namespace { @@ -438,47 +441,10 @@ FMT_FUNC void vprint_colored(color c, string_view format, format_args args) { FMT_FUNC locale locale_provider::locale() { return fmt::locale(); } -#ifndef FMT_HEADER_ONLY - -template struct internal::basic_data; - -// Explicit instantiations for char. - -template char internal::thousands_sep(locale_provider *lp); - -template void basic_fixed_buffer::grow(std::size_t); - -template void internal::arg_map::init( - const basic_format_args &args); - -template FMT_API int internal::char_traits::format_float( - char *buffer, std::size_t size, const char *format, - unsigned width, int precision, double value); - -template FMT_API int internal::char_traits::format_float( - char *buffer, std::size_t size, const char *format, - unsigned width, int precision, long double value); - -// Explicit instantiations for wchar_t. - -template wchar_t internal::thousands_sep(locale_provider *lp); - -template void basic_fixed_buffer::grow(std::size_t); - -template void internal::arg_map::init(const wformat_args &args); - -template FMT_API int internal::char_traits::format_float( - wchar_t *buffer, std::size_t size, const wchar_t *format, - unsigned width, int precision, double value); - -template FMT_API int internal::char_traits::format_float( - wchar_t *buffer, std::size_t size, const wchar_t *format, - unsigned width, int precision, long double value); - -#endif // FMT_HEADER_ONLY - } // namespace fmt #ifdef _MSC_VER # pragma warning(pop) #endif + +#endif // FMT_FORMAT_INL_H_ diff --git a/include/fmt/format.h b/include/fmt/format.h index 6283780a..4c31bd31 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3546,7 +3546,7 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; } #ifdef FMT_HEADER_ONLY # define FMT_FUNC inline -# include "format.cc" +# include "format-inl.h" #else # define FMT_FUNC #endif diff --git a/include/fmt/posix.cc b/src/posix.cc similarity index 99% rename from include/fmt/posix.cc rename to src/posix.cc index 463f22d0..7e0fac43 100644 --- a/include/fmt/posix.cc +++ b/src/posix.cc @@ -10,7 +10,7 @@ # define _CRT_SECURE_NO_WARNINGS #endif -#include "posix.h" +#include "fmt/posix.h" #include #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cf5e56d5..b0c479cb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -73,7 +73,7 @@ function(add_fmt_test name) add_fmt_executable(${name} ${name}.cc ${ARGN}) target_link_libraries(${name} test-main) - # define if certain c++ features can be used + # Define if certain C++ features can be used. target_compile_definitions(${name} PRIVATE FMT_USE_TYPE_TRAITS=$ FMT_USE_ENUM_BASE=$) @@ -101,7 +101,7 @@ endif () if (HAVE_OPEN) add_fmt_executable(posix-mock-test - posix-mock-test.cc ../include/fmt/format.cc ${TEST_MAIN_SRC}) + posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC}) target_include_directories( posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include) target_compile_definitions(posix-mock-test PRIVATE FMT_USE_FILE_DESCRIPTORS=1) @@ -124,7 +124,7 @@ endif () # Test that the library can be compiled with exceptions disabled. check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG) if (HAVE_FNO_EXCEPTIONS_FLAG) - add_library(noexception-test ../include/fmt/format.cc) + add_library(noexception-test ../src/format.cc) target_compile_options(noexception-test PUBLIC ${CPP14_FLAG}) target_include_directories( noexception-test PRIVATE ${PROJECT_SOURCE_DIR}/include) @@ -134,7 +134,7 @@ endif () if (FMT_PEDANTIC) # Test that the library compiles without windows.h. if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - add_library(no-windows-h-test ../include/fmt/format.cc) + add_library(no-windows-h-test ../src/format.cc) target_compile_options(no-windows-h-test PUBLIC ${CPP14_FLAG}) target_include_directories( no-windows-h-test PRIVATE ${PROJECT_SOURCE_DIR}/include) diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index c234c1b4..079b2f27 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -10,7 +10,7 @@ #include "test-assert.h" // Include format.cc instead of format.h to test implementation. -#include "fmt/format.cc" +#include "../src/format.cc" #include "fmt/printf.h" #include diff --git a/test/format-test.cc b/test/format-test.cc index 17dedd3b..aec17273 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1637,7 +1637,7 @@ TEST(FormatTest, OutputIterators) { } TEST(FormatTest, OutputSize) { - EXPECT_EQ(2, fmt::count("{}", 42)); + EXPECT_EQ(2u, fmt::count("{}", 42)); } #if FMT_USE_CONSTEXPR @@ -1974,3 +1974,4 @@ TEST(FormatTest, FormatStringErrors) { int, int); } #endif // FMT_USE_CONSTEXPR + diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 6c913285..950d11c1 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -9,7 +9,7 @@ #define _CRT_SECURE_NO_WARNINGS #include "posix-mock.h" -#include "fmt/posix.cc" +#include "../src/posix.cc" #include #include