Refactor: Move BPY bmesh headers to proper C++ ones.

This commit is contained in:
Bastien Montagne
2024-09-24 16:27:18 +02:00
committed by Bastien Montagne
parent c3247aa4f0
commit 6c0c53161e
21 changed files with 108 additions and 177 deletions

View File

@@ -23,15 +23,15 @@ set(SRC
bmesh_py_types_select.cc
bmesh_py_utils.cc
bmesh_py_api.h
bmesh_py_geometry.h
bmesh_py_ops.h
bmesh_py_ops_call.h
bmesh_py_types.h
bmesh_py_types_customdata.h
bmesh_py_types_meshdata.h
bmesh_py_types_select.h
bmesh_py_utils.h
bmesh_py_api.hh
bmesh_py_geometry.hh
bmesh_py_ops.hh
bmesh_py_ops_call.hh
bmesh_py_types.hh
bmesh_py_types_customdata.hh
bmesh_py_types_meshdata.hh
bmesh_py_types_select.hh
bmesh_py_utils.hh
)
set(LIB

View File

@@ -14,14 +14,14 @@
#include "bmesh.hh"
#include "bmesh_py_types.h"
#include "bmesh_py_types_customdata.h"
#include "bmesh_py_types_meshdata.h"
#include "bmesh_py_types_select.h"
#include "bmesh_py_types.hh"
#include "bmesh_py_types_customdata.hh"
#include "bmesh_py_types_meshdata.hh"
#include "bmesh_py_types_select.hh"
#include "bmesh_py_geometry.h"
#include "bmesh_py_ops.h"
#include "bmesh_py_utils.h"
#include "bmesh_py_geometry.hh"
#include "bmesh_py_ops.hh"
#include "bmesh_py_utils.hh"
#include "BKE_editmesh.hh"
#include "BKE_mesh_types.hh"
@@ -30,7 +30,7 @@
#include "../generic/py_capi_utils.hh"
#include "bmesh_py_api.h" /* own include */
#include "bmesh_py_api.hh" /* own include */
PyDoc_STRVAR(
/* Wrap. */

View File

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

View File

@@ -16,8 +16,8 @@
#include "../mathutils/mathutils.hh"
#include "bmesh.hh"
#include "bmesh_py_geometry.h" /* own include */
#include "bmesh_py_types.h"
#include "bmesh_py_geometry.hh" /* own include */
#include "bmesh_py_types.hh"
PyDoc_STRVAR(
/* Wrap. */

View File

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

View File

@@ -18,8 +18,8 @@
#include "bmesh.hh"
#include "bmesh_py_ops.h" /* own include */
#include "bmesh_py_ops_call.h"
#include "bmesh_py_ops.hh" /* own include */
#include "bmesh_py_ops_call.hh"
/* bmesh operator 'bmesh.ops.*' callable types
* ******************************************* */

View File

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

View File

@@ -18,9 +18,9 @@
#include "bmesh.hh"
#include "bmesh_py_ops_call.h" /* own include */
#include "bmesh_py_ops_call.hh" /* own include */
#include "bmesh_py_types.h"
#include "bmesh_py_types.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"

View File

@@ -8,20 +8,12 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
struct BPy_BMeshOpFunc {
PyObject_HEAD /* Required Python macro. */
const char *opname;
} BPy_BMeshOpFunc;
};
/**
* This is the `__call__` for `bmesh.ops.xxx()`.
*/
PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw);
#ifdef __cplusplus
}
#endif

View File

@@ -36,10 +36,10 @@
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"
#include "bmesh_py_types.h" /* own include */
#include "bmesh_py_types_customdata.h"
#include "bmesh_py_types_meshdata.h"
#include "bmesh_py_types_select.h"
#include "bmesh_py_types.hh" /* own include */
#include "bmesh_py_types_customdata.hh"
#include "bmesh_py_types_meshdata.hh"
#include "bmesh_py_types_select.hh"
static void bm_dealloc_editmode_warn(BPy_BMesh *self);

View File

