Skip to content

Commit 9607cab

Browse files
Tidy up preview module
1 parent 921d83c commit 9607cab

File tree

4 files changed

+270
-283
lines changed

4 files changed

+270
-283
lines changed

src/interface/preview.i

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ DECLARE_METADATUM_WRAPPERS(XmpData, Xmpdatum)
7171
KEEP_REFERENCE_EX(Exiv2::PreviewManager*, args)
7272

7373
// Enable len(PreviewImage)
74-
SQ_LENGTH(Exiv2::PreviewImage, self->size())
74+
%feature("python:slot", "sq_length", functype="lenfunc")
75+
Exiv2::PreviewImage::size;
7576

7677
// Expose Exiv2::PreviewImage contents as a Python buffer
7778
%fragment("buffer_fill_info"{Exiv2::PreviewImage}, "header") {
@@ -96,29 +97,17 @@ RETURN_VIEW(Exiv2::byte* data, arg1->size(), PyBUF_READ,
9697
DEFINE_VIEW_CALLBACK(Exiv2::PreviewImage,)
9798

9899
// Deprecate pData() in favour of data() since 2025-07-02
99-
%extend Exiv2::PreviewImage {
100-
const Exiv2::byte* pData() {
101-
PyErr_WarnEx(PyExc_DeprecationWarning,
102-
"Please use data() instead of pData().", 1);
103-
return $self->pData();
104-
};
105-
}
106-
%ignore Exiv2::PreviewImage::pData;
100+
DEPRECATE(Exiv2::PreviewImage::pData,
101+
"Please use data() instead of pData().")
107102

108103
// Give Exiv2::PreviewProperties dict-like behaviour
109104
STRUCT_DICT(Exiv2::PreviewProperties, false, true)
110105

111-
%immutable Exiv2::PreviewProperties::mimeType_;
112-
%immutable Exiv2::PreviewProperties::extension_;
113-
%immutable Exiv2::PreviewProperties::wextension_;
114-
%immutable Exiv2::PreviewProperties::size_;
115-
%immutable Exiv2::PreviewProperties::width_;
116-
%immutable Exiv2::PreviewProperties::height_;
117-
%immutable Exiv2::PreviewProperties::id_;
118-
119106
%ignore Exiv2::PreviewImage::operator=;
120107
%ignore Exiv2::PreviewProperties::PreviewProperties;
121108

122109
#define EXV_ENABLE_FILESYSTEM
110+
%immutable;
123111
%include "exiv2/preview.hpp"
112+
%mutable;
124113
#undef EXV_ENABLE_FILESYSTEM

src/interface/shared/exception.i

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fail:
7272
%enddef // EXCEPTION
7373

7474
// Macros to deprecate a function
75-
%define _DEPRECATE(method, message)
75+
%define DEPRECATE(method, message)
7676
%fragment("_set_python_exception");
7777
%exception method {
7878
PyErr_WarnEx(PyExc_DeprecationWarning, message, 1);
@@ -84,17 +84,17 @@ PyErr_WarnEx(PyExc_DeprecationWarning, message, 1);
8484
SWIG_fail;
8585
}
8686
}
87-
%enddef // _DEPRECATE
87+
%enddef // DEPRECATE
8888

8989
%define DEPRECATE_FUNCTION(method, preserve_doc)
90-
_DEPRECATE(method, "Python scripts should not need to call " #method)
90+
DEPRECATE(method, "Python scripts should not need to call " #method)
9191
#if #preserve_doc == ""
9292
%feature("docstring") method "Deprecated."
9393
#endif
9494
%enddef // DEPRECATE_FUNCTION
9595

9696
%define EXIV2_DEPRECATED(method)
97-
_DEPRECATE(method, #method " is deprecated in libexiv2")
97+
DEPRECATE(method, #method " is deprecated in libexiv2")
9898
%enddef // EXIV2_DEPRECATED
9999

100100
// Macro to not call a function if EXV_ENABLE_FILESYSTEM is OFF

0 commit comments

Comments
 (0)