Blender V5.0
bpy_rna_context.cc File Reference
#include <Python.h>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "BKE_main.hh"
#include "BKE_screen.hh"
#include "BKE_workspace.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "bpy_rna_context.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.hh"

Go to the source code of this file.

Classes

struct  ContextStore
struct  BPyContextTempOverride

Functions

Private Utility Functions
static void bpy_rna_context_temp_set_screen_for_window (bContext *C, wmWindow *win, bScreen *screen)
static bool wm_check_screen_switch_supported (const bScreen *screen)
static bool wm_check_window_exists (const Main *bmain, const wmWindow *win)
static bool wm_check_screen_exists (const Main *bmain, const bScreen *screen)
static bool wm_check_area_exists (const wmWindow *win, const bScreen *screen, const ScrArea *area)
static bool wm_check_region_exists (const bScreen *screen, const ScrArea *area, const ARegion *region)
static void bpy_rna_context_logging_set (bContext *C, bool enable)
Context Temporary Override Method
static PyObject * bpy_context_temp_override_extract_known_args (const char *const *kwds_static, PyObject *kwds)
 PyDoc_STRVAR (bpy_context_temp_override_doc, ".. method:: temp_override(*, window=None, screen=None, area=None, region=None, **keywords)\n" "\n" " Context manager to temporarily override members in the context.\n" "\n" " :arg window: Window override or None.\n" " :type window: :class:`bpy.types.Window`\n" " :arg screen: Screen override or None.\n" "\n" " .. note:: Switching to or away from full-screen areas & temporary screens " "isn't supported. Passing in these screens will raise an exception, " "actions that leave the context such screens won't restore the prior screen.\n" "\n" " .. note:: Changing the screen has wider implications " "than other arguments as it will also change the works-space " "and potentially the scene (when pinned).\n" "\n" " :type screen: :class:`bpy.types.Screen`\n" " :arg area: Area override or None.\n" " :type area: :class:`bpy.types.Area`\n" " :arg region: Region override or None.\n" " :type region: :class:`bpy.types.Region`\n" " :arg keywords: Additional keywords override context members.\n" " :return: The context manager .\n" " :rtype: ContextTempOverride\n")
static PyObject * bpy_context_temp_override (PyObject *self, PyObject *args, PyObject *kwds)

Temporary Context Override (Python Context Manager)

static PyMethodDef bpy_rna_context_temp_override_methods []
static PyTypeObject BPyContextTempOverride_Type
static void bpy_rna_context_temp_override_dealloc (BPyContextTempOverride *self)
static int bpy_rna_context_temp_override_traverse (BPyContextTempOverride *self, visitproc visit, void *arg)
static int bpy_rna_context_temp_override_clear (BPyContextTempOverride *self)
static bool bpy_rna_context_temp_override_enter_ok_or_error (const BPyContextTempOverride *self, const Main *bmain, const wmWindow *win, const bScreen *screen, const ScrArea *area, const ARegion *region)
static PyObject * bpy_rna_context_temp_override_enter (BPyContextTempOverride *self)
static PyObject * bpy_rna_context_temp_override_exit (BPyContextTempOverride *self, PyObject *)
static PyObject * bpy_rna_context_temp_override_logging_set (BPyContextTempOverride *self, PyObject *args, PyObject *kwds)

Public Type Definition

PyMethodDef BPY_rna_context_temp_override_method_def
void bpy_rna_context_types_init ()

Detailed Description

This file adds some helper methods to the context, that cannot fit well in RNA itself.

Definition in file bpy_rna_context.cc.

Function Documentation

◆ bpy_context_temp_override()

◆ bpy_context_temp_override_extract_known_args()

PyObject * bpy_context_temp_override_extract_known_args ( const char *const * kwds_static,
PyObject * kwds )
static

Definition at line 634 of file bpy_rna_context.cc.

References BLI_assert, BLI_assert_unreachable, i, and Py_DECREF().

Referenced by bpy_context_temp_override().

◆ bpy_rna_context_logging_set()

void bpy_rna_context_logging_set ( bContext * C,
bool enable )
static

Helper function to configure context logging with extensible options.

Definition at line 113 of file bpy_rna_context.cc.

References C, and CTX_member_logging_set().

Referenced by bpy_rna_context_temp_override_enter(), bpy_rna_context_temp_override_exit(), and bpy_rna_context_temp_override_logging_set().

◆ bpy_rna_context_temp_override_clear()

int bpy_rna_context_temp_override_clear ( BPyContextTempOverride * self)
static

Definition at line 181 of file bpy_rna_context.cc.

References self.

◆ bpy_rna_context_temp_override_dealloc()

void bpy_rna_context_temp_override_dealloc ( BPyContextTempOverride * self)
static

Definition at line 166 of file bpy_rna_context.cc.

References self.

◆ bpy_rna_context_temp_override_enter()

