Refactor: Move BPY intern bpy_rna headers to proper C++ ones.

This commit is contained in:
Bastien Montagne
2024-09-24 11:30:38 +02:00
committed by Bastien Montagne
parent 120d2b867b
commit 91e4bcd204
46 changed files with 112 additions and 207 deletions

View File

@@ -566,7 +566,7 @@ if(WITH_PYTHON_MODULE)
endif()
if(WITH_PYTHON_SAFETY)
# For bpy_rna.h access.
# For bpy_rna.hh access.
add_definitions(-DWITH_PYTHON_SAFETY)
endif()

View File

@@ -38,7 +38,7 @@
#include "FRS_freestyle.h"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.h" /* pyrna_struct_CreatePyObject() */
#include "bpy_rna.hh" /* pyrna_struct_CreatePyObject() */
#include "../generic/py_capi_utils.h" /* #PyC_UnicodeFromBytes */

View File

@@ -30,7 +30,7 @@
#include "DEG_depsgraph_query.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "hydra_scene_delegate.hh"
#include "image.hh"

View File

@@ -21,7 +21,7 @@
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "RNA_types.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include <list>
#include <memory>

View File

@@ -14,6 +14,7 @@
#include "DNA_listBase.h"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_types.hh"
struct BlenderRNA;

View File

@@ -29,9 +29,9 @@
#include "python_utildefines.h"
extern "C" bool pyrna_id_FromPyObject(PyObject *obj, ID **id);
extern "C" PyObject *pyrna_id_CreatePyObject(ID *id);
extern "C" bool pyrna_id_CheckPyObject(PyObject *obj);
extern bool pyrna_id_FromPyObject(PyObject *obj, ID **id);
extern PyObject *pyrna_id_CreatePyObject(ID *id);
extern bool pyrna_id_CheckPyObject(PyObject *obj);
/* Currently there is no need to expose this publicly. */
static PyObject *BPy_IDGroup_IterKeys_CreatePyObject(BPy_IDProperty *group, const bool reversed);

View File

