Skip to content

Commit cd7e0e2

Browse files
Replace Py_ssize_t with long for array value index
1 parent bafcb95 commit cd7e0e2

File tree

5 files changed

+396
-378
lines changed

5 files changed

+396
-378
lines changed

src/interface/value.i

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ UNIQUE_PTR(Exiv2::Value);
6060
%noexception Exiv2::XmpValue::xmpStruct;
6161

6262
// ---- Typemaps ----
63-
// SWIG doesn't have typemaps for Py_ssize_t
64-
%apply long {Py_ssize_t};
65-
6663
// Convert std::ostream inputs and outputs
6764
%typemap(in) std::ostream& os (PyObject* _global_io, std::ostringstream temp) {
6865
$1 = &temp;
@@ -79,8 +76,8 @@ UNIQUE_PTR(Exiv2::Value);
7976
}
8077

8178
// for indexing multi-value values, assumes arg1 points to self
82-
%typemap(check) Py_ssize_t i %{
83-
if ($1 < 0 || $1 >= static_cast< Py_ssize_t >(arg1->count())) {
79+
%typemap(check) long idx %{
80+
if ($1 < 0 || $1 >= static_cast< long >(arg1->count())) {
8481
PyErr_Format(PyExc_IndexError, "index %d out of range", $1);
8582
SWIG_fail;
8683
}
@@ -355,14 +352,14 @@ VALUE_SUBCLASS(Exiv2::ValueType<item_type>, type_name)
355352
result->value_ = value;
356353
return result;
357354
}
358-
item_type __getitem__(Py_ssize_t i) {
359-
return $self->value_[i];
355+
item_type __getitem__(long idx) {
356+
return $self->value_[idx];
360357
}
361-
void __setitem__(Py_ssize_t i, const item_type* INPUT) {
358+
void __setitem__(long idx, const item_type* INPUT) {
362359
if (INPUT)
363-
$self->value_[i] = *INPUT;
360+
$self->value_[idx] = *INPUT;
364361
else
365-
$self->value_.erase($self->value_.begin() + i);
362+
$self->value_.erase($self->value_.begin() + idx);
366363
}
367364
void append(item_type value) {
368365
$self->value_.push_back(value);
@@ -574,8 +571,8 @@ RAW_STRING_DATA(Exiv2::XmpTextValue)
574571
XmpArrayValue(Exiv2::TypeId typeId_xmpBag) {
575572
return new Exiv2::XmpArrayValue(typeId_xmpBag);
576573
}
577-
std::string __getitem__(long i) {
578-
return $self->toString(i);
574+
std::string __getitem__(long idx) {
575+
return $self->toString(idx);
579576
}
580577
void append(std::string value) {
581578
$self->read(value);

0 commit comments

Comments
 (0)