Skip to content

Commit

Permalink
Force EXIV2_ENABLE_WIN_UNICODE=OFF always
Browse files Browse the repository at this point in the history
The code-page to utf-8 translation works OK and is required for exiv2
v0.28.x anyway, so ignoring the wchar versions of some methods entirely
makes sense.
  • Loading branch information
jim-easterbrook committed Feb 18, 2024
1 parent 10c2e27 commit a1e64cf
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-windows-27.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
cmake -B build-msvc
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_INSTALL_PREFIX=build-msvc/install
-D EXIV2_ENABLE_WIN_UNICODE=ON
-D EXIV2_ENABLE_WIN_UNICODE=OFF
-D EXIV2_BUILD_SAMPLES=OFF
-D EXIV2_BUILD_EXIV2_COMMAND=OFF
-D EXIV2_ENABLE_BMFF=ON
Expand Down
15 changes: 6 additions & 9 deletions src/interface/shared/windows_path.i
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,34 @@

%include "shared/windows_cp.i"

// If exiv2's wstring methods are available then use them!
#ifdef EXV_UNICODE_PATH
%include "std_wstring.i"
#endif

// Macro to convert Windows path inputs from utf-8 to current code page
%define WINDOWS_PATH(signature)
#ifndef EXV_UNICODE_PATH
%typemap(check, fragment="utf8_to_wcp") signature {
%#ifdef _WIN32
if (utf8_to_wcp($1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
%#endif
}
#endif
%enddef // WINDOWS_PATH

// Macro to convert Windows path outputs from current code page to utf-8
%define WINDOWS_PATH_OUT(function)
#ifndef EXV_UNICODE_PATH
%typemap(out, fragment="utf8_to_wcp") std::string function {
%#ifdef _WIN32
if (utf8_to_wcp(&$1, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
%#endif
$result = SWIG_From_std_string($1);
}
%typemap(out, fragment="utf8_to_wcp") const std::string& function {
std::string copy = *$1;
%#ifdef _WIN32
if (utf8_to_wcp(&copy, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
%#endif
$result = SWIG_From_std_string(copy);
}
#endif
%enddef // WINDOWS_PATH_OUT
3 changes: 0 additions & 3 deletions src/interface/version.i
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ static PyObject* versionInfo() {
#ifdef EXV_ENABLE_VIDEO
video = true;
#endif
#ifdef EXV_UNICODE_PATH
unicode = true;
#endif
#ifdef EXV_ENABLE_WEBREADY
webready = true;
#endif
Expand Down
20 changes: 20 additions & 0 deletions src/swig-0_27_3/basicio_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5735,9 +5735,11 @@ SWIGINTERN PyObject *_wrap_BasicIo_path(PyObject *self, PyObject *args) {
arg1 = reinterpret_cast< Exiv2::BasicIo * >(argp1);
result = ((Exiv2::BasicIo const *)arg1)->path();
{
#ifdef _WIN32
if (utf8_to_wcp(&result, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
#endif
resultobj = SWIG_From_std_string(result);
}
return resultobj;
Expand Down Expand Up @@ -5767,9 +5769,11 @@ SWIGINTERN int _wrap_new_FileIo(PyObject *self, PyObject *args, PyObject *kwargs
arg1 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6536,9 +6540,11 @@ SWIGINTERN PyObject *_wrap_FileIo_setPath(PyObject *self, PyObject *args) {
arg2 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6702,9 +6708,11 @@ SWIGINTERN PyObject *_wrap_FileIo_path(PyObject *self, PyObject *args) {
arg1 = reinterpret_cast< Exiv2::FileIo * >(argp1);
result = ((Exiv2::FileIo const *)arg1)->path();
{
#ifdef _WIN32
if (utf8_to_wcp(&result, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
#endif
resultobj = SWIG_From_std_string(result);
}
return resultobj;
Expand Down Expand Up @@ -7483,9 +7491,11 @@ SWIGINTERN PyObject *_wrap_MemIo_path(PyObject *self, PyObject *args) {
arg1 = reinterpret_cast< Exiv2::MemIo * >(argp1);
result = ((Exiv2::MemIo const *)arg1)->path();
{
#ifdef _WIN32
if (utf8_to_wcp(&result, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
#endif
resultobj = SWIG_From_std_string(result);
}
return resultobj;
Expand Down Expand Up @@ -7519,9 +7529,11 @@ SWIGINTERN int _wrap_new_XPathIo(PyObject *self, PyObject *args, PyObject *kwarg
arg1 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -7633,9 +7645,11 @@ SWIGINTERN PyObject *_wrap_XPathIo_writeDataToFile(PyObject *self, PyObject *arg
arg1 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -8389,9 +8403,11 @@ SWIGINTERN PyObject *_wrap_RemoteIo_path(PyObject *self, PyObject *args) {
arg1 = reinterpret_cast< Exiv2::RemoteIo * >(argp1);
result = ((Exiv2::RemoteIo const *)arg1)->path();
{
#ifdef _WIN32
if (utf8_to_wcp(&result, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
#endif
resultobj = SWIG_From_std_string(result);
}
return resultobj;
Expand Down Expand Up @@ -8434,9 +8450,11 @@ SWIGINTERN int _wrap_new_HttpIo__SWIG_0(PyObject *self, PyObject *args, PyObject
}
arg2 = static_cast< size_t >(val2);
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -8477,9 +8495,11 @@ SWIGINTERN int _wrap_new_HttpIo__SWIG_1(PyObject *self, PyObject *args, PyObject
arg1 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down
6 changes: 6 additions & 0 deletions src/swig-0_27_3/exif_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8633,9 +8633,11 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args)
arg2 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -8841,9 +8843,11 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py
}
arg5 = static_cast< uint16_t >(val5);
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -8970,9 +8974,11 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py
arg2 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down
8 changes: 8 additions & 0 deletions src/swig-0_27_3/image_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6245,9 +6245,11 @@ SWIGINTERN PyObject *_wrap_ImageFactory_createIo(PyObject *self, PyObject *args)
arg2 = static_cast< bool >(val2);
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6303,9 +6305,11 @@ SWIGINTERN PyObject *_wrap_ImageFactory_open__SWIG_0(PyObject *self, Py_ssize_t
arg2 = static_cast< bool >(val2);
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6451,9 +6455,11 @@ SWIGINTERN PyObject *_wrap_ImageFactory_create__SWIG_0(PyObject *self, Py_ssize_
arg2 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6568,9 +6574,11 @@ SWIGINTERN PyObject *_wrap_ImageFactory_getType__SWIG_0(PyObject *self, Py_ssize
arg1 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg1, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down
4 changes: 4 additions & 0 deletions src/swig-0_27_3/preview_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6347,9 +6347,11 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args
arg2 = ptr;
}
{
#ifdef _WIN32
if (utf8_to_wcp(arg2, true) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode path");
}
#endif
}
{
try {
Expand Down Expand Up @@ -6405,9 +6407,11 @@ SWIGINTERN PyObject *_wrap_PreviewImage_extension(PyObject *self, PyObject *args
arg1 = reinterpret_cast< Exiv2::PreviewImage * >(argp1);
result = ((Exiv2::PreviewImage const *)arg1)->extension();
{
#ifdef _WIN32
if (utf8_to_wcp(&result, false) < 0) {
SWIG_exception_fail(SWIG_ValueError, "failed to transcode result");
}
#endif
resultobj = SWIG_From_std_string(result);
}
return resultobj;
Expand Down
3 changes: 0 additions & 3 deletions src/swig-0_27_3/version_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4272,9 +4272,6 @@ static PyObject* versionInfo() {
#ifdef EXV_ENABLE_VIDEO
video = true;
#endif
#ifdef EXV_UNICODE_PATH
unicode = true;
#endif
#ifdef EXV_ENABLE_WEBREADY
webready = true;
#endif
Expand Down
Loading

0 comments on commit a1e64cf

Please sign in to comment.