@@ -98,18 +98,18 @@ set(SRC
bpy_operator_wrap.h
bpy_path.h
bpy_props.h
bpy_rna.h
bpy_rna_anim.h
bpy_rna_callback.h
bpy_rna_context.h
bpy_rna_data.h
bpy_rna_driver.h
bpy_rna_gizmo.h
bpy_rna_id_collection.h
bpy_rna_operator.h
bpy_rna_text.h
bpy_rna_types_capi.h
bpy_rna_ui.h
bpy_rna.hh
bpy_rna_anim.hh
bpy_rna_callback.hh
bpy_rna_context.hh
bpy_rna_data.hh
bpy_rna_driver.hh
bpy_rna_gizmo.hh
bpy_rna_id_collection.hh
bpy_rna_operator.hh
bpy_rna_text.hh
bpy_rna_types_capi.hh
bpy_rna_ui.hh
bpy_traceback.h
bpy_utils_previews.h
bpy_utils_units.h

View File

@@ -39,10 +39,10 @@
#include "bpy_library.h"
#include "bpy_operator.h"
#include "bpy_props.h"
#include "bpy_rna.h"
#include "bpy_rna_data.h"
#include "bpy_rna_gizmo.h"
#include "bpy_rna_types_capi.h"
#include "bpy_rna.hh"
#include "bpy_rna_data.hh"
#include "bpy_rna_gizmo.hh"
#include "bpy_rna_types_capi.hh"
#include "bpy_utils_previews.h"
#include "bpy_utils_units.h"

View File

@@ -18,7 +18,7 @@
#include "RNA_access.hh"
#include "bpy_app_handlers.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "../generic/python_utildefines.h"

View File

@@ -26,12 +26,12 @@
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna_driver.h" /* For #pyrna_driver_get_variable_value. */
#include "bpy_rna_driver.hh" /* For #pyrna_driver_get_variable_value. */
#include "bpy_intern_string.h"
#include "bpy_driver.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "BPY_extern.h"

View File

@@ -26,7 +26,7 @@
#include "bpy_gizmo_wrap.h" /* own include */
#include "bpy_intern_string.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "../generic/py_capi_rna.h"
#include "../generic/python_compat.h"

View File

@@ -38,7 +38,7 @@
#include "bpy_intern_string.h"
#include "bpy_path.h"
#include "bpy_props.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "bpy_traceback.h"
#include "bpy_app_translations.h"

View File

@@ -46,7 +46,7 @@
#ifdef USE_RNA_DATABLOCKS
# include "RNA_access.hh"
# include "bpy_rna.h"
# include "bpy_rna.hh"
#endif
struct BPy_Library {

View File

@@ -30,7 +30,7 @@
#include "bpy_capi_utils.h"
#include "bpy_library.h" /* Declaration for #BPY_library_load_method_def */
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"

View File

@@ -25,7 +25,7 @@
#include "RNA_access.hh"
#include "bpy_capi_utils.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "bpy_msgbus.h" /* own include */

View File

@@ -29,7 +29,7 @@
#include "bpy_capi_utils.h"
#include "bpy_operator.h"
#include "bpy_operator_wrap.h"
#include "bpy_rna.h" /* for setting argument properties & type method `get_rna_type`. */
#include "bpy_rna.hh" /* for setting argument properties & type method `get_rna_type`. */
#include "RNA_access.hh"
#include "RNA_enum_types.hh"

View File

@@ -24,7 +24,7 @@
#include "bpy_intern_string.h"
#include "bpy_operator_wrap.h" /* own include */
#include "bpy_rna.h"
#include "bpy_rna.hh"
static void operator_properties_init(wmOperatorType *ot)
{

View File

@@ -25,7 +25,7 @@
#include "bpy_capi_utils.h"
#include "bpy_props.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "RNA_access.hh"
#include "RNA_define.hh" /* for defining our own rna */

View File

@@ -33,9 +33,9 @@
#include "bpy_capi_utils.h"
#include "bpy_intern_string.h"
#include "bpy_props.h"
#include "bpy_rna.h"
#include "bpy_rna_anim.h"
#include "bpy_rna_callback.h"
#include "bpy_rna.hh"
#include "bpy_rna_anim.hh"
#include "bpy_rna_callback.hh"
#ifdef USE_PYRNA_INVALIDATE_WEAKREF
# include "BLI_ghash.h"

View File

@@ -9,6 +9,7 @@
#pragma once
/* --- bpy build options --- */
#include "intern/rna_internal_types.hh"
#ifdef WITH_PYTHON_SAFETY
/**
@@ -54,10 +55,6 @@
struct ID;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sub-classes of #pyrna_struct_Type which support idprop definitions use this as a meta-class.
* \note tp_base member is set to `&PyType_Type` on initialization.
@@ -111,15 +108,15 @@ extern PyTypeObject pyrna_func_Type;
/* 'in_weakreflist' MUST be aligned */
typedef struct {
struct BPy_DummyPointerRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
#endif
PointerRNA ptr;
} BPy_DummyPointerRNA;
};
typedef struct BPy_StructRNA {
struct BPy_StructRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
@@ -135,18 +132,18 @@ typedef struct BPy_StructRNA {
/** Needed in some cases if ptr.data is created on the fly, free when deallocating. */
bool freeptr;
#endif /* PYRNA_FREE_SUPPORT */
} BPy_StructRNA;
};
typedef struct {
struct BPy_PropertyRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
#endif
PointerRNA ptr;
PropertyRNA *prop;
} BPy_PropertyRNA;
};
typedef struct {
struct BPy_PropertyArrayRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
@@ -159,9 +156,9 @@ typedef struct {
int arraydim;
/** Array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n. */
int arrayoffset;
} BPy_PropertyArrayRNA;
};
typedef struct {
struct BPy_PropertyCollectionIterRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
@@ -169,16 +166,16 @@ typedef struct {
/* collection iterator specific parts */
CollectionPropertyIterator iter;
} BPy_PropertyCollectionIterRNA;
};
typedef struct {
struct BPy_FunctionRNA {
PyObject_HEAD /* Required Python macro. */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
#endif
PointerRNA ptr;
FunctionRNA *func;
} BPy_FunctionRNA;
};
StructRNA *srna_from_self(PyObject *self, const char *error_prefix);
StructRNA *pyrna_struct_as_srna(PyObject *self, bool parent, const char *error_prefix);
@@ -196,15 +193,15 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr);
PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop);
/* extern'd by other modules which don't deal closely with RNA */
PyObject *pyrna_id_CreatePyObject(struct ID *id);
bool pyrna_id_FromPyObject(PyObject *obj, struct ID **id);
PyObject *pyrna_id_CreatePyObject(ID *id);
bool pyrna_id_FromPyObject(PyObject *obj, ID **id);
bool pyrna_id_CheckPyObject(PyObject *obj);
/* operators also need this to set args */
int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, bool all_args, const char *error_prefix);
PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
int pyrna_deferred_register_class(struct StructRNA *srna, PyTypeObject *py_class);
int pyrna_deferred_register_class(StructRNA *srna, PyTypeObject *py_class);
const PointerRNA *pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna);
const PointerRNA *pyrna_struct_as_ptr_or_null(PyObject *py_obj, const StructRNA *srna);
@@ -233,9 +230,7 @@ int pyrna_struct_as_ptr_parse(PyObject *o, void *p);
*/
int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p);
void pyrna_struct_type_extend_capi(struct StructRNA *srna,
struct PyMethodDef *method,
struct PyGetSetDef *getset);
void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSetDef *getset);
/* Called before stopping Python. */
@@ -283,7 +278,3 @@ extern PyMethodDef meth_bpy_owner_id_set;
extern PyMethodDef meth_bpy_owner_id_get;
extern BPy_StructRNA *bpy_context_module;
#ifdef __cplusplus
}
#endif

