@@ -145,8 +145,8 @@ static void make_numpy_dtype_for_copy(py_ref *out_numpy_dtype, intptr_t ndim, co
145145 make_numpy_dtype_for_copy (&child_numpy_dtype, 0 , element_tp, arrmeta);
146146 // Create the result numpy dtype
147147 py_ref tuple_obj = capture_if_not_null (PyTuple_New (2 ));
148- PyTuple_SET_ITEM (tuple_obj.get (), 0 , child_numpy_dtype. release ());
149- PyTuple_SET_ITEM (tuple_obj.get (), 1 , shape. release ());
148+ PyTuple_SET_ITEM (tuple_obj.get (), 0 , release (std::move (child_numpy_dtype) ));
149+ PyTuple_SET_ITEM (tuple_obj.get (), 1 , release (std::move (shape) ));
150150
151151 PyArray_Descr *result = NULL ;
152152 if (!PyArray_DescrConverter (tuple_obj.get (), &result)) {
@@ -170,7 +170,7 @@ static void make_numpy_dtype_for_copy(py_ref *out_numpy_dtype, intptr_t ndim, co
170170#else
171171 py_ref name_str = capture_if_not_null (PyString_FromStringAndSize (fn.begin (), fn.end () - fn.begin ()));
172172#endif
173- PyList_SET_ITEM (names_obj.get (), i, name_str. release ());
173+ PyList_SET_ITEM (names_obj.get (), i, release (std::move (name_str) ));
174174 }
175175
176176 py_ref formats_obj = capture_if_not_null (PyList_New (field_count));
@@ -184,7 +184,7 @@ static void make_numpy_dtype_for_copy(py_ref *out_numpy_dtype, intptr_t ndim, co
184184 size_t field_size = ((PyArray_Descr *)field_numpy_dtype.get ())->elsize ;
185185 standard_offset = inc_to_alignment (standard_offset, field_alignment);
186186 standard_alignment = max (standard_alignment, field_alignment);
187- PyList_SET_ITEM (formats_obj.get (), i, field_numpy_dtype. release ());
187+ PyList_SET_ITEM (formats_obj.get (), i, release (std::move (field_numpy_dtype) ));
188188 PyList_SET_ITEM (offsets_obj.get (), i, PyLong_FromSize_t (standard_offset));
189189 standard_offset += field_size;
190190 }
@@ -333,8 +333,8 @@ static void as_numpy_analysis(py_ref *out_numpy_dtype, bool *out_requires_copy,
333333 }
334334 // Create the result numpy dtype
335335 py_ref tuple_obj = capture_if_not_null(PyTuple_New(2));
336- PyTuple_SET_ITEM(tuple_obj.get(), 0, child_numpy_dtype. release());
337- PyTuple_SET_ITEM(tuple_obj.get(), 1, shape. release());
336+ PyTuple_SET_ITEM(tuple_obj.get(), 0, release(std::move(child_numpy_dtype) ));
337+ PyTuple_SET_ITEM(tuple_obj.get(), 1, release(std::move(shape) ));
338338
339339 PyArray_Descr *result = NULL;
340340 if (!PyArray_DescrConverter(tuple_obj, &result)) {
@@ -367,7 +367,7 @@ static void as_numpy_analysis(py_ref *out_numpy_dtype, bool *out_requires_copy,
367367#else
368368 py_ref name_str = capture_if_not_null (PyString_FromStringAndSize (fn.begin (), fn.end () - fn.begin ()));
369369#endif
370- PyList_SET_ITEM (names_obj.get (), i, name_str. release ());
370+ PyList_SET_ITEM (names_obj.get (), i, release (std::move (name_str) ));
371371 }
372372
373373 py_ref formats_obj = capture_if_not_null (PyList_New (field_count));
@@ -380,7 +380,7 @@ static void as_numpy_analysis(py_ref *out_numpy_dtype, bool *out_requires_copy,
380380 *out_numpy_dtype = py_ref (Py_None, false );
381381 return ;
382382 }
383- PyList_SET_ITEM (formats_obj.get (), i, field_numpy_dtype. release ());
383+ PyList_SET_ITEM (formats_obj.get (), i, release (std::move (field_numpy_dtype) ));
384384 }
385385
386386 py_ref offsets_obj = capture_if_not_null (PyList_New (field_count));
@@ -528,7 +528,7 @@ PyObject *pydynd::array_as_numpy(PyObject *a_obj, bool allow_copy)
528528 throw dynd::type_error (ss.str ());
529529 }
530530 }
531- return result. release ();
531+ return release (std::move (result) );
532532 }
533533
534534 if (a.get_type ().get_id () == var_dim_id) {
@@ -571,18 +571,19 @@ PyObject *pydynd::array_as_numpy(PyObject *a_obj, bool allow_copy)
571571 }
572572
573573 // Create a new NumPy array, and copy from the dynd array
574- py_ref result = capture_if_not_null (PyArray_NewFromDescr (&PyArray_Type, (PyArray_Descr *)numpy_dtype.release (),
575- (int )ndim, shape.get (), strides.get (), NULL , 0 , NULL ));
574+ py_ref result = capture_if_not_null (
575+ PyArray_NewFromDescr (&PyArray_Type, reinterpret_cast <PyArray_Descr *>(release (std::move (numpy_dtype))),
576+ (int )ndim, shape.get (), strides.get (), NULL , 0 , NULL ));
576577 array_copy_to_numpy ((PyArrayObject *)result.get (), a.get_type (), a.get ()->metadata (), a.cdata ());
577578
578579 // Return the NumPy array
579- return result. release ();
580+ return release (std::move (result) );
580581 }
581582 else {
582583 // Create a view directly to the dynd array
583584 py_ref result = capture_if_not_null (PyArray_NewFromDescr (
584- &PyArray_Type, ( PyArray_Descr *)numpy_dtype. release () , (int )ndim, shape. get (), strides .get (),
585- const_cast <char *>(a.cdata ()),
585+ &PyArray_Type, reinterpret_cast < PyArray_Descr *>( release (std::move (numpy_dtype))) , (int )ndim, shape.get (),
586+ strides. get (), const_cast <char *>(a.cdata ()),
586587 ((a.get_flags () & nd::write_access_flag) ? NPY_ARRAY_WRITEABLE : 0 ) | NPY_ARRAY_ALIGNED, NULL ));
587588
588589#if NPY_API_VERSION >= 7 // At least NumPy 1.7
@@ -594,7 +595,7 @@ PyObject *pydynd::array_as_numpy(PyObject *a_obj, bool allow_copy)
594595 PyArray_BASE (result.get ()) = n_obj;
595596 Py_INCREF (n_obj);
596597#endif
597- return result. release ();
598+ return release (std::move (result) );
598599 }
599600}
600601
0 commit comments