Blender  V2.93
python_utildefines.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
23 #pragma once
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define PyTuple_SET_ITEMS(op_arg, ...) \
30  { \
31  PyTupleObject *op = (PyTupleObject *)op_arg; \
32  PyObject **ob_items = op->ob_item; \
33  CHECK_TYPE_ANY(op_arg, PyObject *, PyTupleObject *); \
34  BLI_assert(VA_NARGS_COUNT(__VA_ARGS__) == PyTuple_GET_SIZE(op)); \
35  ARRAY_SET_ITEMS(ob_items, __VA_ARGS__); \
36  } \
37  (void)0
38 
39 /* wrap Py_INCREF & return the result,
40  * use sparingly to avoid comma operator or temp var assignment */
41 Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *op)
42 {
43  Py_INCREF(op);
44  return op;
45 }
46 
47 /* Append & transfer ownership to the list,
48  * avoids inline Py_DECREF all over (which is quite a large macro). */
49 Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
50 {
51  int ret = PyList_Append(op, v);
53  return ret;
54 }
55 
56 #ifdef __cplusplus
57 }
58 #endif
return ret
PyObject * v
Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *op)
Py_DecRef(v)