summaryrefslogtreecommitdiff
path: root/src/qpdf/pikepdf.h
diff options
context:
space:
mode:
authorJames R. Barlow <jim@purplerock.ca>2018-11-21 17:46:08 -0800
committerJames R. Barlow <jim@purplerock.ca>2018-11-21 17:46:08 -0800
commit1cfd5adc28a62abc01e7b74a1617638a8c22808e (patch)
treecdc5394b4a292e44ef2df2e5f5bc4407e9cf2886 /src/qpdf/pikepdf.h
parentd99a304e74001fba457be8861ae89b25785c11ba (diff)
Improve const-correctness policy
Change convention to passing QPDFObjectHandle by value, removing some cases where we use const_cast to add const and some cases where a reference was used for a efficiency alone. It seems more clear to pass by value as a way of expressing that the passed object is not modified. At the same time, enforce const more strongly for code that deals with pybind11 which is const-correct. Exempt from this change is our custom type converter.
Diffstat (limited to 'src/qpdf/pikepdf.h')
-rw-r--r--src/qpdf/pikepdf.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/qpdf/pikepdf.h b/src/qpdf/pikepdf.h
index 212268d..120bbbe 100644
--- a/src/qpdf/pikepdf.h
+++ b/src/qpdf/pikepdf.h
@@ -61,7 +61,7 @@ namespace pybind11 { namespace detail {
#if CUSTOM_TYPE_CONVERSION
// From object_convert.cpp
-pybind11::object decimal_from_pdfobject(QPDFObjectHandle& h);
+pybind11::object decimal_from_pdfobject(QPDFObjectHandle h);
namespace pybind11 { namespace detail {
template <> struct type_caster<QPDFObjectHandle> : public type_caster_base<QPDFObjectHandle> {
@@ -187,21 +187,20 @@ PYBIND11_MAKE_OPAQUE(ObjectMap);
// From object.cpp
-size_t list_range_check(QPDFObjectHandle& h, int index);
+size_t list_range_check(QPDFObjectHandle h, int index);
void init_object(py::module& m);
// From object_repr.cpp
-std::string objecthandle_scalar_value(QPDFObjectHandle& h, bool escaped=true);
-std::string objecthandle_pythonic_typename(QPDFObjectHandle& h, std::string prefix = "pikepdf.");
-std::string objecthandle_repr_typename_and_value(QPDFObjectHandle& h);
-std::string objecthandle_repr(QPDFObjectHandle& h);
+std::string objecthandle_scalar_value(QPDFObjectHandle h, bool escaped=true);
+std::string objecthandle_pythonic_typename(QPDFObjectHandle h, std::string prefix = "pikepdf.");
+std::string objecthandle_repr_typename_and_value(QPDFObjectHandle h);
+std::string objecthandle_repr(QPDFObjectHandle h);
// From object_convert.cpp
-py::object decimal_from_pdfobject(QPDFObjectHandle& h);
-py::object objecthandle_decode(QPDFObjectHandle& h);
-QPDFObjectHandle objecthandle_encode(py::handle handle);
-std::vector<QPDFObjectHandle> array_builder(py::iterable iter);
-std::map<std::string, QPDFObjectHandle> dict_builder(py::dict dict);
+py::object decimal_from_pdfobject(QPDFObjectHandle h);
+QPDFObjectHandle objecthandle_encode(const py::handle handle);
+std::vector<QPDFObjectHandle> array_builder(const py::iterable iter);
+std::map<std::string, QPDFObjectHandle> dict_builder(const py::dict dict);
// Support for recursion checks
class StackGuard