Skip to content

Commit a41a237

Browse files
Defined BUFLEN_T for 0.27/0.28 data len type change
1 parent 94407f7 commit a41a237

12 files changed

Lines changed: 171 additions & 510 deletions

File tree

src/interface/basicio.i

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ typedef Exiv2::ErrorCode ErrorCode;
130130
KEEP_REFERENCE(Exiv2::BasicIo&)
131131

132132
// Allow BasicIo::write to take any Python buffer
133-
INPUT_BUFFER_RO(const Exiv2::byte* data, long wcount)
134-
INPUT_BUFFER_RO(const Exiv2::byte* data, size_t wcount)
133+
INPUT_BUFFER_RO(const Exiv2::byte* data, BUFLEN_T wcount)
135134

136135
// BasicIo::read can write to a Python buffer
137-
OUTPUT_BUFFER_RW(Exiv2::byte* buf, long rcount)
138-
OUTPUT_BUFFER_RW(Exiv2::byte* buf, size_t rcount)
136+
OUTPUT_BUFFER_RW(Exiv2::byte* buf, BUFLEN_T rcount)
139137

140138
// Use default typemap for isWriteable parameter.
141139
%typemap(default) bool isWriteable {$1 = false;}

src/interface/exif.i

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::ExifThumbC::writeFile)
5050
// ExifThumb keeps a reference to the ExifData it uses
5151
KEEP_REFERENCE_EX(Exiv2::ExifThumb*, args)
5252

53-
#if EXIV2_VERSION_HEX < 0x001c0000
54-
INPUT_BUFFER_RO(const Exiv2::byte* buf, long size)
55-
#else
56-
INPUT_BUFFER_RO(const Exiv2::byte* buf, size_t size)
57-
#endif
53+
INPUT_BUFFER_RO(const Exiv2::byte* buf, BUFLEN_T size)
5854

5955
EXTEND_METADATUM(Exiv2::Exifdatum)
6056

src/interface/image.i

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ UNIQUE_PTR(Exiv2::Image);
5656
%thread Exiv2::ImageFactory::open;
5757

