Skip to content

Commit eecf442

Browse files
Reduce bloat by not implementing wrapped data
The definition of the wrapped classes is needed in several places, such as easyaccess, but they don't need the Python definition.
1 parent 2385ff0 commit eecf442

15 files changed

Lines changed: 28 additions & 4934 deletions

File tree

src/interface/easyaccess.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef SWIGIMPORTED
2323
// Get definition of ExifDataWrap so functions can be passed
2424
// either ExifDataWrap or Exiv2::ExifData
25-
DATA_WRAPPER(ExifData, Exiv2::ExifData, Exiv2::Exifdatum, Exiv2::ExifKey)
25+
DATA_WRAPPER_DEC(ExifData, Exiv2::ExifData, Exiv2::Exifdatum, Exiv2::ExifKey)
2626
#endif
2727

2828
// Store data.end() after converting input

src/interface/exif.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DATA_ITERATOR(ExifData, Exiv2::ExifData, Exiv2::ExifData::iterator,
4343
Exiv2::Exifdatum)
4444
// Get definition of ExifDataWrap so ExifThumb constructor can be passed
4545
// either ExifDataWrap or Exiv2::ExifData
46-
DATA_WRAPPER(ExifData, Exiv2::ExifData, Exiv2::Exifdatum, Exiv2::ExifKey)
46+
DATA_WRAPPER_DEC(ExifData, Exiv2::ExifData, Exiv2::Exifdatum, Exiv2::ExifKey)
4747
#endif
4848

4949
%ignore Exiv2::ExifData::operator[];

src/interface/preamble.i

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@ public:
252252
%}
253253
%enddef // DATA_ITERATOR
254254

255-
// Macro to wrap data while keeping a reference to its image
256-
%define DATA_WRAPPER(name, base_class, datum_type, key_type)
255+
// Macros to wrap data while keeping a reference to its image
256+
// Macro that actually does everything, either declaration only or implemented
257+
%define _DATA_WRAPPER(name, base_class, datum_type, key_type, mode)
257258
// Allow name##Wrap to be passed where base_class is expected
258259
%typemap(in) base_class& (int res, name##Wrap* arg_wrap, base_class* arg_base) %{
259260
res = SWIG_ConvertPtr($input, (void**)&arg_wrap, $descriptor(name##Wrap*), 0);
@@ -288,7 +289,7 @@ public:
288289
%feature("docstring") name##Wrap
289290
"Python wrapper for "#base_class
290291
".\nSee that class's documentation for full details."
291-
%inline %{
292+
mode %{
292293
class name##Wrap {
293294
private:
294295
base_class* base;
@@ -331,6 +332,16 @@ public:
331332
}
332333
};
333334
%}
335+
%enddef // _DATA_WRAPPER
336+
337+
// Macro to declare wrapped class for C++ use but not for Python
338+
%define DATA_WRAPPER_DEC(name, base_class, datum_type, key_type)
339+
_DATA_WRAPPER(name, base_class, datum_type, key_type, )
340+
%enddef // DATA_WRAPPER_DEC
341+
342+
// Macro to declare wrapped class for Python and C++
343+
%define DATA_WRAPPER(name, base_class, datum_type, key_type)
344+
_DATA_WRAPPER(name, base_class, datum_type, key_type, %inline)
334345
%enddef // DATA_WRAPPER
335346

336347
// Macro to make enums more Pythonic

src/swig_0.26/easyaccess.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ class _SwigNonDynamicMeta(type):
6363

6464

6565

66-

0 commit comments

Comments
 (0)