Commit 2a7d2b63c2a7284d1b1179eefbf64f5dd29aa510

Authored by Jay Berkenbilt
1 parent dd359663

Make ABI-breaking changes that don't modify API at all

* Merge overloaded functions by adding default values
* Remove non-const methods that are identical to const methods
@@ -481,12 +481,10 @@ Comments appear in the code prefixed by "ABI" @@ -481,12 +481,10 @@ Comments appear in the code prefixed by "ABI"
481 481
482 * Search for ABI to find items not listed here. 482 * Search for ABI to find items not listed here.
483 * Switch default --json to latest 483 * Switch default --json to latest
484 -* See PointerHolder to std::shared_ptr above.  
485 * See where anonymous namespaces can be used to keep things private to 484 * See where anonymous namespaces can be used to keep things private to
486 a source file. Search for `(class|struct)` in **/*.cc. 485 a source file. Search for `(class|struct)` in **/*.cc.
487 * See if we can use constructor delegation instead of init() in 486 * See if we can use constructor delegation instead of init() in
488 classes with overloaded constructors. 487 classes with overloaded constructors.
489 -* Merge two versions of QPDFObjectHandle::makeDirect per comment  
490 * After removing legacy QPDFNameTreeObjectHelper and 488 * After removing legacy QPDFNameTreeObjectHelper and
491 QPDFNumberTreeObjectHelper constructors, NNTreeImpl can switch to 489 QPDFNumberTreeObjectHelper constructors, NNTreeImpl can switch to
492 having a QPDF reference and assume that the reference is always 490 having a QPDF reference and assume that the reference is always
include/qpdf/QPDF.hh
@@ -619,13 +619,8 @@ class QPDF @@ -619,13 +619,8 @@ class QPDF
619 QPDF_DLL 619 QPDF_DLL
620 void optimize( 620 void optimize(
621 std::map<int, int> const& object_stream_data, 621 std::map<int, int> const& object_stream_data,
622 - bool allow_changes = true);  
623 - // ABI: make function optional and merge overloaded versions  
624 - QPDF_DLL  
625 - void optimize(  
626 - std::map<int, int> const& object_stream_data,  
627 - bool allow_changes,  
628 - std::function<int(QPDFObjectHandle&)> skip_stream_parameters); 622 + bool allow_changes = true,
  623 + std::function<int(QPDFObjectHandle&)> skip_stream_parameters = nullptr);
629 624
630 // Traverse page tree return all /Page objects. It also detects 625 // Traverse page tree return all /Page objects. It also detects
631 // and resolves cases in which the same /Page object is 626 // and resolves cases in which the same /Page object is
include/qpdf/QPDFMatrix.hh
@@ -74,9 +74,6 @@ class QPDFMatrix @@ -74,9 +74,6 @@ class QPDFMatrix
74 // and take the first and second rows of the result as xp and yp. 74 // and take the first and second rows of the result as xp and yp.
75 QPDF_DLL 75 QPDF_DLL
76 void transform(double x, double y, double& xp, double& yp) const; 76 void transform(double x, double y, double& xp, double& yp) const;
77 - // ABI: delete non-const version  
78 - QPDF_DLL  
79 - void transform(double x, double y, double& xp, double& yp);  
80 77
81 // Transform a rectangle by creating a new rectangle that tightly 78 // Transform a rectangle by creating a new rectangle that tightly
82 // bounds the polygon resulting from transforming the four 79 // bounds the polygon resulting from transforming the four
@@ -84,10 +81,6 @@ class QPDFMatrix @@ -84,10 +81,6 @@ class QPDFMatrix
84 QPDF_DLL 81 QPDF_DLL
85 QPDFObjectHandle::Rectangle 82 QPDFObjectHandle::Rectangle
86 transformRectangle(QPDFObjectHandle::Rectangle r) const; 83 transformRectangle(QPDFObjectHandle::Rectangle r) const;
87 - // ABI: delete non-const version  
88 - QPDF_DLL  
89 - QPDFObjectHandle::Rectangle  
90 - transformRectangle(QPDFObjectHandle::Rectangle r);  
91 84
92 // operator== tests for exact equality, not considering deltas for 85 // operator== tests for exact equality, not considering deltas for
93 // floating point. 86 // floating point.
include/qpdf/QPDFNameTreeObjectHelper.hh
@@ -61,7 +61,6 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -61,7 +61,6 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
61 QPDF_DLL 61 QPDF_DLL
62 static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true); 62 static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true);
63 63
64 - // ABI: = default  
65 QPDF_DLL 64 QPDF_DLL
66 virtual ~QPDFNameTreeObjectHelper(); 65 virtual ~QPDFNameTreeObjectHelper();
67 66
include/qpdf/QPDFObjectHandle.hh
@@ -530,12 +530,8 @@ class QPDFObjectHandle @@ -530,12 +530,8 @@ class QPDFObjectHandle
530 QPDF_DLL 530 QPDF_DLL
531 static QPDFObjectHandle newReal(std::string const& value); 531 static QPDFObjectHandle newReal(std::string const& value);
532 QPDF_DLL 532 QPDF_DLL
533 - static QPDFObjectHandle newReal(double value, int decimal_places = 0);  
534 - // ABI: combine with other newReal by adding trim_trailing_zeroes  
535 - // above as an optional parameter with a default of true.  
536 - QPDF_DLL  
537 - static QPDFObjectHandle  
538 - newReal(double value, int decimal_places, bool trim_trailing_zeroes); 533 + static QPDFObjectHandle newReal(
  534 + double value, int decimal_places = 0, bool trim_trailing_zeroes = true);
