Skip to content

Commit 711f10f

Browse files
Update to allow EXV_ENABLE_FILESYSTEM off
1 parent d4a1e08 commit 711f10f

21 files changed

+315
-0
lines changed

src/interface/basicio.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ EXCEPTION()
4343

4444
%fragment("EXV_USE_CURL");
4545
%fragment("EXV_USE_SSH");
46+
%fragment("EXV_ENABLE_FILESYSTEM");
4647

4748
UNIQUE_PTR(Exiv2::BasicIo);
4849

src/interface/exif.i

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
%include "shared/data_iterator.i"
3030
%include "shared/enum.i"
3131
%include "shared/exception.i"
32+
%include "shared/exv_options.i"
3233
%include "shared/keep_reference.i"
3334
%include "shared/windows_path.i"
3435

@@ -43,6 +44,12 @@ IMPORT_ENUM(TypeId)
4344
// Catch all C++ exceptions
4445
EXCEPTION()
4546

47+
EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::ExifThumb::setJpegThumbnail(
48+
const std::string&))
49+
EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::ExifThumb::setJpegThumbnail(
50+
const std::string&, URational, URational, uint16_t))
51+
EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::ExifThumbC::writeFile)
52+
4653
// ExifThumb keeps a reference to the ExifData it uses
4754
KEEP_REFERENCE_EX(Exiv2::ExifThumb*, args)
4855

src/interface/image.i

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ EXCEPTION()
4848

4949
%fragment("EXV_USE_CURL");
5050
%fragment("EXV_USE_SSH");
51+
%fragment("EXV_ENABLE_FILESYSTEM");
52+
EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::ImageFactory::create(
53+
ImageType, const std::string&))
5154

5255
UNIQUE_PTR(Exiv2::Image);
5356

src/interface/preview.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ EXCEPTION()
4444

4545
%fragment("EXV_USE_CURL");
4646
%fragment("EXV_USE_SSH");
47+
%fragment("EXV_ENABLE_FILESYSTEM");
48+
EXV_ENABLE_FILESYSTEM_FUNCTION(Exiv2::PreviewImage::writeFile)
4749

4850
// Some calls don't raise exceptions
4951
%noexception Exiv2::PreviewImage::__len__;

src/interface/shared/exv_options.i

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,44 @@ namespace Exiv2 {
3333
}
3434
#endif // EXV_USE_SSH
3535
%}
36+
37+
// Fragment to set EXV_ENABLE_FILESYSTEM on old libexiv2 versions
38+
%fragment("set_EXV_ENABLE_FILESYSTEM", "header") %{
39+
#if !EXIV2_TEST_VERSION(0, 28, 3)
40+
#define EXV_ENABLE_FILESYSTEM
41+
#endif
42+
// Copy EXV_ENABLE_FILESYSTEM for use in macro
43+
#ifdef EXV_ENABLE_FILESYSTEM
44+
#define _EXV_ENABLE_FILESYSTEM
45+
#endif
46+
%}
47+
48+
// Fragment to define FileIo and XPathIo if EXV_ENABLE_FILESYSTEM is OFF
49+
%fragment("EXV_ENABLE_FILESYSTEM", "header",
50+
fragment="set_EXV_ENABLE_FILESYSTEM") %{
51+
#ifndef EXV_ENABLE_FILESYSTEM
52+
namespace Exiv2 {
53+
class FileIo : public BasicIo {};
54+
class XPathIo : public MemIo {};
55+
}
56+
#endif // EXV_ENABLE_FILESYSTEM
57+
%}
58+
59+
// Macro to not call a function if EXV_ENABLE_FILESYSTEM is OFF
60+
%define EXV_ENABLE_FILESYSTEM_FUNCTION(signature)
61+
%fragment("_set_python_exception");
62+
%fragment("set_EXV_ENABLE_FILESYSTEM");
63+
%exception signature {
64+
try {
65+
%#ifdef _EXV_ENABLE_FILESYSTEM
66+
$action
67+
%#else
68+
throw Exiv2::Error(Exiv2::ErrorCode::kerFunctionNotSupported);
69+
%#endif
70+
}
71+
catch(std::exception const& e) {
72+
_set_python_exception();
73+
SWIG_fail;
74+
}
75+
}
76+
%enddef // EXV_ENABLE_FILESYSTEM_FUNCTION

src/interface/version.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
%include "shared/preamble.i"
2525
%include "shared/exception.i"
26+
%include "shared/exv_options.i"
2627

2728
%include "stdint.i"
2829
%include "std_string.i"
@@ -39,6 +40,7 @@ EXCEPTION()
3940

