Blender V4.3
bpy_rna_data.cc File Reference
#include <Python.h>
#include <cstddef>
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_global.hh"
#include "BKE_main.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.hh"
#include "bpy_rna_data.hh"

Go to the source code of this file.

Classes

struct  BPy_DataContext
 

Functions

static PyObject * bpy_rna_data_temp_data (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * bpy_rna_data_context_enter (BPy_DataContext *self)
 
static PyObject * bpy_rna_data_context_exit (BPy_DataContext *self, PyObject *args)
 
static int bpy_rna_data_context_traverse (BPy_DataContext *self, visitproc visit, void *arg)
 
static int bpy_rna_data_context_clear (BPy_DataContext *self)
 
static void bpy_rna_data_context_dealloc (BPy_DataContext *self)
 
 PyDoc_STRVAR (bpy_rna_data_context_load_doc, ".. method:: temp_data(filepath=None)\n" "\n" " A context manager that temporarily creates blender file data.\n" "\n" " :arg filepath: The file path for the newly temporary data. " "When None, the path of the currently open file is used.\n" " :type filepath: str | bytes | None\n" "\n" " :return: Blend file data which is freed once the context exists.\n" " :rtype: :class:`bpy.types.BlendData`\n")
 
int BPY_rna_data_context_type_ready ()
 

Variables

static PyMethodDef bpy_rna_data_context_methods []
 
static PyTypeObject bpy_rna_data_context_Type
 
PyMethodDef BPY_rna_data_context_method_def
 

Detailed Description

This file defines the API to support temporarily creating Main data. The only use case for this is currently to support temporarily loading data-blocks which can be freed, without them polluting the current G_MAIN.

This is exposed via a context manager bpy.types.BlendData.temp_data(...) which returns a new bpy.types.BlendData that is freed once the context manager exits.

Definition in file bpy_rna_data.cc.

Function Documentation

◆ bpy_rna_data_context_clear()

static int bpy_rna_data_context_clear ( BPy_DataContext * self)
static

Definition at line 65 of file bpy_rna_data.cc.

References self.

◆ bpy_rna_data_context_dealloc()

static void bpy_rna_data_context_dealloc ( BPy_DataContext * self)
static

Definition at line 71 of file bpy_rna_data.cc.

References self.

◆ bpy_rna_data_context_enter()

static PyObject * bpy_rna_data_context_enter ( BPy_DataContext * self)
static

◆ bpy_rna_data_context_exit()

static PyObject * bpy_rna_data_context_exit ( BPy_DataContext * self,
PyObject * args )
static

Definition at line 183 of file bpy_rna_data.cc.

References BKE_main_free(), RNA_POINTER_INVALIDATE, and self.

◆ bpy_rna_data_context_traverse()

static int bpy_rna_data_context_traverse ( BPy_DataContext * self,
visitproc visit,
void * arg )
static

Definition at line 59 of file bpy_rna_data.cc.

References self.

◆ BPY_rna_data_context_type_ready()

int BPY_rna_data_context_type_ready ( void )

Definition at line 206 of file bpy_rna_data.cc.

References bpy_rna_data_context_Type.

Referenced by BPy_init_modules().

◆ bpy_rna_data_temp_data()

static PyObject * bpy_rna_data_temp_data ( PyObject * self,
PyObject * args,
PyObject * kw )
static

◆ PyDoc_STRVAR()

PyDoc_STRVAR ( bpy_rna_data_context_load_doc ,
".. method:: temp_data(filepath=None)\n" "\n" " A context manager that temporarily creates blender file data.\n" "\n" " :arg filepath: The file path for the newly temporary data. " "When None,
the path of the currently open file is used.\n" " :type filepath:str|bytes|None\n" "\n" " :return:Blend file data which is freed once the context exists.\n" " :rtype::class:`bpy.types.BlendData`\n"  )

Variable Documentation

◆ BPY_rna_data_context_method_def

PyMethodDef BPY_rna_data_context_method_def
Initial value:
= {
"temp_data",
(PyCFunction)bpy_rna_data_temp_data,
METH_STATIC | METH_VARARGS | METH_KEYWORDS,
bpy_rna_data_context_load_doc,
}
static PyObject * bpy_rna_data_temp_data(PyObject *self, PyObject *args, PyObject *kw)

Definition at line 195 of file bpy_rna_data.cc.

Referenced by BPY_rna_types_extend_capi().

◆ bpy_rna_data_context_methods

PyMethodDef bpy_rna_data_context_methods[]
static
Initial value:
= {
{"__enter__", (PyCFunction)bpy_rna_data_context_enter, METH_NOARGS},
{"__exit__", (PyCFunction)bpy_rna_data_context_exit, METH_VARARGS},
{nullptr}
}
static PyObject * bpy_rna_data_context_enter(BPy_DataContext *self)
static PyObject * bpy_rna_data_context_exit(BPy_DataContext *self, PyObject *args)

Definition at line 49 of file bpy_rna_data.cc.

◆ bpy_rna_data_context_Type

PyTypeObject bpy_rna_data_context_Type
static

Definition at line 77 of file bpy_rna_data.cc.

Referenced by BPY_rna_data_context_type_ready(), and bpy_rna_data_temp_data().