diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 09:55:04 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-30 20:16:57 +0200 |
commit | ce9611d13ff69306f8c44ac53110cc2cb4116e85 (patch) | |
tree | 9d3c42ea354ce54f3eb5ce5d5a6115d0eecfc422 /pyuno | |
parent | 3c1085fcdd8814180507d8ea1aa6e75d4f94f14f (diff) |
Prepare for removal of non-const operator[] from Sequence in pyuno
Change-Id: Ifea4a6baa5fd3878e807ffde6b3fd2e2794312f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124379
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'pyuno')
-rw-r--r-- | pyuno/source/module/pyuno.cxx | 13 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_callable.cxx | 3 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_runtime.cxx | 11 |
3 files changed, 11 insertions, 16 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index a177be410c79..cdd5e417feeb 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -593,8 +593,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey ) // Single string key is sugar for getCellRangeByName() if ( PyUnicode_Check( pKey ) ) { - aParams.realloc (1); - aParams[0] <<= pyString2ustring( pKey ); + aParams = { Any(pyString2ustring( pKey )) }; { PyThreadDetach antiguard; aRet = me->members->xInvocation->invoke ( @@ -632,9 +631,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey ) if ( ((nKey0_s == -1) || (nKey1_s == -1)) && PyErr_Occurred() ) return nullptr; - aParams.realloc( 2 ); - aParams[0] <<= nKey1_s; - aParams[1] <<= nKey0_s; + aParams = { Any(nKey1_s), Any(nKey0_s) }; { PyThreadDetach antiguard; aRet = me->members->xInvocation->invoke ( @@ -680,11 +677,7 @@ static PyObject* lcl_getitem_XCellRange( PyUNO const * me, PyObject* pKey ) if ( nStep0 == 1 && nStep1 == 1 ) { - aParams.realloc (4); - aParams[0] <<= nStart1; - aParams[1] <<= nStart0; - aParams[2] <<= nStop1 - 1; - aParams[3] <<= nStop0 - 1; + aParams = { Any(nStart1), Any(nStart0), Any(nStop1 - 1), Any(nStop0 - 1) }; { PyThreadDetach antiguard; aRet = me->members->xInvocation->invoke ( diff --git a/pyuno/source/module/pyuno_callable.cxx b/pyuno/source/module/pyuno_callable.cxx index 1c138f71b419..7816bbf7de3b 100644 --- a/pyuno/source/module/pyuno_callable.cxx +++ b/pyuno/source/module/pyuno_callable.cxx @@ -83,8 +83,7 @@ static PyObject* PyUNO_callable_call( } else { - aParams.realloc (1); - aParams [0] = any_params; + aParams = { any_params }; } { diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx index 8c14bc0d2953..7f3eb7a6e95f 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -581,12 +581,13 @@ static Sequence< Type > invokeGetTypes( const Runtime & r , PyObject * o ) // add the XUnoTunnel interface for uno object identity concept (hack) ret.realloc( size + 1 ); + auto pret = ret.getArray(); for( int i = 0 ; i < size ; i ++ ) { Any a = r.pyObject2Any(PyTuple_GetItem(types.get(),i)); - a >>= ret[i]; + a >>= pret[i]; } - ret[size] = cppu::UnoType<css::lang::XUnoTunnel>::get(); + pret[size] = cppu::UnoType<css::lang::XUnoTunnel>::get(); } } return ret; @@ -699,9 +700,10 @@ Any Runtime::pyObject2Any(const PyRef & source, enum ConversionMode mode) const else if (PyTuple_Check (o)) { Sequence<Any> s (PyTuple_Size (o)); + auto sRange = asNonConstRange(s); for (Py_ssize_t i = 0; i < PyTuple_Size (o); i++) { - s[i] = pyObject2Any (PyTuple_GetItem (o, i), mode ); + sRange[i] = pyObject2Any (PyTuple_GetItem (o, i), mode ); } a <<= s; } @@ -709,9 +711,10 @@ Any Runtime::pyObject2Any(const PyRef & source, enum ConversionMode mode) const { Py_ssize_t l = PyList_Size (o); Sequence<Any> s (l); + auto sRange = asNonConstRange(s); for (Py_ssize_t i = 0; i < l; i++) { - s[i] = pyObject2Any (PyList_GetItem (o, i), mode ); + sRange[i] = pyObject2Any (PyList_GetItem (o, i), mode ); } a <<= s; } |