Blender  V2.93
bpy_rna_ui.c
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 #include <Python.h>
24 
25 #include "MEM_guardedalloc.h"
26 
27 #include "../generic/py_capi_utils.h"
28 
29 #include "UI_interface.h"
30 
31 #include "RNA_types.h"
32 
33 #include "bpy_rna.h"
34 #include "bpy_rna_ui.h"
35 
36 PyDoc_STRVAR(bpy_rna_uilayout_introspect_doc,
37  ".. method:: introspect()\n"
38  "\n"
39  " Return a dictionary containing a textual representation of the UI layout.\n");
40 static PyObject *bpy_rna_uilayout_introspect(PyObject *self)
41 {
42  BPy_StructRNA *pyrna = (BPy_StructRNA *)self;
43  uiLayout *layout = pyrna->ptr.data;
44 
45  const char *expr = UI_layout_introspect(layout);
46  PyObject *main_mod = NULL;
47  PyC_MainModule_Backup(&main_mod);
48  PyObject *py_dict = PyC_DefaultNameSpace("<introspect>");
49  PyObject *result = PyRun_String(expr, Py_eval_input, py_dict, py_dict);
50  MEM_freeN((void *)expr);
51  Py_DECREF(py_dict);
52  PyC_MainModule_Restore(main_mod);
53  return result;
54 }
55 
57  "introspect",
58  (PyCFunction)bpy_rna_uilayout_introspect,
59  METH_NOARGS,
60  bpy_rna_uilayout_introspect_doc,
61 };
Read Guarded memory(de)allocation.
const char * UI_layout_introspect(uiLayout *layout)
static PyObject * bpy_rna_uilayout_introspect(PyObject *self)
Definition: bpy_rna_ui.c:40
PyDoc_STRVAR(bpy_rna_uilayout_introspect_doc, ".. method:: introspect()\n" "\n" " Return a dictionary containing a textual representation of the UI layout.\n")
PyMethodDef BPY_rna_uilayout_introspect_method_def
Definition: bpy_rna_ui.c:56
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
PyObject * PyC_DefaultNameSpace(const char *filename)
void PyC_MainModule_Backup(PyObject **r_main_mod)
void PyC_MainModule_Restore(PyObject *main_mod)
PyObject_HEAD PointerRNA ptr
Definition: bpy_rna.h:125
void * data
Definition: RNA_types.h:52