From 3e78796433c40a99b6d95b0bcde844e0b1d2dc5f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 12 May 2017 13:26:15 +0200 Subject: Clean up uses of SAL_U/SAL_W: pyuno ...and clean up MACOSX specific code Change-Id: I1796b4b8f2695359557a5374b5d7592ccf8f86a6 --- pyuno/source/module/pyuno_util.cxx | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'pyuno') diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx index 30e636ffe2a2..aecca4ad2eae 100644 --- a/pyuno/source/module/pyuno_util.cxx +++ b/pyuno/source/module/pyuno_util.cxx @@ -39,16 +39,11 @@ PyRef ustring2PyUnicode( const OUString & str ) { PyRef ret; #if Py_UNICODE_SIZE == 2 - // 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 ); + ret = PyRef( PyUnicode_FromUnicode( reinterpret_cast(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); #else - ret = PyRef( PyUnicode_FromUnicode( SAL_W(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); + static_assert(sizeof (wchar_t) == Py_UNICODE_SIZE, "bad assumption"); + ret = PyRef( PyUnicode_FromUnicode( reinterpret_cast(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); #endif #else OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8)); @@ -69,15 +64,8 @@ OUString pyString2ustring( PyObject *pystr ) if( PyUnicode_Check( pystr ) ) { #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( SAL_U(PyUnicode_AS_UNICODE( pystr )) ); -#endif + ret = OUString( + reinterpret_cast(PyUnicode_AS_UNICODE( pystr )) ); #else #if PY_MAJOR_VERSION >= 3 Py_ssize_t size(0); -- cgit