Kaydet (Commit) bfbc5e53 authored tarafından jan Iversen's avatar jan Iversen

pyuno osx Sierra problem.

On a fresh installed Sierra pyuno fails to build due to a py_UNICODE
conversion problem.

Py_UNICODE expand to "unsigned short", and OUString expect a form of sal_UNICODE
The hack was done locally and not generally expand OUString functionality.

Change-Id: Ib7834c423c1c5cd9cd1e8d1ed8393e80bf8a5e5d
üst 74fdcfdf
...@@ -40,7 +40,16 @@ PyRef ustring2PyUnicode( const OUString & str ) ...@@ -40,7 +40,16 @@ PyRef ustring2PyUnicode( const OUString & str )
PyRef ret; PyRef ret;
#if Py_UNICODE_SIZE == 2 #if Py_UNICODE_SIZE == 2
// YD force conversion since python/2 uses wchar_t // YD force conversion since python/2 uses wchar_t
#ifdef MACOSX
// on Sierra, python 2.7 (builtin)
// no known conversion from 'const sal_Unicode *' (aka 'const char16_t *') to
// 'const Py_UNICODE *' (aka 'const unsigned short *')
// An explicit cast to sal_Unicode does not work
// Hack to avoid that error
ret = PyRef( PyUnicode_FromUnicode( (const unsigned short *)str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
#else
ret = PyRef( PyUnicode_FromUnicode( str.getStr(), str.getLength() ), SAL_NO_ACQUIRE ); ret = PyRef( PyUnicode_FromUnicode( str.getStr(), str.getLength() ), SAL_NO_ACQUIRE );
#endif
#else #else
OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8)); OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), nullptr) , SAL_NO_ACQUIRE ); ret = PyRef( PyUnicode_DecodeUTF8( sUtf8.getStr(), sUtf8.getLength(), nullptr) , SAL_NO_ACQUIRE );
...@@ -60,7 +69,15 @@ OUString pyString2ustring( PyObject *pystr ) ...@@ -60,7 +69,15 @@ OUString pyString2ustring( PyObject *pystr )
if( PyUnicode_Check( pystr ) ) if( PyUnicode_Check( pystr ) )
{ {
#if Py_UNICODE_SIZE == 2 #if Py_UNICODE_SIZE == 2
#ifdef MACOSX
// on Sierra, python 2.7 (builtin)
// no known conversion from 'Py_UNICODE *' (aka 'unsigned short *') to
// 'sal_Unicode' (aka 'char16_t') for 1st argument
// Hack to avoid that error
ret = OUString( (sal_Unicode *)PyUnicode_AS_UNICODE( pystr ) );
#else
ret = OUString( PyUnicode_AS_UNICODE( pystr ) ); ret = OUString( PyUnicode_AS_UNICODE( pystr ) );
#endif
#else #else
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0); Py_ssize_t size(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment