Commit 5f4675bb24dcffa616d6ae3bd38e532510522615

Authored by Jay Berkenbilt
1 parent 5525c931

Mark non-ABI symbols in exported class with QPDF_DLL_PRIVATE

@@ -30,31 +30,17 @@ Misc @@ -30,31 +30,17 @@ Misc
30 encryption dictionary normally. 30 encryption dictionary normally.
31 * Have a warn in QPDF that passes its variable arguments onto QPDFExc 31 * Have a warn in QPDF that passes its variable arguments onto QPDFExc
32 so you don't have to do warn(QPDFExc(...)) 32 so you don't have to do warn(QPDFExc(...))
  33 +* Nice to have:
  34 + * Split qpdf.test into multiple tests
  35 + * Rework tests so that nothing is written into the source directory.
  36 + * Ideally then the entire build could be done with a read-only
  37 + source tree.
33 38
34 Soon: Break ground on "Document-level work" 39 Soon: Break ground on "Document-level work"
35 40
36 cmake 41 cmake
37 ===== 42 =====
38 43
39 -* DLL.h  
40 - * The effect of QPDF_DLL_CLASS is to export everything in the class,  
41 - not just the vtable. On MSVC, we don't need this as the vtable  
42 - gets exported automatically when needed. With gcc, we need it to  
43 - export typeinfo and vtable. Whenever QPDF_DLL_CLASS is defined,  
44 - also define QPDF_DLL_LOCAL to __attribute__  
45 - ((visibility("hidden"))). Then add QPDF_DLL_LOCAL to everything in  
46 - QPDF_DLL_CLASS that is not marked with QPDF_DLL. The effect is  
47 - that, with MSVC, only methods are marked QPDF_DLL are public  
48 - because QPDF_DLL_CLASS is empty. For gcc, only methods marked  
49 - QPDF_DLL are public because QPDF_DLL_LOCAL makes the other things  
50 - private. See https://gcc.gnu.org/wiki/Visibility. Make sure this  
51 - is documented.  
52 - * Update "CODING RULES" in "README-maintainer" - search for QPDF_DLL  
53 -* Nice to have:  
54 - * Split qpdf.test into multiple tests  
55 - * Rework tests so that nothing is written into the source directory.  
56 - * Ideally then the entire build could be done with a read-only  
57 - source tree.  
58 * pikepdf 44 * pikepdf
59 * https://github.com/pikepdf/pikepdf/pull/315 -- setup.py + docs 45 * https://github.com/pikepdf/pikepdf/pull/315 -- setup.py + docs
60 * https://github.com/pikepdf/pikepdf/pull/316 -- setup.py only 46 * https://github.com/pikepdf/pikepdf/pull/316 -- setup.py only
include/qpdf/ClosedFileInputSource.hh
@@ -68,7 +68,9 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource @@ -68,7 +68,9 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource
68 ClosedFileInputSource(ClosedFileInputSource const&) = delete; 68 ClosedFileInputSource(ClosedFileInputSource const&) = delete;
69 ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete; 69 ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete;
70 70
  71 + QPDF_DLL_PRIVATE
71 void before(); 72 void before();
  73 + QPDF_DLL_PRIVATE