@@ -8,9 +8,12 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct BMesh;
struct BMEdge;
struct BMElem;
struct BMFace;
struct BMLoop;
struct BMVert;
extern PyTypeObject BPy_BMesh_Type;
extern PyTypeObject BPy_BMVert_Type;
@@ -41,48 +44,48 @@ extern PyTypeObject BPy_BMIter_Type;
#define BPy_BMElem_Check(v) (Py_TYPE(v)->tp_hash == BPy_BMVert_Type.tp_hash)
/* cast from _any_ bmesh type - they all have BMesh first */
typedef struct BPy_BMGeneric {
struct BPy_BMGeneric {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
} BPy_BMGeneric;
BMesh *bm; /* keep first */
};
/* BPy_BMVert/BPy_BMEdge/BPy_BMFace/BPy_BMLoop can cast to this */
typedef struct BPy_BMElem {
struct BPy_BMElem {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMElem *ele;
} BPy_BMElem;
BMesh *bm; /* keep first */
BMElem *ele;
};
typedef struct BPy_BMesh {
struct BPy_BMesh {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
int flag;
} BPy_BMesh;
};
/* element types */
typedef struct BPy_BMVert {
struct BPy_BMVert {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMVert *v;
} BPy_BMVert;
BMesh *bm; /* keep first */
BMVert *v;
};
typedef struct BPy_BMEdge {
struct BPy_BMEdge {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMEdge *e;
} BPy_BMEdge;
BMesh *bm; /* keep first */
BMEdge *e;
};
typedef struct BPy_BMFace {
struct BPy_BMFace {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMFace *f;
} BPy_BMFace;
BMesh *bm; /* keep first */
BMFace *f;
};
typedef struct BPy_BMLoop {
struct BPy_BMLoop {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMLoop *l;
} BPy_BMLoop;
BMesh *bm; /* keep first */
BMLoop *l;
};
/* iterators */
@@ -93,9 +96,9 @@ typedef struct BPy_BMLoop {
* - BPy_BMFaceSeq_Type
* - BPy_BMLoopSeq_Type
*/
typedef struct BPy_BMElemSeq {
struct BPy_BMElemSeq {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
/* if this is a sequence on an existing element,
* loops of faces for eg.
@@ -108,17 +111,17 @@ typedef struct BPy_BMElemSeq {
/* iterator type */
short itype;
} BPy_BMElemSeq;
};
typedef struct BPy_BMIter {
struct BPy_BMIter {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
BMIter iter;
} BPy_BMIter;
};
void BPy_BM_init_types(void);
void BPy_BM_init_types();
PyObject *BPyInit_bmesh_types(void);
PyObject *BPyInit_bmesh_types();
enum {
BPY_BMFLAG_NOP = 0, /* do nothing */
@@ -230,15 +233,3 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
(bpy_bmelemseq)->py_ele ? ((BPy_BMElem *)(bpy_bmelemseq)->py_ele)->ele : NULL); \
ele; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_step(iter))
#ifdef __PY_CAPI_UTILS_H__
struct PyC_FlagSet;
extern struct PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[];
extern struct PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[];
extern struct PyC_FlagSet bpy_bm_htype_all_flags[];
extern struct PyC_FlagSet bpy_bm_hflag_all_flags[];
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -16,9 +16,9 @@
#include "bmesh.hh"
#include "bmesh_py_types.h"
#include "bmesh_py_types_customdata.h"
#include "bmesh_py_types_meshdata.h"
#include "bmesh_py_types.hh"
#include "bmesh_py_types_customdata.hh"
#include "bmesh_py_types_meshdata.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"

View File

@@ -8,9 +8,7 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct BMesh;
/* All use #BPy_BMLayerAccess struct. */
@@ -27,34 +25,34 @@ extern PyTypeObject BPy_BMLayerItem_Type;
#define BPy_BMLayerItem_Check(v) (Py_TYPE(v) == &BPy_BMLayerItem_Type)
/** All layers for vert/edge/face/loop. */
typedef struct BPy_BMLayerAccess {
struct BPy_BMLayerAccess {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
char htype;
} BPy_BMLayerAccess;
};
/** Access different layer types deform/uv/vertex-color. */
typedef struct BPy_BMLayerCollection {
struct BPy_BMLayerCollection {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
char htype;
int type; /* customdata type - CD_XXX */
} BPy_BMLayerCollection;
};
/** Access a specific layer directly. */
typedef struct BPy_BMLayerItem {
struct BPy_BMLayerItem {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
BMesh *bm; /* keep first */
char htype;
int type; /* customdata type - CD_XXX */
int index; /* index of this layer type */
} BPy_BMLayerItem;
};
PyObject *BPy_BMLayerAccess_CreatePyObject(BMesh *bm, char htype);
PyObject *BPy_BMLayerCollection_CreatePyObject(BMesh *bm, char htype, int type);
PyObject *BPy_BMLayerItem_CreatePyObject(BMesh *bm, char htype, int type, int index);
void BPy_BM_init_types_customdata(void);
void BPy_BM_init_types_customdata();
/**
*\brief BMElem.__getitem__() / __setitem__()
@@ -63,7 +61,3 @@ void BPy_BM_init_types_customdata(void);
*/
PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer);
int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObject *value);
#ifdef __cplusplus
}
#endif

