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

This module actually was confusing, since only a few headers were
effectively still C ones (using the `extern "C"` blocks)...
This commit is contained in:
Bastien Montagne
2024-09-24 12:56:16 +02:00
committed by Bastien Montagne
parent 4dd11465bc
commit 4fac7828e4
38 changed files with 70 additions and 79 deletions

View File

@@ -68,7 +68,7 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
#include "generic/python_utildefines.h"
#include "mathutils/mathutils.h"
#include "mathutils/mathutils.hh"
//==============================
// C++ => Python

View File

@@ -13,7 +13,7 @@
#include "BLI_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "bmesh.hh"
#include "bmesh_py_geometry.h" /* own include */

View File

@@ -14,7 +14,7 @@
#include "BLI_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "bmesh.hh"

View File

@@ -31,7 +31,7 @@
#include <Python.h>
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"

View File

@@ -22,7 +22,7 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "BKE_customdata.hh"

View File

@@ -19,7 +19,7 @@
#include <Python.h>
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "DNA_meshdata_types.h"

View File

@@ -16,7 +16,7 @@
#include "MEM_guardedalloc.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "bmesh.hh"
#include "bmesh_py_types.h"

View File

@@ -22,7 +22,7 @@
#include "../generic/python_compat.h"
#include "../generic/python_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "gpu_py.hh"
#include "gpu_py_buffer.hh"

View File

@@ -18,7 +18,7 @@
#include "BLI_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "../generic/py_capi_utils.h"

View File

@@ -30,7 +30,7 @@
#include "ED_view3d_offscreen.hh"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "../generic/py_capi_utils.h"
#include "../generic/python_compat.h"

View File

@@ -21,7 +21,7 @@
#include "../generic/python_compat.h"
#include "../generic/python_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "gpu_py.hh"
#include "gpu_py_texture.hh"

View File

@@ -69,7 +69,7 @@
#include "../generic/idprop_py_api.h"
#include "../generic/imbuf_py_api.h"
#include "../gpu/gpu_py_api.hh"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
/* Logging types to use anywhere in the Python modules. */

View File

@@ -14,7 +14,7 @@
#include "../generic/python_compat.h"
#include "../generic/python_utildefines.h"
#include "../mathutils/mathutils.h"
#include "../mathutils/mathutils.hh"
#include "BLI_utildefines.h"

View File

@@ -393,7 +393,7 @@ static int pyrna_py_to_prop(
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item);
#ifdef USE_MATHUTILS
# include "../mathutils/mathutils.h" /* So we can have mathutils callbacks. */
# include "../mathutils/mathutils.hh" /* So we can have mathutils callbacks. */
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self,
PointerRNA *ptr,

View File

@@ -29,7 +29,7 @@
#define USE_MATHUTILS
#ifdef USE_MATHUTILS
# include "../mathutils/mathutils.h" /* so we can have mathutils callbacks */
# include "../mathutils/mathutils.hh" /* so we can have mathutils callbacks */
#endif
#define MAX_ARRAY_DIMENSION 10

View File

@@ -26,17 +26,17 @@ set(SRC
mathutils_kdtree.cc
mathutils_noise.cc
mathutils.h
mathutils_Color.h
mathutils_Euler.h
mathutils_Matrix.h
mathutils_Quaternion.h
mathutils_Vector.h
mathutils_bvhtree.h
mathutils_geometry.h
mathutils_interpolate.h
mathutils_kdtree.h
mathutils_noise.h
mathutils.hh
mathutils_Color.hh
mathutils_Euler.hh
mathutils_Matrix.hh
mathutils_Quaternion.hh
mathutils_Vector.hh
mathutils_bvhtree.hh
mathutils_geometry.hh
mathutils_interpolate.hh
mathutils_kdtree.hh
mathutils_noise.hh
)
set(LIB

View File

@@ -8,7 +8,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
@@ -755,12 +755,12 @@ static PyModuleDef M_Mathutils_module_def = {
};
/* submodules only */
#include "mathutils_geometry.h"
#include "mathutils_interpolate.h"
#include "mathutils_geometry.hh"
#include "mathutils_interpolate.hh"
#ifndef MATH_STANDALONE
# include "mathutils_bvhtree.h"
# include "mathutils_kdtree.h"
# include "mathutils_noise.h"
# include "mathutils_bvhtree.hh"
# include "mathutils_kdtree.hh"
# include "mathutils_noise.hh"
#endif
PyMODINIT_FUNC PyInit_mathutils()

View File

@@ -56,16 +56,16 @@ enum {
/** Wrapped data type. */ \
unsigned char flag
typedef struct {
struct BaseMathObject {
BASE_MATH_MEMBERS(data);
} BaseMathObject;
};
/* types */
#include "mathutils_Color.h"
#include "mathutils_Euler.h"
#include "mathutils_Matrix.h"
#include "mathutils_Quaternion.h"
#include "mathutils_Vector.h"
#include "mathutils_Color.hh"
#include "mathutils_Euler.hh"
#include "mathutils_Matrix.hh"
#include "mathutils_Quaternion.hh"
#include "mathutils_Vector.hh"
/* avoid checking all types */
#define BaseMathObject_CheckExact(v) (Py_TYPE(v)->tp_dealloc == (destructor)BaseMathObject_dealloc)
@@ -83,7 +83,7 @@ int BaseMathObject_clear(BaseMathObject *self);
void BaseMathObject_dealloc(BaseMathObject *self);
int BaseMathObject_is_gc(BaseMathObject *self);
PyMODINIT_FUNC PyInit_mathutils(void);
PyMODINIT_FUNC PyInit_mathutils();
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff);
int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int floatSteps);

View File

