Blender  V3.3
Classes | Functions | Variables
bpy_rna_data.c File Reference
#include <Python.h>
#include <stddef.h>
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "bpy_rna.h"
#include "bpy_rna_data.h"

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 *kwds)
 
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 or NoneType\n" "\n" " :return: Blend file data which is freed once the context exists.\n" " :rtype: :class:`bpy.types.BlendData`\n")
 
static PyObject * bpy_rna_data_temp_data (PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 
static PyObject * bpy_rna_data_context_exit (BPy_DataContext *self, PyObject *UNUSED(args))
 
int BPY_rna_data_context_type_ready (void)
 

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.c.

Function Documentation

◆ bpy_rna_data_context_clear()

static int bpy_rna_data_context_clear ( BPy_DataContext self)
static

Definition at line 51 of file bpy_rna_data.c.

References self.

◆ bpy_rna_data_context_dealloc()

static void bpy_rna_data_context_dealloc ( BPy_DataContext self)
static

Definition at line 57 of file bpy_rna_data.c.

References self.

◆ bpy_rna_data_context_enter()

static PyObject * bpy_rna_data_context_enter ( BPy_DataContext self)
static

◆ bpy_rna_data_context_exit() [1/2]

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

◆ bpy_rna_data_context_exit() [2/2]

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

Definition at line 191 of file bpy_rna_data.c.

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 45 of file bpy_rna_data.c.

References self.

◆ BPY_rna_data_context_type_ready()

int BPY_rna_data_context_type_ready ( void  )

Definition at line 205 of file bpy_rna_data.c.

References bpy_rna_data_context_Type.

Referenced by BPy_init_modules().

◆ bpy_rna_data_temp_data() [1/2]

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

◆ bpy_rna_data_temp_data() [2/2]

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

Definition at line 155 of file bpy_rna_data.c.

References bpy_rna_data_context_Type, G_MAIN, NULL, ret, and STRNCPY.

◆ 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 or NoneType\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 *kwds)

Definition at line 198 of file bpy_rna_data.c.

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},
{NULL}
}
static PyObject * bpy_rna_data_context_exit(BPy_DataContext *self, PyObject *args)
static PyObject * bpy_rna_data_context_enter(BPy_DataContext *self)
Definition: bpy_rna_data.c:178

Definition at line 39 of file bpy_rna_data.c.

◆ bpy_rna_data_context_Type

PyTypeObject bpy_rna_data_context_Type
static

Definition at line 64 of file bpy_rna_data.c.

Referenced by BPY_rna_data_context_type_ready(), and bpy_rna_data_temp_data().