Blender V5.3
bpy_rna_types_capi.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
16
17#include <Python.h>
18#include <descrobject.h>
19
20#include "BLI_utildefines.hh"
21
22#include "bpy_library.hh"
23#include "bpy_rna.hh"
24#include "bpy_rna_callback.hh"
25#include "bpy_rna_context.hh"
26#include "bpy_rna_data.hh"
28#include "bpy_rna_text.hh"
29#include "bpy_rna_types_capi.hh"
30#include "bpy_rna_ui.hh"
31#include "bpy_rna_wm.hh"
32
33#include "bpy_rna_operator.hh"
34
35#include "RNA_prototypes.hh"
36
37namespace blender {
38
39/* -------------------------------------------------------------------- */
42
43static PyMethodDef pyrna_blenddata_methods[] = {
44 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_user_map_method_def */
45 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_file_path_map_method_def */
46 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_file_path_foreach_method_def */
47 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_batch_remove_method_def */
48 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_id_collection_orphans_purge_method_def */
49 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_data_context_method_def */
50 {nullptr, nullptr, 0, nullptr},
51};
52
54
55/* -------------------------------------------------------------------- */
58
59static PyMethodDef pyrna_blenddatalibraries_methods[] = {
60 {nullptr, nullptr, 0, nullptr}, /* #BPY_library_load_method_def */
61 {nullptr, nullptr, 0, nullptr}, /* #BPY_library_write_method_def */
62 {nullptr, nullptr, 0, nullptr},
63};
64
66
67/* -------------------------------------------------------------------- */
70
71static PyMethodDef pyrna_uilayout_methods[] = {
72 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_uilayout_introspect_method_def */
73 {nullptr, nullptr, 0, nullptr},
74};
75
77
78/* -------------------------------------------------------------------- */
81
82static PyMethodDef pyrna_operator_methods[] = {
83 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_operator_poll_message_set */
84 {nullptr, nullptr, 0, nullptr},
85};
86
88
89/* -------------------------------------------------------------------- */
92
93static PyMethodDef pyrna_text_methods[] = {
94 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_region_as_string_method_def */
95 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_region_from_string_method_def */
96 {nullptr, nullptr, 0, nullptr},
97};
98
100
101/* -------------------------------------------------------------------- */
104
105static PyMethodDef pyrna_windowmanager_methods[] = {
106 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_windowmanager_draw_cursor_add_method_def */
107 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_windowmanager_draw_cursor_remove_method_def */
108 {nullptr, nullptr, 0, nullptr},
109};
110
111static PyGetSetDef pyrna_windowmanager_getset[] = {
112 {nullptr,
113 nullptr,
114 nullptr,
115 nullptr,
116 nullptr}, /* #BPY_rna_windowmanager_clipboard_getset_def */
117 {nullptr, nullptr, nullptr, nullptr, nullptr}, /* Sentinel */
118};
119
121
122/* -------------------------------------------------------------------- */
125
126static PyMethodDef pyrna_window_methods[] = {
127 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_window_screenshot_method_def */
128 {nullptr, nullptr, 0, nullptr},
129};
130
132
133/* -------------------------------------------------------------------- */
136
137static PyMethodDef pyrna_context_methods[] = {
138 {nullptr, nullptr, 0, nullptr}, /* #BPY_rna_context_temp_override_method_def */
139 {nullptr, nullptr, 0, nullptr},
140};
141
143
144/* -------------------------------------------------------------------- */
147
149 /* Wrap. */
150 pyrna_draw_handler_add_doc,
151 ".. classmethod:: draw_handler_add(callback, args, region_type, draw_type)\n"
152 "\n"
153 " Add a new draw handler to this space type.\n"
154 " It will be called every time the specified region in the space type will be drawn.\n"
155 " Note: All arguments are positional only for now.\n"
156 "\n"
157 " :param callback:\n"
158 " A function that will be called when the region is drawn.\n"
159 " It gets the specified arguments as input, it's return value is ignored.\n"
160 " :type callback: Callable[..., Any]\n"
161 " :param args: Arguments that will be passed to the callback.\n"
162 " :type args: tuple[Any, ...]\n"
163 " :param region_type: The region type the callback draws in; usually ``WINDOW``. "
164 "(:class:`bpy.types.Region.type`)\n"
165 " :type region_type: str\n"
166 " :param draw_type: Usually ``POST_PIXEL`` for 2D drawing and ``POST_VIEW`` for 3D drawing. "
167 "In some cases ``PRE_VIEW`` can be used. ``BACKDROP`` can be used for backdrops in the node "
168 "editor.\n"
169 " :type draw_type: str\n"
170 " :return: Handler that can be removed later on.\n"
171 " :rtype: object\n");
173 /* Wrap. */
174 pyrna_draw_handler_remove_doc,
175 ".. classmethod:: draw_handler_remove(handler, region_type)\n"
176 "\n"
177 " Remove a draw handler that was added previously.\n"
178 "\n"
179 " :param handler: The draw handler that should be removed.\n"
180 " :type handler: object\n"
181 " :param region_type: Region type the callback was added to.\n"
182 " :type region_type: str\n");
183
184static PyMethodDef pyrna_space_methods[] = {
185 {"draw_handler_add",
186 static_cast<PyCFunction>(pyrna_callback_classmethod_add),
187 METH_VARARGS | METH_CLASS,
188 pyrna_draw_handler_add_doc},
189 {"draw_handler_remove",
190 static_cast<PyCFunction>(pyrna_callback_classmethod_remove),
191 METH_VARARGS | METH_CLASS,
192 pyrna_draw_handler_remove_doc},
193 {nullptr, nullptr, 0, nullptr},
194};
195
197
198/* -------------------------------------------------------------------- */
201
202void BPY_rna_types_extend_capi(PyObject *bpy_types)
203{
204 /* BlendData */
212 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_blenddata_methods) == 7, "Unexpected number of methods")
214
215 /* BlendDataLibraries */
219 "Unexpected number of methods")
220 pyrna_struct_type_extend_capi(RNA_BlendDataLibraries, pyrna_blenddatalibraries_methods, nullptr);
221
222 /* ui::Layout */
224 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_uilayout_methods) == 2, "Unexpected number of methods")
226
227 /* Space */
229
230 /* Text Editor */
234 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_text_methods) == 3, "Unexpected number of methods")
236
237 /* wmOperator */
239 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_operator_methods) == 2, "Unexpected number of methods")
241
242 /* WindowManager */
246 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_windowmanager_methods) == 3, "Unexpected number of methods")
250
251 /* Window */
253 BLI_STATIC_ASSERT(ARRAY_SIZE(pyrna_window_methods) == 2, "Unexpected number of methods")
255
256 /* Context */
258
261}
262
264
265} // namespace blender
#define ARRAY_SET_ITEMS(...)
BMesh Iterators.
PyGetSetDef BPY_rna_windowmanager_clipboard_getset_def
PyMethodDef BPY_rna_region_from_string_method_def
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
PyMethodDef BPY_rna_window_screenshot_method_def
static PyMethodDef pyrna_operator_methods[]
PyMethodDef BPY_library_write_method_def
PyMethodDef BPY_rna_windowmanager_draw_cursor_remove_method_def
PyMethodDef BPY_rna_id_collection_orphans_purge_method_def
static PyMethodDef pyrna_windowmanager_methods[]
PyMethodDef BPY_rna_id_collection_batch_remove_method_def
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
PyMethodDef BPY_rna_operator_poll_message_set_method_def
static PyMethodDef pyrna_uilayout_methods[]
static PyMethodDef pyrna_space_methods[]
PyMethodDef BPY_rna_data_context_method_def
PyMethodDef BPY_rna_windowmanager_draw_cursor_add_method_def
static PyGetSetDef pyrna_windowmanager_getset[]
PyObject * pyrna_callback_classmethod_add(PyObject *, PyObject *args)
void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSetDef *getset)
Definition bpy_rna.cc:10943
static PyMethodDef pyrna_context_methods[]
static PyMethodDef pyrna_blenddatalibraries_methods[]
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
PyMethodDef BPY_rna_uilayout_introspect_method_def
Definition bpy_rna_ui.cc:55
PyMethodDef BPY_rna_id_collection_user_map_method_def
static PyMethodDef pyrna_blenddata_methods[]
PyObject * pyrna_callback_classmethod_remove(PyObject *, PyObject *args)
static PyMethodDef pyrna_window_methods[]
PyMethodDef BPY_rna_id_collection_file_path_map_method_def
PyMethodDef BPY_rna_context_temp_override_method_def
void bpy_rna_context_types_init(PyObject *bpy_types)
PyMethodDef BPY_rna_region_as_string_method_def
PyMethodDef BPY_library_load_method_def
void BPY_rna_types_extend_capi(PyObject *bpy_types)
PyMethodDef BPY_rna_id_collection_file_path_foreach_method_def
static PyMethodDef pyrna_text_methods[]