Blender V5.0
BPY_extern.hh File Reference
#include <optional>
#include <string>
#include "BLI_sys_types.h"

Go to the source code of this file.

Macros

#define BPy_BEGIN_ALLOW_THREADS
#define BPy_END_ALLOW_THREADS

Typedefs

using BPy_ThreadStatePtr = void *

Functions

BPy_ThreadStatePtr BPY_thread_save ()
void BPY_thread_restore (BPy_ThreadStatePtr tstate)
void BPY_thread_backtrace_print ()
void BPY_text_free_code (Text *text)
void BPY_modules_update ()
void BPY_modules_load_user (bContext *C)
void BPY_app_handlers_reset (bool do_all)
void BPY_driver_exit ()
void BPY_driver_reset ()
float BPY_driver_exec (PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
void BPY_DECREF (void *pyob_ptr)
void BPY_DECREF_RNA_INVALIDATE (void *pyob_ptr)
bool BPY_context_member_get (bContext *C, const char *member, bContextDataResult *result)
void BPY_context_set (bContext *C)
void BPY_context_update (bContext *C)
void BPY_context_dict_clear_members_array (void **dict_p, void *dict_orig, const char *context_members[], uint context_members_len)
void BPY_id_release (ID *id)
void BPY_free_srna_pytype (StructRNA *srna)
bool BPY_string_is_keyword (const char *str)
std::optional< std::string > BPY_python_current_file_and_line (void)
void BPY_callback_screen_free (ARegionType *art)
void BPY_callback_wm_free (wmWindowManager *wm)

Macro Definition Documentation

◆ BPy_BEGIN_ALLOW_THREADS

#define BPy_BEGIN_ALLOW_THREADS
Value:
{ \
BPy_ThreadStatePtr _bpy_saved_tstate = BPY_thread_save(); \
(void)0
void * BPy_ThreadStatePtr
Definition BPY_extern.hh:40
BPy_ThreadStatePtr BPY_thread_save()

Our own wrappers to #Py_BEGIN_ALLOW_THREADS / #Py_END_ALLOW_THREADS

Definition at line 52 of file BPY_extern.hh.

Referenced by blender::deg::deg_evaluate_on_refresh(), and ED_view3d_stop_render_preview().

◆ BPy_END_ALLOW_THREADS

#define BPy_END_ALLOW_THREADS
Value:
BPY_thread_restore(_bpy_saved_tstate); \
} \
(void)0
void BPY_thread_restore(BPy_ThreadStatePtr tstate)

Definition at line 56 of file BPY_extern.hh.

Referenced by blender::deg::deg_evaluate_on_refresh(), and ED_view3d_stop_render_preview().

Typedef Documentation

◆ BPy_ThreadStatePtr

using BPy_ThreadStatePtr = void *

Definition at line 40 of file BPY_extern.hh.

Function Documentation

◆ BPY_app_handlers_reset()

void BPY_app_handlers_reset ( bool do_all)

Definition at line 314 of file bpy_app_handlers.cc.

References BKE_CB_EVT_TOT, i, PERMINENT_CB_ID, pos, py_cb_array, and Py_DECREF().

Referenced by BPY_python_reset().

◆ BPY_callback_screen_free()

void BPY_callback_screen_free ( ARegionType * art)

◆ BPY_callback_wm_free()

void BPY_callback_wm_free ( wmWindowManager * wm)

◆ BPY_context_dict_clear_members_array()

void BPY_context_dict_clear_members_array ( void ** dict_p,
void * dict_orig,
const char * context_members[],
uint context_members_len )

Use for CTX_*_set(..) functions need to set values which are later read back as expected. In this case we don't want the Python context to override the values as it causes problems see #66256.

Parameters
dict_pA pointer to #bContext.data.py_context so we can assign a new value.
dict_origThe value of #bContext.data.py_context_orig to check if we need to copy.

Definition at line 174 of file bpy_interface.cc.

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

Referenced by CTX_data_scene_set(), CTX_wm_area_set(), CTX_wm_region_set(), CTX_wm_screen_set(), and CTX_wm_window_set().

◆ BPY_context_member_get()

◆ BPY_context_set()

void BPY_context_set ( bContext * C)

Definition at line 263 of file bpy_interface.cc.

References bpy_context_module, and C.

Referenced by bpy_context_clear(), and BPY_context_update().

◆ BPY_context_update()

void BPY_context_update ( bContext * C)

Use for updating while a python script runs - in case of file load.

Definition at line 102 of file bpy_interface.cc.

References BLI_thread_is_main(), BPY_context_set(), BPY_modules_update(), and C.

Referenced by bpy_context_set(), BPY_modules_load_user(), and setup_app_data().

◆ BPY_DECREF()

void BPY_DECREF ( void * pyob_ptr)

Acquire the global-interpreter-lock (GIL) and wrap Py_DECREF. as there are some cases when this needs to be called outside the Python API code.

Definition at line 714 of file bpy_interface.cc.

References Py_DECREF().

Referenced by fcurve_free_driver(), pyop_poll_message_free_fn(), and RNA_struct_free_extension().

◆ BPY_DECREF_RNA_INVALIDATE()

void BPY_DECREF_RNA_INVALIDATE ( void * pyob_ptr)

◆ BPY_driver_exec()

◆ BPY_driver_exit()

void BPY_driver_exit ( )

Run on exit to free any cached data.

Definition at line 241 of file bpy_driver.cc.

References bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, FLT_MAX, g_pydriver_state_prev, and Py_DECREF().

Referenced by BPY_driver_reset(), and BPY_python_end().

◆ BPY_driver_reset()

void BPY_driver_reset ( )

Update function, it gets rid of python-drivers global dictionary: bpy.app.driver_namespace, forcing BPY_driver_exec to recreate it. Use this when loading a new .blend file so any variables setup by the previous blend file are cleared.

Definition at line 264 of file bpy_driver.cc.

References BPY_driver_exit().

Referenced by BPY_python_reset().

◆ BPY_free_srna_pytype()

void BPY_free_srna_pytype ( StructRNA * srna)

Free (actually dereference) the Python type object representing the given #StrucRNA type, if it is defined.

Definition at line 10084 of file bpy_rna.cc.

References bpy_class_free_ex(), RNA_struct_py_type_get(), and RNA_struct_py_type_set().

Referenced by RNA_bpy_exit(), and WM_operatortype_remove_ptr().

◆ BPY_id_release()

void BPY_id_release ( ID * id)

Definition at line 397 of file bpy_rna.cc.

Referenced by BKE_libblock_free_data_py().

◆ BPY_modules_load_user()

◆ BPY_modules_update()

void BPY_modules_update ( )

Needed so the Main pointer in bpy.data doesn't become out of date.

Definition at line 244 of file bpy_interface.cc.

References BPY_rna_module(), BPY_rna_types(), BPY_update_rna_module(), and mod.

Referenced by BPY_context_update(), and pyop_call().

◆ BPY_python_current_file_and_line()

std::optional< std::string > BPY_python_current_file_and_line ( void )
nodiscard

Get current Python stack location. Returns a string like filename.py:123 if available, #std::nullopt otherwise.

Definition at line 876 of file bpy_interface.cc.

References PyC_FileAndNum_Safe(), PyC_IsInterpreterActive(), and result.

Referenced by bpy_context_log_member_error(), and ctx_member_log_access().

◆ BPY_string_is_keyword()

bool BPY_string_is_keyword ( const char * str)
nodiscard

Avoids duplicating keyword list.

Definition at line 1135 of file bpy_interface.cc.

References i, str, and STREQ.

Referenced by driver_variable_name_validate().

◆ BPY_text_free_code()

void BPY_text_free_code ( Text * text)

◆ BPY_thread_backtrace_print()

void BPY_thread_backtrace_print ( )

Print the Python backtrace of the current thread state.

Should be safe to call from anywhere at any point, may not output anything if there is no valid python thread state available.

Definition at line 38 of file bpy_threads.cc.

References printf, and Py_DECREF().

◆ BPY_thread_restore()

void BPY_thread_restore ( BPy_ThreadStatePtr tstate)

Analogue of #PyEval_RestoreThread()

Definition at line 31 of file bpy_threads.cc.

◆ BPY_thread_save()

BPy_ThreadStatePtr BPY_thread_save ( )
nodiscard

Analogue of #PyEval_SaveThread()

Definition at line 18 of file bpy_threads.cc.

References PyThreadState_GetUnchecked.