◆ bpy_rna_context_temp_override_enter_ok_or_error()

bool bpy_rna_context_temp_override_enter_ok_or_error ( const BPyContextTempOverride * self,
const Main * bmain,
const wmWindow * win,
const bScreen * screen,
const ScrArea * area,
const ARegion * region )
static

◆ bpy_rna_context_temp_override_exit()

◆ bpy_rna_context_temp_override_logging_set()

PyObject * bpy_rna_context_temp_override_logging_set ( BPyContextTempOverride * self,
PyObject * args,
PyObject * kwds )
static

Definition at line 531 of file bpy_rna_context.cc.

References bpy_rna_context_logging_set(), PyC_ParseBool(), and self.

◆ bpy_rna_context_temp_override_traverse()

int bpy_rna_context_temp_override_traverse ( BPyContextTempOverride * self,
visitproc visit,
void * arg )
static

Definition at line 173 of file bpy_rna_context.cc.

References self.

◆ bpy_rna_context_temp_set_screen_for_window()

◆ bpy_rna_context_types_init()

void bpy_rna_context_types_init ( )

Definition at line 850 of file bpy_rna_context.cc.

References BLI_assert_unreachable, and BPyContextTempOverride_Type.

Referenced by BPY_rna_types_extend_capi().

◆ PyDoc_STRVAR()

PyDoc_STRVAR ( bpy_context_temp_override_doc ,
".. method:: temp_override(*, window=None, screen=None, area=None, region=None, **keywords)\n" "\n" " Context manager to temporarily override members in the context.\n" "\n" " :arg window: Window override or None.\n" " :type window: :class:`bpy.types.Window`\n" " :arg screen: Screen override or None.\n" "\n" " .. note:: Switching to or away from full-screen areas & temporary screens " "isn't supported. Passing in these screens will raise an exception,
" "actions that leave the context such screens won 't restore the prior screen.\n" "\n" " .. note::Changing the screen has wider implications " "than other arguments as it will also change the works-space " "and potentially the scene(when pinned).\n" "\n" " :type screen::class:`bpy.types.Screen`\n" " :arg area:Area override or None.\n" " :type area::class:`bpy.types.Area`\n" " :arg region:Region override or None.\n" " :type region::class:`bpy.types.Region`\n" " :arg keywords:Additional keywords override context members.\n" " :return:The context manager .\n" " :rtype:ContextTempOverride\n"  )

◆ wm_check_area_exists()

bool wm_check_area_exists ( const wmWindow * win,
const bScreen * screen,
const ScrArea * area )
static

◆ wm_check_region_exists()

bool wm_check_region_exists ( const bScreen * screen,
const ScrArea * area,
const ARegion * region )
static

◆ wm_check_screen_exists()

bool wm_check_screen_exists ( const Main * bmain,
const bScreen * screen )
static

◆ wm_check_screen_switch_supported()

bool wm_check_screen_switch_supported ( const bScreen * screen)
static

Switching to or away from this screen is not supported.

Definition at line 57 of file bpy_rna_context.cc.

References BKE_screen_is_fullscreen_area(), and bScreen::temp.

Referenced by bpy_rna_context_temp_override_enter_ok_or_error(), and bpy_rna_context_temp_override_exit().

◆ wm_check_window_exists()

bool wm_check_window_exists ( const Main * bmain,
const wmWindow * win )
static

Variable Documentation

◆ BPY_rna_context_temp_override_method_def

PyMethodDef BPY_rna_context_temp_override_method_def
Initial value:
= {
"temp_override",
METH_VARARGS | METH_KEYWORDS,
bpy_context_temp_override_doc,
}
static PyObject * bpy_context_temp_override(PyObject *self, PyObject *args, PyObject *kwds)

Definition at line 835 of file bpy_rna_context.cc.

Referenced by BPY_rna_types_extend_capi().

◆ bpy_rna_context_temp_override_methods

PyMethodDef bpy_rna_context_temp_override_methods[]
static
Initial value:
= {
{"__enter__", (PyCFunction)bpy_rna_context_temp_override_enter, METH_NOARGS},
{"__exit__", (PyCFunction)bpy_rna_context_temp_override_exit, METH_VARARGS},
{"logging_set",
METH_VARARGS | METH_KEYWORDS},
{nullptr},
}
static PyObject * bpy_rna_context_temp_override_enter(BPyContextTempOverride *self)
static PyObject * bpy_rna_context_temp_override_logging_set(BPyContextTempOverride *self, PyObject *args, PyObject *kwds)
static PyObject * bpy_rna_context_temp_override_exit(BPyContextTempOverride *self, PyObject *)

Definition at line 559 of file bpy_rna_context.cc.

◆ BPyContextTempOverride_Type

PyTypeObject BPyContextTempOverride_Type
static

Definition at line 576 of file bpy_rna_context.cc.

Referenced by bpy_context_temp_override(), and bpy_rna_context_types_init().