Blender
V4.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
9
#include "
BLI_utildefines.h
"
10
#include <Python.h>
11
12
#include "
bpy_app_oiio.hh
"
13
14
#include "
../generic/py_capi_utils.hh
"
15
16
#include "
openimageio_api.h
"
17
18
static
PyTypeObject
BlenderAppOIIOType
;
19
20
static
PyStructSequence_Field
app_oiio_info_fields
[] = {
21
{
"supported"
,
"Boolean, True when Blender is built with OpenImageIO support"
},
22
{
"version"
,
"The OpenImageIO version as a tuple of 3 numbers"
},
23
{
"version_string"
,
"The OpenImageIO version formatted as a string"
},
24
{
nullptr
},
25
};
26
27
static
PyStructSequence_Desc
app_oiio_info_desc
= {
28
/*name*/
"bpy.app.oiio"
,
29
/*doc*/
"This module contains information about OpeImageIO blender is linked against"
,
30
/*fields*/
app_oiio_info_fields
,
31
/*n_in_sequence*/
ARRAY_SIZE
(
app_oiio_info_fields
) - 1,
32
};
33
34
static
PyObject *
make_oiio_info
()
35
{
36
PyObject *oiio_info;
37
int
pos
= 0;
38
39
int
curversion;
40
41
oiio_info = PyStructSequence_New(&
BlenderAppOIIOType
);
42
if
(oiio_info ==
nullptr
) {
43
return
nullptr
;
44
}
45
46
#define SetObjItem(obj) PyStructSequence_SET_ITEM(oiio_info, pos++, obj)
47
48
curversion =
OIIO_getVersionHex
();
49
SetObjItem
(PyBool_FromLong(1));
50
SetObjItem
(
PyC_Tuple_Pack_I32
({curversion / 10000, (curversion / 100) % 100, curversion % 100}));
51
SetObjItem
(PyUnicode_FromFormat(
52
"%2d, %2d, %2d"
, curversion / 10000, (curversion / 100) % 100, curversion % 100));
53
54
if
(
UNLIKELY
(PyErr_Occurred())) {
55
Py_DECREF(oiio_info);
56
return
nullptr
;
57
}
58
59
#undef SetStrItem
60
#undef SetObjItem
61
62
return
oiio_info;
63
}
64
65
PyObject *
BPY_app_oiio_struct
()
66
{
67
PyObject *
ret
;
68
69
PyStructSequence_InitType(&
BlenderAppOIIOType
, &
app_oiio_info_desc
);
70
71
ret
=
make_oiio_info
();
72
73
/* prevent user from creating new instances */
74
BlenderAppOIIOType
.tp_init =
nullptr
;
75
BlenderAppOIIOType
.tp_new =
nullptr
;
76
/* Without this we can't do `set(sys.modules)` #29635. */
77
BlenderAppOIIOType
.tp_hash = (hashfunc)_Py_HashPointer;
78
79
return
ret
;
80
}
BLI_utildefines.h
ARRAY_SIZE
#define ARRAY_SIZE(arr)
Definition
BLI_utildefines.h:296
UNLIKELY
#define UNLIKELY(x)
Definition
BLI_utildefines.h:554
app_oiio_info_fields
static PyStructSequence_Field app_oiio_info_fields[]
Definition
bpy_app_oiio.cc:20
app_oiio_info_desc
static PyStructSequence_Desc app_oiio_info_desc
Definition
bpy_app_oiio.cc:27
BlenderAppOIIOType
static PyTypeObject BlenderAppOIIOType
Definition
bpy_app_oiio.cc:18
BPY_app_oiio_struct
PyObject * BPY_app_oiio_struct()
Definition
bpy_app_oiio.cc:65
make_oiio_info
static PyObject * make_oiio_info()
Definition
bpy_app_oiio.cc:34
SetObjItem
#define SetObjItem(obj)
bpy_app_oiio.hh
OIIO_getVersionHex
int OIIO_getVersionHex()
Definition
openimageio_api.cpp:31
openimageio_api.h
pos
pos[]
Definition
overlay_armature_info.hh:107
py_capi_utils.hh
PyC_Tuple_Pack_I32
PyObject * PyC_Tuple_Pack_I32(const blender::Span< int > values)
Definition
py_capi_utils.hh:369
ret
return ret
Definition
python_utildefines.hh:31
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0