539 // Note about name objects: qpdf's internal representation of a 535 // Note about name objects: qpdf's internal representation of a
540 // PDF name is a sequence of bytes, excluding the NUL character, 536 // PDF name is a sequence of bytes, excluding the NUL character,
541 // and starting with a slash. Name objects as represented in the 537 // and starting with a slash. Name objects as represented in the
@@ -933,11 +929,8 @@ class QPDFObjectHandle @@ -933,11 +929,8 @@ class QPDFObjectHandle
933 QPDF_DLL 929 QPDF_DLL
934 void mergeResources( 930 void mergeResources(
935 QPDFObjectHandle other, 931 QPDFObjectHandle other,
936 - std::map<std::string, std::map<std::string, std::string>>* conflicts);  
937 - // ABI: eliminate version without conflicts and make conflicts  
938 - // default to nullptr.  
939 - QPDF_DLL  
940 - void mergeResources(QPDFObjectHandle other); 932 + std::map<std::string, std::map<std::string, std::string>>* conflicts =
  933 + nullptr);
941 934
942 // Get all resource names from a resource dictionary. If this 935 // Get all resource names from a resource dictionary. If this
943 // object is a dictionary, this method returns a set of all the 936 // object is a dictionary, this method returns a set of all the
@@ -964,12 +957,7 @@ class QPDFObjectHandle @@ -964,12 +957,7 @@ class QPDFObjectHandle
964 std::string getUniqueResourceName( 957 std::string getUniqueResourceName(
965 std::string const& prefix, 958 std::string const& prefix,
966 int& min_suffix, 959 int& min_suffix,
967 - std::set<std::string>* resource_names);  
968 - // ABI: remove this version and make resource_names default to  
969 - // nullptr.  
970 - QPDF_DLL  
971 - std::string  
972 - getUniqueResourceName(std::string const& prefix, int& min_suffix); 960 + std::set<std::string>* resource_names = nullptr);
973 961
974 // Return the QPDF object that owns an indirect object. Returns 962 // Return the QPDF object that owns an indirect object. Returns
975 // null for a direct object. 963 // null for a direct object.
@@ -1024,12 +1012,7 @@ class QPDFObjectHandle @@ -1024,12 +1012,7 @@ class QPDFObjectHandle
1024 // to the original QPDF object after this call completes 1012 // to the original QPDF object after this call completes
1025 // successfully. 1013 // successfully.
1026 QPDF_DLL 1014 QPDF_DLL
1027 - void makeDirect(bool allow_streams);  
1028 - // Zero-arg version is equivalent to makeDirect(false).  
1029 - // ABI: delete zero-arg version of makeDirect, and make  
1030 - // allow_streams default to false.  
1031 - QPDF_DLL  
1032 - void makeDirect(); 1015 + void makeDirect(bool allow_streams = false);
1033 1016
1034 // Mutator methods for array objects 1017 // Mutator methods for array objects
1035 QPDF_DLL 1018 QPDF_DLL
include/qpdf/QPDFPageObjectHelper.hh
@@ -132,10 +132,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -132,10 +132,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
132 // this behavior. Prior to qpdf 10.1, form XObjects were ignored, 132 // this behavior. Prior to qpdf 10.1, form XObjects were ignored,
133 // but this was considered a bug. 133 // but this was considered a bug.
134 QPDF_DLL 134 QPDF_DLL
135 - void externalizeInlineImages(size_t min_size, bool shallow);  
136 - // ABI: make shallow optional (default false) and merge  
137 - QPDF_DLL  
138 - void externalizeInlineImages(size_t min_size = 0); 135 + void externalizeInlineImages(size_t min_size = 0, bool shallow = false);
139 136
140 // Return the annotations in the page's "/Annots" list, if any. If 137 // Return the annotations in the page's "/Annots" list, if any. If
141 // only_subtype is non-empty, only include annotations of the 138 // only_subtype is non-empty, only include annotations of the
@@ -344,10 +341,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -344,10 +341,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
344 // rotated. If not, one will be created inside the function, which 341 // rotated. If not, one will be created inside the function, which
345 // is less efficient. 342 // is less efficient.
346 QPDF_DLL 343 QPDF_DLL
347 - void flattenRotation();  
348 - // ABI: merge versions and make afdh default to nullptr  
349 - QPDF_DLL  
350 - void flattenRotation(QPDFAcroFormDocumentHelper* afdh); 344 + void flattenRotation(QPDFAcroFormDocumentHelper* afdh = nullptr);
351 345
352 // Copy annotations from another page into this page. The other 346 // Copy annotations from another page into this page. The other
353 // page may be from the same QPDF or from a different QPDF. Each 347 // page may be from the same QPDF or from a different QPDF. Each
include/qpdf/QUtil.hh
@@ -51,13 +51,8 @@ namespace QUtil @@ -51,13 +51,8 @@ namespace QUtil
51 std::string 51 std::string
52 uint_to_string_base(unsigned long long, int base, int length = 0); 52 uint_to_string_base(unsigned long long, int base, int length = 0);
53 QPDF_DLL 53 QPDF_DLL
54 - std::string double_to_string(double, int decimal_places = 0);  
55 - // ABI: combine with other double_to_string by adding  
56 - // trim_trailing_zeroes above as an optional parameter with a  
57 - // default of true.  
58 - QPDF_DLL  
59 - std::string  
60 - double_to_string(double, int decimal_places, bool trim_trailing_zeroes); 54 + std::string double_to_string(
  55 + double, int decimal_places = 0, bool trim_trailing_zeroes = true);