View File

@@ -42,8 +42,8 @@
#include "WM_types.hh"
#include "bpy_capi_utils.h"
#include "bpy_rna.h"
#include "bpy_rna_anim.h"
#include "bpy_rna.hh"
#include "bpy_rna_anim.hh"
#include "../generic/py_capi_rna.h"
#include "../generic/python_utildefines.h"

View File

@@ -8,10 +8,6 @@
* \ingroup pythonintern
*/
#ifdef __cplusplus
extern "C" {
#endif
extern char pyrna_struct_keyframe_insert_doc[];
extern char pyrna_struct_keyframe_delete_doc[];
extern char pyrna_struct_driver_add_doc[];
@@ -21,7 +17,3 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw);
PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args);
PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args);
#ifdef __cplusplus
}
#endif

View File

@@ -16,7 +16,7 @@
#include "RNA_types.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "MEM_guardedalloc.h"

View File

@@ -29,8 +29,8 @@
#include "BPY_extern.h" /* For public API. */
#include "bpy_capi_utils.h"
#include "bpy_rna.h"
#include "bpy_rna_callback.h" /* Own include. */
#include "bpy_rna.hh"
#include "bpy_rna_callback.hh" /* Own include. */
/* Use this to stop other capsules from being mis-used. */
static const char *rna_capsual_id = "RNA_HANDLE";

View File

@@ -10,10 +10,6 @@
struct BPy_StructRNA;
#ifdef __cplusplus
extern "C" {
#endif
#if 0
PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args);
PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args);
@@ -21,7 +17,3 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args);
PyObject *pyrna_callback_classmethod_add(PyObject *self, PyObject *args);
PyObject *pyrna_callback_classmethod_remove(PyObject *self, PyObject *args);
#ifdef __cplusplus
}
#endif

View File

@@ -21,14 +21,14 @@
#include "WM_api.hh"
#include "WM_types.hh"
#include "bpy_rna_context.h"
#include "bpy_rna_context.hh"
#include "../generic/python_compat.h"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
/* -------------------------------------------------------------------- */
/** \name Private Utility Functions

View File

@@ -8,14 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyMethodDef BPY_rna_context_temp_override_method_def;
void bpy_rna_context_types_init(void);
#ifdef __cplusplus
}
#endif

View File

@@ -28,8 +28,8 @@
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.h"
#include "bpy_rna_data.h"
#include "bpy_rna.hh"
#include "bpy_rna_data.hh"
struct BPy_DataContext {
PyObject_HEAD /* Required Python macro. */

View File

@@ -8,14 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
int BPY_rna_data_context_type_ready(void);
extern PyMethodDef BPY_rna_data_context_method_def;
#ifdef __cplusplus
}
#endif

View File