4041
// Function to report build options used
4142
%feature("docstring") versionInfo "Return a dict of libexiv2 build options."
43+
%fragment("set_EXV_ENABLE_FILESYSTEM");
4244
%inline %{
4345
static PyObject* versionInfo() {
4446
bool nls = false;

src/swig-0_27_3/basicio_wrap.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,6 +4290,23 @@ namespace Exiv2 {
42904290
#endif // EXV_USE_SSH
42914291

42924292

4293+
#if !EXIV2_TEST_VERSION(0, 28, 3)
4294+
#define EXV_ENABLE_FILESYSTEM
4295+
#endif
4296+
// Copy EXV_ENABLE_FILESYSTEM for use in macro
4297+
#ifdef EXV_ENABLE_FILESYSTEM
4298+
#define _EXV_ENABLE_FILESYSTEM
4299+
#endif
4300+
4301+
4302+
#ifndef EXV_ENABLE_FILESYSTEM
4303+
namespace Exiv2 {
4304+
class FileIo : public BasicIo {};
4305+
class XPathIo : public MemIo {};
4306+
}
4307+
#endif // EXV_ENABLE_FILESYSTEM
4308+
4309+
42934310
typedef Exiv2::ErrorCode ErrorCode;
42944311

42954312

src/swig-0_27_3/exif_wrap.cxx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,6 +4313,15 @@ static void _set_python_exception() {
43134313
};
43144314

43154315

4316+
#if !EXIV2_TEST_VERSION(0, 28, 3)
4317+
#define EXV_ENABLE_FILESYSTEM
4318+
#endif
4319+
// Copy EXV_ENABLE_FILESYSTEM for use in macro
4320+
#ifdef EXV_ENABLE_FILESYSTEM
4321+
#define _EXV_ENABLE_FILESYSTEM
4322+
#endif
4323+
4324+
43164325
// Base class implements all methods except dereferencing
43174326
class ExifData_iterator_base {
43184327
protected:
@@ -8649,7 +8658,11 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args)
86498658
}
86508659
{
86518660
try {
8661+
#ifdef _EXV_ENABLE_FILESYSTEM
86528662
result = (long)((Exiv2::ExifThumbC const *)arg1)->writeFile((std::string const &)*arg2);
8663+
#else
8664+
throw Exiv2::Error(Exiv2::ErrorCode::kerFunctionNotSupported);
8665+
#endif
86538666
}
86548667
catch(std::exception const& e) {
86558668
_set_python_exception();
@@ -8859,7 +8872,11 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py
88598872
}
88608873
{
88618874
try {
8875+
#ifdef _EXV_ENABLE_FILESYSTEM
88628876
(arg1)->setJpegThumbnail((std::string const &)*arg2,arg3,arg4,arg5);
8877+
#else
8878+
throw Exiv2::Error(Exiv2::ErrorCode::kerFunctionNotSupported);
8879+
#endif
88638880
}
88648881
catch(std::exception const& e) {
88658882
_set_python_exception();
@@ -8990,7 +9007,11 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py
89909007
}
89919008
{
89929009
try {
9010+
#ifdef _EXV_ENABLE_FILESYSTEM
89939011
(arg1)->setJpegThumbnail((std::string const &)*arg2);
9012+
#else
9013+
throw Exiv2::Error(Exiv2::ErrorCode::kerFunctionNotSupported);
9014+
#endif
89949015
}
89959016
catch(std::exception const& e) {
89969017
_set_python_exception();

src/swig-0_27_3/image_wrap.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,6 +4341,23 @@ namespace Exiv2 {
43414341
#endif // EXV_USE_SSH
43424342

43434343

4344+
#if !EXIV2_TEST_VERSION(0, 28, 3)
4345+
#define EXV_ENABLE_FILESYSTEM
4346+
#endif
4347+
// Copy EXV_ENABLE_FILESYSTEM for use in macro
4348+
#ifdef EXV_ENABLE_FILESYSTEM
4349+
#define _EXV_ENABLE_FILESYSTEM
4350+
#endif
4351+
4352+
4353+
#ifndef EXV_ENABLE_FILESYSTEM
4354+
namespace Exiv2 {
4355+
class FileIo : public BasicIo {};
4356+
class XPathIo : public MemIo {};
4357+
}
4358+
#endif // EXV_ENABLE_FILESYSTEM
4359+
4360+
43444361
static bool enableBMFF(bool enable) {
43454362
#ifdef EXV_ENABLE_BMFF
43464363
return Exiv2::enableBMFF(enable);

src/swig-0_27_3/preview_wrap.cxx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,23 @@ namespace Exiv2 {
44964496
#endif // EXV_USE_SSH
44974497

44984498

4499+
#if !EXIV2_TEST_VERSION(0, 28, 3)
4500+
#define EXV_ENABLE_FILESYSTEM
4501+
#endif
4502+
// Copy EXV_ENABLE_FILESYSTEM for use in macro
4503+
#ifdef EXV_ENABLE_FILESYSTEM
4504+
#define _EXV_ENABLE_FILESYSTEM
4505+
#endif
4506+
4507+
4508+
#ifndef EXV_ENABLE_FILESYSTEM
4509+
namespace Exiv2 {
4510+
class FileIo : public BasicIo {};
4511+
class XPathIo : public MemIo {};
4512+
}
4513+
#endif // EXV_ENABLE_FILESYSTEM
4514+
4515+
44994516
namespace swig {
45004517
template <class Type>
45014518
struct noconst_traits {
@@ -6379,7 +6396,11 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args
63796396
}
63806397
{
63816398
try {
6399+
#ifdef _EXV_ENABLE_FILESYSTEM
63826400
result = (long)((Exiv2::PreviewImage const *)arg1)->writeFile((std::string const &)*arg2);
6401+
#else
6402+
throw Exiv2::Error(Exiv2::ErrorCode::kerFunctionNotSupported);
6403+
#endif
63836404
}
63846405
catch(std::exception const& e) {
63856406
_set_python_exception();

0 commit comments

Comments
 (0)