Blender
V5.3
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.hh
"
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
namespace
blender
{
21
22
static
PyTypeObject
BlenderAppOIIOType
;
23
24
static
PyStructSequence_Field
app_oiio_info_fields
[] = {
25
{
"supported"
,
"Boolean, True when Blender is built with OpenImageIO support"
},
26
{
"version"
,
"The OpenImageIO version as a tuple of 3 numbers"
},
27
{
"version_string"
,
"The OpenImageIO version formatted as a string"
},
28
{
nullptr
},
29
};
30
31
static
PyStructSequence_Desc
app_oiio_info_desc
= {
32
/*name*/
"bpy.app.oiio"
,
33
/*doc*/
"This module contains information about OpeImageIO blender is linked against"
,
34
/*fields*/
app_oiio_info_fields
,
35
/*n_in_sequence*/
ARRAY_SIZE
(
app_oiio_info_fields
) - 1,
36
};
37
38
static
PyObject *
make_oiio_info
()
39
{
40
PyObject *oiio_info;
41
int
pos = 0;
42
43
int
curversion;
44
45
oiio_info = PyStructSequence_New(&
BlenderAppOIIOType
);
46
if
(oiio_info ==
nullptr
) {
47
return
nullptr
;
48
}
49
50
#define SetObjItem(obj) PyStructSequence_SET_ITEM(oiio_info, pos++, obj)
51
52
curversion =
OIIO_getVersionHex
();
53
SetObjItem
(PyBool_FromLong(1));
54
SetObjItem
(
PyC_Tuple_Pack_I32
({curversion / 10000, (curversion / 100) % 100, curversion % 100}));
55
SetObjItem
(PyUnicode_FromFormat(
56
"%2d, %2d, %2d"
, curversion / 10000, (curversion / 100) % 100, curversion % 100));
57
58
if
(PyErr_Occurred()) [[unlikely]] {
59
Py_DECREF(oiio_info);
60
return
nullptr
;
61
}
62
63
#undef SetStrItem
64
#undef SetObjItem
65
66
return
oiio_info;
67
}
68
69
PyObject *
BPY_app_oiio_struct
()
70
{
71
PyObject *
ret
;
72
73
PyStructSequence_InitType(&
BlenderAppOIIOType
, &
app_oiio_info_desc
);
74
75
ret
=
make_oiio_info
();
76
77
/* prevent user from creating new instances */
78
BlenderAppOIIOType
.tp_init =
nullptr
;
79
BlenderAppOIIOType
.tp_new =
nullptr
;
80
/* Without this we can't do `set(sys.modules)` #29635. */
81
BlenderAppOIIOType
.tp_hash =
reinterpret_cast<
hashfunc
>
(
Py_HashPointer
);
82
83
return
ret
;
84
}
85
86
}
// namespace blender
BLI_utildefines.hh
SetObjItem
#define SetObjItem(obj)
bpy_app_oiio.hh
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::BPY_app_oiio_struct
PyObject * BPY_app_oiio_struct()
Definition
bpy_app_oiio.cc:69
blender::make_oiio_info
static PyObject * make_oiio_info()
Definition
bpy_app_oiio.cc:38
blender::ret
return ret
Definition
python_utildefines.hh:35
blender::PyC_Tuple_Pack_I32
PyObject * PyC_Tuple_Pack_I32(const Span< int > values)
Definition
py_capi_utils.hh:509
blender::app_oiio_info_desc
static PyStructSequence_Desc app_oiio_info_desc
Definition
bpy_app_oiio.cc:31
blender::ARRAY_SIZE
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
Definition
BLI_utildefines.hh:608
blender::app_oiio_info_fields
static PyStructSequence_Field app_oiio_info_fields[]
Definition
bpy_app_oiio.cc:24
blender::BlenderAppOIIOType
static PyTypeObject BlenderAppOIIOType
Definition
bpy_app_oiio.cc:22
blender::OIIO_getVersionHex
int OIIO_getVersionHex()
Definition
openimageio_api.cpp:36
openimageio_api.h
py_capi_utils.hh
python_compat.hh
header-only compatibility defines.
Py_HashPointer
#define Py_HashPointer
Definition
python_compat.hh:22
Generated on
for Blender by
doxygen
1.18.0