72 void after(); 74 void after();
73 75
74 class QPDF_DLL_PRIVATE Members 76 class QPDF_DLL_PRIVATE Members
include/qpdf/InputSource.hh
@@ -104,7 +104,7 @@ class QPDF_DLL_CLASS InputSource @@ -104,7 +104,7 @@ class QPDF_DLL_CLASS InputSource
104 qpdf_offset_t last_offset; 104 qpdf_offset_t last_offset;
105 105
106 private: 106 private:
107 - class Members 107 + class QPDF_DLL_PRIVATE Members
108 { 108 {
109 friend class InputSource; 109 friend class InputSource;
110 110
include/qpdf/Pl_DCT.hh
@@ -70,7 +70,9 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -70,7 +70,9 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
70 virtual void finish(); 70 virtual void finish();
71 71
72 private: 72 private:
  73 + QPDF_DLL_PRIVATE
73 void compress(void* cinfo, Buffer*); 74 void compress(void* cinfo, Buffer*);
  75 + QPDF_DLL_PRIVATE
74 void decompress(void* cinfo, Buffer*); 76 void decompress(void* cinfo, Buffer*);
75 77
76 enum action_e { a_compress, a_decompress }; 78 enum action_e { a_compress, a_decompress };
include/qpdf/Pl_Flate.hh
@@ -30,7 +30,6 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline @@ -30,7 +30,6 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
30 { 30 {
31 public: 31 public:
32 static unsigned int const def_bufsize = 65536; 32 static unsigned int const def_bufsize = 65536;
33 - static int compression_level;  
34 33
35 enum action_e { a_inflate, a_deflate }; 34 enum action_e { a_inflate, a_deflate };
36 35
@@ -61,10 +60,16 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline @@ -61,10 +60,16 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
61 void setWarnCallback(std::function<void(char const*, int)> callback); 60 void setWarnCallback(std::function<void(char const*, int)> callback);
62 61
63 private: 62 private:
  63 + QPDF_DLL_PRIVATE
64 void handleData(unsigned char* data, size_t len, int flush); 64 void handleData(unsigned char* data, size_t len, int flush);
  65 + QPDF_DLL_PRIVATE
65 void checkError(char const* prefix, int error_code); 66 void checkError(char const* prefix, int error_code);
  67 + QPDF_DLL_PRIVATE
66 void warn(char const*, int error_code); 68 void warn(char const*, int error_code);
67 69
  70 + QPDF_DLL_PRIVATE
  71 + static int compression_level;
  72 +
68 class QPDF_DLL_PRIVATE Members 73 class QPDF_DLL_PRIVATE Members
69 { 74 {
70 friend class Pl_Flate; 75 friend class Pl_Flate;
include/qpdf/Pl_RunLength.hh
@@ -40,8 +40,11 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline @@ -40,8 +40,11 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline
40 virtual void finish(); 40 virtual void finish();
41 41
42 private: 42 private:
  43 + QPDF_DLL_PRIVATE
43 void encode(unsigned char* data, size_t len); 44 void encode(unsigned char* data, size_t len);
  45 + QPDF_DLL_PRIVATE
44 void decode(unsigned char* data, size_t len); 46 void decode(unsigned char* data, size_t len);
  47 + QPDF_DLL_PRIVATE
45 void flush_encode(); 48 void flush_encode();
46 49
47 enum state_e { st_top, st_copying, st_run }; 50 enum state_e { st_top, st_copying, st_run };
include/qpdf/QPDFExc.hh
@@ -66,6 +66,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error @@ -66,6 +66,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
66 std::string const& getMessageDetail() const; 66 std::string const& getMessageDetail() const;
67 67
68 private: 68 private:
  69 + QPDF_DLL_PRIVATE
69 static std::string createWhat( 70 static std::string createWhat(
70 std::string const& filename, 71 std::string const& filename,
71 std::string const& object, 72 std::string const& object,
include/qpdf/QPDFObject.hh
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 class QPDF; 32 class QPDF;
33 class QPDFObjectHandle; 33 class QPDFObjectHandle;
34 34
35 -class QPDF_DLL_CLASS QPDFObject 35 +class QPDFObject
36 { 36 {
37 public: 37 public:
38 QPDFObject(); 38 QPDFObject();
include/qpdf/QPDFObjectHandle.hh
@@ -204,6 +204,7 @@ class QPDFObjectHandle @@ -204,6 +204,7 @@ class QPDFObjectHandle
204 void writeToken(QPDFTokenizer::Token const&); 204 void writeToken(QPDFTokenizer::Token const&);
205 205
206 private: 206 private:
  207 + QPDF_DLL_PRIVATE
207 void setPipeline(Pipeline*); 208 void setPipeline(Pipeline*);
208 209
209 Pipeline* pipeline; 210 Pipeline* pipeline;
include/qpdf/QPDFSystemError.hh
@@ -47,6 +47,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error @@ -47,6 +47,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
47 int getErrno() const; 47 int getErrno() const;
48 48
49 private: 49 private:
  50 + QPDF_DLL_PRIVATE
50 static std::string 51 static std::string
51 createWhat(std::string const& description, int system_errno); 52 createWhat(std::string const& description, int system_errno);
52 53
include/qpdf/RandomDataProvider.hh
@@ -34,9 +34,8 @@ class QPDF_DLL_CLASS RandomDataProvider @@ -34,9 +34,8 @@ class QPDF_DLL_CLASS RandomDataProvider
34 virtual void provideRandomData(unsigned char* data, size_t len) = 0; 34 virtual void provideRandomData(unsigned char* data, size_t len) = 0;
35 35
36 protected: 36 protected:
37 - RandomDataProvider()  
38 - {  
39 - } 37 + QPDF_DLL_PRIVATE
  38 + RandomDataProvider() = default;
40 39
41 private: 40 private:
42 RandomDataProvider(RandomDataProvider const&) = delete; 41 RandomDataProvider(RandomDataProvider const&) = delete;
qpdf/sizes.cc
@@ -33,7 +33,6 @@ @@ -33,7 +33,6 @@
33 #include <qpdf/QPDFNameTreeObjectHelper.hh> 33 #include <qpdf/QPDFNameTreeObjectHelper.hh>
34 #include <qpdf/QPDFNumberTreeObjectHelper.hh> 34 #include <qpdf/QPDFNumberTreeObjectHelper.hh>
35 #include <qpdf/QPDFObjGen.hh> 35 #include <qpdf/QPDFObjGen.hh>
36 -#include <qpdf/QPDFObject.hh>  
37 #include <qpdf/QPDFObjectHandle.hh> 36 #include <qpdf/QPDFObjectHandle.hh>
38 #include <qpdf/QPDFOutlineDocumentHelper.hh> 37 #include <qpdf/QPDFOutlineDocumentHelper.hh>
39 #include <qpdf/QPDFOutlineObjectHelper.hh> 38 #include <qpdf/QPDFOutlineObjectHelper.hh>
@@ -50,10 +49,6 @@ @@ -50,10 +49,6 @@
50 #define ignore_class(cls) 49 #define ignore_class(cls)
51 #define print_size(cls) std::cout << #cls << " " << sizeof(cls) << std::endl 50 #define print_size(cls) std::cout << #cls << " " << sizeof(cls) << std::endl
52 51
53 -// This is public because of QPDF_DLL_CLASS on InputSource  
54 -// -------  
55 -ignore_class(InputSource::Members);  
56 -  
57 // These are not classes 52 // These are not classes
58 // ------- 53 // -------
59 ignore_class(QUtil); 54 ignore_class(QUtil);
@@ -105,7 +100,6 @@ main() @@ -105,7 +100,6 @@ main()
105 print_size(QPDFNumberTreeObjectHelper); 100 print_size(QPDFNumberTreeObjectHelper);
106 print_size(QPDFNumberTreeObjectHelper::iterator); 101 print_size(QPDFNumberTreeObjectHelper::iterator);
107 print_size(QPDFObjGen); 102 print_size(QPDFObjGen);
108 - print_size(QPDFObject);  
109 print_size(QPDFObjectHandle); 103 print_size(QPDFObjectHandle);
110 print_size(QPDFObjectHandle::ParserCallbacks); 104 print_size(QPDFObjectHandle::ParserCallbacks);
111 print_size(QPDFObjectHandle::QPDFArrayItems); 105 print_size(QPDFObjectHandle::QPDFArrayItems);