From 4d536ce2e97df7530c9420942953ea5ddefb0c46 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 14 Jun 2024 16:12:47 +0200 Subject: [PATCH] fixup! Make internal classes LIBZIM_API. --- meson.build | 1 + src/_dirent.h | 3 ++- src/buffer.h | 2 +- src/buffer_reader.h | 2 +- src/cluster.h | 2 +- src/compression.h | 4 ++-- src/config.h.in | 10 ++++++++++ src/dirent_accessor.h | 3 ++- src/direntreader.h | 2 +- src/file_compound.h | 4 +++- src/file_reader.h | 6 +++--- src/fileheader.h | 4 +++- src/fs_windows.h | 5 +++-- src/istreamreader.h | 2 +- src/tools.h | 14 +++++++------- src/writer/_dirent.h | 2 +- src/writer/cluster.h | 3 ++- src/xapian/htmlparse.h | 4 +++- src/xapian/myhtmlparse.h | 2 +- 19 files changed, 48 insertions(+), 27 deletions(-) diff --git a/meson.build b/meson.build index fad5bf963..a769abffd 100644 --- a/meson.build +++ b/meson.build @@ -41,6 +41,7 @@ endif if get_option('default_library') == 'shared' public_conf.set('LIBZIM_EXPORT_DLL', true) + add_project_arguments('-DLIBZIM_EXPORT_PRIVATE_DLL', language: 'cpp') endif zstd_dep = dependency('libzstd', static:static_linkage, default_options:['werror=false']) diff --git a/src/_dirent.h b/src/_dirent.h index 574ed9225..e6ee14457 100644 --- a/src/_dirent.h +++ b/src/_dirent.h @@ -27,12 +27,13 @@ #include #include "zim_types.h" +#include "config.h" namespace zim { class Buffer; class InvalidSize : public std::exception {}; - class LIBZIM_API Dirent + class LIBZIM_PRIVATE_API Dirent { protected: uint16_t mimeType; diff --git a/src/buffer.h b/src/buffer.h index 39961ca30..9c59647e6 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -29,7 +29,7 @@ namespace zim { -class LIBZIM_API Buffer { +class LIBZIM_PRIVATE_API Buffer { public: // types typedef std::shared_ptr DataPtr; diff --git a/src/buffer_reader.h b/src/buffer_reader.h index bcbafa5bd..de3469449 100644 --- a/src/buffer_reader.h +++ b/src/buffer_reader.h @@ -24,7 +24,7 @@ namespace zim { -class LIBZIM_API BufferReader : public Reader { +class LIBZIM_PRIVATE_API BufferReader : public Reader { public: BufferReader(const Buffer& source) : source(source) {} diff --git a/src/cluster.h b/src/cluster.h index 9ee39414a..db1be37c1 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -37,7 +37,7 @@ namespace zim class Reader; class IStreamReader; - class LIBZIM_API Cluster : public std::enable_shared_from_this { + class LIBZIM_PRIVATE_API Cluster : public std::enable_shared_from_this { typedef std::vector BlobOffsets; typedef std::vector> BlobReaders; diff --git a/src/compression.h b/src/compression.h index ab6ce8146..4daba33b5 100644 --- a/src/compression.h +++ b/src/compression.h @@ -68,8 +68,8 @@ struct LZMA_INFO { }; -struct LIBZIM_API ZSTD_INFO { - struct LIBZIM_API stream_t +struct LIBZIM_PRIVATE_API ZSTD_INFO { + struct LIBZIM_PRIVATE_API stream_t { const unsigned char* next_in; size_t avail_in; diff --git a/src/config.h.in b/src/config.h.in index 77991c3fa..b3018333c 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,3 +1,11 @@ +#ifndef ZIM_CONFIG_H +#define ZIM_CONFIG_H + +#if defined(_MSC_VER) && defined(LIBZIM_EXPORT_PRIVATE_DLL) + #define LIBZIM_PRIVATE_API __declspec(dllexport) +#else + #define LIBZIM_PRIVATE_API +#endif #mesondefine VERSION @@ -20,3 +28,5 @@ #mesondefine ENV64BIT #mesondefine ENV32BIT + +#endif // ZIM_CONFIG_H diff --git a/src/dirent_accessor.h b/src/dirent_accessor.h index d4945e3f5..fb1bc3ec5 100644 --- a/src/dirent_accessor.h +++ b/src/dirent_accessor.h @@ -22,6 +22,7 @@ #include "zim_types.h" #include "lrucache.h" +#include "config.h" #include #include @@ -42,7 +43,7 @@ class DirentReader; * */ -class LIBZIM_API DirectDirentAccessor +class LIBZIM_PRIVATE_API DirectDirentAccessor { public: // functions DirectDirentAccessor(std::shared_ptr direntReader, diff --git a/src/direntreader.h b/src/direntreader.h index 79c8b4f96..7c1ea2761 100644 --- a/src/direntreader.h +++ b/src/direntreader.h @@ -33,7 +33,7 @@ namespace zim // Unlke FileReader and MemoryReader (which read data from a file and memory, // respectively), DirentReader is a helper class that reads Dirents (rather // than from a Dirent). -class LIBZIM_API DirentReader +class LIBZIM_PRIVATE_API DirentReader { public: // functions explicit DirentReader(std::shared_ptr zimReader) diff --git a/src/file_compound.h b/src/file_compound.h index cd7c04f76..f50d672b0 100644 --- a/src/file_compound.h +++ b/src/file_compound.h @@ -24,6 +24,8 @@ #include "file_part.h" #include "zim_types.h" #include "debug.h" +#include "config.h" + #include #include #include @@ -48,7 +50,7 @@ struct less_range } }; -class LIBZIM_API FileCompound : private std::map { +class LIBZIM_PRIVATE_API FileCompound : private std::map { typedef std::map ImplType; public: // types diff --git a/src/file_reader.h b/src/file_reader.h index 120b50cbd..248df1527 100644 --- a/src/file_reader.h +++ b/src/file_reader.h @@ -28,7 +28,7 @@ namespace zim { class FileCompound; -class LIBZIM_API BaseFileReader : public Reader { +class LIBZIM_PRIVATE_API BaseFileReader : public Reader { public: // functions BaseFileReader(offset_t offset, zsize_t size) : _offset(offset), _size(size) {} @@ -45,7 +45,7 @@ class LIBZIM_API BaseFileReader : public Reader { zsize_t _size; }; -class LIBZIM_API FileReader : public BaseFileReader { +class LIBZIM_PRIVATE_API FileReader : public BaseFileReader { public: // types typedef std::shared_ptr FileHandle; @@ -66,7 +66,7 @@ class LIBZIM_API FileReader : public BaseFileReader { FileHandle _fhandle; }; -class LIBZIM_API MultiPartFileReader : public BaseFileReader { +class LIBZIM_PRIVATE_API MultiPartFileReader : public BaseFileReader { public: explicit MultiPartFileReader(std::shared_ptr source); ~MultiPartFileReader() {}; diff --git a/src/fileheader.h b/src/fileheader.h index 3f23b64e5..0dd311b47 100644 --- a/src/fileheader.h +++ b/src/fileheader.h @@ -23,6 +23,8 @@ #include #include +#include "config.h" + #include // max may be defined as a macro by window includes @@ -33,7 +35,7 @@ namespace zim { class Reader; - class LIBZIM_API Fileheader + class LIBZIM_PRIVATE_API Fileheader { public: static const uint32_t zimMagic; diff --git a/src/fs_windows.h b/src/fs_windows.h index adbfa8af6..009092ecb 100644 --- a/src/fs_windows.h +++ b/src/fs_windows.h @@ -21,6 +21,7 @@ #define ZIM_FS_WINDOWS_H_ #include "zim_types.h" +#include "config.h" #include @@ -34,7 +35,7 @@ using path_t = const std::string&; struct ImplFD; -class LIBZIM_API FD { +class LIBZIM_PRIVATE_API FD { public: typedef HANDLE fd_t; private: @@ -55,7 +56,7 @@ class LIBZIM_API FD { bool close(); }; -struct LIBZIM_API FS { +struct LIBZIM_PRIVATE_API FS { using FD = zim::windows::FD; static std::string join(path_t base, path_t name); static std::unique_ptr toWideChar(path_t path); diff --git a/src/istreamreader.h b/src/istreamreader.h index 3c0f74638..a0a5349b2 100644 --- a/src/istreamreader.h +++ b/src/istreamreader.h @@ -44,7 +44,7 @@ namespace zim // } // } // -class LIBZIM_API IStreamReader +class LIBZIM_PRIVATE_API IStreamReader { public: // functions virtual ~IStreamReader() = default; diff --git a/src/tools.h b/src/tools.h index 44c02e593..014f828f1 100644 --- a/src/tools.h +++ b/src/tools.h @@ -37,19 +37,19 @@ namespace Xapian { #endif // ENABLE_XAPIAN namespace zim { bool isCompressibleMimetype(const std::string& mimetype); - uint32_t LIBZIM_API countWords(const std::string& text); - void LIBZIM_API microsleep(int microseconds); + uint32_t LIBZIM_PRIVATE_API countWords(const std::string& text); + void LIBZIM_PRIVATE_API microsleep(int microseconds); - std::tuple LIBZIM_API parseLongPath(const std::string& longPath); + std::tuple LIBZIM_PRIVATE_API parseLongPath(const std::string& longPath); // Parse a illustration path ("Illustration_x@1") to a size. - unsigned int LIBZIM_API parseIllustrationPathToSize(const std::string& s); + unsigned int LIBZIM_PRIVATE_API parseIllustrationPathToSize(const std::string& s); /** Return a random number from range [0, max] * * This function is threadsafe **/ - uint32_t LIBZIM_API randomNumber(uint32_t max); + uint32_t LIBZIM_PRIVATE_API randomNumber(uint32_t max); std::vector split(const std::string & str, const std::string & delims=" *-"); @@ -57,7 +57,7 @@ namespace zim { std::map read_valuesmap(const std::string& s); using MimeCounterType = std::map; - MimeCounterType LIBZIM_API parseMimetypeCounter(const std::string& counterData); + MimeCounterType LIBZIM_PRIVATE_API parseMimetypeCounter(const std::string& counterData); template entry_index_type countMimeType(const std::string& counterData, Filter filter) { @@ -72,7 +72,7 @@ namespace zim { // Xapian based tools #if defined(ENABLE_XAPIAN) - std::string LIBZIM_API removeAccents(const std::string& text); + std::string LIBZIM_PRIVATE_API removeAccents(const std::string& text); bool getDbFromAccessInfo(Item::DirectAccessInfo accessInfo, Xapian::Database& database); #endif } diff --git a/src/writer/_dirent.h b/src/writer/_dirent.h index 5d15c8544..dd04007db 100644 --- a/src/writer/_dirent.h +++ b/src/writer/_dirent.h @@ -148,7 +148,7 @@ namespace zim enum : char {DIRECT, REDIRECT, RESOLVED} tag; } PACKED; - class LIBZIM_API Dirent + class LIBZIM_PRIVATE_API Dirent { static const uint16_t redirectMimeType = 0xffff; static const uint32_t version = 0; diff --git a/src/writer/cluster.h b/src/writer/cluster.h index 162dc7801..c4f9634cd 100644 --- a/src/writer/cluster.h +++ b/src/writer/cluster.h @@ -30,6 +30,7 @@ #include #include "../zim_types.h" #include "../debug.h" +#include "config.h" namespace zim { @@ -38,7 +39,7 @@ namespace writer { using writer_t = std::function; class ContentProvider; -class LIBZIM_API Cluster { +class LIBZIM_PRIVATE_API Cluster { typedef std::vector Offsets; typedef std::vector> ClusterProviders; diff --git a/src/xapian/htmlparse.h b/src/xapian/htmlparse.h index 68acc40eb..1239eae07 100644 --- a/src/xapian/htmlparse.h +++ b/src/xapian/htmlparse.h @@ -23,6 +23,8 @@ #define OMEGA_INCLUDED_HTMLPARSE_H #include +#include "config.h" + #include #include @@ -31,7 +33,7 @@ using std::map; namespace zim { -class LIBZIM_API HtmlParser { +class LIBZIM_PRIVATE_API HtmlParser { map parameters; protected: void decode_entities(string &s); diff --git a/src/xapian/myhtmlparse.h b/src/xapian/myhtmlparse.h index 78924ade9..ab8569c6a 100644 --- a/src/xapian/myhtmlparse.h +++ b/src/xapian/myhtmlparse.h @@ -32,7 +32,7 @@ namespace zim { -class LIBZIM_API MyHtmlParser : public HtmlParser { +class LIBZIM_PRIVATE_API MyHtmlParser : public HtmlParser { public: bool in_script_tag; bool in_style_tag;