61 56
62 // These string to number methods throw std::runtime_error on 57 // These string to number methods throw std::runtime_error on
63 // underflow/overflow. 58 // underflow/overflow.
libqpdf/QPDFMatrix.cc
@@ -110,12 +110,6 @@ QPDFMatrix::rotatex90(int angle) @@ -110,12 +110,6 @@ QPDFMatrix::rotatex90(int angle)
110 } 110 }
111 111
112 void 112 void
113 -QPDFMatrix::transform(double x, double y, double& xp, double& yp)  
114 -{  
115 - const_cast<QPDFMatrix const*>(this)->transform(x, y, xp, yp);  
116 -}  
117 -  
118 -void  
119 QPDFMatrix::transform(double x, double y, double& xp, double& yp) const 113 QPDFMatrix::transform(double x, double y, double& xp, double& yp) const
120 { 114 {
121 xp = (this->a * x) + (this->c * y) + this->e; 115 xp = (this->a * x) + (this->c * y) + this->e;
@@ -123,12 +117,6 @@ QPDFMatrix::transform(double x, double y, double&amp; xp, double&amp; yp) const @@ -123,12 +117,6 @@ QPDFMatrix::transform(double x, double y, double&amp; xp, double&amp; yp) const
123 } 117 }
124 118
125 QPDFObjectHandle::Rectangle 119 QPDFObjectHandle::Rectangle
126 -QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r)  
127 -{  
128 - return const_cast<QPDFMatrix const*>(this)->transformRectangle(r);  
129 -}  
130 -  
131 -QPDFObjectHandle::Rectangle  
132 QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const 120 QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
133 { 121 {
134 std::vector<double> tx(4); 122 std::vector<double> tx(4);
libqpdf/QPDFObjectHandle.cc
@@ -1095,12 +1095,6 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf) @@ -1095,12 +1095,6 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf)
1095 } 1095 }
1096 1096
1097 void 1097 void
1098 -QPDFObjectHandle::mergeResources(QPDFObjectHandle other)  
1099 -{  
1100 - mergeResources(other, nullptr);  
1101 -}  
1102 -  
1103 -void  
1104 QPDFObjectHandle::mergeResources( 1098 QPDFObjectHandle::mergeResources(
1105 QPDFObjectHandle other, 1099 QPDFObjectHandle other,
1106 std::map<std::string, std::map<std::string, std::string>>* conflicts) 1100 std::map<std::string, std::map<std::string, std::string>>* conflicts)
@@ -1226,13 +1220,6 @@ QPDFObjectHandle::getResourceNames() @@ -1226,13 +1220,6 @@ QPDFObjectHandle::getResourceNames()
1226 1220
1227 std::string 1221 std::string
1228 QPDFObjectHandle::getUniqueResourceName( 1222 QPDFObjectHandle::getUniqueResourceName(
1229 - std::string const& prefix, int& min_suffix)  
1230 -{  
1231 - return getUniqueResourceName(prefix, min_suffix, nullptr);  
1232 -}  
1233 -  
1234 -std::string  
1235 -QPDFObjectHandle::getUniqueResourceName(  
1236 std::string const& prefix, int& min_suffix, std::set<std::string>* namesp) 1223 std::string const& prefix, int& min_suffix, std::set<std::string>* namesp)
1237 1224
1238 { 1225 {
@@ -2540,12 +2527,6 @@ QPDFObjectHandle::newReal(std::string const&amp; value) @@ -2540,12 +2527,6 @@ QPDFObjectHandle::newReal(std::string const&amp; value)
2540 } 2527 }
2541 2528
2542 QPDFObjectHandle 2529 QPDFObjectHandle
2543 -QPDFObjectHandle::newReal(double value, int decimal_places)  
2544 -{  
2545 - return QPDFObjectHandle(new QPDF_Real(value, decimal_places, true));  
2546 -}  
2547 -  
2548 -QPDFObjectHandle  
2549 QPDFObjectHandle::newReal( 2530 QPDFObjectHandle::newReal(
2550 double value, int decimal_places, bool trim_trailing_zeroes) 2531 double value, int decimal_places, bool trim_trailing_zeroes)
2551 { 2532 {
@@ -2916,12 +2897,6 @@ QPDFObjectHandle::copyStream() @@ -2916,12 +2897,6 @@ QPDFObjectHandle::copyStream()
2916 } 2897 }
2917 2898
2918 void 2899 void
2919 -QPDFObjectHandle::makeDirect()  
2920 -{  
2921 - makeDirect(false);  
2922 -}  
2923 -  
2924 -void  
2925 QPDFObjectHandle::makeDirect(bool allow_streams) 2900 QPDFObjectHandle::makeDirect(bool allow_streams)
2926 { 2901 {
2927 std::set<QPDFObjGen> visited; 2902 std::set<QPDFObjGen> visited;
libqpdf/QPDFPageObjectHelper.cc
@@ -411,12 +411,6 @@ QPDFPageObjectHelper::getFormXObjects() @@ -411,12 +411,6 @@ QPDFPageObjectHelper::getFormXObjects()
411 } 411 }
412 412
413 void 413 void
414 -QPDFPageObjectHelper::externalizeInlineImages(size_t min_size)  
415 -{  
416 - externalizeInlineImages(min_size, false);  
417 -}  
418 -  
419 -void  
420 QPDFPageObjectHelper::externalizeInlineImages(size_t min_size, bool shallow) 414 QPDFPageObjectHelper::externalizeInlineImages(size_t min_size, bool shallow)
421 { 415 {
422 if (shallow) { 416 if (shallow) {
@@ -930,12 +924,6 @@ QPDFPageObjectHelper::placeFormXObject( @@ -930,12 +924,6 @@ QPDFPageObjectHelper::placeFormXObject(
930 } 924 }
931 925
932 void 926 void
933 -QPDFPageObjectHelper::flattenRotation()  
934 -{  
935 - flattenRotation(nullptr);  
936 -}  
937 -  
938 -void  
939 QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh) 927 QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
940 { 928 {
941 QPDF* qpdf = this->oh.getOwningQPDF(); 929 QPDF* qpdf = this->oh.getOwningQPDF();
libqpdf/QPDF_optimization.cc
@@ -53,12 +53,6 @@ QPDF::ObjUser::operator&lt;(ObjUser const&amp; rhs) const @@ -53,12 +53,6 @@ QPDF::ObjUser::operator&lt;(ObjUser const&amp; rhs) const
53 } 53 }
54 54
55 void 55 void
56 -QPDF::optimize(std::map<int, int> const& object_stream_data, bool allow_changes)  
57 -{  
58 - optimize(object_stream_data, allow_changes, nullptr);  
59 -}  
60 -  
61 -void  
62 QPDF::optimize( 56 QPDF::optimize(
63 std::map<int, int> const& object_stream_data, 57 std::map<int, int> const& object_stream_data,
64 bool allow_changes, 58 bool allow_changes,
libqpdf/QUtil.cc
@@ -327,12 +327,6 @@ QUtil::uint_to_string_base(unsigned long long num, int base, int length) @@ -327,12 +327,6 @@ QUtil::uint_to_string_base(unsigned long long num, int base, int length)
327 } 327 }
328 328
329 std::string 329 std::string
330 -QUtil::double_to_string(double num, int decimal_places)  
331 -{  
332 - return double_to_string(num, decimal_places, true);  
333 -}  
334 -  
335 -std::string  
336 QUtil::double_to_string( 330 QUtil::double_to_string(
337 double num, int decimal_places, bool trim_trailing_zeroes) 331 double num, int decimal_places, bool trim_trailing_zeroes)
338 { 332 {