Revert changes from main commits that were merged into blender-v4.1-release
The last good commit wasf57e4c5b98. After this one more fix was committed, this one is preserved as well:67bd678887.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BKE_customdata.hh"
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_mesh.hh"
|
||||
#include "BKE_mesh_runtime.hh"
|
||||
@@ -1266,7 +1266,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
Object *ob, *ob_eval;
|
||||
Depsgraph *depsgraph;
|
||||
Scene *scene_eval;
|
||||
const Mesh *mesh_eval;
|
||||
const Mesh *me_eval;
|
||||
BMesh *bm;
|
||||
bool use_cage = false;
|
||||
bool use_fnorm = true;
|
||||
@@ -1313,19 +1313,19 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mesh_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true, false);
|
||||
me_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true, false);
|
||||
need_free = true;
|
||||
}
|
||||
else {
|
||||
if (use_cage) {
|
||||
mesh_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
}
|
||||
else {
|
||||
mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
|
||||
me_eval = BKE_object_get_evaluated_mesh(ob_eval);
|
||||
}
|
||||
}
|
||||
|
||||
if (mesh_eval == nullptr) {
|
||||
if (me_eval == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"from_object(...): Object '%s' has no usable mesh data",
|
||||
ob->id.name + 2);
|
||||
@@ -1337,10 +1337,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
BMeshFromMeshParams params{};
|
||||
params.calc_face_normal = use_fnorm;
|
||||
params.calc_vert_normal = use_vert_normal;
|
||||
BM_mesh_bm_from_me(bm, mesh_eval, ¶ms);
|
||||
BM_mesh_bm_from_me(bm, me_eval, ¶ms);
|
||||
|
||||
if (need_free) {
|
||||
BKE_id_free(nullptr, (Mesh *)mesh_eval);
|
||||
BKE_id_free(nullptr, (Mesh *)me_eval);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../mathutils/mathutils.h"
|
||||
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BKE_customdata.hh"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "bmesh_py_types.h"
|
||||
#include "bmesh_py_types_select.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "py_capi_utils.h"
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "py_capi_utils.h"
|
||||
|
||||
#include "bl_math_py_api.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Python.h>
|
||||
|
||||
#include "../BPY_extern.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
BPy_ThreadStatePtr BPY_thread_save()
|
||||
{
|
||||
|
||||
@@ -181,19 +181,6 @@ PyDoc_STRVAR(
|
||||
" :type program: :class:`gpu.types.GPUShader`\n");
|
||||
static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
|
||||
{
|
||||
|
||||
static bool deprecation_warning_issued = false;
|
||||
|
||||
/* Deprecation warning raised when calling `gpu.types.GPUBatch.program_set`. */
|
||||
if (!deprecation_warning_issued) {
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"Calls to GPUBatch.program_set are deprecated."
|
||||
"Please set the shader via the 'program' parameter when calling "
|
||||
"GPUBatch.draw/draw_instanced/draw_range.",
|
||||
1);
|
||||
deprecation_warning_issued = true;
|
||||
}
|
||||
|
||||
if (!BPyGPUShader_Check(py_shader)) {
|
||||
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
|
||||
return nullptr;
|
||||
@@ -235,25 +222,12 @@ PyDoc_STRVAR(
|
||||
" :type program: :class:`gpu.types.GPUShader`\n");
|
||||
static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
|
||||
{
|
||||
static bool deprecation_warning_issued = false;
|
||||
|
||||
BPyGPUShader *py_program = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!:GPUBatch.draw", &BPyGPUShader_Type, &py_program)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (py_program == nullptr) {
|
||||
|
||||
if (!deprecation_warning_issued) {
|
||||
/* Deprecation warning raised when calling gpu.types.GPUBatch.draw without a valid GPUShader.
|
||||
*/
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"Calling GPUBatch.draw without specifying a program is deprecated. "
|
||||
"Please provide a valid GPUShader as the 'program' parameter.",
|
||||
1);
|
||||
deprecation_warning_issued = true;
|
||||
}
|
||||
|
||||
if (!pygpu_batch_is_program_or_error(self)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -111,20 +111,6 @@ static PyObject *pygpu_max_textures_frag_get(PyObject * /*self*/)
|
||||
return PyLong_FromLong(GPU_max_textures_frag());
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
pygpu_max_images_get_doc,
|
||||
".. function:: max_images_get()\n"
|
||||
"\n"
|
||||
" Get maximum supported number of image units.\n"
|
||||
"\n"
|
||||
" :return: Number of image units.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_images_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_images());
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
pygpu_max_uniforms_vert_get_doc,
|
||||
@@ -359,7 +345,6 @@ static PyMethodDef pygpu_capabilities__tp_methods[] = {
|
||||
(PyCFunction)pygpu_max_textures_frag_get,
|
||||
METH_NOARGS,
|
||||
pygpu_max_textures_frag_get_doc},
|
||||
{"max_images_get", (PyCFunction)pygpu_max_images_get, METH_NOARGS, pygpu_max_images_get_doc},
|
||||
{"max_uniforms_vert_get",
|
||||
(PyCFunction)pygpu_max_uniforms_vert_get,
|
||||
METH_NOARGS,
|
||||
|
||||
@@ -15,13 +15,23 @@
|
||||
|
||||
#include "GPU_capabilities.h"
|
||||
#include "GPU_compute.h"
|
||||
#include "GPU_shader.h"
|
||||
#include "GPU_state.h"
|
||||
#include "GPU_texture.h"
|
||||
#include "GPU_uniform_buffer.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "../mathutils/mathutils.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
#include "gpu_py_compute.h" /* own include */
|
||||
#include "gpu_py_shader.h"
|
||||
#include "gpu_py_texture.h"
|
||||
#include "gpu_py_uniformbuffer.h"
|
||||
#include "gpu_py_vertex_format.h"
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
#include "gpu_py_element.h" /* own include */
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_lib_id.hh" /* For #BKE_id_is_in_global_main. */
|
||||
#include "BKE_scene.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "GPU_context.h"
|
||||
@@ -35,6 +37,7 @@
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
#include "gpu_py_texture.h"
|
||||
|
||||
#include "gpu_py_offscreen.h" /* own include */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "GPU_shader.h"
|
||||
#include "GPU_texture.h"
|
||||
#include "GPU_uniform_buffer.hh"
|
||||
#include "GPU_uniform_buffer.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
#include "gpu_py_types.h" /* own include */
|
||||
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "GPU_context.h"
|
||||
#include "GPU_uniform_buffer.hh"
|
||||
#include "GPU_uniform_buffer.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
|
||||
#include "gpu_py_uniformbuffer.h" /* own include */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "gpu_py_vertex_format.h" /* own include */
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ set(SRC
|
||||
bpy_app_translations.cc
|
||||
bpy_app_usd.cc
|
||||
bpy_capi_utils.cc
|
||||
bpy_cli_command.cc
|
||||
bpy_driver.cc
|
||||
bpy_gizmo_wrap.cc
|
||||
bpy_interface.cc
|
||||
@@ -88,7 +87,6 @@ set(SRC
|
||||
bpy_app_translations.h
|
||||
bpy_app_usd.h
|
||||
bpy_capi_utils.h
|
||||
bpy_cli_command.h
|
||||
bpy_driver.h
|
||||
bpy_gizmo_wrap.h
|
||||
bpy_intern_string.h
|
||||
@@ -182,6 +180,10 @@ if(WITH_BULLET)
|
||||
add_definitions(-DWITH_BULLET)
|
||||
endif()
|
||||
|
||||
if(WITH_CODEC_AVI)
|
||||
add_definitions(-DWITH_AVI)
|
||||
endif()
|
||||
|
||||
if(WITH_CODEC_FFMPEG)
|
||||
list(APPEND INC_SYS
|
||||
${FFMPEG_INCLUDE_DIRS}
|
||||
|
||||
@@ -21,12 +21,13 @@
|
||||
|
||||
#include "BKE_appdir.hh"
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_bpath.hh"
|
||||
#include "BKE_global.hh" /* XXX, G_MAIN only */
|
||||
#include "BKE_bpath.h"
|
||||
#include "BKE_global.h" /* XXX, G_MAIN only */
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "GPU_state.h"
|
||||
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
#include "bpy.h"
|
||||
#include "bpy_app.h"
|
||||
#include "bpy_cli_command.h"
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_driver.h"
|
||||
#include "bpy_library.h"
|
||||
#include "bpy_operator.h"
|
||||
@@ -42,6 +43,7 @@
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_rna_data.h"
|
||||
#include "bpy_rna_gizmo.h"
|
||||
#include "bpy_rna_id_collection.h"
|
||||
#include "bpy_rna_types_capi.h"
|
||||
#include "bpy_utils_previews.h"
|
||||
#include "bpy_utils_units.h"
|
||||
@@ -76,11 +78,11 @@ static PyObject *bpy_script_paths(PyObject * /*self*/)
|
||||
PyObject *item;
|
||||
|
||||
std::optional<std::string> path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr);
|
||||
item = PyC_UnicodeFromStdStr(path.value_or(""));
|
||||
item = PyC_UnicodeFromStdStr(path.has_value() ? path.value() : "");
|
||||
BLI_assert(item != nullptr);
|
||||
PyTuple_SET_ITEM(ret, 0, item);
|
||||
path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, nullptr);
|
||||
item = PyC_UnicodeFromStdStr(path.value_or(""));
|
||||
item = PyC_UnicodeFromStdStr(path.has_value() ? path.value() : "");
|
||||
BLI_assert(item != nullptr);
|
||||
PyTuple_SET_ITEM(ret, 1, item);
|
||||
|
||||
@@ -256,7 +258,7 @@ static PyObject *bpy_user_resource(PyObject * /*self*/, PyObject *args, PyObject
|
||||
subdir_data.value);
|
||||
Py_XDECREF(subdir_data.value_coerce);
|
||||
|
||||
return PyC_UnicodeFromStdStr(path.value_or(""));
|
||||
return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : "");
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -306,7 +308,7 @@ static PyObject *bpy_system_resource(PyObject * /*self*/, PyObject *args, PyObje
|
||||
std::optional<std::string> path = BKE_appdir_folder_id(type.value_found, subdir_data.value);
|
||||
Py_XDECREF(subdir_data.value_coerce);
|
||||
|
||||
return PyC_UnicodeFromStdStr(path.value_or(""));
|
||||
return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : "");
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -356,7 +358,7 @@ static PyObject *bpy_resource_path(PyObject * /*self*/, PyObject *args, PyObject
|
||||
const std::optional<std::string> path = BKE_appdir_resource_path_id_with_version(
|
||||
type.value_found, false, (major * 100) + minor);
|
||||
|
||||
return PyC_UnicodeFromStdStr(path.value_or(""));
|
||||
return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : "");
|
||||
}
|
||||
|
||||
/* This is only exposed for tests, see: `tests/python/bl_pyapi_bpy_driver_secure_eval.py`. */
|
||||
@@ -718,28 +720,27 @@ void BPy_init_modules(bContext *C)
|
||||
/* Register methods and property get/set for RNA types. */
|
||||
BPY_rna_types_extend_capi();
|
||||
|
||||
#define PYMODULE_ADD_METHOD(mod, meth) \
|
||||
PyModule_AddObject(mod, (meth)->ml_name, (PyObject *)PyCFunction_New(meth, nullptr))
|
||||
|
||||
for (int i = 0; bpy_methods[i].ml_name; i++) {
|
||||
PyMethodDef *m = &bpy_methods[i];
|
||||
/* Currently there is no need to support these. */
|
||||
BLI_assert((m->ml_flags & (METH_CLASS | METH_STATIC)) == 0);
|
||||
PYMODULE_ADD_METHOD(mod, m);
|
||||
PyModule_AddObject(mod, m->ml_name, (PyObject *)PyCFunction_New(m, nullptr));
|
||||
}
|
||||
|
||||
/* Register functions (`bpy_rna.cc`). */
|
||||
PYMODULE_ADD_METHOD(mod, &meth_bpy_register_class);
|
||||
PYMODULE_ADD_METHOD(mod, &meth_bpy_unregister_class);
|
||||
PyModule_AddObject(mod,
|
||||
meth_bpy_register_class.ml_name,
|
||||
(PyObject *)PyCFunction_New(&meth_bpy_register_class, nullptr));
|
||||
PyModule_AddObject(mod,
|
||||
meth_bpy_unregister_class.ml_name,
|
||||
(PyObject *)PyCFunction_New(&meth_bpy_unregister_class, nullptr));
|
||||
|
||||
PYMODULE_ADD_METHOD(mod, &meth_bpy_owner_id_get);
|
||||
PYMODULE_ADD_METHOD(mod, &meth_bpy_owner_id_set);
|
||||
|
||||
/* Register command functions. */
|
||||
PYMODULE_ADD_METHOD(mod, &BPY_cli_command_register_def);
|
||||
PYMODULE_ADD_METHOD(mod, &BPY_cli_command_unregister_def);
|
||||
|
||||
#undef PYMODULE_ADD_METHOD
|
||||
PyModule_AddObject(mod,
|
||||
meth_bpy_owner_id_get.ml_name,
|
||||
(PyObject *)PyCFunction_New(&meth_bpy_owner_id_get, nullptr));
|
||||
PyModule_AddObject(mod,
|
||||
meth_bpy_owner_id_set.ml_name,
|
||||
(PyObject *)PyCFunction_New(&meth_bpy_owner_id_set, nullptr));
|
||||
|
||||
/* add our own modules dir, this is a python package */
|
||||
bpy_package_py = bpy_import_test("bpy");
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include "BKE_appdir.hh"
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.hh"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
@@ -89,8 +89,11 @@ static PyObject *make_builtopts_info()
|
||||
SetObjIncref(Py_False);
|
||||
#endif
|
||||
|
||||
/* AVI */
|
||||
#ifdef WITH_AVI
|
||||
SetObjIncref(Py_True);
|
||||
#else
|
||||
SetObjIncref(Py_False);
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FFMPEG
|
||||
SetObjIncref(Py_True);
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include <Python.h>
|
||||
|
||||
#include "BKE_callbacks.hh"
|
||||
#include "BKE_callbacks.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_app_handlers.h"
|
||||
#include "bpy_rna.h"
|
||||
@@ -39,7 +41,7 @@ static PyTypeObject BlenderAppCbType;
|
||||
"the file being loaded, an empty string for the startup-file."
|
||||
|
||||
/**
|
||||
* See `BKE_callbacks.hh` #eCbEvent declaration for the policy on naming.
|
||||
* See `BKE_callbacks.h` #eCbEvent declaration for the policy on naming.
|
||||
*/
|
||||
static PyStructSequence_Field app_cb_info_fields[] = {
|
||||
{"frame_change_pre",
|
||||
@@ -96,7 +98,6 @@ static PyStructSequence_Field app_cb_info_fields[] = {
|
||||
{"_extension_repos_update_post", "on changes to extension repos (after)"},
|
||||
{"_extension_repos_sync", "on creating or synchronizing the active repository"},
|
||||
{"_extension_repos_upgrade", "on upgrading the active repository"},
|
||||
{"_extension_drop_url", "on dropping a URL"},
|
||||
|
||||
/* sets the permanent tag */
|
||||
#define APP_CB_OTHER_FIELDS 1
|
||||
|
||||
@@ -6,13 +6,18 @@
|
||||
* \ingroup pythonintern
|
||||
*/
|
||||
|
||||
#include "BLI_time.h"
|
||||
#include "BLI_timer.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "bpy_app_timers.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
static double handle_returned_value(PyObject *function, PyObject *ret)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLT_lang.hh"
|
||||
#include "BLT_translation.hh"
|
||||
#include "BLT_lang.h"
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
@@ -416,7 +416,7 @@ static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC;
|
||||
|
||||
/* These fields are just empty placeholders, actual values get set in app_translations_struct().
|
||||
* This allows us to avoid many handwriting, and above all,
|
||||
* to keep all context definition stuff in BLT_translation.hh! */
|
||||
* to keep all context definition stuff in BLT_translation.h! */
|
||||
static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {
|
||||
{nullptr}};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@@ -18,7 +19,10 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup pythonintern
|
||||
*
|
||||
* Wrap `BKE_command_cli_*` to support custom CLI commands.
|
||||
*/
|
||||
#include <Python.h>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_blender_cli_command.hh"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "bpy_cli_command.h" /* Own include. */
|
||||
|
||||
static const char *bpy_cli_command_capsule_name = "bpy_cli_command";
|
||||
static const char *bpy_cli_command_capsule_name_invalid = "bpy_cli_command<invalid>";
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Utilities
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Return a list of strings, compatible with the construction of Python's `sys.argv`.
|
||||
*/
|
||||
static PyObject *py_argv_from_bytes(const int argc, const char **argv)
|
||||
{
|
||||
/* Copy functionality from Python's internal `sys.argv` initialization. */
|
||||
PyConfig config;
|
||||
PyConfig_InitPythonConfig(&config);
|
||||
PyStatus status = PyConfig_SetBytesArgv(&config, argc, (char *const *)argv);
|
||||
PyObject *py_argv = nullptr;
|
||||
if (UNLIKELY(PyStatus_Exception(status))) {
|
||||
PyErr_Format(PyExc_ValueError, "%s", status.err_msg);
|
||||
}
|
||||
else {
|
||||
BLI_assert(argc == config.argv.length);
|
||||
py_argv = PyList_New(config.argv.length);
|
||||
for (Py_ssize_t i = 0; i < config.argv.length; i++) {
|
||||
PyList_SET_ITEM(py_argv, i, PyUnicode_FromWideChar(config.argv.items[i], -1));
|
||||
}
|
||||
}
|
||||
PyConfig_Clear(&config);
|
||||
return py_argv;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Implementation
|
||||
* \{ */
|
||||
|
||||
static int bpy_cli_command_exec(struct bContext *C,
|
||||
PyObject *py_exec_fn,
|
||||
const int argc,
|
||||
const char **argv)
|
||||
{
|
||||
int exit_code = EXIT_FAILURE;
|
||||
PyGILState_STATE gilstate;
|
||||
bpy_context_set(C, &gilstate);
|
||||
|
||||
/* For the most part `sys.argv[-argc:]` is sufficient & less trouble than re-creating this
|
||||
* list. Don't do this because:
|
||||
* - Python scripts *could* have manipulated `sys.argv` (although it's bad practice).
|
||||
* - We may want to support invoking commands directly,
|
||||
* where the arguments aren't necessarily from `sys.argv`.
|
||||
*/
|
||||
bool has_error = false;
|
||||
PyObject *py_argv = py_argv_from_bytes(argc, argv);
|
||||
|
||||
if (py_argv == nullptr) {
|
||||
has_error = true;
|
||||
}
|
||||
else {
|
||||
PyObject *exec_args = PyTuple_New(1);
|
||||
PyTuple_SET_ITEM(exec_args, 0, py_argv);
|
||||
|
||||
PyObject *result = PyObject_Call(py_exec_fn, exec_args, nullptr);
|
||||
|
||||
Py_DECREF(exec_args); /* Frees `py_argv` too. */
|
||||
|
||||
/* Convert `sys.exit` into a return-value.
|
||||
* NOTE: typically `sys.exit` *doesn't* need any special handling,
|
||||
* however it's neater if we use the same code paths for exiting either way. */
|
||||
if ((result == nullptr) && PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
if (PyObject_TypeCheck(error_value, (PyTypeObject *)PyExc_SystemExit) &&
|
||||
(((PySystemExitObject *)error_value)->code != nullptr))
|
||||
{
|
||||
/* When `SystemExit(..)` is raised. */
|
||||
result = ((PySystemExitObject *)error_value)->code;
|
||||
}
|
||||
else {
|
||||
/* When `sys.exit()` is called. */
|
||||
result = error_value;
|
||||
}
|
||||
Py_INCREF(result);
|
||||
PyErr_Restore(error_type, error_value, error_traceback);
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
if (result == nullptr) {
|
||||
has_error = true;
|
||||
}
|
||||
else {
|
||||
if (!PyLong_Check(result)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Expected an int return value, not a %.200s",
|
||||
Py_TYPE(result)->tp_name);
|
||||
has_error = true;
|
||||
}
|
||||
else {
|
||||
const int exit_code_test = PyC_Long_AsI32(result);
|
||||
if ((exit_code_test == -1) && PyErr_Occurred()) {
|
||||
exit_code = EXIT_SUCCESS;
|
||||
has_error = true;
|
||||
}
|
||||
else {
|
||||
exit_code = exit_code_test;
|
||||
}
|
||||
}
|
||||
Py_DECREF(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_error) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
bpy_context_clear(C, &gilstate);
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
static void bpy_cli_command_free(PyObject *py_exec_fn)
|
||||
{
|
||||
/* An explicit unregister clears to avoid acquiring a lock. */
|
||||
if (py_exec_fn) {
|
||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||
Py_DECREF(py_exec_fn);
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Class
|
||||
* \{ */
|
||||
|
||||
class BPyCommandHandler : public CommandHandler {
|
||||
public:
|
||||
BPyCommandHandler(const std::string &id, PyObject *py_exec_fn)
|
||||
: CommandHandler(id), py_exec_fn(py_exec_fn)
|
||||
{
|
||||
}
|
||||
~BPyCommandHandler() override
|
||||
{
|
||||
bpy_cli_command_free(this->py_exec_fn);
|
||||
}
|
||||
|
||||
int exec(struct bContext *C, int argc, const char **argv) override
|
||||
{
|
||||
return bpy_cli_command_exec(C, this->py_exec_fn, argc, argv);
|
||||
}
|
||||
|
||||
PyObject *py_exec_fn = nullptr;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Public Methods
|
||||
* \{ */
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
bpy_cli_command_register_doc,
|
||||
".. method:: register_cli_command(id, execute)\n"
|
||||
"\n"
|
||||
" Register a command, accessible via the (``-c`` / ``--command``) command-line argument.\n"
|
||||
"\n"
|
||||
" :arg id: The command identifier (must pass an ``str.isidentifier`` check).\n"
|
||||
"\n"
|
||||
" If the ``id`` is already registered, a warning is printed and "
|
||||
"the command is inaccessible to prevent accidents invoking the wrong command.\n"
|
||||
" :type id: str\n"
|
||||
" :arg execute: Callback, taking a single list of strings and returns an int.\n"
|
||||
" The arguments are built from all command-line arguments following the command id.\n"
|
||||
" The return value should be 0 for success, 1 on failure "
|
||||
"(specific error codes from the ``os`` module can also be used).\n"
|
||||
" :type execute: callable\n"
|
||||
" :return: The command handle which can be passed to :func:`unregister_cli_command`.\n"
|
||||
" :rtype: capsule\n");
|
||||
static PyObject *bpy_cli_command_register(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *py_id;
|
||||
PyObject *py_exec_fn;
|
||||
|
||||
static const char *_keywords[] = {
|
||||
"id",
|
||||
"execute",
|
||||
nullptr,
|
||||
};
|
||||
static _PyArg_Parser _parser = {
|
||||
PY_ARG_PARSER_HEAD_COMPAT()
|
||||
"O!" /* `id` */
|
||||
"O" /* `execute` */
|
||||
":register_cli_command",
|
||||
_keywords,
|
||||
nullptr,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &PyUnicode_Type, &py_id, &py_exec_fn))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyUnicode_IsIdentifier(py_id)) {
|
||||
PyErr_SetString(PyExc_ValueError, "The command id is not a valid identifier");
|
||||
return nullptr;
|
||||
}
|
||||
if (!PyCallable_Check(py_exec_fn)) {
|
||||
PyErr_SetString(PyExc_ValueError, "The execute argument must be callable");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *id = PyUnicode_AsUTF8(py_id);
|
||||
|
||||
std::unique_ptr<CommandHandler> cmd_ptr = std::make_unique<BPyCommandHandler>(
|
||||
std::string(id), Py_INCREF_RET(py_exec_fn));
|
||||
void *cmd_p = cmd_ptr.get();
|
||||
|
||||
BKE_blender_cli_command_register(std::move(cmd_ptr));
|
||||
|
||||
return PyCapsule_New(cmd_p, bpy_cli_command_capsule_name, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
bpy_cli_command_unregister_doc,
|
||||
".. method:: unregister_cli_command(handle)\n"
|
||||
"\n"
|
||||
" Unregister a CLI command.\n"
|
||||
"\n"
|
||||
" :arg handle: The return value of :func:`register_cli_command`.\n"
|
||||
" :type handle: capsule\n");
|
||||
static PyObject *bpy_cli_command_unregister(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
if (!PyCapsule_CheckExact(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Expected a capsule returned from register_cli_command(...), found a: %.200s",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPyCommandHandler *cmd = static_cast<BPyCommandHandler *>(
|
||||
PyCapsule_GetPointer(value, bpy_cli_command_capsule_name));
|
||||
if (cmd == nullptr) {
|
||||
const char *capsule_name = PyCapsule_GetName(value);
|
||||
if (capsule_name == bpy_cli_command_capsule_name_invalid) {
|
||||
PyErr_SetString(PyExc_ValueError, "The command has already been removed");
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Unrecognized capsule ID \"%.200s\"",
|
||||
capsule_name ? capsule_name : "<null>");
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Don't acquire the GIL when un-registering. */
|
||||
Py_CLEAR(cmd->py_exec_fn);
|
||||
|
||||
/* Don't allow removing again. */
|
||||
PyCapsule_SetName(value, bpy_cli_command_capsule_name_invalid);
|
||||
|
||||
BKE_blender_cli_command_unregister((CommandHandler *)cmd);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
#if (defined(__GNUC__) && !defined(__clang__))
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
|
||||
PyMethodDef BPY_cli_command_register_def = {
|
||||
"register_cli_command",
|
||||
(PyCFunction)bpy_cli_command_register,
|
||||
METH_STATIC | METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_cli_command_register_doc,
|
||||
};
|
||||
PyMethodDef BPY_cli_command_unregister_def = {
|
||||
"unregister_cli_command",
|
||||
(PyCFunction)bpy_cli_command_unregister,
|
||||
METH_STATIC | METH_O,
|
||||
bpy_cli_command_unregister_doc,
|
||||
};
|
||||
|
||||
#if (defined(__GNUC__) && !defined(__clang__))
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
@@ -1,20 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup pythonintern
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyMethodDef BPY_cli_command_register_def;
|
||||
extern PyMethodDef BPY_cli_command_unregister_def;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -20,11 +20,12 @@
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_fcurve_driver.h"
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idtype.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_rna_driver.h" /* For #pyrna_driver_get_variable_value. */
|
||||
|
||||
@@ -493,7 +494,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna,
|
||||
* now release the GIL on python operator execution instead, using
|
||||
* #PyEval_SaveThread() / #PyEval_RestoreThread() so we don't lock up blender.
|
||||
*
|
||||
* For copy-on-evaluation we always cache expressions and write errors in the
|
||||
* For copy-on-write we always cache expressions and write errors in the
|
||||
* original driver, otherwise these would get freed while editing.
|
||||
* Due to the GIL this is thread-safe. */
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
#include "BKE_appdir.hh"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_global.hh" /* Only for script checking. */
|
||||
#include "BKE_global.h" /* Only for script checking. */
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_text.h"
|
||||
|
||||
@@ -128,10 +128,10 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
|
||||
#ifdef TIME_PY_RUN
|
||||
if (bpy_timer_count == 0) {
|
||||
/* Record time from the beginning. */
|
||||
bpy_timer = BLI_time_now_seconds();
|
||||
bpy_timer = BLI_check_seconds_timer();
|
||||
bpy_timer_run = bpy_timer_run_tot = 0.0;
|
||||
}
|
||||
bpy_timer_run = BLI_time_now_seconds();
|
||||
bpy_timer_run = BLI_check_seconds_timer();
|
||||
|
||||
bpy_timer_count++;
|
||||
#endif
|
||||
@@ -157,7 +157,7 @@ void bpy_context_clear(bContext * /*C*/, const PyGILState_STATE *gilstate)
|
||||
#endif
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
bpy_timer_run_tot += BLI_time_now_seconds() - bpy_timer_run;
|
||||
bpy_timer_run_tot += BLI_check_seconds_timer() - bpy_timer_run;
|
||||
bpy_timer_count++;
|
||||
#endif
|
||||
}
|
||||
@@ -593,7 +593,7 @@ void BPY_python_end(const bool do_python_exit)
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
/* Measure time since Python started. */
|
||||
bpy_timer = BLI_time_now_seconds() - bpy_timer;
|
||||
bpy_timer = BLI_check_seconds_timer() - bpy_timer;
|
||||
|
||||
printf("*bpy stats* - ");
|
||||
printf("tot exec: %d, ", bpy_timer_count);
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_text.h"
|
||||
|
||||
#include "DNA_text_types.h"
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "BPY_extern_run.h"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <Python.h>
|
||||
#include <cstddef>
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
@@ -26,11 +27,11 @@
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */
|
||||
|
||||
#include "BLO_readfile.hh"
|
||||
#include "BLO_readfile.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_blendfile.hh"
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "BLO_writefile.hh"
|
||||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_library.h" /* Declaration for #BPY_library_load_method_def */
|
||||
#include "bpy_library.h"
|
||||
#include "bpy_rna.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
@@ -20,11 +20,17 @@
|
||||
|
||||
#include "BKE_context.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_message.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_define.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_gizmo_wrap.h" /* own include */
|
||||
#include "bpy_intern_string.h"
|
||||
#include "bpy_rna.h"
|
||||
|
||||
#include "bpy_msgbus.h" /* own include */
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "BLI_ghash.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
/* so operators called can spawn threads which acquire the GIL */
|
||||
#define BPY_RELEASE_GIL
|
||||
@@ -226,7 +226,7 @@ static PyObject *pyop_call(PyObject * /*self*/, PyObject *args)
|
||||
|
||||
if (kw && PyDict_Size(kw)) {
|
||||
error_val = pyrna_pydict_to_props(
|
||||
&ptr, kw, false, "Converting py args to operator properties:");
|
||||
&ptr, kw, false, "Converting py args to operator properties: ");
|
||||
}
|
||||
|
||||
if (error_val == 0) {
|
||||
@@ -366,7 +366,7 @@ static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args)
|
||||
|
||||
if (kw && PyDict_Size(kw)) {
|
||||
error_val = pyrna_pydict_to_props(
|
||||
&ptr, kw, false, "Converting py args to operator properties:");
|
||||
&ptr, kw, false, "Converting py args to operator properties: ");
|
||||
}
|
||||
|
||||
std::string op_string;
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "bpy_props.h"
|
||||
#include "bpy_rna.h"
|
||||
|
||||
#include "BKE_idprop.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_define.hh" /* for defining our own rna */
|
||||
#include "RNA_enum_types.hh"
|
||||
@@ -1597,10 +1599,10 @@ static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const cha
|
||||
}
|
||||
}
|
||||
|
||||
static bool bpy_prop_string_visit_fn_call(
|
||||
PyObject *py_func,
|
||||
PyObject *item,
|
||||
blender::FunctionRef<void(StringPropertySearchVisitParams)> visit_fn)
|
||||
static bool bpy_prop_string_visit_fn_call(PyObject *py_func,
|
||||
PyObject *item,
|
||||
StringPropertySearchVisitFunc visit_fn,
|
||||
void *visit_user_data)
|
||||
{
|
||||
const char *text;
|
||||
const char *info = nullptr;
|
||||
@@ -1637,19 +1639,19 @@ static bool bpy_prop_string_visit_fn_call(
|
||||
}
|
||||
}
|
||||
|
||||
StringPropertySearchVisitParams visit_params{};
|
||||
StringPropertySearchVisitParams visit_params = {nullptr};
|
||||
visit_params.text = text;
|
||||
visit_params.info = info ? info : "";
|
||||
visit_fn(visit_params);
|
||||
visit_params.info = info;
|
||||
visit_fn(visit_user_data, &visit_params);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void bpy_prop_string_visit_for_search_fn(
|
||||
const bContext *C,
|
||||
PointerRNA *ptr,
|
||||
PropertyRNA *prop,
|
||||
const char *edit_text,
|
||||
blender::FunctionRef<void(StringPropertySearchVisitParams)> visit_fn)
|
||||
static void bpy_prop_string_visit_for_search_fn(const bContext *C,
|
||||
PointerRNA *ptr,
|
||||
PropertyRNA *prop,
|
||||
const char *edit_text,
|
||||
StringPropertySearchVisitFunc visit_fn,
|
||||
void *visit_user_data)
|
||||
{
|
||||
BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
|
||||
PyObject *py_func;
|
||||
@@ -1703,7 +1705,8 @@ static void bpy_prop_string_visit_for_search_fn(
|
||||
if (py_text == nullptr) {
|
||||
break;
|
||||
}
|
||||
const bool ok = bpy_prop_string_visit_fn_call(py_func, py_text, visit_fn);
|
||||
const bool ok = bpy_prop_string_visit_fn_call(
|
||||
py_func, py_text, visit_fn, visit_user_data);
|
||||
Py_DECREF(py_text);
|
||||
if (!ok) {
|
||||
break;
|
||||
@@ -1733,7 +1736,8 @@ static void bpy_prop_string_visit_for_search_fn(
|
||||
const Py_ssize_t ret_num = PySequence_Fast_GET_SIZE(ret_fast);
|
||||
PyObject **ret_fast_items = PySequence_Fast_ITEMS(ret_fast);
|
||||
for (Py_ssize_t i = 0; i < ret_num; i++) {
|
||||
const bool ok = bpy_prop_string_visit_fn_call(py_func, ret_fast_items[i], visit_fn);
|
||||
const bool ok = bpy_prop_string_visit_fn_call(
|
||||
py_func, ret_fast_items[i], visit_fn, visit_user_data);
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_global.hh" /* evil G.* */
|
||||
#include "BKE_global.h" /* evil G.* */
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
/* Only for types. */
|
||||
#include "BKE_node.hh"
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "DEG_depsgraph_query.hh"
|
||||
|
||||
|
||||
@@ -20,18 +20,19 @@
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "ED_keyframes_edit.hh"
|
||||
#include "ED_keyframing.hh"
|
||||
|
||||
#include "ANIM_keyframing.hh"
|
||||
|
||||
#include "BKE_anim_data.hh"
|
||||
#include "BKE_anim_data.h"
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_fcurve.hh"
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_report.hh"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
@@ -594,7 +595,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
bContext *context = BPY_context_get();
|
||||
WM_event_add_notifier(BPY_context_get(), NC_ANIMATION | ND_FCURVES_ORDER, nullptr);
|
||||
DEG_id_tag_update(id, ID_RECALC_SYNC_TO_EVAL);
|
||||
DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
|
||||
DEG_relations_tag_update(CTX_data_main(context));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
@@ -23,9 +24,12 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_lib_query.hh"
|
||||
#include "BKE_main.hh"
|
||||
@@ -24,17 +24,23 @@
|
||||
#include "DNA_ID.h"
|
||||
/* Those following are only to support hack of not listing some internal
|
||||
* 'backward' pointers in generated user_map. */
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_rna_id_collection.h"
|
||||
|
||||
#include "../generic/py_capi_rna.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
#include "../generic/python_compat.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
|
||||
@@ -377,10 +383,11 @@ static PyObject *bpy_orphans_purge(PyObject * /*self*/, PyObject *args, PyObject
|
||||
Main *bmain = G_MAIN; /* XXX Ugly, but should work! */
|
||||
#endif
|
||||
|
||||
LibQueryUnusedIDsData unused_ids_data;
|
||||
unused_ids_data.do_local_ids = true;
|
||||
unused_ids_data.do_linked_ids = true;
|
||||
unused_ids_data.do_recursive = false;
|
||||
int num_tagged[INDEX_ID_MAX] = {0};
|
||||
|
||||
bool do_local_ids = true;
|
||||
bool do_linked_ids = true;
|
||||
bool do_recursive_cleanup = false;
|
||||
|
||||
static const char *_keywords[] = {"do_local_ids", "do_linked_ids", "do_recursive", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
@@ -397,19 +404,20 @@ static PyObject *bpy_orphans_purge(PyObject * /*self*/, PyObject *args, PyObject
|
||||
kwds,
|
||||
&_parser,
|
||||
PyC_ParseBool,
|
||||
&unused_ids_data.do_local_ids,
|
||||
&do_local_ids,
|
||||
PyC_ParseBool,
|
||||
&unused_ids_data.do_linked_ids,
|
||||
&do_linked_ids,
|
||||
PyC_ParseBool,
|
||||
&unused_ids_data.do_recursive))
|
||||
&do_recursive_cleanup))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Tag all IDs to delete. */
|
||||
BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, unused_ids_data);
|
||||
BKE_lib_query_unused_ids_tag(
|
||||
bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged);
|
||||
|
||||
if (unused_ids_data.num_total[INDEX_ID_NULL] == 0) {
|
||||
if (num_tagged[INDEX_ID_NULL] == 0) {
|
||||
return PyLong_FromSize_t(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "BPY_extern.h"
|
||||
#include "bpy_capi_utils.h"
|
||||
|
||||
#include "bpy_rna_operator.h" /* Own include, #BPY_rna_operator_poll_message_set_method_def. */
|
||||
#include "bpy_rna_operator.h" /* Own include. */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Operator `poll_message_set` Method
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "DNA_text_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
@@ -20,8 +22,9 @@
|
||||
|
||||
#include "../generic/python_compat.h"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_rna_text.h" /* Declare #BPY_rna_region_as_string_method_def. */
|
||||
#include "bpy_rna_text.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Data structures.
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
#include "UI_interface.hh"
|
||||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_rna_ui.h" /* Declare #BPY_rna_uilayout_introspect_method_def. */
|
||||
#include "bpy_rna_ui.h"
|
||||
|
||||
PyDoc_STRVAR(
|
||||
/* Wrap. */
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_utils_previews.h"
|
||||
|
||||
@@ -26,10 +28,16 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "IMB_imbuf.hh"
|
||||
#include "IMB_imbuf_types.hh"
|
||||
#include "IMB_thumbs.hh"
|
||||
|
||||
#include "BKE_preview_image.hh"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
#define STR_SOURCE_TYPES "'IMAGE', 'MOVIE', 'BLEND', 'FONT'"
|
||||
|
||||
PyDoc_STRVAR(
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
# include "DNA_object_types.h"
|
||||
|
||||
# include "BKE_customdata.hh"
|
||||
# include "BKE_editmesh_bvh.h"
|
||||
# include "BKE_lib_id.hh"
|
||||
# include "BKE_mesh.hh"
|
||||
# include "BKE_mesh_runtime.hh"
|
||||
@@ -47,7 +48,7 @@
|
||||
# include "../bmesh/bmesh_py_types.h"
|
||||
#endif /* MATH_STANDALONE */
|
||||
|
||||
#include "BLI_strict_flags.h" /* Keep last. */
|
||||
#include "BLI_strict_flags.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Documentation String (snippets)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "mathutils.h"
|
||||
#include "mathutils_kdtree.h" /* own include */
|
||||
|
||||
#include "BLI_strict_flags.h" /* Keep last. */
|
||||
#include "BLI_strict_flags.h"
|
||||
|
||||
struct PyKDTree {
|
||||
PyObject_HEAD
|
||||
|
||||
Reference in New Issue
Block a user