View File

@@ -33,7 +33,7 @@
#include "BKE_deform.hh"
#include "bmesh.hh"
#include "bmesh_py_types_meshdata.h"
#include "bmesh_py_types_meshdata.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"

View File

@@ -8,19 +8,15 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject BPy_BMLoopUV_Type;
extern PyTypeObject BPy_BMDeformVert_Type;
#define BPy_BMLoopUV_Check(v) (Py_TYPE(v) == &BPy_BMLoopUV_Type)
typedef struct BPy_BMGenericMeshData {
struct BPy_BMGenericMeshData {
PyObject_VAR_HEAD
void *data;
} BPy_BMGenericMeshData;
};
struct MDeformVert;
struct MLoopCol;
@@ -40,8 +36,4 @@ int BPy_BMDeformVert_AssignPyObject(struct MDeformVert *dvert, PyObject *value);
PyObject *BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert);
/* call to init all types */
void BPy_BM_init_types_meshdata(void);
#ifdef __cplusplus
}
#endif
void BPy_BM_init_types_meshdata();

View File

@@ -19,8 +19,8 @@
#include "bmesh.hh"
#include "bmesh_py_types.h"
#include "bmesh_py_types_select.h"
#include "bmesh_py_types.hh"
#include "bmesh_py_types_select.hh"
#include "../generic/python_utildefines.hh"

View File

@@ -8,10 +8,8 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct BBMesh;
struct BMEditSelection;
struct BPy_BMesh;
extern PyTypeObject BPy_BMEditSelSeq_Type;
@@ -20,26 +18,22 @@ extern PyTypeObject BPy_BMEditSelIter_Type;
#define BPy_BMSelectHistory_Check(v) (Py_TYPE(v) == &BPy_BMEditSelSeq_Type)
#define BPy_BMSelectHistoryIter_Check(v) (Py_TYPE(v) == &BPy_BMEditSelIter_Type)
typedef struct BPy_BMEditSelSeq {
struct BPy_BMEditSelSeq {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
} BPy_BMEditSelSeq;
BMesh *bm; /* keep first */
};
typedef struct BPy_BMEditSelIter {
struct BPy_BMEditSelIter {
PyObject_VAR_HEAD
struct BMesh *bm; /* keep first */
struct BMEditSelection *ese;
} BPy_BMEditSelIter;
BMesh *bm; /* keep first */
BMEditSelection *ese;
};
void BPy_BM_init_types_select(void);
void BPy_BM_init_types_select();
PyObject *BPy_BMEditSel_CreatePyObject(BMesh *bm);
PyObject *BPy_BMEditSelIter_CreatePyObject(BMesh *bm);
/**
* \note doesn't actually check selection.
*/
int BPy_BMEditSel_Assign(struct BPy_BMesh *self, PyObject *value);
#ifdef __cplusplus
}
#endif
int BPy_BMEditSel_Assign(BPy_BMesh *self, PyObject *value);

View File

@@ -19,8 +19,8 @@
#include "../mathutils/mathutils.hh"
#include "bmesh.hh"
#include "bmesh_py_types.h"
#include "bmesh_py_utils.h" /* own include */
#include "bmesh_py_types.hh"
#include "bmesh_py_utils.hh" /* own include */
#include "../generic/py_capi_utils.hh"
#include "../generic/python_utildefines.hh"

View File

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

View File

@@ -62,7 +62,7 @@
#include "../generic/py_capi_utils.hh"
/* `inittab` initialization functions. */
#include "../bmesh/bmesh_py_api.h"
#include "../bmesh/bmesh_py_api.hh"
#include "../generic/bgl.h"
#include "../generic/bl_math_py_api.hh"
#include "../generic/blf_py_api.hh"

View File

@@ -44,7 +44,7 @@
# include "bmesh.hh"
# include "../bmesh/bmesh_py_types.h"
# include "../bmesh/bmesh_py_types.hh"
#endif /* MATH_STANDALONE */
#include "BLI_strict_flags.h" /* Keep last. */