summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-29 17:33:15 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-30 19:08:28 +0200
commitc3609f107b16eb888edf284f4637be6cb09234eb (patch)
treeda52e05b5cdf26d5d3a57f510f8b32d8af10a026 /pyuno
parent8a4df9376bf299beb49fe116882ffdbd10b5e02b (diff)
Use SAL_W/SAL_U instead of reinterpret_cast btwn wchar_t* and sal_Unicode*
This is type-safe, and allows to catch cases where a source type is changed for some reason, but reinterpret_cast masks that Change-Id: Ib64b6fa2e22d94a6bba890f0ccc3e20325c6f0a1 Reviewed-on: https://gerrit.libreoffice.org/42961 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno_util.cxx5
1 files changed, 2 insertions, 3 deletions
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index e92dad2e8bca..055ef736695b 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -43,7 +43,7 @@ PyRef ustring2PyUnicode( const OUString & str )
ret = PyRef( PyUnicode_FromUnicode( reinterpret_cast<const unsigned short *>(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE );
#else
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 );
+ ret = PyRef( PyUnicode_FromUnicode( SAL_W(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE );
#endif
#else
OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8));
@@ -64,8 +64,7 @@ OUString pyString2ustring( PyObject *pystr )
if( PyUnicode_Check( pystr ) )
{
#if Py_UNICODE_SIZE == 2
- ret = OUString(
- reinterpret_cast<sal_Unicode const *>(PyUnicode_AS_UNICODE( pystr )) );
+ ret = SAL_U(PyUnicode_AS_UNICODE( pystr ));
#else
#if PY_MAJOR_VERSION >= 3
Py_ssize_t size(0);