@@ -10,7 +10,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "BLI_utildefines.h"

View File

@@ -12,9 +12,9 @@ extern PyTypeObject color_Type;
#define ColorObject_Check(v) PyObject_TypeCheck((v), &color_Type)
#define ColorObject_CheckExact(v) (Py_TYPE(v) == &color_Type)
typedef struct {
struct ColorObject {
BASE_MATH_MEMBERS(col);
} ColorObject;
};
/* struct data contains a pointer to the actual data that the
* object uses. It can use either PyMem allocated data (which will

View File

@@ -10,7 +10,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"

View File

@@ -12,11 +12,10 @@ extern PyTypeObject euler_Type;
#define EulerObject_Check(v) PyObject_TypeCheck((v), &euler_Type)
#define EulerObject_CheckExact(v) (Py_TYPE(v) == &euler_Type)
typedef struct {
struct EulerObject {
BASE_MATH_MEMBERS(eul);
unsigned char order; /* rotation order */
} EulerObject;
};
/* struct data contains a pointer to the actual data that the
* object uses. It can use either PyMem allocated data (which will

View File

@@ -10,7 +10,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"

View File

@@ -36,11 +36,11 @@ typedef unsigned short ushort;
#define MATRIX_COL_INDEX(_mat, _col) (MATRIX_ITEM_INDEX(_mat, 0, _col))
#define MATRIX_COL_PTR(_mat, _col) ((_mat)->matrix + MATRIX_COL_INDEX(_mat, _col))
typedef struct {
struct MatrixObject {
BASE_MATH_MEMBERS(matrix);
ushort col_num;
ushort row_num;
} MatrixObject;
};
/* struct data contains a pointer to the actual data that the
* object uses. It can use either PyMem allocated data (which will

View File

@@ -10,7 +10,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "BLI_math_base_safe.h"
#include "BLI_math_matrix.h"

View File

@@ -13,9 +13,9 @@ extern PyTypeObject quaternion_Type;
#define QuaternionObject_Check(v) PyObject_TypeCheck((v), &quaternion_Type)
#define QuaternionObject_CheckExact(v) (Py_TYPE(v) == &quaternion_Type)
typedef struct {
struct QuaternionObject {
BASE_MATH_MEMBERS(quat);
} QuaternionObject;
};
/* struct data contains a pointer to the actual data that the
* object uses. It can use either PyMem allocated data (which will

View File

@@ -10,7 +10,7 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils.hh"
#include "BLI_math_base_safe.h"
#include "BLI_math_matrix.h"

View File

@@ -8,21 +8,17 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern PyTypeObject vector_Type;
#define VectorObject_Check(v) PyObject_TypeCheck((v), &vector_Type)
#define VectorObject_CheckExact(v) (Py_TYPE(v) == &vector_Type)
typedef struct {
struct VectorObject {
BASE_MATH_MEMBERS(vec);
/** Number of items in this vector (2 or more). */
int vec_num;
} VectorObject;
};
/* Prototypes. */
@@ -53,7 +49,3 @@ PyObject *Vector_CreatePyObject_alloc(float *vec,
int vec_num,
PyTypeObject *base_type) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif

View File

@@ -27,8 +27,8 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "mathutils.h"
#include "mathutils_bvhtree.h" /* own include */
#include "mathutils.hh"
#include "mathutils_bvhtree.hh" /* own include */
#ifndef MATH_STANDALONE
# include "DNA_mesh_types.h"

View File

@@ -8,7 +8,7 @@
#pragma once
PyMODINIT_FUNC PyInit_mathutils_bvhtree(void);
PyMODINIT_FUNC PyInit_mathutils_bvhtree();
extern PyTypeObject PyBVHTree_Type;

View File

@@ -8,8 +8,8 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils_geometry.h"
#include "mathutils.hh"
#include "mathutils_geometry.hh"
/* Used for PolyFill */
#ifndef MATH_STANDALONE /* define when building outside blender */

View File

@@ -8,4 +8,4 @@
* \ingroup pymathutils
*/
PyMODINIT_FUNC PyInit_mathutils_geometry(void);
PyMODINIT_FUNC PyInit_mathutils_geometry();

View File

@@ -8,8 +8,8 @@
#include <Python.h>
#include "mathutils.h"
#include "mathutils_interpolate.h"
#include "mathutils.hh"
#include "mathutils_interpolate.hh"
#include "BLI_math_geom.h"
#include "BLI_utildefines.h"

View File

@@ -8,4 +8,4 @@
* \ingroup pymathutils
*/
PyMODINIT_FUNC PyInit_mathutils_interpolate(void);
PyMODINIT_FUNC PyInit_mathutils_interpolate();

View File

@@ -19,8 +19,8 @@
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "mathutils.h"
#include "mathutils_kdtree.h" /* own include */
#include "mathutils.hh"
#include "mathutils_kdtree.hh" /* own include */
#include "BLI_strict_flags.h" /* Keep last. */

View File

@@ -8,6 +8,6 @@
#pragma once
PyMODINIT_FUNC PyInit_mathutils_kdtree(void);
PyMODINIT_FUNC PyInit_mathutils_kdtree();
extern PyTypeObject PyKDTree_Type;

View File

@@ -23,8 +23,8 @@
#include "../generic/py_capi_utils.h"
#include "mathutils.h"
#include "mathutils_noise.h"
#include "mathutils.hh"
#include "mathutils_noise.hh"
/*-----------------------------------------*/
/* 'mersenne twister' random number generator */

View File

@@ -8,4 +8,4 @@
#pragma once
PyMODINIT_FUNC PyInit_mathutils_noise(void);
PyMODINIT_FUNC PyInit_mathutils_noise();