summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-05-12 13:26:15 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-05-12 13:26:15 +0200
commit3e78796433c40a99b6d95b0bcde844e0b1d2dc5f (patch)
tree904ecd31a75f83dda2e5ba41cf3d18060246e087 /pyuno
parent6d3a43fa80d8ad54fe8982b2b056ce15ea4268b4 (diff)
Clean up uses of SAL_U/SAL_W: pyuno
...and clean up MACOSX specific code Change-Id: I1796b4b8f2695359557a5374b5d7592ccf8f86a6
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno_util.cxx22
1 files changed, 5 insertions, 17 deletions
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<const unsigned short *>(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<wchar_t const *>(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<sal_Unicode const *>(PyUnicode_AS_UNICODE( pystr )) );
#else
#if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0);