Blender
V5.0
source
blender
python
intern
bpy_app_oiio.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
BLI_utildefines.h
"
10
#include <Python.h>
11
12
#include "
../generic/python_compat.hh
"
/* IWYU pragma: keep. */
13
14
#include "
bpy_app_oiio.hh
"
15
16
#include "
../generic/py_capi_utils.hh
"
17
18
#include "
openimageio_api.h
"
19
20
static
PyTypeObject
BlenderAppOIIOType
;
21
22
static
PyStructSequence_Field
app_oiio_info_fields
[] = {
23
{
"supported"
,
"Boolean, True when Blender is built with OpenImageIO support"
},
24
{
"version"
,
"The OpenImageIO version as a tuple of 3 numbers"
},
25
{
"version_string"
,
"The OpenImageIO version formatted as a string"
},
26
{
nullptr
},
27
};
28
29
static
PyStructSequence_Desc
app_oiio_info_desc
= {
30
/*name*/
"bpy.app.oiio"
,
31
/*doc*/
"This module contains information about OpeImageIO blender is linked against"
,
32
/*fields*/
app_oiio_info_fields
,
33
/*n_in_sequence*/
ARRAY_SIZE
(
app_oiio_info_fields
) - 1,
34
};
35
36
static
PyObject *
make_oiio_info
()
37
{
38
PyObject *oiio_info;
39
int
pos
= 0;
40
41
int
curversion;
42
43
oiio_info = PyStructSequence_New(&
BlenderAppOIIOType
);
44
if
(oiio_info ==
nullptr
) {
45
return
nullptr
;
46
}
47
48
#define SetObjItem(obj) PyStructSequence_SET_ITEM(oiio_info, pos++, obj)
49
50
curversion =
OIIO_getVersionHex
();
51
SetObjItem
(PyBool_FromLong(1));
52
SetObjItem
(
PyC_Tuple_Pack_I32
({curversion / 10000, (curversion / 100) % 100, curversion % 100}));
53
SetObjItem
(PyUnicode_FromFormat(
54
"%2d, %2d, %2d"
, curversion / 10000, (curversion / 100) % 100, curversion % 100));
55
56
if
(
UNLIKELY
(PyErr_Occurred())) {
57
Py_DECREF
(oiio_info);
58
return
nullptr
;
59
}
60
61
#undef SetStrItem
62
#undef SetObjItem
63
64
return
oiio_info;
65
}
66
67
PyObject *
BPY_app_oiio_struct
()
68
{
69
PyObject *
ret
;
70
71
PyStructSequence_InitType(&
BlenderAppOIIOType
, &
app_oiio_info_desc
);
72
73
ret
=
make_oiio_info
();
74
75
/* prevent user from creating new instances */
76
BlenderAppOIIOType
.tp_init =
nullptr
;
77
BlenderAppOIIOType
.tp_new =
nullptr
;
78
/* Without this we can't do `set(sys.modules)` #29635. */
79
BlenderAppOIIOType
.tp_hash = (hashfunc)
Py_HashPointer
;
80
81
return
ret
;
82
}
BLI_utildefines.h
ARRAY_SIZE
#define ARRAY_SIZE(arr)
Definition
BLI_utildefines.h:271
UNLIKELY
#define UNLIKELY(x)
Definition
BLI_utildefines.h:526
app_oiio_info_fields
static PyStructSequence_Field app_oiio_info_fields[]
Definition
bpy_app_oiio.cc:22
app_oiio_info_desc
static PyStructSequence_Desc app_oiio_info_desc
Definition
bpy_app_oiio.cc:29
BlenderAppOIIOType
static PyTypeObject BlenderAppOIIOType
Definition
bpy_app_oiio.cc:20
BPY_app_oiio_struct
PyObject * BPY_app_oiio_struct()
Definition
bpy_app_oiio.cc:67
make_oiio_info
static PyObject * make_oiio_info()
Definition
bpy_app_oiio.cc:36
SetObjItem
#define SetObjItem(obj)
bpy_app_oiio.hh
pos
uint pos
Definition
gpu_batch_presets.cc:36
OIIO_getVersionHex
int OIIO_getVersionHex()
Definition
openimageio_api.cpp:34
openimageio_api.h
py_capi_utils.hh
PyC_Tuple_Pack_I32
PyObject * PyC_Tuple_Pack_I32(const blender::Span< int > values)
Definition
py_capi_utils.hh:391
python_compat.hh
header-only compatibility defines.
Py_HashPointer
#define Py_HashPointer
Definition
python_compat.hh:49
Py_DECREF
Py_DECREF(oname)
ret
return ret
Definition
python_utildefines.hh:33
Generated on
for Blender by
doxygen
1.16.1