@@ -20,9 +20,9 @@
#include "RNA_access.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "bpy_rna_driver.h" /* own include */
#include "bpy_rna_driver.hh" /* own include */
PyObject *pyrna_driver_get_variable_value(const AnimationEvalContext *anim_eval_context,
ChannelDriver *driver,

View File

@@ -1,33 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup pythonintern
*/
struct ChannelDriver;
struct DriverTarget;
struct PathResolvedRNA;
#ifdef __cplusplus
extern "C" {
#endif
/**
* A version of #driver_get_variable_value which returns a #PyObject.
*/
PyObject *pyrna_driver_get_variable_value(const struct AnimationEvalContext *anim_eval_context,
struct ChannelDriver *driver,
struct DriverVar *dvar,
struct DriverTarget *dtar);
PyObject *pyrna_driver_self_from_anim_rna(struct PathResolvedRNA *anim_rna);
bool pyrna_driver_is_equal_anim_rna(const struct PathResolvedRNA *anim_rna,
const PyObject *py_anim_rna);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,26 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup pythonintern
*/
struct AnimationEvalContext;
struct ChannelDriver;
struct DriverTarget;
struct DriverVar;
struct PathResolvedRNA;
/**
* A version of #driver_get_variable_value which returns a #PyObject.
*/
PyObject *pyrna_driver_get_variable_value(const AnimationEvalContext *anim_eval_context,
ChannelDriver *driver,
DriverVar *dvar,
DriverTarget *dtar);
PyObject *pyrna_driver_self_from_anim_rna(PathResolvedRNA *anim_rna);
bool pyrna_driver_is_equal_anim_rna(const PathResolvedRNA *anim_rna, const PyObject *py_anim_rna);

View File

@@ -19,7 +19,7 @@
#include "WM_types.hh"
#include "bpy_capi_utils.h"
#include "bpy_rna_gizmo.h"
#include "bpy_rna_gizmo.hh"
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"
@@ -27,7 +27,7 @@
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
/* -------------------------------------------------------------------- */
/** \name Parsing Utility Functions

View File

@@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
bool BPY_rna_gizmo_module(PyObject *);
#ifdef __cplusplus
}
#endif

View File

@@ -28,7 +28,7 @@
#include "WM_api.hh"
#include "WM_types.hh"
#include "bpy_rna_id_collection.h"
#include "bpy_rna_id_collection.hh"
#include "../generic/py_capi_rna.h"
#include "../generic/py_capi_utils.h"
@@ -36,7 +36,7 @@
#include "RNA_enum_types.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
struct IDUserMapData {
/** We loop over data-blocks that this ID points to (do build a reverse lookup table) */

View File

@@ -8,14 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyMethodDef BPY_rna_id_collection_user_map_method_def;
extern PyMethodDef BPY_rna_id_collection_batch_remove_method_def;
extern PyMethodDef BPY_rna_id_collection_orphans_purge_method_def;
#ifdef __cplusplus
}
#endif

View File

@@ -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.hh" /* Own include, #BPY_rna_operator_poll_message_set_method_def. */
/* -------------------------------------------------------------------- */
/** \name Operator `poll_message_set` Method

View File

@@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyMethodDef BPY_rna_operator_poll_message_set_method_def;
#ifdef __cplusplus
}
#endif

View File

@@ -20,8 +20,8 @@
#include "../generic/python_compat.h"
#include "bpy_rna.h"
#include "bpy_rna_text.h" /* Declare #BPY_rna_region_as_string_method_def. */
#include "bpy_rna.hh"
#include "bpy_rna_text.hh" /* Declare #BPY_rna_region_as_string_method_def. */
/* -------------------------------------------------------------------- */
/** \name Data structures.

View File

@@ -8,13 +8,5 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyMethodDef BPY_rna_region_as_string_method_def;
extern PyMethodDef BPY_rna_region_from_string_method_def;
#ifdef __cplusplus
}
#endif

View File

@@ -22,16 +22,16 @@
#include "BLI_utildefines.h"
#include "bpy_library.h"
#include "bpy_rna.h"
#include "bpy_rna_callback.h"
#include "bpy_rna_context.h"
#include "bpy_rna_data.h"
#include "bpy_rna_id_collection.h"
#include "bpy_rna_text.h"
#include "bpy_rna_types_capi.h"
#include "bpy_rna_ui.h"
#include "bpy_rna.hh"
#include "bpy_rna_callback.hh"
#include "bpy_rna_context.hh"
#include "bpy_rna_data.hh"
#include "bpy_rna_id_collection.hh"
#include "bpy_rna_text.hh"
#include "bpy_rna_types_capi.hh"
#include "bpy_rna_ui.hh"
#include "bpy_rna_operator.h"
#include "bpy_rna_operator.hh"
#include "../generic/py_capi_utils.h"

View File

@@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void BPY_rna_types_extend_capi(void);
#ifdef __cplusplus
}
#endif

View File

@@ -16,8 +16,8 @@
#include "UI_interface.hh"
#include "bpy_rna.h"
#include "bpy_rna_ui.h" /* Declare #BPY_rna_uilayout_introspect_method_def. */
#include "bpy_rna.hh"
#include "bpy_rna_ui.hh" /* Declare #BPY_rna_uilayout_introspect_method_def. */
PyDoc_STRVAR(
/* Wrap. */

View File

@@ -8,12 +8,4 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyMethodDef BPY_rna_uilayout_introspect_method_def;
#ifdef __cplusplus
}
#endif

View File

@@ -19,7 +19,7 @@
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "bpy_utils_previews.h"
#include "../generic/py_capi_utils.h"

View File

@@ -11,7 +11,7 @@
#include "RE_engine.h"
#include "../generic/py_capi_utils.h"
#include "bpy_rna.h"
#include "bpy_rna.hh"
#include "BKE_context.hh"