@@ -145,8 +145,8 @@ static void make_numpy_dtype_for_copy(py_ref *out_numpy_dtype, intptr_t ndim, co
145
145
make_numpy_dtype_for_copy (&child_numpy_dtype, 0 , element_tp, arrmeta);
146
146
// Create the result numpy dtype
147
147
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) ));
150
150
151
151
PyArray_Descr *result = NULL ;
152
152
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
170
170
#else
171
171
py_ref name_str = capture_if_not_null (PyString_FromStringAndSize (fn.begin (), fn.end () - fn.begin ()));
172
172
#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) ));
174
174
}
175
175
176
176
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
184
184
size_t field_size = ((PyArray_Descr *)field_numpy_dtype.get ())->elsize ;
185
185
standard_offset = inc_to_alignment (standard_offset, field_alignment);
186
186
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) ));
188
188
PyList_SET_ITEM (offsets_obj.get (), i, PyLong_FromSize_t (standard_offset));
189
189
standard_offset += field_size;
190
190
}
@@ -333,8 +333,8 @@ static void as_numpy_analysis(py_ref *out_numpy_dtype, bool *out_requires_copy,
333
333
}
334
334
// Create the result numpy dtype
335
335
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) ));
338
338
339
339
PyArray_Descr *result = NULL;
340
340
if (!PyArray_DescrConverter(tuple_obj, &result)) {
@@ -367,7 +367,7 @@ static void as_numpy_analysis(py_ref *out_numpy_dtype, bool *out_requires_copy,
367
367
#else
368
368
py_ref name_str = capture_if_not_null (PyString_FromStringAndSize (fn.begin (), fn.end () - fn.begin ()));
369
369
#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) ));
371
371
}
372
372
373
373
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,
380
380
*out_numpy_dtype = py_ref (Py_None, false );
381
381
return ;
382
382
}
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) ));
384
384
}
385
385
386
386
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)
528
528
throw dynd::type_error (ss.str ());
529
529
}
530
530
}
531
- return result. release ();
531
+ return release (std::move (result) );
532
532
}
533
533
534
534
if (a.get_type ().get_id () == var_dim_id) {
@@ -571,18 +571,19 @@ PyObject *pydynd::array_as_numpy(PyObject *a_obj, bool allow_copy)
571
571
}
572
572
573
573
// 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 ));
576
577
array_copy_to_numpy ((PyArrayObject *)result.get (), a.get_type (), a.get ()->metadata (), a.cdata ());
577
578
578
579
// Return the NumPy array
579
- return result. release ();
580
+ return release (std::move (result) );
580
581
}
581
582
else {
582
583
// Create a view directly to the dynd array
583
584
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 ()),
586
587
((a.get_flags () & nd::write_access_flag) ? NPY_ARRAY_WRITEABLE : 0 ) | NPY_ARRAY_ALIGNED, NULL ));
587
588
588
589
#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)
594
595
PyArray_BASE (result.get ()) = n_obj;
595
596
Py_INCREF (n_obj);
596
597
#endif
597
- return result. release ();
598
+ return release (std::move (result) );
598
599
}
599
600
}
600
601
0 commit comments