5858
// ImageFactory can open image or get type from a buffer
59-
INPUT_BUFFER_RO(const Exiv2::byte* data, long size,
60-
ImageFactory_open, ImageFactory_createIo)
61-
INPUT_BUFFER_RO(const Exiv2::byte* data, size_t size,
59+
INPUT_BUFFER_RO(const Exiv2::byte* data, BUFLEN_T size,
6260
ImageFactory_open, ImageFactory_createIo)
6361

6462
// Release memory buffer after writeMetadata, as it creates its own copy
@@ -117,7 +115,7 @@ Create a MemIo subclass of BasicIo using the provided memory.
117115
"
118116
%extend Exiv2::ImageFactory {
119117
static Exiv2::BasicIo::SMART_PTR createIo(
120-
const Exiv2::byte* data, size_t size) {
118+
const Exiv2::byte* data, BUFLEN_T size) {
121119
#if EXIV2_VERSION_HEX < 0x001c0000
122120
return Exiv2::BasicIo::AutoPtr(new Exiv2::MemIo(data, size));
123121
#else

src/interface/metadatum.i

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ EXCEPTION()
3939
%ignore Exiv2::Metadatum::toLong() const;
4040
%ignore Exiv2::Metadatum::toRational() const;
4141
%ignore Exiv2::Metadatum::toString() const;
42-
%ignore Exiv2::Metadatum::toString(long) const;
43-
%ignore Exiv2::Metadatum::toString(size_t) const;
42+
%ignore Exiv2::Metadatum::toString(BUFLEN_T) const;
4443
%ignore Exiv2::Metadatum::toUint32() const;
4544

4645
// Use default parameter in print() and write()
@@ -118,7 +117,7 @@ static PyObject* set_value_from_py(datum_type* datum, PyObject* py_value) {
118117
}
119118
// toString parameter does not default to 0, so bypass default typemap
120119
std::string toString() const { return self->toString(); }
121-
std::string toString(size_t i) const { return self->toString(i); }
120+
std::string toString(BUFLEN_T i) const { return self->toString(i); }
122121
}
123122
%enddef // EXTEND_METADATUM
124123

src/interface/shared/preamble.i

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
#define EXV_DLLLOCAL
4141
#define EXV_DLLPUBLIC
4242

43+
// Data sizes have different types in exiv2 0.27 and 0.28
44+
#if EXIV2_VERSION_HEX < 0x001c0000
45+
#define BUFLEN_T long
46+
#else
47+
#define BUFLEN_T size_t
48+
#endif
49+
4350
// Stuff to handle auto_ptr or unique_ptr
4451
#if EXIV2_VERSION_HEX < 0x001c0000
4552
#define SMART_PTR AutoPtr

src/interface/types.i

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ DEFINE_ENUM(TypeId, "Exiv2 value type identifiers.\n"
221221
%}
222222

223223
// Allow Exiv2::DataBuf to be initialised from a Python buffer
224-
#if EXIV2_VERSION_HEX < 0x001c0000
225-
INPUT_BUFFER_RO(const Exiv2::byte *pData, long size)
226-
#else
227-
INPUT_BUFFER_RO(const Exiv2::byte *pData, size_t size)
228-
#endif
224+
INPUT_BUFFER_RO(const Exiv2::byte *pData, BUFLEN_T size)
229225

230226
// Expose Exiv2::DataBuf contents as a Python buffer
231227
%fragment("get_ptr_size"{Exiv2::DataBuf}, "header") {

src/interface/value.i

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ UNIQUE_PTR(Exiv2::Value);
8888
}
8989
%}
9090
// DataValue constructor and DataValue::read can take a Python buffer
91-
#if EXIV2_VERSION_HEX < 0x001c0000
92-
INPUT_BUFFER_RO(const Exiv2::byte* buf, long len)
93-
#else
94-
INPUT_BUFFER_RO(const Exiv2::byte* buf, size_t len)
95-
#endif
91+
INPUT_BUFFER_RO(const Exiv2::byte* buf, BUFLEN_T len)
92+
9693
// Value::copy can write to a Python buffer
9794
OUTPUT_BUFFER_RW(Exiv2::byte* buf,)
9895

@@ -196,10 +193,8 @@ static swig_type_info* get_swig_type(Exiv2::Value* value) {
196193

197194
// Ignore now redundant overloaded methods
198195
%ignore Exiv2::DataValue::DataValue();
199-
%ignore Exiv2::DataValue::DataValue(byte const *, long);
200-
%ignore Exiv2::DataValue::DataValue(byte const *, long, ByteOrder);
201-
%ignore Exiv2::DataValue::DataValue(byte const *, size_t);
202-
%ignore Exiv2::DataValue::DataValue(byte const *, size_t, ByteOrder);
196+
%ignore Exiv2::DataValue::DataValue(byte const *, BUFLEN_T);
197+
%ignore Exiv2::DataValue::DataValue(byte const *, BUFLEN_T, ByteOrder);
203198
%ignore Exiv2::Value::toFloat() const;
204199
%ignore Exiv2::Value::toInt64() const;
205200
%ignore Exiv2::Value::toLong() const;
@@ -252,8 +247,7 @@ DEPRECATED_ENUM(XmpValue, XmpStruct, "XMP structure indicator.",
252247
%ignore type_name::value_;
253248
// Ignore overloaded methods replaced by default typemaps
254249
%ignore type_name::copy(byte *) const;
255-
%ignore type_name::read(byte const *, long);
256-
%ignore type_name::read(byte const *, size_t);
250+
%ignore type_name::read(byte const *, BUFLEN_T);
257251
%noexception type_name::~part_name;
258252
%noexception type_name::__getitem__;
259253
%noexception type_name::__setitem__;
@@ -271,13 +265,10 @@ VALUE_SUBCLASS(Exiv2::ValueType<item_type>, type_name)
271265
// Ignore now overloaded constructors
272266
%ignore Exiv2::ValueType<item_type>::ValueType(item_type const &);
273267
#if EXIV2_VERSION_HEX < 0x001c0000
274-
%ignore Exiv2::ValueType<item_type>::ValueType(
275-
byte const *, long, ByteOrder);
276268
%ignore Exiv2::ValueType<item_type>::ValueType();
277-
#else
278-
%ignore Exiv2::ValueType<item_type>::ValueType(
279-
byte const *, size_t, ByteOrder);
280269
#endif
270+
%ignore Exiv2::ValueType<item_type>::ValueType(
271+
byte const *, BUFLEN_T, ByteOrder);
281272
// Also need to ignore equivalent primitive type definitions
282273
%ignore Exiv2::ValueType<item_type>::ValueType(short const &);
283274
%ignore Exiv2::ValueType<item_type>::ValueType(unsigned short const &);

0 commit comments

Comments
 (0)