This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/python/intern/bpy_rna_ui.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

48 lines
1.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup pythonintern
*
* This adds helpers to #uiLayout which can't be added easily to RNA itself.
*/
#include <Python.h>
#include "MEM_guardedalloc.h"
#include "../generic/py_capi_utils.h"
#include "UI_interface.h"
#include "RNA_types.h"
#include "bpy_rna.h"
#include "bpy_rna_ui.h"
PyDoc_STRVAR(bpy_rna_uilayout_introspect_doc,
".. method:: introspect()\n"
"\n"
" Return a dictionary containing a textual representation of the UI layout.\n");
static PyObject *bpy_rna_uilayout_introspect(PyObject *self)
{
BPy_StructRNA *pyrna = (BPy_StructRNA *)self;
uiLayout *layout = pyrna->ptr.data;
const char *expr = UI_layout_introspect(layout);
PyObject *main_mod = NULL;
PyC_MainModule_Backup(&main_mod);
PyObject *py_dict = PyC_DefaultNameSpace("<introspect>");
PyObject *result = PyRun_String(expr, Py_eval_input, py_dict, py_dict);
MEM_freeN((void *)expr);
Py_DECREF(py_dict);
PyC_MainModule_Restore(main_mod);
return result;
}
PyMethodDef BPY_rna_uilayout_introspect_method_def = {
"introspect",
(PyCFunction)bpy_rna_uilayout_introspect,
METH_NOARGS,
bpy_rna_uilayout_introspect_doc,
};