|
Blender
V2.93
|
#include <Python.h>#include <frameobject.h>#include "MEM_guardedalloc.h"#include "CLG_log.h"#include "BLI_fileops.h"#include "BLI_listbase.h"#include "BLI_path_util.h"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "RNA_types.h"#include "bpy.h"#include "bpy_capi_utils.h"#include "bpy_intern_string.h"#include "bpy_path.h"#include "bpy_props.h"#include "bpy_rna.h"#include "bpy_traceback.h"#include "bpy_app_translations.h"#include "DNA_text_types.h"#include "BKE_appdir.h"#include "BKE_context.h"#include "BKE_global.h"#include "BKE_main.h"#include "BKE_text.h"#include "BPY_extern.h"#include "BPY_extern_python.h"#include "BPY_extern_run.h"#include "../generic/py_capi_utils.h"#include "../bmesh/bmesh_py_api.h"#include "../generic/bgl.h"#include "../generic/bl_math_py_api.h"#include "../generic/blf_py_api.h"#include "../generic/idprop_py_api.h"#include "../generic/imbuf_py_api.h"#include "../gpu/gpu_py_api.h"#include "../mathutils/mathutils.h"Go to the source code of this file.
Variables | |
| static int | py_call_level = 0 |
| static bool | py_use_system_env = false |
| static struct _inittab | bpy_internal_modules [] |
This file deals with embedding the python interpreter within blender, starting and stopping python and exposing blender/python modules so they can be accesses from scripts.
Definition in file bpy_interface.c.
| void bpy_context_clear | ( | bContext * | UNUSEDC, |
| const PyGILState_STATE * | gilstate | ||
| ) |
Definition at line 145 of file bpy_interface.c.
References BPY_context_set(), NULL, PIL_check_seconds_timer(), and py_call_level.
Referenced by BPY_modules_load_user().
| 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 T66256.
| dict_p | A pointer to #bContext.data.py_context so we can assign a new value. |
| dict_orig | The value of #bContext.data.py_context_orig to check if we need to copy. |
Definition at line 180 of file bpy_interface.c.
References BLI_assert, and PyC_IsInterpreterActive().
| bContext* BPY_context_get | ( | void | ) |
Definition at line 248 of file bpy_interface.c.
References bpy_context_module, PointerRNA::data, and BPy_StructRNA::ptr.
Referenced by bpy_atexit(), bpy_class_call(), bpy_gizmo_target_set_value(), bpy_lib_load(), bpy_msgbus_publish_rna(), bpy_msgbus_subscribe_rna(), mathutils_rna_matrix_set(), mathutils_rna_vector_set(), mathutils_rna_vector_set_index(), pyop_as_string(), pyop_call(), pyop_poll(), pyrna_enum_as_string(), pyrna_enum_to_py(), pyrna_func_call(), pyrna_prop_array_ass_subscript(), pyrna_prop_to_enum_bitfield(), pyrna_prop_update(), pyrna_py_to_prop(), pyrna_py_to_prop_array_index(), pyrna_register_class(), pyrna_string_to_enum(), pyrna_struct_driver_add(), pyrna_struct_driver_remove(), pyrna_struct_keyframe_insert(), pyrna_struct_keyframe_parse(), and pyrna_unregister_class().
| int BPY_context_member_get | ( | bContext * | C, |
| const char * | member, | ||
| bContextDataResult * | result | ||
| ) |
Definition at line 666 of file bpy_interface.c.
References BLI_addtail(), BPY_LOG_CONTEXT, BPy_StructRNA_Check, C, CLOG_INFO, CTX_data_list_add(), CTX_data_pointer_set(), CTX_DATA_TYPE_COLLECTION, CTX_DATA_TYPE_POINTER, CTX_data_type_set(), CTX_py_dict_get(), PointerRNA::data, len, MEM_callocN, NULL, PointerRNA::owner_id, CollectionPointerLink::ptr, ptr, PyC_IsInterpreterActive(), result, and PointerRNA::type.
Referenced by ctx_data_get(), and ctx_wm_python_context_get().
| void BPY_context_set | ( | bContext * | C | ) |
Definition at line 253 of file bpy_interface.c.
References bpy_context_module, C, PointerRNA::data, and BPy_StructRNA::ptr.
Referenced by bpy_context_clear(), and BPY_context_update().
| void bpy_context_set | ( | bContext * | C, |
| PyGILState_STATE * | gilstate | ||
| ) |
Definition at line 120 of file bpy_interface.c.
References BPY_context_update(), C, PIL_check_seconds_timer(), and py_call_level.
Referenced by bpy_class_call(), BPY_modules_load_user(), bpy_msgbus_notify(), bpy_prop_enum_itemf_fn(), bpy_prop_update_fn(), BPY_run_string_as_intptr(), BPY_run_string_as_number(), BPY_run_string_as_string_and_size(), bpy_run_string_impl(), cb_region_draw(), cb_wm_cursor_draw(), and python_script_exec().
| void BPY_context_update | ( | bContext * | C | ) |
Definition at line 107 of file bpy_interface.c.
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().
| void BPY_DECREF | ( | void * | pyob_ptr | ) |
Definition at line 604 of file bpy_interface.c.
Referenced by fcurve_free_driver().
| void BPY_DECREF_RNA_INVALIDATE | ( | void * | pyob_ptr | ) |
Definition at line 611 of file bpy_interface.c.
References pyrna_invalidate().
Referenced by BKE_libblock_free_data_py(), RE_engine_free(), WM_gizmo_free(), wm_gizmogroup_free(), and WM_operator_free().
| void BPY_modules_load_user | ( | bContext * | C | ) |
Definition at line 622 of file bpy_interface.c.
References BKE_main_blendfile_path(), BLI_path_extension_check(), BLI_snprintf(), bpy_context_clear(), bpy_context_set(), BPY_context_update(), BPY_run_text(), C, CTX_data_main(), ListBase::first, Text::flags, G, G_FLAG_SCRIPT_AUTOEXEC, G_FLAG_SCRIPT_AUTOEXEC_FAIL, G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET, Text::id, ID::name, ID::next, NULL, py_call_level, Main::texts, and TXT_ISSCRIPT.
Referenced by BPY_python_reset().
| void BPY_modules_update | ( | void | ) |
Needed so the Main pointer in bpy.data doesn't become out of date.
Definition at line 236 of file bpy_interface.c.
References BPY_rna_module(), BPY_rna_types(), BPY_update_rna_module(), mod(), and NULL.
Referenced by BPY_context_update(), and pyop_call().
| void BPY_python_backtrace | ( | FILE * | fp | ) |
| void BPY_python_end | ( | void | ) |
Definition at line 519 of file bpy_interface.c.
References BPY_app_translations_end(), BPY_atexit_unregister(), bpy_intern_string_exit(), BPY_rna_props_clear_all(), PIL_check_seconds_timer(), and pyrna_free_types().
Referenced by arg_handle_python_expr_run(), arg_handle_python_file_run(), arg_handle_python_text_run(), and WM_exit_ex().
| void BPY_python_reset | ( | bContext * | C | ) |
Definition at line 572 of file bpy_interface.c.
References BPY_app_handlers_reset(), BPY_driver_reset(), BPY_modules_load_user(), C, G, G_FLAG_SCRIPT_AUTOEXEC_FAIL, and G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET.
Referenced by wm_file_read_post(), and WM_init().
| void BPY_python_start | ( | bContext * | C, |
| int | argc, | ||
| const char ** | argv | ||
| ) |
Definition at line 329 of file bpy_interface.c.
References BKE_appdir_folder_id(), BKE_appdir_program_path(), BKE_appdir_program_python_search(), BLENDER_SYSTEM_PYTHON, BPY_atexit_register(), BPy_init_modules(), bpy_intern_string_init(), bpy_internal_modules, BPY_run_string_eval(), C, FILE_MAX, mod(), NULL, py_use_system_env, pyrna_alloc_types(), and pystatus_exit_on_error().
Referenced by WM_init().
| void BPY_python_use_system_env | ( | void | ) |
Definition at line 583 of file bpy_interface.c.
References BLI_assert, and py_use_system_env.
Referenced by arg_handle_python_use_system_env_set().
| bool BPY_string_is_keyword | ( | const char * | str | ) |
Avoids duplicating keyword list.
Definition at line 871 of file bpy_interface.c.
References NULL, str, and STREQ.
Referenced by driver_variable_name_validate().
| void BPY_text_free_code | ( | Text * | text | ) |
Definition at line 214 of file bpy_interface.c.
References Text::compiled, NULL, and PyC_IsInterpreterActive().
Referenced by python_script_exec(), text_free_data(), text_reload_exec(), and txt_make_dirty().
| CLG_LOGREF_DECLARE_GLOBAL | ( | BPY_LOG_CONTEXT | , |
| "bpy.context" | |||
| ) |
| CLG_LOGREF_DECLARE_GLOBAL | ( | BPY_LOG_INTERFACE | , |
| "bpy.interface" | |||
| ) |
| CLG_LOGREF_DECLARE_GLOBAL | ( | BPY_LOG_RNA | , |
| "bpy.rna" | |||
| ) |
|
static |
Convenience function for BPY_python_start.
These should happen so rarely that having comprehensive errors isn't needed. For example if sys.argv fails to allocate memory.
Show an error just to avoid silent failure in the unlikely event something goes wrong, in this case a developer will need to track down the root cause.
Definition at line 318 of file bpy_interface.c.
References UNLIKELY.
Referenced by BPY_python_start().
| int text_check_identifier_nodigit_unicode | ( | const uint | ch | ) |
Definition at line 899 of file bpy_interface.c.
References text_check_identifier_nodigit().
Referenced by text_autocomplete_build().
| int text_check_identifier_unicode | ( | const uint | ch | ) |
Definition at line 894 of file bpy_interface.c.
References text_check_identifier().
Referenced by text_autocomplete_build().
|
static |
Definition at line 253 of file bpy_interface.c.
Referenced by BPY_python_start().
|
static |
Definition at line 91 of file bpy_interface.c.
Referenced by bpy_context_clear(), bpy_context_set(), and BPY_modules_load_user().
|
static |
Definition at line 94 of file bpy_interface.c.
Referenced by BPY_python_start(), and BPY_python_use_system_env().