Skip to content

Commit

Permalink
Make some easyaccess functions conditional
Browse files Browse the repository at this point in the history
This eliminates the need to have separate SWIG files for libexiv2
v0.27.3 and older.
  • Loading branch information
jim-easterbrook committed Jul 31, 2024
1 parent f5219cc commit 6f27274
Show file tree
Hide file tree
Showing 36 changed files with 132 additions and 151,341 deletions.
14 changes: 14 additions & 0 deletions src/interface/easyaccess.i
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@

%include "shared/preamble.i"
%include "shared/exception.i"
%include "shared/exv_options.i"

// Catch all C++ exceptions
EXCEPTION()

EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::apertureValue)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::brightnessValue)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::dateTimeOriginal)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::exposureBiasValue)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::exposureIndex)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::flash)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::flashEnergy)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::lightSource)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::maxApertureValue)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::sensingMethod)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::shutterSpeedValue)
EXV_ENABLE_EASYACCESS_FUNCTION(Exiv2::subjectArea)

// Store data.end() after converting input
%typemap(check) Exiv2::ExifData& (Exiv2::ExifData::const_iterator _global_end) %{
_global_end = $1->end();
Expand Down
19 changes: 19 additions & 0 deletions src/interface/shared/exv_options.i
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,22 @@ namespace Exiv2 {
}
}
%enddef // EXV_ENABLE_FILESYSTEM_FUNCTION

// Macro to not call a function if libexiv2 version is <= 0.27.3
%define EXV_ENABLE_EASYACCESS_FUNCTION(signature)
%fragment("_set_python_exception");
%fragment("set_EXV_ENABLE_FILESYSTEM");
%exception signature {
try {
%#if EXIV2_TEST_VERSION(0, 27, 4)
$action
%#else
throw Exiv2::Error(Exiv2::kerFunctionNotSupported);
%#endif
}
catch(std::exception const& e) {
_set_python_exception();
SWIG_fail;
}
}
%enddef // EXV_ENABLE_EASYACCESS_FUNCTION
60 changes: 0 additions & 60 deletions src/swig-0_27_3/__init__.py

This file was deleted.

40 changes: 0 additions & 40 deletions src/swig-0_27_3/__main__.py

This file was deleted.

35 changes: 0 additions & 35 deletions src/swig-0_27_3/basicio.py

This file was deleted.

Loading

0 comments on commit 6f27274

Please sign in to comment.