On Saturday, 31 August 2019 09:55:20 CEST Sven Eckelmann wrote: > This is just the first stepping stone to get Python3 support. The biggest > blocker right now is the support of the binary string interface for > encodeImage and decodeImage. The problem is described at > http://www.swig.org/Doc3.0/Python.html#Python_nn77
I had a closer look at this part and it looks to me like the main problem here
is the check for SWIG_CSTRING_UNIMPL. This one is always set and doesn't seem
to be relevant for us here. I couldn't find any documentation when this should
be used or not.
Following change was enough to get the test.py working with Python3 (yes, I
know that more cleanup is necessary in api.cc but I didn't do this yet because
I have no knowledge why SWIG_CSTRING_UNIMPL and the std::string implementation
was required in the first place):
--- a/api/api.hh
+++ b/api/api.hh
@@ -57,16 +57,10 @@ Image* copyImageCropRotate (Image* image, int x, int y,
unsigned int w, unsigned int h, double angle);
// decode image from memory data of size n
-#if defined(SWIG) && !defined(SWIG_CSTRING_UNIMPL)
+#if defined(SWIG)
%apply (char *STRING, int LENGTH) { (char *data, int n) };
#endif
-#if !defined(SWIG) || (defined(SWIG) && !defined(SWIG_CSTRING_UNIMPL))
bool decodeImage (Image* image, char* data, int n);
-#endif
-
-#if !defined(SWIG) || (defined(SWIG) && defined(SWIG_CSTRING_UNIMPL))
-bool decodeImage (Image* image, const std::string& data);
-#endif
// decode image from given filename
bool decodeImageFile (Image* image, const char* filename);
@@ -75,18 +69,12 @@ bool decodeImageFile (Image* image, const char* filename);
// encode image to memory, the data is newly allocated and returned
// return 0 i the image could not be decoded
-#if defined(SWIG) && !defined(SWIG_CSTRING_UNIMPL)
+#if defined(SWIG)
%cstring_output_allocate_size(char ** s, int *slen, free(*$1))
#endif
-#if !defined(SWIG) || (defined(SWIG) && !defined(SWIG_CSTRING_UNIMPL))
void encodeImage (char **s, int *slen,
Image* image, const char* codec, int quality = 75,
const char* compression = "");
-#endif
-#if !defined(SWIG) || (defined(SWIG) && defined(SWIG_CSTRING_UNIMPL))
-const std::string encodeImage (Image* image, const char* codec, int quality =
75,
- const char* compression = "");
-#endif
// encode image into specified filename
bool encodeImageFile (Image* image, const char* filename,
signature.asc
Description: This is a digitally signed message part.
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [email protected] with a subject of: unsubscribe exact-image
