Python: move remaining python files to C++
Also see #103343. Pull Request: https://projects.blender.org/blender/blender/pulls/110352
This commit is contained in:
@@ -12,15 +12,15 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
bmesh_py_api.c
|
||||
bmesh_py_geometry.c
|
||||
bmesh_py_ops.c
|
||||
bmesh_py_ops_call.c
|
||||
bmesh_py_types.c
|
||||
bmesh_py_types_customdata.c
|
||||
bmesh_py_types_meshdata.c
|
||||
bmesh_py_types_select.c
|
||||
bmesh_py_utils.c
|
||||
bmesh_py_api.cc
|
||||
bmesh_py_geometry.cc
|
||||
bmesh_py_ops.cc
|
||||
bmesh_py_ops_call.cc
|
||||
bmesh_py_types.cc
|
||||
bmesh_py_types_customdata.cc
|
||||
bmesh_py_types_meshdata.cc
|
||||
bmesh_py_types_select.cc
|
||||
bmesh_py_utils.cc
|
||||
|
||||
bmesh_py_api.h
|
||||
bmesh_py_geometry.h
|
||||
|
||||
@@ -40,9 +40,9 @@ PyDoc_STRVAR(bpy_bm_new_doc,
|
||||
" :return: Return a new, empty BMesh.\n"
|
||||
" :rtype: :class:`bmesh.types.BMesh`\n");
|
||||
|
||||
static PyObject *bpy_bm_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *bpy_bm_new(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"use_operators", NULL};
|
||||
static const char *kwlist[] = {"use_operators", nullptr};
|
||||
BMesh *bm;
|
||||
|
||||
bool use_operators = true;
|
||||
@@ -50,13 +50,12 @@ static PyObject *bpy_bm_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kw, "|$O&:new", (char **)kwlist, PyC_ParseBool, &use_operators))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = BM_mesh_create(&bm_mesh_allocsize_default,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = use_operators,
|
||||
}));
|
||||
BMeshCreateParams params{};
|
||||
params.use_toolflags = use_operators;
|
||||
bm = BM_mesh_create(&bm_mesh_allocsize_default, ¶ms);
|
||||
|
||||
return BPy_BMesh_CreatePyObject(bm, BPY_BMFLAG_NOP);
|
||||
}
|
||||
@@ -70,18 +69,18 @@ PyDoc_STRVAR(bpy_bm_from_edit_mesh_doc,
|
||||
" :type mesh: :class:`bpy.types.Mesh`\n"
|
||||
" :return: the BMesh associated with this mesh.\n"
|
||||
" :rtype: :class:`bmesh.types.BMesh`\n");
|
||||
static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *bpy_bm_from_edit_mesh(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
BMesh *bm;
|
||||
Mesh *me = PyC_RNA_AsPointer(value, "Mesh");
|
||||
Mesh *me = static_cast<Mesh *>(PyC_RNA_AsPointer(value, "Mesh"));
|
||||
|
||||
if (me == NULL) {
|
||||
return NULL;
|
||||
if (me == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (me->edit_mesh == NULL) {
|
||||
if (me->edit_mesh == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "The mesh must be in editmode");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = me->edit_mesh->bm;
|
||||
@@ -89,6 +88,8 @@ static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value)
|
||||
return BPy_BMesh_CreatePyObject(bm, BPY_BMFLAG_IS_WRAPPED);
|
||||
}
|
||||
|
||||
extern "C" void EDBM_update_extern(Mesh *me, const bool do_tessface, const bool is_destructive);
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_update_edit_mesh_doc,
|
||||
".. method:: update_edit_mesh(mesh, loop_triangles=True, destructive=True)\n"
|
||||
"\n"
|
||||
@@ -101,9 +102,9 @@ PyDoc_STRVAR(bpy_bm_update_edit_mesh_doc,
|
||||
" :type loop_triangles: boolean\n"
|
||||
" :arg destructive: Use when geometry has been added or removed.\n"
|
||||
" :type destructive: boolean\n");
|
||||
static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *bpy_bm_update_edit_mesh(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"mesh", "loop_triangles", "destructive", NULL};
|
||||
static const char *kwlist[] = {"mesh", "loop_triangles", "destructive", nullptr};
|
||||
PyObject *py_me;
|
||||
Mesh *me;
|
||||
bool do_loop_triangles = true;
|
||||
@@ -119,23 +120,21 @@ static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args,
|
||||
PyC_ParseBool,
|
||||
&is_destructive))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
me = PyC_RNA_AsPointer(py_me, "Mesh");
|
||||
me = static_cast<Mesh *>(PyC_RNA_AsPointer(py_me, "Mesh"));
|
||||
|
||||
if (me == NULL) {
|
||||
return NULL;
|
||||
if (me == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (me->edit_mesh == NULL) {
|
||||
if (me->edit_mesh == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "The mesh must be in editmode");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
extern void EDBM_update_extern(Mesh * me, const bool do_tessface, const bool is_destructive);
|
||||
|
||||
EDBM_update_extern(me, do_loop_triangles, is_destructive);
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ static PyMethodDef BPy_BM_methods[] = {
|
||||
(PyCFunction)bpy_bm_update_edit_mesh,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_bm_update_edit_mesh_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_BM_doc,
|
||||
@@ -162,10 +161,10 @@ static PyModuleDef BPy_BM_module_def = {
|
||||
/*m_doc*/ BPy_BM_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ BPy_BM_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_bmesh(void)
|
||||
@@ -30,7 +30,7 @@ PyDoc_STRVAR(bpy_bm_geometry_intersect_face_point_doc,
|
||||
" :type point: float triplet\n"
|
||||
" :return: True when the projection of the point is in the face.\n"
|
||||
" :rtype: bool\n");
|
||||
static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMFace *py_face;
|
||||
PyObject *py_point;
|
||||
@@ -38,12 +38,12 @@ static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace *UNUSED(self),
|
||||
bool ret;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O:intersect_face_point", &BPy_BMFace_Type, &py_face, &py_point)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_face);
|
||||
if (mathutils_array_parse(point, 3, 3, py_point, "intersect_face_point") == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ret = BM_face_point_inside_test(py_face->f, point);
|
||||
@@ -56,7 +56,7 @@ static PyMethodDef BPy_BM_geometry_methods[] = {
|
||||
(PyCFunction)bpy_bm_geometry_intersect_face_point,
|
||||
METH_VARARGS,
|
||||
bpy_bm_geometry_intersect_face_point_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_BM_utils_doc,
|
||||
@@ -67,10 +67,10 @@ static PyModuleDef BPy_BM_geometry_module_def = {
|
||||
/*m_doc*/ BPy_BM_utils_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ BPy_BM_geometry_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_bmesh_geometry(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *BPyInit_bmesh_geometry(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,16 +23,6 @@
|
||||
|
||||
/* bmesh operator 'bmesh.ops.*' callable types
|
||||
* ******************************************* */
|
||||
static PyTypeObject bmesh_op_Type;
|
||||
|
||||
static PyObject *bpy_bmesh_op_CreatePyObject(const char *opname)
|
||||
{
|
||||
BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type);
|
||||
|
||||
self->opname = opname;
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmesh_op_repr(BPy_BMeshOpFunc *self)
|
||||
{
|
||||
@@ -114,7 +104,7 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmesh_op_doc_get(BPy_BMeshOpFunc *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmesh_op_doc_get(BPy_BMeshOpFunc *self, void * /*closure*/)
|
||||
{
|
||||
PyObject *ret;
|
||||
char *slot_in;
|
||||
@@ -139,69 +129,78 @@ static PyObject *bpy_bmesh_op_doc_get(BPy_BMeshOpFunc *self, void *UNUSED(closur
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmesh_op_getseters[] = {
|
||||
{"__doc__", (getter)bpy_bmesh_op_doc_get, (setter)NULL, NULL, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{"__doc__", (getter)bpy_bmesh_op_doc_get, (setter) nullptr, nullptr, nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
/* Types
|
||||
* ===== */
|
||||
|
||||
static PyTypeObject bmesh_op_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "BMeshOpFunc",
|
||||
/*tp_basicsize*/ sizeof(BPy_BMeshOpFunc),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ NULL,
|
||||
/*tp_dealloc*/ nullptr,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)bpy_bmesh_op_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ (ternaryfunc)BPy_BMO_call,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_methods*/ NULL,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ nullptr,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ bpy_bmesh_op_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/* bmesh module 'bmesh.ops'
|
||||
* ************************ */
|
||||
|
||||
static PyObject *bpy_bmesh_ops_module_getattro(PyObject *UNUSED(self), PyObject *pyname)
|
||||
static PyObject *bpy_bmesh_op_CreatePyObject(const char *opname)
|
||||
{
|
||||
BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type);
|
||||
|
||||
self->opname = opname;
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmesh_ops_module_getattro(PyObject * /*self*/, PyObject *pyname)
|
||||
{
|
||||
const char *opname = PyUnicode_AsUTF8(pyname);
|
||||
|
||||
@@ -210,10 +209,10 @@ static PyObject *bpy_bmesh_ops_module_getattro(PyObject *UNUSED(self), PyObject
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmesh_ops_module_dir(PyObject *UNUSED(self))
|
||||
static PyObject *bpy_bmesh_ops_module_dir(PyObject * /*self*/)
|
||||
{
|
||||
const uint tot = bmo_opdefines_total;
|
||||
uint i;
|
||||
@@ -229,9 +228,9 @@ static PyObject *bpy_bmesh_ops_module_dir(PyObject *UNUSED(self))
|
||||
}
|
||||
|
||||
static PyMethodDef BPy_BM_ops_methods[] = {
|
||||
{"__getattr__", (PyCFunction)bpy_bmesh_ops_module_getattro, METH_O, NULL},
|
||||
{"__dir__", (PyCFunction)bpy_bmesh_ops_module_dir, METH_NOARGS, NULL},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{"__getattr__", (PyCFunction)bpy_bmesh_ops_module_getattro, METH_O, nullptr},
|
||||
{"__dir__", (PyCFunction)bpy_bmesh_ops_module_dir, METH_NOARGS, nullptr},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_BM_ops_doc, "Access to BMesh operators");
|
||||
@@ -241,10 +240,10 @@ static PyModuleDef BPy_BM_ops_module_def = {
|
||||
/*m_doc*/ BPy_BM_ops_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ BPy_BM_ops_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_bmesh_ops(void)
|
||||
@@ -252,7 +251,7 @@ PyObject *BPyInit_bmesh_ops(void)
|
||||
PyObject *submodule = PyModule_Create(&BPy_BM_ops_module_def);
|
||||
|
||||
if (PyType_Ready(&bmesh_op_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return submodule;
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *BPyInit_bmesh_ops(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,7 @@ static int bpy_bm_op_as_py_error(BMesh *bm)
|
||||
if (BMO_error_occurred_at_level(bm, BMO_ERROR_FATAL)) {
|
||||
/* NOTE: we could have multiple errors. */
|
||||
const char *errmsg;
|
||||
if (BMO_error_get(bm, &errmsg, NULL, NULL)) {
|
||||
if (BMO_error_get(bm, &errmsg, nullptr, nullptr)) {
|
||||
PyErr_Format(PyExc_RuntimeError, "bmesh operator: %.200s", errmsg);
|
||||
BMO_error_clear(bm);
|
||||
return -1;
|
||||
@@ -67,7 +67,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (value->bm == NULL) {
|
||||
if (value->bm == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s invalidated element",
|
||||
opname,
|
||||
@@ -75,7 +75,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
|
||||
descr);
|
||||
return -1;
|
||||
}
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to nullptr */
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s invalidated element",
|
||||
opname,
|
||||
@@ -104,7 +104,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
|
||||
const char *slot_name,
|
||||
const char *descr)
|
||||
{
|
||||
if (value->bm == NULL) {
|
||||
if (value->bm == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
|
||||
opname,
|
||||
@@ -112,7 +112,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
|
||||
descr);
|
||||
return -1;
|
||||
}
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
|
||||
if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to nullptr */
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
|
||||
opname,
|
||||
@@ -171,7 +171,7 @@ static int bpy_slot_from_py(BMesh *bm,
|
||||
PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_data.flags;
|
||||
const char *enum_str = PyUnicode_AsUTF8(value);
|
||||
|
||||
if (enum_str == NULL) {
|
||||
if (enum_str == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: keyword \"%.200s\" expected a string, not %.200s",
|
||||
opname,
|
||||
@@ -353,21 +353,22 @@ static int bpy_slot_from_py(BMesh *bm,
|
||||
}
|
||||
/* keep this last */
|
||||
else if (PySequence_Check(value)) {
|
||||
BMElem **elem_array = NULL;
|
||||
BMElem **elem_array = nullptr;
|
||||
Py_ssize_t elem_array_len;
|
||||
|
||||
elem_array = BPy_BMElem_PySeq_As_Array(&bm,
|
||||
value,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&elem_array_len,
|
||||
(slot->slot_subtype.elem & BM_ALL_NOLOOP),
|
||||
true,
|
||||
true,
|
||||
slot_name);
|
||||
elem_array = static_cast<BMElem **>(
|
||||
BPy_BMElem_PySeq_As_Array(&bm,
|
||||
value,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&elem_array_len,
|
||||
(slot->slot_subtype.elem & BM_ALL_NOLOOP),
|
||||
true,
|
||||
true,
|
||||
slot_name));
|
||||
|
||||
/* error is set above */
|
||||
if (elem_array == NULL) {
|
||||
if (elem_array == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -599,7 +600,7 @@ static int bpy_slot_from_py(BMesh *bm,
|
||||
*/
|
||||
static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
{
|
||||
PyObject *item = NULL;
|
||||
PyObject *item = nullptr;
|
||||
|
||||
/* keep switch in same order as above */
|
||||
switch (slot->slot_type) {
|
||||
@@ -613,10 +614,10 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot));
|
||||
break;
|
||||
case BMO_OP_SLOT_MAT:
|
||||
item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, NULL);
|
||||
item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, nullptr);
|
||||
break;
|
||||
case BMO_OP_SLOT_VEC:
|
||||
item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, NULL);
|
||||
item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, nullptr);
|
||||
break;
|
||||
case BMO_OP_SLOT_PTR:
|
||||
BLI_assert(0); /* currently we don't have any pointer return values in use */
|
||||
@@ -624,7 +625,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
break;
|
||||
case BMO_OP_SLOT_ELEMENT_BUF: {
|
||||
if (slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) {
|
||||
BMHeader *ele = BMO_slot_buffer_get_single(slot);
|
||||
BMHeader *ele = static_cast<BMHeader *>(BMO_slot_buffer_get_single(slot));
|
||||
item = ele ? BPy_BMElem_CreatePyObject(bm, ele) : Py_INCREF_RET(Py_None);
|
||||
}
|
||||
else {
|
||||
@@ -634,7 +635,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
|
||||
item = PyList_New(size);
|
||||
for (j = 0; j < size; j++) {
|
||||
BMHeader *ele = buffer[j];
|
||||
BMHeader *ele = static_cast<BMHeader *>(buffer[j]);
|
||||
PyList_SET_ITEM(item, j, BPy_BMElem_CreatePyObject(bm, ele));
|
||||
}
|
||||
}
|
||||
@@ -649,11 +650,11 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_len(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
BMHeader *ele_key = static_cast<BMHeader *>(BLI_ghashIterator_getKey(&hash_iter));
|
||||
void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
|
||||
|
||||
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
|
||||
PyObject *py_val = BPy_BMElem_CreatePyObject(bm, ele_val);
|
||||
PyObject *py_val = BPy_BMElem_CreatePyObject(bm, static_cast<BMHeader *>(ele_val));
|
||||
|
||||
PyDict_SetItem(item, py_key, py_val);
|
||||
Py_DECREF(py_key);
|
||||
@@ -666,7 +667,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_len(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
BMHeader *ele_key = static_cast<BMHeader *>(BLI_ghashIterator_getKey(&hash_iter));
|
||||
void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
|
||||
|
||||
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
|
||||
@@ -683,7 +684,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_len(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
BMHeader *ele_key = static_cast<BMHeader *>(BLI_ghashIterator_getKey(&hash_iter));
|
||||
void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
|
||||
|
||||
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
|
||||
@@ -700,7 +701,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
item = _PyDict_NewPresized(slot_hash ? BLI_ghash_len(slot_hash) : 0);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
BMHeader *ele_key = static_cast<BMHeader *>(BLI_ghashIterator_getKey(&hash_iter));
|
||||
void *ele_val = BLI_ghashIterator_getValue(&hash_iter);
|
||||
|
||||
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
|
||||
@@ -714,10 +715,10 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
break;
|
||||
}
|
||||
case BMO_OP_SLOT_SUBTYPE_MAP_EMPTY: {
|
||||
item = PySet_New(NULL);
|
||||
item = PySet_New(nullptr);
|
||||
if (slot_hash) {
|
||||
GHASH_ITER (hash_iter, slot_hash) {
|
||||
BMHeader *ele_key = BLI_ghashIterator_getKey(&hash_iter);
|
||||
BMHeader *ele_key = static_cast<BMHeader *>(BLI_ghashIterator_getKey(&hash_iter));
|
||||
|
||||
PyObject *py_key = BPy_BMElem_CreatePyObject(bm, ele_key);
|
||||
|
||||
@@ -736,7 +737,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
|
||||
break;
|
||||
}
|
||||
}
|
||||
BLI_assert(item != NULL);
|
||||
BLI_assert(item != nullptr);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -757,7 +758,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
|
||||
if (bm->use_toolflags == false) {
|
||||
PyErr_SetString(PyExc_ValueError, "bmesh created with 'use_operators=False'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* could complain about entering with exceptions... */
|
||||
@@ -767,7 +768,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bmesh operators expect a single BMesh positional argument, all other args "
|
||||
"must be keywords");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* TODO: error check this!, though we do the error check on attribute access. */
|
||||
@@ -790,7 +791,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
self->opname,
|
||||
slot_name);
|
||||
BMO_op_finish(bm, &bmop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
slot = BMO_slot_get(bmop.slots_in, slot_name);
|
||||
@@ -798,7 +799,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
/* now assign the value */
|
||||
if (bpy_slot_from_py(bm, &bmop, slot, value, self->opname, slot_name) == -1) {
|
||||
BMO_op_finish(bm, &bmop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -807,9 +808,9 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
|
||||
/* from here until the end of the function, no returns, just set 'ret' */
|
||||
if (UNLIKELY(bpy_bm_op_as_py_error(bm) == -1)) {
|
||||
ret = NULL; /* exception raised above */
|
||||
ret = nullptr; /* exception raised above */
|
||||
}
|
||||
else if (bmop.slots_out[0].slot_name == NULL) {
|
||||
else if (bmop.slots_out[0].slot_name == nullptr) {
|
||||
ret = Py_INCREF_RET(Py_None);
|
||||
}
|
||||
else {
|
||||
@@ -825,7 +826,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
|
||||
/* this function doesn't throw exceptions */
|
||||
item = bpy_slot_to_py(bm, slot);
|
||||
if (item == NULL) {
|
||||
if (item == nullptr) {
|
||||
item = Py_INCREF_RET(Py_None);
|
||||
}
|
||||
|
||||
@@ -835,7 +836,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
|
||||
char slot_name_strip[MAX_SLOTNAME];
|
||||
const char *ch = strchr(slot->slot_name, '.'); /* can't fail! */
|
||||
const int tot = ch - slot->slot_name;
|
||||
BLI_assert(ch != NULL);
|
||||
BLI_assert(ch != nullptr);
|
||||
memcpy(slot_name_strip, slot->slot_name, tot);
|
||||
slot_name_strip[tot] = '\0';
|
||||
PyDict_SetItemString(ret, slot_name_strip, item);
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD /* Required Python macro. */
|
||||
const char *opname;
|
||||
@@ -17,3 +21,7 @@ typedef struct {
|
||||
* This is the `__call__` for `bmesh.ops.xxx()`.
|
||||
*/
|
||||
PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -49,14 +49,14 @@ PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[] = {
|
||||
{1, "VERT"},
|
||||
{2, "EDGE"},
|
||||
{4, "FACE"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[] = {
|
||||
{BM_VERT, "VERT"},
|
||||
{BM_EDGE, "EDGE"},
|
||||
{BM_FACE, "FACE"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
PyC_FlagSet bpy_bm_htype_all_flags[] = {
|
||||
@@ -64,7 +64,7 @@ PyC_FlagSet bpy_bm_htype_all_flags[] = {
|
||||
{BM_LOOP, "EDGE"},
|
||||
{BM_FACE, "FACE"},
|
||||
{BM_LOOP, "LOOP"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
#define BPY_BM_HFLAG_ALL_STR "('SELECT', 'HIDE', 'SEAM', 'SMOOTH', 'TAG')"
|
||||
@@ -75,7 +75,7 @@ PyC_FlagSet bpy_bm_hflag_all_flags[] = {
|
||||
{BM_ELEM_SEAM, "SEAM"},
|
||||
{BM_ELEM_SMOOTH, "SMOOTH"},
|
||||
{BM_ELEM_TAG, "TAG"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
/* py-type definitions
|
||||
@@ -136,14 +136,14 @@ PyDoc_STRVAR(
|
||||
" It's also possible to assign any number to this attribute for a scripts internal logic.\n"
|
||||
"\n"
|
||||
" To ensure the value is up to date - see :class:`BMElemSeq.index_update`.\n");
|
||||
static PyObject *bpy_bm_elem_index_get(BPy_BMElem *self, void *UNUSED(flag))
|
||||
static PyObject *bpy_bm_elem_index_get(BPy_BMElem *self, void * /*flag*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
return PyLong_FromLong(BM_elem_index_get(self->ele));
|
||||
}
|
||||
|
||||
static int bpy_bm_elem_index_set(BPy_BMElem *self, PyObject *value, void *UNUSED(flag))
|
||||
static int bpy_bm_elem_index_set(BPy_BMElem *self, PyObject *value, void * /*flag*/)
|
||||
{
|
||||
int param;
|
||||
|
||||
@@ -172,7 +172,7 @@ static int bpy_bm_elem_index_set(BPy_BMElem *self, PyObject *value, void *UNUSED
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvertseq_doc,
|
||||
"This meshes vert sequence (read-only).\n\n:type: :class:`BMVertSeq`");
|
||||
static PyObject *bpy_bmvertseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmvertseq_get(BPy_BMesh *self, void * /*closure*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return BPy_BMVertSeq_CreatePyObject(self->bm);
|
||||
@@ -180,7 +180,7 @@ static PyObject *bpy_bmvertseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedgeseq_doc,
|
||||
"This meshes edge sequence (read-only).\n\n:type: :class:`BMEdgeSeq`");
|
||||
static PyObject *bpy_bmedgeseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmedgeseq_get(BPy_BMesh *self, void * /*closure*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return BPy_BMEdgeSeq_CreatePyObject(self->bm);
|
||||
@@ -188,7 +188,7 @@ static PyObject *bpy_bmedgeseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
|
||||
PyDoc_STRVAR(bpy_bmfaceseq_doc,
|
||||
"This meshes face sequence (read-only).\n\n:type: :class:`BMFaceSeq`");
|
||||
static PyObject *bpy_bmfaceseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmfaceseq_get(BPy_BMesh *self, void * /*closure*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return BPy_BMFaceSeq_CreatePyObject(self->bm);
|
||||
@@ -200,7 +200,7 @@ PyDoc_STRVAR(bpy_bmloopseq_doc,
|
||||
".. note::\n"
|
||||
"\n"
|
||||
" Loops must be accessed via faces, this is only exposed for layer access.\n");
|
||||
static PyObject *bpy_bmloopseq_get(BPy_BMesh *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmloopseq_get(BPy_BMesh *self, void * /*closure*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return BPy_BMLoopSeq_CreatePyObject(self->bm);
|
||||
@@ -316,7 +316,7 @@ PyDoc_STRVAR(bpy_bmvert_co_doc,
|
||||
static PyObject *bpy_bmvert_co_get(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject_wrap(self->v->co, 3, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->v->co, 3, nullptr);
|
||||
}
|
||||
|
||||
static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value)
|
||||
@@ -336,7 +336,7 @@ PyDoc_STRVAR(
|
||||
static PyObject *bpy_bmvert_normal_get(BPy_BMVert *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject_wrap(self->v->no, 3, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->v->no, 3, nullptr);
|
||||
}
|
||||
|
||||
static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value)
|
||||
@@ -429,7 +429,7 @@ PyDoc_STRVAR(
|
||||
static PyObject *bpy_bmface_normal_get(BPy_BMFace *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return Vector_CreatePyObject_wrap(self->f->no, 3, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->f->no, 3, nullptr);
|
||||
}
|
||||
|
||||
static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value)
|
||||
@@ -562,7 +562,7 @@ static PyObject *bpy_bmelemseq_layers_get(BPy_BMElemSeq *self, void *htype)
|
||||
* ^^^^^^^ */
|
||||
|
||||
PyDoc_STRVAR(bpy_bmfaceseq_active_doc, "active face.\n\n:type: :class:`BMFace` or None");
|
||||
static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void * /*closure*/)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
@@ -574,11 +574,11 @@ static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(clos
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
if (value == Py_None) {
|
||||
bm->act_face = NULL;
|
||||
bm->act_face = nullptr;
|
||||
return 0;
|
||||
}
|
||||
if (BPy_BMFace_Check(value)) {
|
||||
@@ -595,31 +595,31 @@ static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNU
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmesh_getseters[] = {
|
||||
{"verts", (getter)bpy_bmvertseq_get, (setter)NULL, bpy_bmvertseq_doc, NULL},
|
||||
{"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, bpy_bmedgeseq_doc, NULL},
|
||||
{"faces", (getter)bpy_bmfaceseq_get, (setter)NULL, bpy_bmfaceseq_doc, NULL},
|
||||
{"loops", (getter)bpy_bmloopseq_get, (setter)NULL, bpy_bmloopseq_doc, NULL},
|
||||
{"verts", (getter)bpy_bmvertseq_get, (setter) nullptr, bpy_bmvertseq_doc, nullptr},
|
||||
{"edges", (getter)bpy_bmedgeseq_get, (setter) nullptr, bpy_bmedgeseq_doc, nullptr},
|
||||
{"faces", (getter)bpy_bmfaceseq_get, (setter) nullptr, bpy_bmfaceseq_doc, nullptr},
|
||||
{"loops", (getter)bpy_bmloopseq_get, (setter) nullptr, bpy_bmloopseq_doc, nullptr},
|
||||
{"select_mode",
|
||||
(getter)bpy_bmesh_select_mode_get,
|
||||
(setter)bpy_bmesh_select_mode_set,
|
||||
bpy_bmesh_select_mode_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"select_history",
|
||||
(getter)bpy_bmesh_select_history_get,
|
||||
(setter)bpy_bmesh_select_history_set,
|
||||
bpy_bmesh_select_history_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
/* readonly checks */
|
||||
{"is_wrapped",
|
||||
(getter)bpy_bmesh_is_wrapped_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmesh_is_wrapped_doc,
|
||||
NULL}, /* as with mathutils */
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, bpy_bm_is_valid_doc, NULL},
|
||||
nullptr}, /* as with mathutils */
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter) nullptr, bpy_bm_is_valid_doc, nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmvert_getseters[] = {
|
||||
@@ -643,47 +643,47 @@ static PyGetSetDef bpy_bmvert_getseters[] = {
|
||||
(getter)bpy_bm_elem_index_get,
|
||||
(setter)bpy_bm_elem_index_set,
|
||||
bpy_bm_elem_index_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"co", (getter)bpy_bmvert_co_get, (setter)bpy_bmvert_co_set, bpy_bmvert_co_doc, NULL},
|
||||
{"co", (getter)bpy_bmvert_co_get, (setter)bpy_bmvert_co_set, bpy_bmvert_co_doc, nullptr},
|
||||
{"normal",
|
||||
(getter)bpy_bmvert_normal_get,
|
||||
(setter)bpy_bmvert_normal_set,
|
||||
bpy_bmvert_normal_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
/* connectivity data */
|
||||
{"link_edges",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmvert_link_edges_doc,
|
||||
(void *)BM_EDGES_OF_VERT},
|
||||
{"link_faces",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmvert_link_faces_doc,
|
||||
(void *)BM_FACES_OF_VERT},
|
||||
{"link_loops",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmvert_link_loops_doc,
|
||||
(void *)BM_LOOPS_OF_VERT},
|
||||
|
||||
/* readonly checks */
|
||||
{"is_manifold",
|
||||
(getter)bpy_bmvert_is_manifold_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmvert_is_manifold_doc,
|
||||
NULL},
|
||||
{"is_wire", (getter)bpy_bmvert_is_wire_get, (setter)NULL, bpy_bmvert_is_wire_doc, NULL},
|
||||
nullptr},
|
||||
{"is_wire", (getter)bpy_bmvert_is_wire_get, (setter) nullptr, bpy_bmvert_is_wire_doc, nullptr},
|
||||
{"is_boundary",
|
||||
(getter)bpy_bmvert_is_boundary_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmvert_is_boundary_doc,
|
||||
NULL},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, bpy_bm_is_valid_doc, NULL},
|
||||
nullptr},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter) nullptr, bpy_bm_is_valid_doc, nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmedge_getseters[] = {
|
||||
@@ -707,7 +707,7 @@ static PyGetSetDef bpy_bmedge_getseters[] = {
|
||||
(getter)bpy_bm_elem_index_get,
|
||||
(setter)bpy_bm_elem_index_set,
|
||||
bpy_bm_elem_index_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"smooth",
|
||||
(getter)bpy_bm_elem_hflag_get,
|
||||
@@ -723,42 +723,46 @@ static PyGetSetDef bpy_bmedge_getseters[] = {
|
||||
/* connectivity data */
|
||||
{"verts",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_verts_doc,
|
||||
(void *)BM_VERTS_OF_EDGE},
|
||||
|
||||
{"link_faces",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_link_faces_doc,
|
||||
(void *)BM_FACES_OF_EDGE},
|
||||
{"link_loops",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_link_loops_doc,
|
||||
(void *)BM_LOOPS_OF_EDGE},
|
||||
|
||||
/* readonly checks */
|
||||
{"is_manifold",
|
||||
(getter)bpy_bmedge_is_manifold_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_is_manifold_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"is_contiguous",
|
||||
(getter)bpy_bmedge_is_contiguous_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_is_contiguous_doc,
|
||||
NULL},
|
||||
{"is_convex", (getter)bpy_bmedge_is_convex_get, (setter)NULL, bpy_bmedge_is_convex_doc, NULL},
|
||||
{"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, bpy_bmedge_is_wire_doc, NULL},
|
||||
nullptr},
|
||||
{"is_convex",
|
||||
(getter)bpy_bmedge_is_convex_get,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_is_convex_doc,
|
||||
nullptr},
|
||||
{"is_wire", (getter)bpy_bmedge_is_wire_get, (setter) nullptr, bpy_bmedge_is_wire_doc, nullptr},
|
||||
{"is_boundary",
|
||||
(getter)bpy_bmedge_is_boundary_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmedge_is_boundary_doc,
|
||||
NULL},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, bpy_bm_is_valid_doc, NULL},
|
||||
nullptr},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter) nullptr, bpy_bm_is_valid_doc, nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmface_getseters[] = {
|
||||
@@ -782,7 +786,7 @@ static PyGetSetDef bpy_bmface_getseters[] = {
|
||||
(getter)bpy_bm_elem_index_get,
|
||||
(setter)bpy_bm_elem_index_set,
|
||||
bpy_bm_elem_index_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"smooth",
|
||||
(getter)bpy_bm_elem_hflag_get,
|
||||
@@ -794,35 +798,35 @@ static PyGetSetDef bpy_bmface_getseters[] = {
|
||||
(getter)bpy_bmface_normal_get,
|
||||
(setter)bpy_bmface_normal_set,
|
||||
bpy_bmface_normal_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"material_index",
|
||||
(getter)bpy_bmface_material_index_get,
|
||||
(setter)bpy_bmface_material_index_set,
|
||||
bpy_bmface_material_index_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
/* connectivity data */
|
||||
{"verts",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmface_verts_doc,
|
||||
(void *)BM_VERTS_OF_FACE},
|
||||
{"edges",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmface_edges_doc,
|
||||
(void *)BM_EDGES_OF_FACE},
|
||||
{"loops",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmface_loops_doc,
|
||||
(void *)BM_LOOPS_OF_FACE},
|
||||
|
||||
/* readonly checks */
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, bpy_bm_is_valid_doc, NULL},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter) nullptr, bpy_bm_is_valid_doc, nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmloop_getseters[] = {
|
||||
@@ -849,66 +853,70 @@ static PyGetSetDef bpy_bmloop_getseters[] = {
|
||||
(getter)bpy_bm_elem_index_get,
|
||||
(setter)bpy_bm_elem_index_set,
|
||||
bpy_bm_elem_index_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{"vert", (getter)bpy_bmloop_vert_get, (setter)NULL, bpy_bmloop_vert_doc, NULL},
|
||||
{"edge", (getter)bpy_bmloop_edge_get, (setter)NULL, bpy_bmloop_edge_doc, NULL},
|
||||
{"face", (getter)bpy_bmloop_face_get, (setter)NULL, bpy_bmloop_face_doc, NULL},
|
||||
{"vert", (getter)bpy_bmloop_vert_get, (setter) nullptr, bpy_bmloop_vert_doc, nullptr},
|
||||
{"edge", (getter)bpy_bmloop_edge_get, (setter) nullptr, bpy_bmloop_edge_doc, nullptr},
|
||||
{"face", (getter)bpy_bmloop_face_get, (setter) nullptr, bpy_bmloop_face_doc, nullptr},
|
||||
|
||||
/* connectivity data */
|
||||
{"link_loops",
|
||||
(getter)bpy_bmelemseq_elem_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmloops_link_loops_doc,
|
||||
(void *)BM_LOOPS_OF_LOOP},
|
||||
{"link_loop_next",
|
||||
(getter)bpy_bmloop_link_loop_next_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmloop_link_loop_next_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"link_loop_prev",
|
||||
(getter)bpy_bmloop_link_loop_prev_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmloop_link_loop_prev_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"link_loop_radial_next",
|
||||
(getter)bpy_bmloop_link_loop_radial_next_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmloop_link_loop_radial_next_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"link_loop_radial_prev",
|
||||
(getter)bpy_bmloop_link_loop_radial_prev_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmloop_link_loop_radial_prev_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
/* readonly checks */
|
||||
{"is_convex", (getter)bpy_bmloop_is_convex_get, (setter)NULL, bpy_bmloop_is_convex_doc, NULL},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, bpy_bm_is_valid_doc, NULL},
|
||||
{"is_convex",
|
||||
(getter)bpy_bmloop_is_convex_get,
|
||||
(setter) nullptr,
|
||||
bpy_bmloop_is_convex_doc,
|
||||
nullptr},
|
||||
{"is_valid", (getter)bpy_bm_is_valid_get, (setter) nullptr, bpy_bm_is_valid_doc, nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmvertseq_getseters[] = {
|
||||
{"layers",
|
||||
(getter)bpy_bmelemseq_layers_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmelemseq_layers_vert_doc,
|
||||
(void *)BM_VERT},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
static PyGetSetDef bpy_bmedgeseq_getseters[] = {
|
||||
{"layers",
|
||||
(getter)bpy_bmelemseq_layers_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmelemseq_layers_edge_doc,
|
||||
(void *)BM_EDGE},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
static PyGetSetDef bpy_bmfaceseq_getseters[] = {
|
||||
{"layers",
|
||||
(getter)bpy_bmelemseq_layers_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmelemseq_layers_face_doc,
|
||||
(void *)BM_FACE},
|
||||
/* face only */
|
||||
@@ -916,16 +924,16 @@ static PyGetSetDef bpy_bmfaceseq_getseters[] = {
|
||||
(getter)bpy_bmfaceseq_active_get,
|
||||
(setter)bpy_bmfaceseq_active_set,
|
||||
bpy_bmfaceseq_active_doc,
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
static PyGetSetDef bpy_bmloopseq_getseters[] = {
|
||||
{"layers",
|
||||
(getter)bpy_bmelemseq_layers_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmelemseq_layers_loop_doc,
|
||||
(void *)BM_LOOP},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
/* Methods
|
||||
@@ -955,7 +963,7 @@ static PyObject *bpy_bmesh_copy(BPy_BMesh *self)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmesh_clear_doc,
|
||||
@@ -995,7 +1003,7 @@ static PyObject *bpy_bmesh_free(BPy_BMesh *self)
|
||||
|
||||
if (self->flag & BPY_BMFLAG_IS_WRAPPED) {
|
||||
/* Ensure further access doesn't return this invalid object, see: #105715. */
|
||||
bm->py_handle = NULL;
|
||||
bm->py_handle = nullptr;
|
||||
}
|
||||
else {
|
||||
BM_mesh_free(bm);
|
||||
@@ -1022,23 +1030,23 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:to_mesh", &py_mesh) || !(me = PyC_RNA_AsPointer(py_mesh, "Mesh")))
|
||||
if (!PyArg_ParseTuple(args, "O:to_mesh", &py_mesh) ||
|
||||
!(me = static_cast<Mesh *>(PyC_RNA_AsPointer(py_mesh, "Mesh"))))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* we could allow this but its almost certainly _not_ what script authors want */
|
||||
if (me->edit_mesh) {
|
||||
PyErr_Format(PyExc_ValueError, "to_mesh(): Mesh '%s' is in editmode", me->id.name + 2);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = self->bm;
|
||||
|
||||
struct Main *bmain = NULL;
|
||||
struct BMeshToMeshParams params = {
|
||||
.update_shapekey_indices = true,
|
||||
};
|
||||
struct Main *bmain = nullptr;
|
||||
BMeshToMeshParams params{};
|
||||
params.update_shapekey_indices = true;
|
||||
if (me->id.tag & LIB_TAG_NO_MAIN) {
|
||||
/* Mesh might be coming from a self-contained source like object.to_mesh(). No need to remap
|
||||
* anything in this case. */
|
||||
@@ -1076,7 +1084,7 @@ PyDoc_STRVAR(bpy_bmesh_from_object_doc,
|
||||
static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {
|
||||
"object", "depsgraph", "cage", "face_normals", "vertex_normals", NULL};
|
||||
"object", "depsgraph", "cage", "face_normals", "vertex_normals", nullptr};
|
||||
PyObject *py_object;
|
||||
PyObject *py_depsgraph;
|
||||
Object *ob, *ob_eval;
|
||||
@@ -1103,16 +1111,16 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
&use_fnorm,
|
||||
PyC_ParseBool,
|
||||
&use_vert_normal) ||
|
||||
!(ob = PyC_RNA_AsPointer(py_object, "Object")) ||
|
||||
!(depsgraph = PyC_RNA_AsPointer(py_depsgraph, "Depsgraph")))
|
||||
!(ob = static_cast<Object *>(PyC_RNA_AsPointer(py_object, "Object"))) ||
|
||||
!(depsgraph = static_cast<Depsgraph *>(PyC_RNA_AsPointer(py_depsgraph, "Depsgraph"))))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ob->type != OB_MESH) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"from_object(...): currently only mesh objects are supported");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const bool use_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER;
|
||||
@@ -1126,7 +1134,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"from_object(...): cage arg is unsupported when dependency graph "
|
||||
"evaluation mode is RENDER");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
me_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true, false);
|
||||
@@ -1141,24 +1149,22 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
}
|
||||
}
|
||||
|
||||
if (me_eval == NULL) {
|
||||
if (me_eval == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"from_object(...): Object '%s' has no usable mesh data",
|
||||
ob->id.name + 2);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = self->bm;
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
me_eval,
|
||||
(&(struct BMeshFromMeshParams){
|
||||
.calc_face_normal = use_fnorm,
|
||||
.calc_vert_normal = use_vert_normal,
|
||||
}));
|
||||
BMeshFromMeshParams params{};
|
||||
params.calc_face_normal = use_fnorm;
|
||||
params.calc_vert_normal = use_vert_normal;
|
||||
BM_mesh_bm_from_me(bm, me_eval, ¶ms);
|
||||
|
||||
if (need_free) {
|
||||
BKE_id_free(NULL, (Mesh *)me_eval);
|
||||
BKE_id_free(nullptr, (Mesh *)me_eval);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -1188,7 +1194,7 @@ PyDoc_STRVAR(
|
||||
static PyObject *bpy_bmesh_from_mesh(BPy_BMesh *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {
|
||||
"mesh", "face_normals", "vertex_normals", "use_shape_key", "shape_key_index", NULL};
|
||||
"mesh", "face_normals", "vertex_normals", "use_shape_key", "shape_key_index", nullptr};
|
||||
BMesh *bm;
|
||||
PyObject *py_mesh;
|
||||
Mesh *me;
|
||||
@@ -1211,21 +1217,19 @@ static PyObject *bpy_bmesh_from_mesh(BPy_BMesh *self, PyObject *args, PyObject *
|
||||
PyC_ParseBool,
|
||||
&use_shape_key,
|
||||
&shape_key_index) ||
|
||||
!(me = PyC_RNA_AsPointer(py_mesh, "Mesh")))
|
||||
!(me = static_cast<Mesh *>(PyC_RNA_AsPointer(py_mesh, "Mesh"))))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = self->bm;
|
||||
|
||||
BM_mesh_bm_from_me(bm,
|
||||
me,
|
||||
(&(struct BMeshFromMeshParams){
|
||||
.calc_face_normal = use_fnorm,
|
||||
.calc_vert_normal = use_vert_normal,
|
||||
.use_shapekey = use_shape_key,
|
||||
.active_shapekey = shape_key_index + 1,
|
||||
}));
|
||||
BMeshFromMeshParams params{};
|
||||
params.calc_face_normal = use_fnorm;
|
||||
params.calc_vert_normal = use_vert_normal;
|
||||
params.use_shapekey = use_shape_key;
|
||||
params.active_shapekey = shape_key_index + 1;
|
||||
BM_mesh_bm_from_me(bm, me, ¶ms);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -1257,7 +1261,7 @@ static PyObject *bpy_bmesh_select_flush(BPy_BMesh *self, PyObject *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if ((param = PyC_Long_AsBool(value)) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (param) {
|
||||
@@ -1301,10 +1305,10 @@ PyDoc_STRVAR(bpy_bmesh_transform_doc,
|
||||
" :type filter: set\n");
|
||||
static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"matrix", "filter", NULL};
|
||||
static const char *kwlist[] = {"matrix", "filter", nullptr};
|
||||
|
||||
MatrixObject *mat;
|
||||
PyObject *filter = NULL;
|
||||
PyObject *filter = nullptr;
|
||||
int filter_flags = 0;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
@@ -1312,7 +1316,7 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kw, "O!|$O!:transform", (char **)kwlist, &matrix_Type, &mat, &PySet_Type, &filter))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMVert *eve;
|
||||
@@ -1320,17 +1324,17 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
|
||||
void *mat_ptr;
|
||||
|
||||
if (BaseMath_ReadCallback(mat) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (mat->col_num != 4 || mat->row_num != 4) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (filter != NULL &&
|
||||
if (filter != nullptr &&
|
||||
PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mat_ptr = mat->matrix;
|
||||
@@ -1363,7 +1367,7 @@ PyDoc_STRVAR(bpy_bmesh_calc_volume_doc,
|
||||
" :rtype: float\n");
|
||||
static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"signed", NULL};
|
||||
static const char *kwlist[] = {"signed", nullptr};
|
||||
PyObject *is_signed = Py_False;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
@@ -1371,7 +1375,7 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kw, "|$O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
|
||||
@@ -1399,7 +1403,7 @@ static PyObject *bpy_bmesh_calc_loop_triangles(BPy_BMElem *self)
|
||||
bm = self->bm;
|
||||
|
||||
looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
|
||||
looptris = PyMem_MALLOC(sizeof(*looptris) * looptris_tot);
|
||||
looptris = static_cast<BMLoop *(*)[3]>(PyMem_MALLOC(sizeof(*looptris) * looptris_tot));
|
||||
|
||||
BM_mesh_calc_tessellation(bm, looptris);
|
||||
|
||||
@@ -1439,7 +1443,7 @@ static PyObject *bpy_bm_elem_select_set(BPy_BMElem *self, PyObject *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if ((param = PyC_Long_AsBool(value)) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_elem_select_set(self->bm, self->ele, param);
|
||||
@@ -1463,7 +1467,7 @@ static PyObject *bpy_bm_elem_hide_set(BPy_BMElem *self, PyObject *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if ((param = PyC_Long_AsBool(value)) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_elem_hide_set(self->bm, self->ele, param);
|
||||
@@ -1484,7 +1488,7 @@ static PyObject *bpy_bm_elem_copy_from(BPy_BMElem *self, BPy_BMElem *value)
|
||||
"expected element of type '%.200s' not '%.200s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (value->ele != self->ele) {
|
||||
@@ -1512,25 +1516,26 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Of:BMVert.copy_from_vert_interp", &vert_seq, &fac)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMVert **vert_array = NULL;
|
||||
BMVert **vert_array = nullptr;
|
||||
Py_ssize_t vert_seq_len; /* always 2 */
|
||||
|
||||
vert_array = BPy_BMElem_PySeq_As_Array(&bm,
|
||||
vert_seq,
|
||||
2,
|
||||
2,
|
||||
&vert_seq_len,
|
||||
BM_VERT,
|
||||
true,
|
||||
true,
|
||||
"BMVert.copy_from_vert_interp(...)");
|
||||
vert_array = static_cast<BMVert **>(
|
||||
BPy_BMElem_PySeq_As_Array(&bm,
|
||||
vert_seq,
|
||||
2,
|
||||
2,
|
||||
&vert_seq_len,
|
||||
BM_VERT,
|
||||
true,
|
||||
true,
|
||||
"BMVert.copy_from_vert_interp(...)"));
|
||||
|
||||
if (vert_array == NULL) {
|
||||
return NULL;
|
||||
if (vert_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, clamp_f(fac, 0.0f, 1.0f));
|
||||
@@ -1549,12 +1554,12 @@ PyDoc_STRVAR(bpy_bmvert_copy_from_face_interp_doc,
|
||||
" :type face: :class:`BMFace`\n");
|
||||
static PyObject *bpy_bmvert_copy_from_face_interp(BPy_BMVert *self, PyObject *args)
|
||||
{
|
||||
BPy_BMFace *py_face = NULL;
|
||||
BPy_BMFace *py_face = nullptr;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!:BMVert.copy_from_face_interp", &BPy_BMFace_Type, &py_face)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -1580,12 +1585,12 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
|
||||
{
|
||||
const float angle_invalid = -1.0f;
|
||||
float angle;
|
||||
PyObject *fallback = NULL;
|
||||
PyObject *fallback = nullptr;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O:calc_edge_angle", &fallback)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
angle = BM_vert_calc_edge_angle_ex(self->v, angle_invalid);
|
||||
@@ -1600,7 +1605,7 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMVert.calc_edge_angle(): "
|
||||
"vert must connect to exactly 2 edges");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
@@ -1666,12 +1671,12 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
|
||||
{
|
||||
const float angle_invalid = -1.0f;
|
||||
float angle;
|
||||
PyObject *fallback = NULL;
|
||||
PyObject *fallback = nullptr;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O:calc_face_angle", &fallback)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
angle = BM_edge_calc_face_angle_ex(self->e, angle_invalid);
|
||||
@@ -1686,7 +1691,7 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMEdge.calc_face_angle(): "
|
||||
"edge doesn't use 2 faces");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
@@ -1705,12 +1710,12 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
|
||||
{
|
||||
const float angle_invalid = -FLT_MAX;
|
||||
float angle;
|
||||
PyObject *fallback = NULL;
|
||||
PyObject *fallback = nullptr;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O:calc_face_angle_signed", &fallback)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
angle = BM_edge_calc_face_angle_signed_ex(self->e, angle_invalid);
|
||||
@@ -1725,7 +1730,7 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"BMEdge.calc_face_angle_signed(): "
|
||||
"edge doesn't use 2 faces");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(angle);
|
||||
@@ -1748,14 +1753,14 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!:BMEdge.calc_face_tangent", &BPy_BMLoop_Type, &py_loop)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(py_loop);
|
||||
/* no need to check if they are from the same mesh or even connected */
|
||||
BM_edge_calc_face_tangent(self->e, py_loop->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -1777,7 +1782,7 @@ static PyObject *bpy_bmedge_other_vert(BPy_BMEdge *self, BPy_BMVert *value)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"BMEdge.other_vert(vert): BMVert expected, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(self->bm, "BMEdge.other_vert(vert)", value);
|
||||
@@ -1825,7 +1830,7 @@ PyDoc_STRVAR(
|
||||
" :type vert: boolean\n");
|
||||
static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *args)
|
||||
{
|
||||
BPy_BMFace *py_face = NULL;
|
||||
BPy_BMFace *py_face = nullptr;
|
||||
bool do_vertex = true;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
@@ -1837,7 +1842,7 @@ static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *ar
|
||||
PyC_ParseBool,
|
||||
&do_vertex))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -1862,7 +1867,7 @@ PyDoc_STRVAR(bpy_bmface_copy_doc,
|
||||
" :rtype: :class:`BMFace`\n");
|
||||
static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"verts", "edges", NULL};
|
||||
static const char *kwlist[] = {"verts", "edges", nullptr};
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
bool do_verts = true;
|
||||
@@ -1880,7 +1885,7 @@ static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
|
||||
PyC_ParseBool,
|
||||
&do_edges))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
f_cpy = BM_face_copy(bm, bm, self->f, do_verts, do_edges);
|
||||
@@ -1890,7 +1895,7 @@ static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "BMFace.copy(): couldn't create the new face, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_area_doc,
|
||||
@@ -1932,7 +1937,7 @@ static PyObject *bpy_bmface_calc_tangent_edge(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_tangent_edge(self->f, tangent);
|
||||
return Vector_CreatePyObject(tangent, 3, NULL);
|
||||
return Vector_CreatePyObject(tangent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_tangent_edge_pair_doc,
|
||||
@@ -1952,7 +1957,7 @@ static PyObject *bpy_bmface_calc_tangent_edge_pair(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_tangent_edge_pair(self->f, tangent);
|
||||
return Vector_CreatePyObject(tangent, 3, NULL);
|
||||
return Vector_CreatePyObject(tangent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_tangent_edge_diagonal_doc,
|
||||
@@ -1968,7 +1973,7 @@ static PyObject *bpy_bmface_calc_tangent_edge_diagonal(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_tangent_edge_diagonal(self->f, tangent);
|
||||
return Vector_CreatePyObject(tangent, 3, NULL);
|
||||
return Vector_CreatePyObject(tangent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_tangent_vert_diagonal_doc,
|
||||
@@ -1984,7 +1989,7 @@ static PyObject *bpy_bmface_calc_tangent_vert_diagonal(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_tangent_vert_diagonal(self->f, tangent);
|
||||
return Vector_CreatePyObject(tangent, 3, NULL);
|
||||
return Vector_CreatePyObject(tangent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_center_median_doc,
|
||||
@@ -2000,7 +2005,7 @@ static PyObject *bpy_bmface_calc_center_mean(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_median(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_center_median_weighted_doc,
|
||||
@@ -2016,7 +2021,7 @@ static PyObject *bpy_bmface_calc_center_median_weighted(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_median_weighted(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_calc_center_bounds_doc,
|
||||
@@ -2032,7 +2037,7 @@ static PyObject *bpy_bmface_calc_center_bounds(BPy_BMFace *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_face_calc_center_bounds(self->f, cent);
|
||||
return Vector_CreatePyObject(cent, 3, NULL);
|
||||
return Vector_CreatePyObject(cent, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmface_normal_update_doc,
|
||||
@@ -2079,7 +2084,7 @@ PyDoc_STRVAR(bpy_bmloop_copy_from_face_interp_doc,
|
||||
" :type multires: boolean\n");
|
||||
static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *args)
|
||||
{
|
||||
BPy_BMFace *py_face = NULL;
|
||||
BPy_BMFace *py_face = nullptr;
|
||||
bool do_vertex = true;
|
||||
bool do_multires = true;
|
||||
|
||||
@@ -2094,7 +2099,7 @@ static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *ar
|
||||
PyC_ParseBool,
|
||||
&do_multires))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -2133,7 +2138,7 @@ static PyObject *bpy_bmloop_calc_normal(BPy_BMLoop *self)
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_calc_face_normal(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -2150,7 +2155,7 @@ static PyObject *bpy_bmloop_calc_tangent(BPy_BMLoop *self)
|
||||
float vec[3];
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
BM_loop_calc_face_tangent(self->l, vec);
|
||||
return Vector_CreatePyObject(vec, 3, NULL);
|
||||
return Vector_CreatePyObject(vec, 3, nullptr);
|
||||
}
|
||||
|
||||
/* Vert Seq
|
||||
@@ -2168,13 +2173,13 @@ PyDoc_STRVAR(bpy_bmvertseq_new_doc,
|
||||
" :rtype: :class:`BMVert`\n");
|
||||
static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_co = NULL;
|
||||
BPy_BMVert *py_vert_example = NULL; /* optional */
|
||||
PyObject *py_co = nullptr;
|
||||
BPy_BMVert *py_vert_example = nullptr; /* optional */
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|OO!:verts.new", &py_co, &BPy_BMVert_Type, &py_vert_example)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -2186,15 +2191,15 @@ static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (py_co && mathutils_array_parse(co, 3, 3, py_co, "verts.new(co)") == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v = BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
|
||||
v = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP);
|
||||
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"faces.new(verts): couldn't create the new face, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (py_vert_example) {
|
||||
@@ -2220,29 +2225,29 @@ PyDoc_STRVAR(bpy_bmedgeseq_new_doc,
|
||||
static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
{
|
||||
PyObject *vert_seq;
|
||||
BPy_BMEdge *py_edge_example = NULL; /* optional */
|
||||
BPy_BMEdge *py_edge_example = nullptr; /* optional */
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O!:edges.new", &vert_seq, &BPy_BMEdge_Type, &py_edge_example)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMEdge *e;
|
||||
BMVert **vert_array = NULL;
|
||||
BMVert **vert_array = nullptr;
|
||||
Py_ssize_t vert_seq_len; /* always 2 */
|
||||
PyObject *ret = NULL;
|
||||
PyObject *ret = nullptr;
|
||||
|
||||
if (py_edge_example) {
|
||||
BPY_BM_CHECK_OBJ(py_edge_example);
|
||||
}
|
||||
|
||||
vert_array = BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.new(...)");
|
||||
vert_array = static_cast<BMVert **>(BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.new(...)"));
|
||||
|
||||
if (vert_array == NULL) {
|
||||
return NULL;
|
||||
if (vert_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BM_edge_exists(vert_array[0], vert_array[1])) {
|
||||
@@ -2250,9 +2255,9 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
e = BM_edge_create(bm, vert_array[0], vert_array[1], NULL, BM_CREATE_NOP);
|
||||
e = BM_edge_create(bm, vert_array[0], vert_array[1], nullptr, BM_CREATE_NOP);
|
||||
|
||||
if (e == NULL) {
|
||||
if (e == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"faces.new(verts): couldn't create the new face, internal error");
|
||||
goto cleanup;
|
||||
@@ -2287,20 +2292,20 @@ PyDoc_STRVAR(bpy_bmfaceseq_new_doc,
|
||||
static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
{
|
||||
PyObject *vert_seq;
|
||||
BPy_BMFace *py_face_example = NULL; /* optional */
|
||||
BPy_BMFace *py_face_example = nullptr; /* optional */
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O!:faces.new", &vert_seq, &BPy_BMFace_Type, &py_face_example)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
Py_ssize_t vert_seq_len;
|
||||
|
||||
BMVert **vert_array = NULL;
|
||||
BMVert **vert_array = nullptr;
|
||||
|
||||
PyObject *ret = NULL;
|
||||
PyObject *ret = nullptr;
|
||||
|
||||
BMFace *f_new;
|
||||
|
||||
@@ -2308,15 +2313,15 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
BPY_BM_CHECK_OBJ(py_face_example);
|
||||
}
|
||||
|
||||
vert_array = BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 3, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.new(...)");
|
||||
vert_array = static_cast<BMVert **>(BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 3, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.new(...)"));
|
||||
|
||||
if (vert_array == NULL) {
|
||||
return NULL;
|
||||
if (vert_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* check if the face exists */
|
||||
if (BM_face_exists(vert_array, vert_seq_len) != NULL) {
|
||||
if (BM_face_exists(vert_array, vert_seq_len) != nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "faces.new(verts): face already exists");
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -2327,11 +2332,11 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
f_new = BM_face_create_verts(bm,
|
||||
vert_array,
|
||||
vert_seq_len,
|
||||
py_face_example ? py_face_example->f : NULL,
|
||||
py_face_example ? py_face_example->f : nullptr,
|
||||
BM_CREATE_NOP,
|
||||
true);
|
||||
|
||||
if (UNLIKELY(f_new == NULL)) {
|
||||
if (UNLIKELY(f_new == nullptr)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"faces.new(verts): couldn't create the new face, internal error");
|
||||
goto cleanup;
|
||||
@@ -2339,7 +2344,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
|
||||
ret = BPy_BMFace_CreatePyObject(bm, f_new);
|
||||
|
||||
/* pass through */
|
||||
/* pass through */
|
||||
cleanup:
|
||||
if (vert_array) {
|
||||
PyMem_FREE(vert_array);
|
||||
@@ -2359,7 +2364,7 @@ static PyObject *bpy_bmvertseq_remove(BPy_BMElemSeq *self, BPy_BMVert *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!BPy_BMVert_Check(value)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -2381,7 +2386,7 @@ static PyObject *bpy_bmedgeseq_remove(BPy_BMElemSeq *self, BPy_BMEdge *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!BPy_BMEdge_Check(value)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -2403,7 +2408,7 @@ static PyObject *bpy_bmfaceseq_remove(BPy_BMElemSeq *self, BPy_BMFace *value)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!BPy_BMFace_Check(value)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
@@ -2434,20 +2439,20 @@ static PyObject *bpy_bmedgeseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O:edges.get", &vert_seq, &fallback)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMEdge *e;
|
||||
BMVert **vert_array = NULL;
|
||||
BMVert **vert_array = nullptr;
|
||||
Py_ssize_t vert_seq_len; /* always 2 */
|
||||
PyObject *ret = NULL;
|
||||
PyObject *ret = nullptr;
|
||||
|
||||
vert_array = BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.get(...)");
|
||||
vert_array = static_cast<BMVert **>(BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.get(...)"));
|
||||
|
||||
if (vert_array == NULL) {
|
||||
return NULL;
|
||||
if (vert_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((e = BM_edge_exists(vert_array[0], vert_array[1]))) {
|
||||
@@ -2480,24 +2485,24 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O:faces.get", &vert_seq, &fallback)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
BMFace *f = NULL;
|
||||
BMVert **vert_array = NULL;
|
||||
BMFace *f = nullptr;
|
||||
BMVert **vert_array = nullptr;
|
||||
Py_ssize_t vert_seq_len;
|
||||
PyObject *ret = NULL;
|
||||
PyObject *ret = nullptr;
|
||||
|
||||
vert_array = BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 1, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.get(...)");
|
||||
vert_array = static_cast<BMVert **>(BPy_BMElem_PySeq_As_Array(
|
||||
&bm, vert_seq, 1, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.get(...)"));
|
||||
|
||||
if (vert_array == NULL) {
|
||||
return NULL;
|
||||
if (vert_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
f = BM_face_exists(vert_array, vert_seq_len);
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
ret = BPy_BMFace_CreatePyObject(bm, f);
|
||||
}
|
||||
else {
|
||||
@@ -2622,7 +2627,7 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v,
|
||||
const void *index2_v,
|
||||
void *keys_v)
|
||||
{
|
||||
const double *keys = keys_v;
|
||||
const double *keys = static_cast<const double *>(keys_v);
|
||||
const int *index1 = (int *)index1_v;
|
||||
const int *index2 = (int *)index2_v;
|
||||
|
||||
@@ -2645,9 +2650,9 @@ static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v,
|
||||
|
||||
static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"key", "reverse", NULL};
|
||||
PyObject *keyfunc = NULL; /* optional */
|
||||
bool do_reverse = false; /* optional */
|
||||
static const char *kwlist[] = {"key", "reverse", nullptr};
|
||||
PyObject *keyfunc = nullptr; /* optional */
|
||||
bool do_reverse = false; /* optional */
|
||||
|
||||
const char htype = bm_iter_itype_htype_map[self->itype];
|
||||
int n_elem;
|
||||
@@ -2660,16 +2665,16 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
uint *elem_map_idx;
|
||||
int (*elem_idx_compare_by_keys)(const void *, const void *, void *);
|
||||
|
||||
uint *vert_idx = NULL;
|
||||
uint *edge_idx = NULL;
|
||||
uint *face_idx = NULL;
|
||||
uint *vert_idx = nullptr;
|
||||
uint *edge_idx = nullptr;
|
||||
uint *face_idx = nullptr;
|
||||
int i;
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (args != NULL) {
|
||||
if (args != nullptr) {
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
kw,
|
||||
"|$OO&:BMElemSeq.sort",
|
||||
@@ -2678,13 +2683,13 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
PyC_ParseBool,
|
||||
&do_reverse))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (keyfunc != NULL && !PyCallable_Check(keyfunc)) {
|
||||
if (keyfunc != nullptr && !PyCallable_Check(keyfunc)) {
|
||||
PyErr_SetString(PyExc_TypeError, "the 'key' argument is not a callable object");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
n_elem = BM_mesh_elem_count(bm, htype);
|
||||
@@ -2693,26 +2698,26 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
keys = PyMem_MALLOC(sizeof(*keys) * n_elem);
|
||||
if (keys == NULL) {
|
||||
keys = static_cast<double *>(PyMem_MALLOC(sizeof(*keys) * n_elem));
|
||||
if (keys == nullptr) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
|
||||
if (keyfunc != NULL) {
|
||||
if (keyfunc != nullptr) {
|
||||
PyObject *py_elem;
|
||||
PyObject *index;
|
||||
|
||||
py_elem = BPy_BMElem_CreatePyObject(self->bm, (BMHeader *)ele);
|
||||
index = PyObject_CallFunctionObjArgs(keyfunc, py_elem, NULL);
|
||||
index = PyObject_CallFunctionObjArgs(keyfunc, py_elem, nullptr);
|
||||
Py_DECREF(py_elem);
|
||||
if (index == NULL) {
|
||||
if (index == nullptr) {
|
||||
/* No need to set the exception here,
|
||||
* PyObject_CallFunctionObjArgs() does that */
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((keys[i] = PyFloat_AsDouble(index)) == -1 && PyErr_Occurred()) {
|
||||
@@ -2720,7 +2725,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
"the value returned by the 'key' function is not a number");
|
||||
Py_DECREF(index);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_DECREF(index);
|
||||
@@ -2734,11 +2739,11 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
i++;
|
||||
}
|
||||
|
||||
elem_idx = PyMem_MALLOC(sizeof(*elem_idx) * n_elem);
|
||||
if (elem_idx == NULL) {
|
||||
elem_idx = static_cast<int *>(PyMem_MALLOC(sizeof(*elem_idx) * n_elem));
|
||||
if (elem_idx == nullptr) {
|
||||
PyErr_NoMemory();
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Initialize the element index array */
|
||||
@@ -2754,12 +2759,12 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
|
||||
BLI_qsort_r(elem_idx, n_elem, sizeof(*elem_idx), elem_idx_compare_by_keys, keys);
|
||||
|
||||
elem_map_idx = PyMem_MALLOC(sizeof(*elem_map_idx) * n_elem);
|
||||
if (elem_map_idx == NULL) {
|
||||
elem_map_idx = static_cast<uint *>(PyMem_MALLOC(sizeof(*elem_map_idx) * n_elem));
|
||||
if (elem_map_idx == nullptr) {
|
||||
PyErr_NoMemory();
|
||||
PyMem_FREE(elem_idx);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Initialize the map array
|
||||
@@ -2786,7 +2791,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
|
||||
PyMem_FREE(elem_map_idx);
|
||||
PyMem_FREE(elem_idx);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_mesh_remap(bm, vert_idx, edge_idx, face_idx);
|
||||
@@ -2839,7 +2844,7 @@ static PyMethodDef bpy_bmesh_methods[] = {
|
||||
(PyCFunction)bpy_bmesh_calc_loop_triangles,
|
||||
METH_NOARGS,
|
||||
bpy_bmesh_calc_loop_triangles_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmvert_methods[] = {
|
||||
@@ -2869,7 +2874,7 @@ static PyMethodDef bpy_bmvert_methods[] = {
|
||||
METH_NOARGS,
|
||||
bpy_bmvert_normal_update_doc},
|
||||
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmedge_methods[] = {
|
||||
@@ -2898,7 +2903,7 @@ static PyMethodDef bpy_bmedge_methods[] = {
|
||||
METH_NOARGS,
|
||||
bpy_bmedge_normal_update_doc},
|
||||
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmface_methods[] = {
|
||||
@@ -2953,7 +2958,7 @@ static PyMethodDef bpy_bmface_methods[] = {
|
||||
bpy_bmface_normal_update_doc},
|
||||
{"normal_flip", (PyCFunction)bpy_bmface_normal_flip, METH_NOARGS, bpy_bmface_normal_flip_doc},
|
||||
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmloop_methods[] = {
|
||||
@@ -2969,7 +2974,7 @@ static PyMethodDef bpy_bmloop_methods[] = {
|
||||
(PyCFunction)bpy_bmloop_calc_tangent,
|
||||
METH_NOARGS,
|
||||
bpy_bmloop_calc_tangent_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmelemseq_methods[] = {
|
||||
@@ -2978,7 +2983,7 @@ static PyMethodDef bpy_bmelemseq_methods[] = {
|
||||
(PyCFunction)bpy_bmelemseq_index_update,
|
||||
METH_NOARGS,
|
||||
bpy_bmelemseq_index_update_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmvertseq_methods[] = {
|
||||
@@ -2998,7 +3003,7 @@ static PyMethodDef bpy_bmvertseq_methods[] = {
|
||||
(PyCFunction)bpy_bmelemseq_sort,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmedgeseq_methods[] = {
|
||||
@@ -3020,7 +3025,7 @@ static PyMethodDef bpy_bmedgeseq_methods[] = {
|
||||
(PyCFunction)bpy_bmelemseq_sort,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmfaceseq_methods[] = {
|
||||
@@ -3042,14 +3047,14 @@ static PyMethodDef bpy_bmfaceseq_methods[] = {
|
||||
(PyCFunction)bpy_bmelemseq_sort,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmloopseq_methods[] = {
|
||||
/* odd function, initializes index values */
|
||||
/* no: index_update() function since we can't iterate over loops */
|
||||
/* no: sort() function since we can't iterate over loops */
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
/* Sequences
|
||||
@@ -3085,7 +3090,7 @@ static PyTypeObject *bpy_bm_itype_as_pytype(const char itype)
|
||||
return &BPy_BMLoop_Type;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static Py_ssize_t bpy_bmelemseq_length(BPy_BMElemSeq *self)
|
||||
@@ -3102,7 +3107,7 @@ static Py_ssize_t bpy_bmelemseq_length(BPy_BMElemSeq *self)
|
||||
case BM_FACES_OF_MESH:
|
||||
return self->bm->totface;
|
||||
|
||||
/* sub-types */
|
||||
/* sub-types */
|
||||
case BM_VERTS_OF_FACE:
|
||||
case BM_EDGES_OF_FACE:
|
||||
case BM_LOOPS_OF_FACE:
|
||||
@@ -3141,7 +3146,7 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, Py_ssize_t key
|
||||
if (keynum >= 0) {
|
||||
if (self->itype <= BM_FACES_OF_MESH) {
|
||||
if ((self->bm->elem_table_dirty & bm_iter_itype_htype_map[self->itype]) == 0) {
|
||||
BMHeader *ele = NULL;
|
||||
BMHeader *ele = nullptr;
|
||||
switch (self->itype) {
|
||||
case BM_VERTS_OF_MESH:
|
||||
if (keynum < self->bm->totvert) {
|
||||
@@ -3168,12 +3173,12 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, Py_ssize_t key
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"BMElemSeq[index]: outdated internal index table, "
|
||||
"run ensure_lookup_table() first");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BMHeader *ele = BM_iter_at_index(
|
||||
self->bm, self->itype, self->py_ele ? self->py_ele->ele : NULL, keynum);
|
||||
BMHeader *ele = static_cast<BMHeader *>(BM_iter_at_index(
|
||||
self->bm, self->itype, self->py_ele ? self->py_ele->ele : nullptr, keynum));
|
||||
if (ele) {
|
||||
return BPy_BMElem_CreatePyObject(self->bm, ele);
|
||||
}
|
||||
@@ -3181,7 +3186,7 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, Py_ssize_t key
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_IndexError, "BMElemSeq[index]: index %d out of range", keynum);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmelemseq_subscript_slice(BPy_BMElemSeq *self,
|
||||
@@ -3199,7 +3204,7 @@ static PyObject *bpy_bmelemseq_subscript_slice(BPy_BMElemSeq *self,
|
||||
|
||||
list = PyList_New(0);
|
||||
|
||||
ok = BM_iter_init(&iter, self->bm, self->itype, self->py_ele ? self->py_ele->ele : NULL);
|
||||
ok = BM_iter_init(&iter, self->bm, self->itype, self->py_ele ? self->py_ele->ele : nullptr);
|
||||
|
||||
BLI_assert(ok == true);
|
||||
|
||||
@@ -3208,7 +3213,7 @@ static PyObject *bpy_bmelemseq_subscript_slice(BPy_BMElemSeq *self,
|
||||
}
|
||||
|
||||
/* first loop up-until the start */
|
||||
for (ok = true; ok; ok = (BM_iter_step(&iter) != NULL)) {
|
||||
for (ok = true; ok; ok = (BM_iter_step(&iter) != nullptr)) {
|
||||
if (count == start) {
|
||||
break;
|
||||
}
|
||||
@@ -3216,7 +3221,7 @@ static PyObject *bpy_bmelemseq_subscript_slice(BPy_BMElemSeq *self,
|
||||
}
|
||||
|
||||
/* add items until stop */
|
||||
while ((ele = BM_iter_step(&iter))) {
|
||||
while ((ele = static_cast<BMHeader *>(BM_iter_step(&iter)))) {
|
||||
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, ele));
|
||||
|
||||
count++;
|
||||
@@ -3234,7 +3239,7 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
||||
if (PyIndex_Check(key)) {
|
||||
const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return bpy_bmelemseq_subscript_int(self, i);
|
||||
}
|
||||
@@ -3243,11 +3248,11 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmelemseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
@@ -3257,10 +3262,10 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (start < 0 || stop < 0) {
|
||||
@@ -3284,7 +3289,7 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int bpy_bmelemseq_contains(BPy_BMElemSeq *self, PyObject *value)
|
||||
@@ -3326,27 +3331,27 @@ static int bpy_bmelem_ass_subscript(BPy_BMElem *self, BPy_BMLayerItem *key, PyOb
|
||||
|
||||
static PySequenceMethods bpy_bmelemseq_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)bpy_bmelemseq_length,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/* Only set this so `PySequence_Check()` returns True. */
|
||||
/*sq_item*/ (ssizeargfunc)bpy_bmelemseq_subscript_int,
|
||||
/*was_sq_slice*/ NULL,
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL,
|
||||
/*was_sq_slice*/ nullptr,
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr,
|
||||
/*sq_contains*/ (objobjproc)bpy_bmelemseq_contains,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods bpy_bmelemseq_as_mapping = {
|
||||
/*mp_length*/ (lenfunc)bpy_bmelemseq_length,
|
||||
/*mp_subscript*/ (binaryfunc)bpy_bmelemseq_subscript,
|
||||
/*mp_ass_subscript*/ (objobjargproc)NULL,
|
||||
/*mp_ass_subscript*/ (objobjargproc) nullptr,
|
||||
};
|
||||
|
||||
/* for customdata access */
|
||||
static PyMappingMethods bpy_bm_elem_as_mapping = {
|
||||
/*mp_length*/ (lenfunc)NULL, /* Keep this empty, messes up `if elem: ...` test. */
|
||||
/*mp_length*/ (lenfunc) nullptr, /* Keep this empty, messes up `if elem: ...` test. */
|
||||
/*mp_subscript*/ (binaryfunc)bpy_bmelem_subscript,
|
||||
/*mp_ass_subscript*/ (objobjargproc)bpy_bmelem_ass_subscript,
|
||||
};
|
||||
@@ -3360,16 +3365,17 @@ static PyObject *bpy_bmelemseq_iter(BPy_BMElemSeq *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
py_iter = (BPy_BMIter *)BPy_BMIter_CreatePyObject(self->bm);
|
||||
BM_iter_init(&(py_iter->iter), self->bm, self->itype, self->py_ele ? self->py_ele->ele : NULL);
|
||||
BM_iter_init(
|
||||
&(py_iter->iter), self->bm, self->itype, self->py_ele ? self->py_ele->ele : nullptr);
|
||||
return (PyObject *)py_iter;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmiter_next(BPy_BMIter *self)
|
||||
{
|
||||
BMHeader *ele = BM_iter_step(&self->iter);
|
||||
if (ele == NULL) {
|
||||
BMHeader *ele = static_cast<BMHeader *>(BM_iter_step(&self->iter));
|
||||
if (ele == nullptr) {
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, ele);
|
||||
@@ -3399,7 +3405,7 @@ static void bpy_bmesh_dealloc(BPy_BMesh *self)
|
||||
BM_data_layer_free(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
|
||||
}
|
||||
|
||||
bm->py_handle = NULL;
|
||||
bm->py_handle = nullptr;
|
||||
|
||||
if ((self->flag & BPY_BMFLAG_IS_WRAPPED) == 0) {
|
||||
BM_mesh_free(bm);
|
||||
@@ -3413,9 +3419,10 @@ static void bpy_bmvert_dealloc(BPy_BMElem *self)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
if (bm) {
|
||||
void **ptr = CustomData_bmesh_get(&bm->vdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->vdata, self->ele->head.data, CD_BM_ELEM_PYPTR));
|
||||
if (ptr) {
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
PyObject_DEL(self);
|
||||
@@ -3425,9 +3432,10 @@ static void bpy_bmedge_dealloc(BPy_BMElem *self)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
if (bm) {
|
||||
void **ptr = CustomData_bmesh_get(&bm->edata, self->ele->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->edata, self->ele->head.data, CD_BM_ELEM_PYPTR));
|
||||
if (ptr) {
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
PyObject_DEL(self);
|
||||
@@ -3437,9 +3445,10 @@ static void bpy_bmface_dealloc(BPy_BMElem *self)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
if (bm) {
|
||||
void **ptr = CustomData_bmesh_get(&bm->pdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->pdata, self->ele->head.data, CD_BM_ELEM_PYPTR));
|
||||
if (ptr) {
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
PyObject_DEL(self);
|
||||
@@ -3449,9 +3458,10 @@ static void bpy_bmloop_dealloc(BPy_BMElem *self)
|
||||
{
|
||||
BMesh *bm = self->bm;
|
||||
if (bm) {
|
||||
void **ptr = CustomData_bmesh_get(&bm->ldata, self->ele->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->ldata, self->ele->head.data, CD_BM_ELEM_PYPTR));
|
||||
if (ptr) {
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
PyObject_DEL(self);
|
||||
@@ -3621,10 +3631,10 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMFace_Type.tp_doc = bpy_bmface_doc;
|
||||
BPy_BMLoop_Type.tp_doc = bpy_bmloop_doc;
|
||||
BPy_BMElemSeq_Type.tp_doc = bpy_bmelemseq_doc;
|
||||
BPy_BMVertSeq_Type.tp_doc = NULL;
|
||||
BPy_BMEdgeSeq_Type.tp_doc = NULL;
|
||||
BPy_BMFaceSeq_Type.tp_doc = NULL;
|
||||
BPy_BMLoopSeq_Type.tp_doc = NULL;
|
||||
BPy_BMVertSeq_Type.tp_doc = nullptr;
|
||||
BPy_BMEdgeSeq_Type.tp_doc = nullptr;
|
||||
BPy_BMFaceSeq_Type.tp_doc = nullptr;
|
||||
BPy_BMLoopSeq_Type.tp_doc = nullptr;
|
||||
BPy_BMIter_Type.tp_doc = bpy_bmiter_doc;
|
||||
|
||||
BPy_BMesh_Type.tp_repr = (reprfunc)bpy_bmesh_repr;
|
||||
@@ -3632,24 +3642,24 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMEdge_Type.tp_repr = (reprfunc)bpy_bmedge_repr;
|
||||
BPy_BMFace_Type.tp_repr = (reprfunc)bpy_bmface_repr;
|
||||
BPy_BMLoop_Type.tp_repr = (reprfunc)bpy_bmloop_repr;
|
||||
BPy_BMElemSeq_Type.tp_repr = NULL;
|
||||
BPy_BMVertSeq_Type.tp_repr = NULL;
|
||||
BPy_BMEdgeSeq_Type.tp_repr = NULL;
|
||||
BPy_BMFaceSeq_Type.tp_repr = NULL;
|
||||
BPy_BMLoopSeq_Type.tp_repr = NULL;
|
||||
BPy_BMIter_Type.tp_repr = NULL;
|
||||
BPy_BMElemSeq_Type.tp_repr = nullptr;
|
||||
BPy_BMVertSeq_Type.tp_repr = nullptr;
|
||||
BPy_BMEdgeSeq_Type.tp_repr = nullptr;
|
||||
BPy_BMFaceSeq_Type.tp_repr = nullptr;
|
||||
BPy_BMLoopSeq_Type.tp_repr = nullptr;
|
||||
BPy_BMIter_Type.tp_repr = nullptr;
|
||||
|
||||
BPy_BMesh_Type.tp_getset = bpy_bmesh_getseters;
|
||||
BPy_BMVert_Type.tp_getset = bpy_bmvert_getseters;
|
||||
BPy_BMEdge_Type.tp_getset = bpy_bmedge_getseters;
|
||||
BPy_BMFace_Type.tp_getset = bpy_bmface_getseters;
|
||||
BPy_BMLoop_Type.tp_getset = bpy_bmloop_getseters;
|
||||
BPy_BMElemSeq_Type.tp_getset = NULL;
|
||||
BPy_BMElemSeq_Type.tp_getset = nullptr;
|
||||
BPy_BMVertSeq_Type.tp_getset = bpy_bmvertseq_getseters;
|
||||
BPy_BMEdgeSeq_Type.tp_getset = bpy_bmedgeseq_getseters;
|
||||
BPy_BMFaceSeq_Type.tp_getset = bpy_bmfaceseq_getseters;
|
||||
BPy_BMLoopSeq_Type.tp_getset = bpy_bmloopseq_getseters;
|
||||
BPy_BMIter_Type.tp_getset = NULL;
|
||||
BPy_BMIter_Type.tp_getset = nullptr;
|
||||
|
||||
BPy_BMesh_Type.tp_methods = bpy_bmesh_methods;
|
||||
BPy_BMVert_Type.tp_methods = bpy_bmvert_methods;
|
||||
@@ -3661,7 +3671,7 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMEdgeSeq_Type.tp_methods = bpy_bmedgeseq_methods;
|
||||
BPy_BMFaceSeq_Type.tp_methods = bpy_bmfaceseq_methods;
|
||||
BPy_BMLoopSeq_Type.tp_methods = bpy_bmloopseq_methods;
|
||||
BPy_BMIter_Type.tp_methods = NULL;
|
||||
BPy_BMIter_Type.tp_methods = nullptr;
|
||||
|
||||
/* #BPy_BMElem_Check() uses #bpy_bm_elem_hash() to check types.
|
||||
* if this changes update the macro. */
|
||||
@@ -3670,24 +3680,25 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMEdge_Type.tp_hash = bpy_bm_elem_hash;
|
||||
BPy_BMFace_Type.tp_hash = bpy_bm_elem_hash;
|
||||
BPy_BMLoop_Type.tp_hash = bpy_bm_elem_hash;
|
||||
BPy_BMElemSeq_Type.tp_hash = NULL;
|
||||
BPy_BMVertSeq_Type.tp_hash = NULL;
|
||||
BPy_BMEdgeSeq_Type.tp_hash = NULL;
|
||||
BPy_BMFaceSeq_Type.tp_hash = NULL;
|
||||
BPy_BMLoopSeq_Type.tp_hash = NULL;
|
||||
BPy_BMIter_Type.tp_hash = NULL;
|
||||
BPy_BMElemSeq_Type.tp_hash = nullptr;
|
||||
BPy_BMVertSeq_Type.tp_hash = nullptr;
|
||||
BPy_BMEdgeSeq_Type.tp_hash = nullptr;
|
||||
BPy_BMFaceSeq_Type.tp_hash = nullptr;
|
||||
BPy_BMLoopSeq_Type.tp_hash = nullptr;
|
||||
BPy_BMIter_Type.tp_hash = nullptr;
|
||||
|
||||
BPy_BMElemSeq_Type.tp_as_sequence = &bpy_bmelemseq_as_sequence;
|
||||
BPy_BMVertSeq_Type.tp_as_sequence = &bpy_bmelemseq_as_sequence;
|
||||
BPy_BMEdgeSeq_Type.tp_as_sequence = &bpy_bmelemseq_as_sequence;
|
||||
BPy_BMFaceSeq_Type.tp_as_sequence = &bpy_bmelemseq_as_sequence;
|
||||
BPy_BMLoopSeq_Type.tp_as_sequence = NULL; /* this is not a seq really, only for layer access */
|
||||
BPy_BMLoopSeq_Type.tp_as_sequence =
|
||||
nullptr; /* this is not a seq really, only for layer access */
|
||||
|
||||
BPy_BMElemSeq_Type.tp_as_mapping = &bpy_bmelemseq_as_mapping;
|
||||
BPy_BMVertSeq_Type.tp_as_mapping = &bpy_bmelemseq_as_mapping;
|
||||
BPy_BMEdgeSeq_Type.tp_as_mapping = &bpy_bmelemseq_as_mapping;
|
||||
BPy_BMFaceSeq_Type.tp_as_mapping = &bpy_bmelemseq_as_mapping;
|
||||
BPy_BMLoopSeq_Type.tp_as_mapping = NULL; /* this is not a seq really, only for layer access */
|
||||
BPy_BMLoopSeq_Type.tp_as_mapping = nullptr; /* this is not a seq really, only for layer access */
|
||||
|
||||
/* layer access */
|
||||
BPy_BMVert_Type.tp_as_mapping = &bpy_bm_elem_as_mapping;
|
||||
@@ -3699,7 +3710,7 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMVertSeq_Type.tp_iter = (getiterfunc)bpy_bmelemseq_iter;
|
||||
BPy_BMEdgeSeq_Type.tp_iter = (getiterfunc)bpy_bmelemseq_iter;
|
||||
BPy_BMFaceSeq_Type.tp_iter = (getiterfunc)bpy_bmelemseq_iter;
|
||||
BPy_BMLoopSeq_Type.tp_iter = NULL; /* no mapping */
|
||||
BPy_BMLoopSeq_Type.tp_iter = nullptr; /* no mapping */
|
||||
|
||||
/* Only 1 iterator so far. */
|
||||
BPy_BMIter_Type.tp_iternext = (iternextfunc)bpy_bmiter_next;
|
||||
@@ -3715,7 +3726,7 @@ void BPy_BM_init_types(void)
|
||||
BPy_BMEdgeSeq_Type.tp_dealloc = (destructor)bpy_bmelemseq_dealloc;
|
||||
BPy_BMFaceSeq_Type.tp_dealloc = (destructor)bpy_bmelemseq_dealloc;
|
||||
BPy_BMLoopSeq_Type.tp_dealloc = (destructor)bpy_bmelemseq_dealloc;
|
||||
BPy_BMIter_Type.tp_dealloc = NULL;
|
||||
BPy_BMIter_Type.tp_dealloc = nullptr;
|
||||
|
||||
BPy_BMesh_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
BPy_BMVert_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
@@ -3748,13 +3759,13 @@ void BPy_BM_init_types(void)
|
||||
static PyModuleDef BPy_BM_types_module_def = {
|
||||
/*m_base*/ PyModuleDef_HEAD_INIT,
|
||||
/*m_name*/ "bmesh.types",
|
||||
/*m_doc*/ NULL,
|
||||
/*m_doc*/ nullptr,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_bmesh_types(void)
|
||||
@@ -3800,7 +3811,7 @@ PyObject *BPy_BMesh_CreatePyObject(BMesh *bm, int flag)
|
||||
BPy_BMesh *self;
|
||||
|
||||
if (bm->py_handle) {
|
||||
self = bm->py_handle;
|
||||
self = static_cast<BPy_BMesh *>(bm->py_handle);
|
||||
Py_INCREF(self);
|
||||
}
|
||||
else {
|
||||
@@ -3810,7 +3821,7 @@ PyObject *BPy_BMesh_CreatePyObject(BMesh *bm, int flag)
|
||||
|
||||
bm->py_handle = self; /* point back */
|
||||
|
||||
/* avoid allocating layers when we don't have to */
|
||||
/* avoid allocating layers when we don't have to */
|
||||
#if 0
|
||||
BM_data_layer_add(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
|
||||
BM_data_layer_add(bm, &bm->edata, CD_BM_ELEM_PYPTR);
|
||||
@@ -3826,21 +3837,22 @@ PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v)
|
||||
{
|
||||
BPy_BMVert *self;
|
||||
|
||||
void **ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR));
|
||||
|
||||
/* bmesh may free layers, ensure we have one to store ourself */
|
||||
if (UNLIKELY(ptr == NULL)) {
|
||||
if (UNLIKELY(ptr == nullptr)) {
|
||||
BM_data_layer_add(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
|
||||
ptr = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR);
|
||||
ptr = static_cast<void **>(CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BM_ELEM_PYPTR));
|
||||
}
|
||||
|
||||
if (*ptr != NULL) {
|
||||
self = *ptr;
|
||||
if (*ptr != nullptr) {
|
||||
self = static_cast<BPy_BMVert *>(*ptr);
|
||||
Py_INCREF(self);
|
||||
}
|
||||
else {
|
||||
self = PyObject_New(BPy_BMVert, &BPy_BMVert_Type);
|
||||
BLI_assert(v != NULL);
|
||||
BLI_assert(v != nullptr);
|
||||
self->bm = bm;
|
||||
self->v = v;
|
||||
*ptr = self;
|
||||
@@ -3852,21 +3864,22 @@ PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e)
|
||||
{
|
||||
BPy_BMEdge *self;
|
||||
|
||||
void **ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR));
|
||||
|
||||
/* bmesh may free layers, ensure we have one to store ourself */
|
||||
if (UNLIKELY(ptr == NULL)) {
|
||||
if (UNLIKELY(ptr == nullptr)) {
|
||||
BM_data_layer_add(bm, &bm->edata, CD_BM_ELEM_PYPTR);
|
||||
ptr = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR);
|
||||
ptr = static_cast<void **>(CustomData_bmesh_get(&bm->edata, e->head.data, CD_BM_ELEM_PYPTR));
|
||||
}
|
||||
|
||||
if (*ptr != NULL) {
|
||||
self = *ptr;
|
||||
if (*ptr != nullptr) {
|
||||
self = static_cast<BPy_BMEdge *>(*ptr);
|
||||
Py_INCREF(self);
|
||||
}
|
||||
else {
|
||||
self = PyObject_New(BPy_BMEdge, &BPy_BMEdge_Type);
|
||||
BLI_assert(e != NULL);
|
||||
BLI_assert(e != nullptr);
|
||||
self->bm = bm;
|
||||
self->e = e;
|
||||
*ptr = self;
|
||||
@@ -3878,21 +3891,22 @@ PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f)
|
||||
{
|
||||
BPy_BMFace *self;
|
||||
|
||||
void **ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR));
|
||||
|
||||
/* bmesh may free layers, ensure we have one to store ourself */
|
||||
if (UNLIKELY(ptr == NULL)) {
|
||||
if (UNLIKELY(ptr == nullptr)) {
|
||||
BM_data_layer_add(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
|
||||
ptr = CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR);
|
||||
ptr = static_cast<void **>(CustomData_bmesh_get(&bm->pdata, f->head.data, CD_BM_ELEM_PYPTR));
|
||||
}
|
||||
|
||||
if (*ptr != NULL) {
|
||||
self = *ptr;
|
||||
if (*ptr != nullptr) {
|
||||
self = static_cast<BPy_BMFace *>(*ptr);
|
||||
Py_INCREF(self);
|
||||
}
|
||||
else {
|
||||
self = PyObject_New(BPy_BMFace, &BPy_BMFace_Type);
|
||||
BLI_assert(f != NULL);
|
||||
BLI_assert(f != nullptr);
|
||||
self->bm = bm;
|
||||
self->f = f;
|
||||
*ptr = self;
|
||||
@@ -3904,21 +3918,22 @@ PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l)
|
||||
{
|
||||
BPy_BMLoop *self;
|
||||
|
||||
void **ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR);
|
||||
void **ptr = static_cast<void **>(
|
||||
CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR));
|
||||
|
||||
/* bmesh may free layers, ensure we have one to store ourself */
|
||||
if (UNLIKELY(ptr == NULL)) {
|
||||
if (UNLIKELY(ptr == nullptr)) {
|
||||
BM_data_layer_add(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
|
||||
ptr = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR);
|
||||
ptr = static_cast<void **>(CustomData_bmesh_get(&bm->ldata, l->head.data, CD_BM_ELEM_PYPTR));
|
||||
}
|
||||
|
||||
if (*ptr != NULL) {
|
||||
self = *ptr;
|
||||
if (*ptr != nullptr) {
|
||||
self = static_cast<BPy_BMLoop *>(*ptr);
|
||||
Py_INCREF(self);
|
||||
}
|
||||
else {
|
||||
self = PyObject_New(BPy_BMLoop, &BPy_BMLoop_Type);
|
||||
BLI_assert(l != NULL);
|
||||
BLI_assert(l != nullptr);
|
||||
self->bm = bm;
|
||||
self->l = l;
|
||||
*ptr = self;
|
||||
@@ -3930,7 +3945,7 @@ PyObject *BPy_BMElemSeq_CreatePyObject(BMesh *bm, BPy_BMElem *py_ele, const char
|
||||
{
|
||||
BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMElemSeq_Type);
|
||||
self->bm = bm;
|
||||
self->py_ele = py_ele; /* can be NULL */
|
||||
self->py_ele = py_ele; /* can be nullptr */
|
||||
self->itype = itype;
|
||||
Py_XINCREF(py_ele);
|
||||
return (PyObject *)self;
|
||||
@@ -3940,7 +3955,7 @@ PyObject *BPy_BMVertSeq_CreatePyObject(BMesh *bm)
|
||||
{
|
||||
BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMVertSeq_Type);
|
||||
self->bm = bm;
|
||||
self->py_ele = NULL; /* unused */
|
||||
self->py_ele = nullptr; /* unused */
|
||||
self->itype = BM_VERTS_OF_MESH;
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -3949,7 +3964,7 @@ PyObject *BPy_BMEdgeSeq_CreatePyObject(BMesh *bm)
|
||||
{
|
||||
BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMEdgeSeq_Type);
|
||||
self->bm = bm;
|
||||
self->py_ele = NULL; /* unused */
|
||||
self->py_ele = nullptr; /* unused */
|
||||
self->itype = BM_EDGES_OF_MESH;
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -3958,7 +3973,7 @@ PyObject *BPy_BMFaceSeq_CreatePyObject(BMesh *bm)
|
||||
{
|
||||
BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMFaceSeq_Type);
|
||||
self->bm = bm;
|
||||
self->py_ele = NULL; /* unused */
|
||||
self->py_ele = nullptr; /* unused */
|
||||
self->itype = BM_FACES_OF_MESH;
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -3967,8 +3982,8 @@ PyObject *BPy_BMLoopSeq_CreatePyObject(BMesh *bm)
|
||||
{
|
||||
BPy_BMElemSeq *self = PyObject_New(BPy_BMElemSeq, &BPy_BMLoopSeq_Type);
|
||||
self->bm = bm;
|
||||
self->py_ele = NULL; /* unused */
|
||||
self->itype = 0; /* should never be passed to the iterator function */
|
||||
self->py_ele = nullptr; /* unused */
|
||||
self->itype = 0; /* should never be passed to the iterator function */
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
@@ -3994,7 +4009,7 @@ PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele)
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
PyErr_SetString(PyExc_SystemError, "internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4002,11 +4017,11 @@ int bpy_bm_generic_valid_check(BPy_BMGeneric *self)
|
||||
{
|
||||
if (LIKELY(self->bm)) {
|
||||
|
||||
/* far too slow to enable by default but handy
|
||||
* to uncomment for debugging tricky errors,
|
||||
* note that this will throw error on entering a
|
||||
* function where the actual error will be caused by
|
||||
* the previous action. */
|
||||
/* far too slow to enable by default but handy
|
||||
* to uncomment for debugging tricky errors,
|
||||
* note that this will throw error on entering a
|
||||
* function where the actual error will be caused by
|
||||
* the previous action. */
|
||||
#if 0
|
||||
if (BM_mesh_validate(self->bm) == false) {
|
||||
PyErr_Format(
|
||||
@@ -4031,7 +4046,7 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
|
||||
int ret = 0;
|
||||
|
||||
while (args_tot--) {
|
||||
BPy_BMGeneric *py_bm_elem = args[args_tot];
|
||||
BPy_BMGeneric *py_bm_elem = static_cast<BPy_BMGeneric *>(args[args_tot]);
|
||||
if (py_bm_elem) {
|
||||
|
||||
BLI_assert(BPy_BMesh_Check(py_bm_elem) || BPy_BMElem_Check(py_bm_elem));
|
||||
@@ -4058,7 +4073,7 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
|
||||
|
||||
void bpy_bm_generic_invalidate(BPy_BMGeneric *self)
|
||||
{
|
||||
self->bm = NULL;
|
||||
self->bm = nullptr;
|
||||
}
|
||||
|
||||
void *BPy_BMElem_PySeq_As_Array_FAST(BMesh **r_bm,
|
||||
@@ -4071,7 +4086,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(BMesh **r_bm,
|
||||
const bool do_bm_check,
|
||||
const char *error_prefix)
|
||||
{
|
||||
BMesh *bm = (r_bm && *r_bm) ? *r_bm : NULL;
|
||||
BMesh *bm = (r_bm && *r_bm) ? *r_bm : nullptr;
|
||||
PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
|
||||
const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast);
|
||||
Py_ssize_t i, i_last_dirty = PY_SSIZE_T_MAX;
|
||||
@@ -4088,11 +4103,11 @@ void *BPy_BMElem_PySeq_As_Array_FAST(BMesh **r_bm,
|
||||
min,
|
||||
max,
|
||||
seq_len);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* from now on, use goto */
|
||||
alloc = PyMem_MALLOC(seq_len * sizeof(BPy_BMElem **));
|
||||
alloc = static_cast<BMElem **>(PyMem_MALLOC(seq_len * sizeof(BPy_BMElem **)));
|
||||
|
||||
for (i = 0; i < seq_len; i++) {
|
||||
item = (BPy_BMElem *)seq_fast_items[i];
|
||||
@@ -4111,7 +4126,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(BMesh **r_bm,
|
||||
goto err_cleanup;
|
||||
}
|
||||
/* trick so we can ensure all items have the same mesh,
|
||||
* and allows us to pass the 'bm' as NULL. */
|
||||
* and allows us to pass the 'bm' as nullptr. */
|
||||
else if (do_bm_check && (bm && bm != item->bm)) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s: %d %s is from another mesh",
|
||||
@@ -4121,7 +4136,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(BMesh **r_bm,
|
||||
goto err_cleanup;
|
||||
}
|
||||
|
||||
if (bm == NULL) {
|
||||
if (bm == nullptr) {
|
||||
bm = item->bm;
|
||||
}
|
||||
|
||||
@@ -4169,7 +4184,7 @@ err_cleanup:
|
||||
}
|
||||
}
|
||||
PyMem_FREE(alloc);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm,
|
||||
@@ -4186,11 +4201,11 @@ void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm,
|
||||
PyObject *ret;
|
||||
|
||||
if (!(seq_fast = PySequence_Fast(seq, error_prefix))) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ret = BPy_BMElem_PySeq_As_Array_FAST(
|
||||
r_bm, seq_fast, min, max, r_size, htype, do_unique_check, do_bm_check, error_prefix);
|
||||
ret = static_cast<PyObject *>(BPy_BMElem_PySeq_As_Array_FAST(
|
||||
r_bm, seq_fast, min, max, r_size, htype, do_unique_check, do_bm_check, error_prefix));
|
||||
|
||||
Py_DECREF(seq_fast);
|
||||
return ret;
|
||||
@@ -4255,7 +4270,7 @@ int BPy_BMElem_CheckHType(PyTypeObject *type, const char htype)
|
||||
|
||||
char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
|
||||
{
|
||||
/* zero to ensure string is always NULL terminated */
|
||||
/* zero to ensure string is always nullptr terminated */
|
||||
const char *ret_array[4];
|
||||
int i = 0;
|
||||
if (htype & BM_VERT) {
|
||||
@@ -4278,7 +4293,7 @@ char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
|
||||
}
|
||||
char *BPy_BMElem_StringFromHType(const char htype)
|
||||
{
|
||||
/* zero to ensure string is always NULL terminated */
|
||||
/* zero to ensure string is always nullptr terminated */
|
||||
static char ret[32];
|
||||
return BPy_BMElem_StringFromHType_ex(htype, ret);
|
||||
}
|
||||
@@ -42,19 +42,20 @@ static CustomData *bpy_bm_customdata_get(BMesh *bm, char htype)
|
||||
}
|
||||
|
||||
BLI_assert_unreachable();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static CustomDataLayer *bpy_bmlayeritem_get(BPy_BMLayerItem *self)
|
||||
{
|
||||
CustomData *data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
const int index_absolute = CustomData_get_layer_index_n(data, self->type, self->index);
|
||||
const int index_absolute = CustomData_get_layer_index_n(
|
||||
data, eCustomDataType(self->type), self->index);
|
||||
if (index_absolute != -1) {
|
||||
return &data->layers[index_absolute];
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_RuntimeError, "layer has become invalid");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* py-type definitions
|
||||
@@ -113,7 +114,7 @@ static PyObject *bpy_bmlayeraccess_collection_get(BPy_BMLayerAccess *self, void
|
||||
|
||||
PyDoc_STRVAR(bpy_bmlayercollection_active_doc,
|
||||
"The active layer of this type (read-only).\n\n:type: :class:`BMLayerItem`");
|
||||
static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *UNUSED(flag))
|
||||
static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void * /*flag*/)
|
||||
{
|
||||
CustomData *data;
|
||||
int index;
|
||||
@@ -121,7 +122,7 @@ static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *U
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_active_layer(data, self->type); /* type relative */
|
||||
index = CustomData_get_active_layer(data, eCustomDataType(self->type)); /* type relative */
|
||||
|
||||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
@@ -133,16 +134,16 @@ static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *U
|
||||
PyDoc_STRVAR(
|
||||
bpy_bmlayercollection_is_singleton_doc,
|
||||
"True if there can exists only one layer of this type (read-only).\n\n:type: boolean");
|
||||
static PyObject *bpy_bmlayercollection_is_singleton_get(BPy_BMLayerItem *self, void *UNUSED(flag))
|
||||
static PyObject *bpy_bmlayercollection_is_singleton_get(BPy_BMLayerItem *self, void * /*flag*/)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
return PyBool_FromLong(CustomData_layertype_is_singleton(self->type));
|
||||
return PyBool_FromLong(CustomData_layertype_is_singleton(eCustomDataType(self->type)));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmlayercollection_name_doc,
|
||||
"The layers unique name (read-only).\n\n:type: string");
|
||||
static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(flag))
|
||||
static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void * /*flag*/)
|
||||
{
|
||||
CustomDataLayer *layer;
|
||||
|
||||
@@ -153,211 +154,215 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl
|
||||
return PyUnicode_FromString(layer->name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
|
||||
{"deform",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__deform_doc,
|
||||
(void *)CD_MDEFORMVERT},
|
||||
|
||||
{"float",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_doc,
|
||||
(void *)CD_PROP_FLOAT},
|
||||
{"int",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__int_doc,
|
||||
(void *)CD_PROP_INT32},
|
||||
{"float_vector",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_vector_doc,
|
||||
(void *)CD_PROP_FLOAT3},
|
||||
{"float_color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_color_doc,
|
||||
(void *)CD_PROP_COLOR},
|
||||
{"color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__color_doc,
|
||||
(void *)CD_PROP_BYTE_COLOR},
|
||||
{"string",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__string_doc,
|
||||
(void *)CD_PROP_STRING},
|
||||
|
||||
{"shape",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__shape_doc,
|
||||
(void *)CD_SHAPEKEY},
|
||||
{"skin",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__skin_doc,
|
||||
(void *)CD_MVERT_SKIN},
|
||||
{"paint_mask",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__paint_mask_doc,
|
||||
(void *)CD_PAINT_MASK},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_edge_getseters[] = {
|
||||
{"float",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_doc,
|
||||
(void *)CD_PROP_FLOAT},
|
||||
{"int",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__int_doc,
|
||||
(void *)CD_PROP_INT32},
|
||||
{"float_vector",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_vector_doc,
|
||||
(void *)CD_PROP_FLOAT3},
|
||||
{"float_color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_color_doc,
|
||||
(void *)CD_PROP_COLOR},
|
||||
{"color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__color_doc,
|
||||
(void *)CD_PROP_BYTE_COLOR},
|
||||
{"string",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__string_doc,
|
||||
(void *)CD_PROP_STRING},
|
||||
#ifdef WITH_FREESTYLE
|
||||
{"freestyle",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__freestyle_edge_doc,
|
||||
(void *)CD_FREESTYLE_EDGE},
|
||||
#endif
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_face_getseters[] = {
|
||||
{"float",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_doc,
|
||||
(void *)CD_PROP_FLOAT},
|
||||
{"int",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__int_doc,
|
||||
(void *)CD_PROP_INT32},
|
||||
{"float_vector",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_vector_doc,
|
||||
(void *)CD_PROP_FLOAT3},
|
||||
{"float_color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_color_doc,
|
||||
(void *)CD_PROP_COLOR},
|
||||
{"color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__color_doc,
|
||||
(void *)CD_PROP_BYTE_COLOR},
|
||||
{"string",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__string_doc,
|
||||
(void *)CD_PROP_STRING},
|
||||
|
||||
#ifdef WITH_FREESTYLE
|
||||
{"freestyle",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__freestyle_face_doc,
|
||||
(void *)CD_FREESTYLE_FACE},
|
||||
#endif
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmlayeraccess_loop_getseters[] = {
|
||||
{"float",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_doc,
|
||||
(void *)CD_PROP_FLOAT},
|
||||
{"int",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__int_doc,
|
||||
(void *)CD_PROP_INT32},
|
||||
{"float_vector",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_vector_doc,
|
||||
(void *)CD_PROP_FLOAT3},
|
||||
{"float_color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__float_color_doc,
|
||||
(void *)CD_PROP_COLOR},
|
||||
{"string",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__string_doc,
|
||||
(void *)CD_PROP_STRING},
|
||||
{"uv",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__uv_doc,
|
||||
(void *)CD_PROP_FLOAT2},
|
||||
{"color",
|
||||
(getter)bpy_bmlayeraccess_collection_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayeraccess_collection__color_doc,
|
||||
(void *)CD_PROP_BYTE_COLOR},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmlayercollection_getseters[] = {
|
||||
/* BMESH_TODO, make writeable */
|
||||
{"active",
|
||||
(getter)bpy_bmlayercollection_active_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayercollection_active_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"is_singleton",
|
||||
(getter)bpy_bmlayercollection_is_singleton_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayercollection_is_singleton_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyGetSetDef bpy_bmlayeritem_getseters[] = {
|
||||
/* BMESH_TODO, make writeable */
|
||||
{"name", (getter)bpy_bmlayeritem_name_get, (setter)NULL, bpy_bmlayercollection_name_doc, NULL},
|
||||
{"name",
|
||||
(getter)bpy_bmlayeritem_name_get,
|
||||
(setter) nullptr,
|
||||
bpy_bmlayercollection_name_doc,
|
||||
nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
/* Methods
|
||||
@@ -381,7 +386,7 @@ static PyObject *bpy_bmlayeritem_copy_from(BPy_BMLayerItem *self, BPy_BMLayerIte
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"layer.copy_from(x): expected BMLayerItem, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
@@ -397,8 +402,8 @@ static PyObject *bpy_bmlayeritem_copy_from(BPy_BMLayerItem *self, BPy_BMLayerIte
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
if ((bpy_bmlayeritem_get(self) == NULL) || (bpy_bmlayeritem_get(value) == NULL)) {
|
||||
return NULL;
|
||||
if ((bpy_bmlayeritem_get(self) == nullptr) || (bpy_bmlayeritem_get(value) == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_data_layer_copy(self->bm, data, self->type, value->index, self->index);
|
||||
@@ -423,7 +428,7 @@ static PyObject *bpy_bmlayercollection_verify(BPy_BMLayerCollection *self)
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
index = CustomData_get_active_layer(data, self->type); /* type relative */
|
||||
index = CustomData_get_active_layer(data, eCustomDataType(self->type)); /* type relative */
|
||||
|
||||
if (index == -1) {
|
||||
BM_data_layer_add(self->bm, data, self->type);
|
||||
@@ -452,21 +457,23 @@ PyDoc_STRVAR(bpy_bmlayercollection_new_doc,
|
||||
" :rtype: :class:`BMLayerItem`\n");
|
||||
static PyObject *bpy_bmlayercollection_new(BPy_BMLayerCollection *self, PyObject *args)
|
||||
{
|
||||
const char *name = NULL;
|
||||
const char *name = nullptr;
|
||||
int index;
|
||||
CustomData *data;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s:new", &name)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
if (CustomData_layertype_is_singleton(self->type) && CustomData_has_layer(data, self->type)) {
|
||||
if (CustomData_layertype_is_singleton(eCustomDataType(self->type)) &&
|
||||
CustomData_has_layer(data, eCustomDataType(self->type)))
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "layers.new(): is a singleton, use verify() instead");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
@@ -483,7 +490,7 @@ static PyObject *bpy_bmlayercollection_new(BPy_BMLayerCollection *self, PyObject
|
||||
BM_uv_map_ensure_select_and_pin_attrs(self->bm);
|
||||
}
|
||||
|
||||
index = CustomData_number_of_layers(data, self->type) - 1;
|
||||
index = CustomData_number_of_layers(data, eCustomDataType(self->type)) - 1;
|
||||
BLI_assert(index >= 0);
|
||||
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
@@ -506,7 +513,7 @@ static PyObject *bpy_bmlayercollection_remove(BPy_BMLayerCollection *self, BPy_B
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"layers.remove(x): expected BMLayerItem, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(value);
|
||||
@@ -542,9 +549,9 @@ static PyObject *bpy_bmlayercollection_keys(BPy_BMLayerCollection *self)
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
/* Absolute, but no need to make relative. */
|
||||
index = CustomData_get_layer_index(data, self->type);
|
||||
index = CustomData_get_layer_index(data, eCustomDataType(self->type));
|
||||
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, self->type) : 0;
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, eCustomDataType(self->type)) : 0;
|
||||
|
||||
ret = PyList_New(tot);
|
||||
|
||||
@@ -575,8 +582,8 @@ static PyObject *bpy_bmlayercollection_items(BPy_BMLayerCollection *self)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_layer_index(data, self->type);
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, self->type) : 0;
|
||||
index = CustomData_get_layer_index(data, eCustomDataType(self->type));
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, eCustomDataType(self->type)) : 0;
|
||||
|
||||
ret = PyList_New(tot);
|
||||
|
||||
@@ -610,8 +617,8 @@ static PyObject *bpy_bmlayercollection_values(BPy_BMLayerCollection *self)
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_layer_index(data, self->type);
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, self->type) : 0;
|
||||
index = CustomData_get_layer_index(data, eCustomDataType(self->type));
|
||||
tot = (index != -1) ? CustomData_number_of_layers(data, eCustomDataType(self->type)) : 0;
|
||||
|
||||
ret = PyList_New(tot);
|
||||
|
||||
@@ -642,14 +649,14 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CustomData *data;
|
||||
int index;
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_named_layer(data, self->type, key); /* type relative */
|
||||
index = CustomData_get_named_layer(data, eCustomDataType(self->type), key); /* type relative */
|
||||
|
||||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
@@ -660,7 +667,7 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
|
||||
|
||||
static PyMethodDef bpy_bmlayeritem_methods[] = {
|
||||
{"copy_from", (PyCFunction)bpy_bmlayeritem_copy_from, METH_O, bpy_bmlayeritem_copy_from_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyMethodDef bpy_bmelemseq_methods[] = {
|
||||
@@ -684,7 +691,7 @@ static PyMethodDef bpy_bmelemseq_methods[] = {
|
||||
METH_NOARGS,
|
||||
bpy_bmlayercollection_items_doc},
|
||||
{"get", (PyCFunction)bpy_bmlayercollection_get, METH_VARARGS, bpy_bmlayercollection_get_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
/* Sequences
|
||||
@@ -698,7 +705,7 @@ static Py_ssize_t bpy_bmlayercollection_length(BPy_BMLayerCollection *self)
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
|
||||
return CustomData_number_of_layers(data, self->type);
|
||||
return CustomData_number_of_layers(data, eCustomDataType(self->type));
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmlayercollection_subscript_str(BPy_BMLayerCollection *self,
|
||||
@@ -710,14 +717,15 @@ static PyObject *bpy_bmlayercollection_subscript_str(BPy_BMLayerCollection *self
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_named_layer(data, self->type, keyname); /* type relative */
|
||||
index = CustomData_get_named_layer(
|
||||
data, eCustomDataType(self->type), keyname); /* type relative */
|
||||
|
||||
if (index != -1) {
|
||||
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_KeyError, "BMLayerCollection[key]: key \"%.200s\" not found", keyname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self,
|
||||
@@ -738,7 +746,7 @@ static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_IndexError, "BMLayerCollection[index]: index %d out of range", keynum);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmlayercollection_subscript_slice(BPy_BMLayerCollection *self,
|
||||
@@ -779,7 +787,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
||||
if (PyIndex_Check(key)) {
|
||||
const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return bpy_bmlayercollection_subscript_int(self, i);
|
||||
}
|
||||
@@ -788,11 +796,11 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMLayerCollection[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmlayercollection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
@@ -802,10 +810,10 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (start < 0 || stop < 0) {
|
||||
@@ -829,7 +837,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMLayerCollection[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject *value)
|
||||
@@ -840,35 +848,35 @@ static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject
|
||||
|
||||
BPY_BM_CHECK_INT(self);
|
||||
|
||||
if (keyname == NULL) {
|
||||
if (keyname == nullptr) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMLayerCollection.__contains__: expected a string");
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = bpy_bm_customdata_get(self->bm, self->htype);
|
||||
index = CustomData_get_named_layer_index(data, self->type, keyname);
|
||||
index = CustomData_get_named_layer_index(data, eCustomDataType(self->type), keyname);
|
||||
|
||||
return (index != -1) ? 1 : 0;
|
||||
}
|
||||
|
||||
static PySequenceMethods bpy_bmlayercollection_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)bpy_bmlayercollection_length,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/* Only set this so `PySequence_Check()` returns True. */
|
||||
/*sq_item*/ (ssizeargfunc)bpy_bmlayercollection_subscript_int,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. */
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_contains*/ (objobjproc)bpy_bmlayercollection_contains,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods bpy_bmlayercollection_as_mapping = {
|
||||
/*mp_length*/ (lenfunc)bpy_bmlayercollection_length,
|
||||
/*mp_subscript*/ (binaryfunc)bpy_bmlayercollection_subscript,
|
||||
/*mp_ass_subscript*/ (objobjargproc)NULL,
|
||||
/*mp_ass_subscript*/ (objobjargproc) nullptr,
|
||||
};
|
||||
|
||||
/* Iterator
|
||||
@@ -878,7 +886,7 @@ static PyObject *bpy_bmlayercollection_iter(BPy_BMLayerCollection *self)
|
||||
{
|
||||
/* fake it with a list iterator */
|
||||
PyObject *ret;
|
||||
PyObject *iter = NULL;
|
||||
PyObject *iter = nullptr;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
@@ -931,7 +939,7 @@ PyObject *BPy_BMLayerAccess_CreatePyObject(BMesh *bm, const char htype)
|
||||
break;
|
||||
default: {
|
||||
BLI_assert_unreachable();
|
||||
type = NULL;
|
||||
type = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -985,12 +993,12 @@ void BPy_BM_init_types_customdata(void)
|
||||
BPy_BMLayerCollection_Type.tp_doc = bpy_bmlayercollection_type_doc;
|
||||
BPy_BMLayerItem_Type.tp_doc = bpy_bmlayeritem_type_doc;
|
||||
|
||||
BPy_BMLayerAccessVert_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerAccessEdge_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerAccessFace_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerAccessLoop_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerCollection_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerItem_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMLayerAccessVert_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMLayerAccessEdge_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMLayerAccessFace_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMLayerAccessLoop_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMLayerCollection_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMLayerItem_Type.tp_repr = (reprfunc) nullptr;
|
||||
|
||||
BPy_BMLayerAccessVert_Type.tp_getset = bpy_bmlayeraccess_vert_getseters;
|
||||
BPy_BMLayerAccessEdge_Type.tp_getset = bpy_bmlayeraccess_edge_getseters;
|
||||
@@ -1009,12 +1017,12 @@ void BPy_BM_init_types_customdata(void)
|
||||
|
||||
BPy_BMLayerCollection_Type.tp_iter = (getiterfunc)bpy_bmlayercollection_iter;
|
||||
|
||||
BPy_BMLayerAccessVert_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerAccessEdge_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerAccessFace_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerAccessLoop_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerCollection_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerItem_Type.tp_dealloc = NULL;
|
||||
BPy_BMLayerAccessVert_Type.tp_dealloc = nullptr;
|
||||
BPy_BMLayerAccessEdge_Type.tp_dealloc = nullptr;
|
||||
BPy_BMLayerAccessFace_Type.tp_dealloc = nullptr;
|
||||
BPy_BMLayerAccessLoop_Type.tp_dealloc = nullptr;
|
||||
BPy_BMLayerCollection_Type.tp_dealloc = nullptr;
|
||||
BPy_BMLayerItem_Type.tp_dealloc = nullptr;
|
||||
|
||||
BPy_BMLayerAccessVert_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
BPy_BMLayerAccessEdge_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
@@ -1035,7 +1043,7 @@ void BPy_BM_init_types_customdata(void)
|
||||
* ******************* */
|
||||
|
||||
/**
|
||||
* helper function for get/set, NULL return means the error is set
|
||||
* helper function for get/set, nullptr return means the error is set
|
||||
*/
|
||||
static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
|
||||
{
|
||||
@@ -1046,11 +1054,11 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
|
||||
/* error checking */
|
||||
if (UNLIKELY(!BPy_BMLayerItem_Check(py_layer))) {
|
||||
PyErr_SetString(PyExc_AttributeError, "BMElem[key]: invalid key, must be a BMLayerItem");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (UNLIKELY(py_ele->bm != py_layer->bm)) {
|
||||
PyErr_SetString(PyExc_ValueError, "BMElem[layer]: layer is from another mesh");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (UNLIKELY(ele->head.htype != py_layer->htype)) {
|
||||
char namestr_1[32], namestr_2[32];
|
||||
@@ -1058,17 +1066,18 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
|
||||
"Layer/Element type mismatch, expected %.200s got layer type %.200s",
|
||||
BPy_BMElem_StringFromHType_ex(ele->head.htype, namestr_1),
|
||||
BPy_BMElem_StringFromHType_ex(py_layer->htype, namestr_2));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
data = bpy_bm_customdata_get(py_layer->bm, py_layer->htype);
|
||||
|
||||
value = CustomData_bmesh_get_n(data, ele->head.data, py_layer->type, py_layer->index);
|
||||
value = CustomData_bmesh_get_n(
|
||||
data, ele->head.data, eCustomDataType(py_layer->type), py_layer->index);
|
||||
|
||||
if (UNLIKELY(value == NULL)) {
|
||||
if (UNLIKELY(value == nullptr)) {
|
||||
/* this should be fairly unlikely but possible if layers move about after we get them */
|
||||
PyErr_SetString(PyExc_KeyError, "BMElem[key]: layer not found");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -1079,13 +1088,13 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
|
||||
void *value = bpy_bmlayeritem_ptr_get(py_ele, py_layer);
|
||||
PyObject *ret;
|
||||
|
||||
if (UNLIKELY(value == NULL)) {
|
||||
return NULL;
|
||||
if (UNLIKELY(value == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (py_layer->type) {
|
||||
case CD_MDEFORMVERT: {
|
||||
ret = BPy_BMDeformVert_CreatePyObject(value);
|
||||
ret = BPy_BMDeformVert_CreatePyObject(static_cast<MDeformVert *>(value));
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT:
|
||||
@@ -1098,36 +1107,36 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT3: {
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL);
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 3, nullptr);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_COLOR: {
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 4, NULL);
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 4, nullptr);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_STRING: {
|
||||
MStringProperty *mstring = value;
|
||||
MStringProperty *mstring = static_cast<MStringProperty *>(value);
|
||||
ret = PyBytes_FromStringAndSize(mstring->s, mstring->s_len);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT2: {
|
||||
if (UNLIKELY(py_ele->bm != py_layer->bm)) {
|
||||
PyErr_SetString(PyExc_ValueError, "BMElem[layer]: layer is from another mesh");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ret = BPy_BMLoopUV_CreatePyObject(py_ele->bm, (BMLoop *)py_ele->ele, py_layer->index);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BYTE_COLOR: {
|
||||
ret = BPy_BMLoopColor_CreatePyObject(value);
|
||||
ret = BPy_BMLoopColor_CreatePyObject(static_cast<MLoopCol *>(value));
|
||||
break;
|
||||
}
|
||||
case CD_SHAPEKEY: {
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL);
|
||||
ret = Vector_CreatePyObject_wrap((float *)value, 3, nullptr);
|
||||
break;
|
||||
}
|
||||
case CD_MVERT_SKIN: {
|
||||
ret = BPy_BMVertSkin_CreatePyObject(value);
|
||||
ret = BPy_BMVertSkin_CreatePyObject(static_cast<MVertSkin *>(value));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -1145,13 +1154,13 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
int ret = 0;
|
||||
void *value = bpy_bmlayeritem_ptr_get(py_ele, py_layer);
|
||||
|
||||
if (UNLIKELY(value == NULL)) {
|
||||
if (UNLIKELY(value == nullptr)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (py_layer->type) {
|
||||
case CD_MDEFORMVERT: {
|
||||
ret = BPy_BMDeformVert_AssignPyObject(value, py_value);
|
||||
ret = BPy_BMDeformVert_AssignPyObject(static_cast<MDeformVert *>(value), py_value);
|
||||
break;
|
||||
}
|
||||
case CD_PROP_FLOAT:
|
||||
@@ -1191,7 +1200,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
break;
|
||||
}
|
||||
case CD_PROP_STRING: {
|
||||
MStringProperty *mstring = value;
|
||||
MStringProperty *mstring = static_cast<MStringProperty *>(value);
|
||||
char *tmp_val;
|
||||
Py_ssize_t tmp_val_len;
|
||||
if (UNLIKELY(PyBytes_AsStringAndSize(py_value, &tmp_val, &tmp_val_len) == -1)) {
|
||||
@@ -1218,7 +1227,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
break;
|
||||
}
|
||||
case CD_PROP_BYTE_COLOR: {
|
||||
ret = BPy_BMLoopColor_AssignPyObject(value, py_value);
|
||||
ret = BPy_BMLoopColor_AssignPyObject(static_cast<MLoopCol *>(value), py_value);
|
||||
break;
|
||||
}
|
||||
case CD_SHAPEKEY: {
|
||||
@@ -1233,7 +1242,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
break;
|
||||
}
|
||||
case CD_MVERT_SKIN: {
|
||||
ret = BPy_BMVertSkin_AssignPyObject(value, py_value);
|
||||
ret = BPy_BMVertSkin_AssignPyObject(static_cast<MVertSkin *>(value), py_value);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* All use #BPy_BMLayerAccess struct. */
|
||||
|
||||
extern PyTypeObject BPy_BMLayerAccessVert_Type;
|
||||
@@ -59,3 +63,7 @@ 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
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
|
||||
#define BPy_BMLoopUV_Check(v) (Py_TYPE(v) == &BPy_BMLoopUV_Type)
|
||||
|
||||
typedef struct BPy_BMLoopUV {
|
||||
struct BPy_BMLoopUV {
|
||||
PyObject_VAR_HEAD
|
||||
float *uv;
|
||||
/* vert_select, edge_select and pin could be NULL, signifying those layers don't exist.
|
||||
/* vert_select, edge_select and pin could be nullptr, signifying those layers don't exist.
|
||||
* Currently those layers are always created on a BMesh because adding layers to an existing
|
||||
* BMesh is slow and invalidates existing python objects having pointers into the original
|
||||
* datablocks (adding a layer re-generates all blocks). But eventually the plan is to lazily
|
||||
@@ -56,16 +56,16 @@ typedef struct BPy_BMLoopUV {
|
||||
bool *edge_select;
|
||||
bool *pin;
|
||||
BMLoop *loop;
|
||||
} BPy_BMLoopUV;
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(bpy_bmloopuv_uv_doc,
|
||||
"Loops UV (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
|
||||
static PyObject *bpy_bmloopuv_uv_get(BPy_BMLoopUV *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmloopuv_uv_get(BPy_BMLoopUV *self, void * /*closure*/)
|
||||
{
|
||||
return Vector_CreatePyObject_wrap(self->uv, 2, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->uv, 2, nullptr);
|
||||
}
|
||||
|
||||
static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
float tvec[2];
|
||||
if (mathutils_array_parse(tvec, 2, 2, value, "BMLoopUV.uv") != -1) {
|
||||
@@ -80,19 +80,19 @@ PyDoc_STRVAR(bpy_bmloopuv_pin_uv_doc, "UV pin state.\n\n:type: boolean");
|
||||
PyDoc_STRVAR(bpy_bmloopuv_select_doc, "UV select state.\n\n:type: boolean");
|
||||
PyDoc_STRVAR(bpy_bmloopuv_select_edge_doc, "UV edge select state.\n\n:type: boolean");
|
||||
|
||||
static PyObject *bpy_bmloopuv_pin_uv_get(BPy_BMLoopUV *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmloopuv_pin_uv_get(BPy_BMLoopUV *self, void * /*closure*/)
|
||||
{
|
||||
/* A non existing pin layer means nothing is currently pinned */
|
||||
return self->pin ? PyBool_FromLong(*self->pin) : false;
|
||||
return self->pin ? PyBool_FromLong(*self->pin) : nullptr;
|
||||
}
|
||||
|
||||
static int bpy_bmloopuv_pin_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmloopuv_pin_uv_set(BPy_BMLoopUV *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
/* TODO: if we add lazy allocation of the associated uv map bool layers to BMesh we need
|
||||
* to add a pin layer and update self->pin in the case of self->pin being NULL.
|
||||
* to add a pin layer and update self->pin in the case of self->pin being nullptr.
|
||||
* This isn't easy to do currently as adding CustomData layers to a BMesh invalidates
|
||||
* existing python objects. So for now lazy allocation isn't done and self->pin should
|
||||
* never be NULL. */
|
||||
* never be nullptr. */
|
||||
BLI_assert(self->pin);
|
||||
if (self->pin) {
|
||||
*self->pin = PyC_Long_AsBool(value);
|
||||
@@ -105,12 +105,12 @@ static int bpy_bmloopuv_pin_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UN
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmloopuv_select_get(BPy_BMLoopUV *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmloopuv_select_get(BPy_BMLoopUV *self, void * /*closure*/)
|
||||
{
|
||||
/* A non existing vert_select layer means nothing is currently selected */
|
||||
return self->vert_select ? PyBool_FromLong(*self->vert_select) : false;
|
||||
return self->vert_select ? PyBool_FromLong(*self->vert_select) : nullptr;
|
||||
}
|
||||
static int bpy_bmloopuv_select_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmloopuv_select_set(BPy_BMLoopUV *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
/* TODO: see comment above on bpy_bmloopuv_pin_uv_set(), the same applies here. */
|
||||
BLI_assert(self->vert_select);
|
||||
@@ -125,12 +125,12 @@ static int bpy_bmloopuv_select_set(BPy_BMLoopUV *self, PyObject *value, void *UN
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmloopuv_select_edge_get(BPy_BMLoopUV *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmloopuv_select_edge_get(BPy_BMLoopUV *self, void * /*closure*/)
|
||||
{
|
||||
/* A non existing edge_select layer means nothing is currently selected */
|
||||
return self->edge_select ? PyBool_FromLong(*self->edge_select) : false;
|
||||
return self->edge_select ? PyBool_FromLong(*self->edge_select) : nullptr;
|
||||
}
|
||||
static int bpy_bmloopuv_select_edge_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmloopuv_select_edge_set(BPy_BMLoopUV *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
/* TODO: see comment above on bpy_bmloopuv_pin_uv_set(), the same applies here. */
|
||||
BLI_assert(self->edge_select);
|
||||
@@ -147,24 +147,24 @@ static int bpy_bmloopuv_select_edge_set(BPy_BMLoopUV *self, PyObject *value, voi
|
||||
|
||||
static PyGetSetDef bpy_bmloopuv_getseters[] = {
|
||||
/* attributes match rna_def_mloopuv. */
|
||||
{"uv", (getter)bpy_bmloopuv_uv_get, (setter)bpy_bmloopuv_uv_set, bpy_bmloopuv_uv_doc, NULL},
|
||||
{"uv", (getter)bpy_bmloopuv_uv_get, (setter)bpy_bmloopuv_uv_set, bpy_bmloopuv_uv_doc, nullptr},
|
||||
{"pin_uv",
|
||||
(getter)bpy_bmloopuv_pin_uv_get,
|
||||
(setter)bpy_bmloopuv_pin_uv_set,
|
||||
bpy_bmloopuv_pin_uv_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"select",
|
||||
(getter)bpy_bmloopuv_select_get,
|
||||
(setter)bpy_bmloopuv_select_set,
|
||||
bpy_bmloopuv_select_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"select_edge",
|
||||
(getter)bpy_bmloopuv_select_edge_get,
|
||||
(setter)bpy_bmloopuv_select_edge_set,
|
||||
bpy_bmloopuv_select_edge_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyTypeObject BPy_BMLoopUV_Type; /* bm.loops.layers.uv.active */
|
||||
@@ -175,7 +175,7 @@ static void bm_init_types_bmloopuv(void)
|
||||
|
||||
BPy_BMLoopUV_Type.tp_name = "BMLoopUV";
|
||||
|
||||
BPy_BMLoopUV_Type.tp_doc = NULL; /* todo */
|
||||
BPy_BMLoopUV_Type.tp_doc = nullptr; /* todo */
|
||||
|
||||
BPy_BMLoopUV_Type.tp_getset = bpy_bmloopuv_getseters;
|
||||
|
||||
@@ -218,10 +218,10 @@ PyObject *BPy_BMLoopUV_CreatePyObject(BMesh *bm, BMLoop *loop, int layer)
|
||||
|
||||
self->uv = BM_ELEM_CD_GET_FLOAT_P(loop, offsets.uv);
|
||||
self->vert_select = offsets.select_vert >= 0 ? BM_ELEM_CD_GET_BOOL_P(loop, offsets.select_vert) :
|
||||
NULL;
|
||||
nullptr;
|
||||
self->edge_select = offsets.select_edge >= 0 ? BM_ELEM_CD_GET_BOOL_P(loop, offsets.select_edge) :
|
||||
NULL;
|
||||
self->pin = offsets.pin >= 0 ? BM_ELEM_CD_GET_BOOL_P(loop, offsets.pin) : NULL;
|
||||
nullptr;
|
||||
self->pin = offsets.pin >= 0 ? BM_ELEM_CD_GET_BOOL_P(loop, offsets.pin) : nullptr;
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -233,19 +233,19 @@ PyObject *BPy_BMLoopUV_CreatePyObject(BMesh *bm, BMLoop *loop, int layer)
|
||||
|
||||
#define BPy_BMVertSkin_Check(v) (Py_TYPE(v) == &BPy_BMVertSkin_Type)
|
||||
|
||||
typedef struct BPy_BMVertSkin {
|
||||
struct BPy_BMVertSkin {
|
||||
PyObject_VAR_HEAD
|
||||
MVertSkin *data;
|
||||
} BPy_BMVertSkin;
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(bpy_bmvertskin_radius_doc,
|
||||
"Vert skin radii (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`");
|
||||
static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void * /*closure*/)
|
||||
{
|
||||
return Vector_CreatePyObject_wrap(self->data->radius, 2, NULL);
|
||||
return Vector_CreatePyObject_wrap(self->data->radius, 2, nullptr);
|
||||
}
|
||||
|
||||
static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure))
|
||||
static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
float tvec[2];
|
||||
if (mathutils_array_parse(tvec, 2, 2, value, "BMVertSkin.radius") != -1) {
|
||||
@@ -290,7 +290,7 @@ static PyGetSetDef bpy_bmvertskin_getseters[] = {
|
||||
(getter)bpy_bmvertskin_radius_get,
|
||||
(setter)bpy_bmvertskin_radius_set,
|
||||
bpy_bmvertskin_radius_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"use_root",
|
||||
(getter)bpy_bmvertskin_flag_get,
|
||||
(setter)bpy_bmvertskin_flag_set,
|
||||
@@ -302,7 +302,7 @@ static PyGetSetDef bpy_bmvertskin_getseters[] = {
|
||||
bpy_bmvertskin_flag__use_loose_doc,
|
||||
(void *)MVERT_SKIN_LOOSE},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyTypeObject BPy_BMVertSkin_Type; /* bm.loops.layers.skin.active */
|
||||
@@ -313,7 +313,7 @@ static void bm_init_types_bmvertskin(void)
|
||||
|
||||
BPy_BMVertSkin_Type.tp_name = "BMVertSkin";
|
||||
|
||||
BPy_BMVertSkin_Type.tp_doc = NULL; /* todo */
|
||||
BPy_BMVertSkin_Type.tp_doc = nullptr; /* todo */
|
||||
|
||||
BPy_BMVertSkin_Type.tp_getset = bpy_bmvertskin_getseters;
|
||||
|
||||
@@ -350,7 +350,7 @@ PyObject *BPy_BMVertSkin_CreatePyObject(MVertSkin *mvertskin)
|
||||
*/
|
||||
|
||||
#define MLOOPCOL_FROM_CAPSULE(color_capsule) \
|
||||
((MLoopCol *)PyCapsule_GetPointer(color_capsule, NULL))
|
||||
((MLoopCol *)PyCapsule_GetPointer(color_capsule, nullptr))
|
||||
|
||||
static void mloopcol_to_float(const MLoopCol *mloopcol, float r_col[4])
|
||||
{
|
||||
@@ -364,27 +364,27 @@ static void mloopcol_from_float(MLoopCol *mloopcol, const float col[4])
|
||||
|
||||
static uchar mathutils_bmloopcol_cb_index = -1;
|
||||
|
||||
static int mathutils_bmloopcol_check(BaseMathObject *UNUSED(bmo))
|
||||
static int mathutils_bmloopcol_check(BaseMathObject * /*bmo*/)
|
||||
{
|
||||
/* always ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mathutils_bmloopcol_get(BaseMathObject *bmo, int UNUSED(subtype))
|
||||
static int mathutils_bmloopcol_get(BaseMathObject *bmo, int /*subtype*/)
|
||||
{
|
||||
MLoopCol *mloopcol = MLOOPCOL_FROM_CAPSULE(bmo->cb_user);
|
||||
mloopcol_to_float(mloopcol, bmo->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mathutils_bmloopcol_set(BaseMathObject *bmo, int UNUSED(subtype))
|
||||
static int mathutils_bmloopcol_set(BaseMathObject *bmo, int /*subtype*/)
|
||||
{
|
||||
MLoopCol *mloopcol = MLOOPCOL_FROM_CAPSULE(bmo->cb_user);
|
||||
mloopcol_from_float(mloopcol, bmo->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mathutils_bmloopcol_get_index(BaseMathObject *bmo, int subtype, int UNUSED(index))
|
||||
static int mathutils_bmloopcol_get_index(BaseMathObject *bmo, int subtype, int /*index*/)
|
||||
{
|
||||
/* Lazy, avoid repeating the case statement. */
|
||||
if (mathutils_bmloopcol_get(bmo, subtype) == -1) {
|
||||
@@ -434,7 +434,7 @@ int BPy_BMLoopColor_AssignPyObject(MLoopCol *mloopcol, PyObject *value)
|
||||
PyObject *BPy_BMLoopColor_CreatePyObject(MLoopCol *mloopcol)
|
||||
{
|
||||
PyObject *color_capsule;
|
||||
color_capsule = PyCapsule_New(mloopcol, NULL, NULL);
|
||||
color_capsule = PyCapsule_New(mloopcol, nullptr, nullptr);
|
||||
return Vector_CreatePyObject_cb(color_capsule, 4, mathutils_bmloopcol_cb_index, 0);
|
||||
}
|
||||
|
||||
@@ -471,10 +471,10 @@ PyObject *BPy_BMLoopColor_CreatePyObject(MLoopCol *mloopcol)
|
||||
|
||||
#define BPy_BMDeformVert_Check(v) (Py_TYPE(v) == &BPy_BMDeformVert_Type)
|
||||
|
||||
typedef struct BPy_BMDeformVert {
|
||||
struct BPy_BMDeformVert {
|
||||
PyObject_VAR_HEAD
|
||||
MDeformVert *data;
|
||||
} BPy_BMDeformVert;
|
||||
};
|
||||
|
||||
/* Mapping Protocols
|
||||
* ================= */
|
||||
@@ -490,16 +490,16 @@ static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *ke
|
||||
int i;
|
||||
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
|
||||
|
||||
if (dw == NULL) {
|
||||
if (dw == nullptr) {
|
||||
PyErr_SetString(PyExc_KeyError,
|
||||
"BMDeformVert[key] = x: "
|
||||
"key not found");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(dw->weight);
|
||||
@@ -507,7 +507,7 @@ static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *ke
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, PyObject *value)
|
||||
@@ -544,7 +544,7 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
|
||||
/* Handle `del dvert[group_index]`. */
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
|
||||
|
||||
if (dw == NULL) {
|
||||
if (dw == nullptr) {
|
||||
PyErr_SetString(PyExc_KeyError,
|
||||
"del BMDeformVert[key]: "
|
||||
"key not found");
|
||||
@@ -569,23 +569,23 @@ static int bpy_bmdeformvert_contains(BPy_BMDeformVert *self, PyObject *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (BKE_defvert_find_index(self->data, key) != NULL) ? 1 : 0;
|
||||
return (BKE_defvert_find_index(self->data, key) != nullptr) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* only defined for __contains__ */
|
||||
static PySequenceMethods bpy_bmdeformvert_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)bpy_bmdeformvert_len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/* NOTE: if this is set #PySequence_Check() returns True,
|
||||
* but in this case we don't want to be treated as a seq. */
|
||||
/*sq_item*/ NULL,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_item*/ nullptr,
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_contains*/ (objobjproc)bpy_bmdeformvert_contains,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods bpy_bmdeformvert_as_mapping = {
|
||||
@@ -683,7 +683,7 @@ static PyObject *bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args)
|
||||
PyObject *def = Py_None;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MDeformWeight *dw = BKE_defvert_find_index(self->data, key);
|
||||
@@ -713,7 +713,7 @@ static PyMethodDef bpy_bmdeformvert_methods[] = {
|
||||
{"get", (PyCFunction)bpy_bmdeformvert_get, METH_VARARGS, bpy_bmdeformvert_get_doc},
|
||||
/* BMESH_TODO `pop`, `popitem`, `update`. */
|
||||
{"clear", (PyCFunction)bpy_bmdeformvert_clear, METH_NOARGS, bpy_bmdeformvert_clear_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyTypeObject BPy_BMDeformVert_Type; /* bm.loops.layers.uv.active */
|
||||
@@ -724,7 +724,7 @@ static void bm_init_types_bmdvert(void)
|
||||
|
||||
BPy_BMDeformVert_Type.tp_name = "BMDeformVert";
|
||||
|
||||
BPy_BMDeformVert_Type.tp_doc = NULL; /* todo */
|
||||
BPy_BMDeformVert_Type.tp_doc = nullptr; /* todo */
|
||||
|
||||
BPy_BMDeformVert_Type.tp_as_sequence = &bpy_bmdeformvert_as_sequence;
|
||||
BPy_BMDeformVert_Type.tp_as_mapping = &bpy_bmdeformvert_as_mapping;
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPy_BMLoopUV_Type;
|
||||
extern PyTypeObject BPy_BMDeformVert_Type;
|
||||
|
||||
@@ -37,3 +41,7 @@ PyObject *BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert);
|
||||
|
||||
/* call to init all types */
|
||||
void BPy_BM_init_types_meshdata(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
PyDoc_STRVAR(bpy_bmeditselseq_active_doc,
|
||||
"The last selected element or None (read-only).\n\n:type: :class:`BMVert`, "
|
||||
":class:`BMEdge` or :class:`BMFace`");
|
||||
static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSED(closure))
|
||||
static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void * /*closure*/)
|
||||
{
|
||||
BMEditSelection *ese;
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if ((ese = self->bm->selected.last)) {
|
||||
if ((ese = static_cast<BMEditSelection *>(self->bm->selected.last))) {
|
||||
return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSE
|
||||
static PyGetSetDef bpy_bmeditselseq_getseters[] = {
|
||||
{"active",
|
||||
(getter)bpy_bmeditselseq_active_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
bpy_bmeditselseq_active_doc,
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(bpy_bmeditselseq_validate_doc,
|
||||
@@ -83,7 +83,7 @@ static PyObject *bpy_bmeditselseq_add(BPy_BMEditSelSeq *self, BPy_BMElem *value)
|
||||
if ((BPy_BMVert_Check(value) || BPy_BMEdge_Check(value) || BPy_BMFace_Check(value)) == false) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "Expected a BMVert/BMedge/BMFace not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(self->bm, "select_history.add()", value);
|
||||
@@ -104,14 +104,14 @@ static PyObject *bpy_bmeditselseq_remove(BPy_BMEditSelSeq *self, BPy_BMElem *val
|
||||
if ((BPy_BMVert_Check(value) || BPy_BMEdge_Check(value) || BPy_BMFace_Check(value)) == false) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "Expected a BMVert/BMedge/BMFace not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(self->bm, "select_history.remove()", value);
|
||||
|
||||
if (BM_select_history_remove(self->bm, value->ele) == false) {
|
||||
PyErr_SetString(PyExc_ValueError, "Element not found in selection history");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -131,7 +131,7 @@ static PyObject *bpy_bmeditselseq_discard(BPy_BMEditSelSeq *self, BPy_BMElem *va
|
||||
if ((BPy_BMVert_Check(value) || BPy_BMEdge_Check(value) || BPy_BMFace_Check(value)) == false) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "Expected a BMVert/BMedge/BMFace not a %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_SOURCE_OBJ(self->bm, "select_history.discard()", value);
|
||||
@@ -151,7 +151,7 @@ static PyMethodDef bpy_bmeditselseq_methods[] = {
|
||||
{"add", (PyCFunction)bpy_bmeditselseq_add, METH_O, bpy_bmeditselseq_add_doc},
|
||||
{"remove", (PyCFunction)bpy_bmeditselseq_remove, METH_O, bpy_bmeditselseq_remove_doc},
|
||||
{"discard", (PyCFunction)bpy_bmeditselseq_discard, METH_O, bpy_bmeditselseq_discard_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
/* Sequences
|
||||
@@ -171,10 +171,10 @@ static PyObject *bpy_bmeditselseq_subscript_int(BPy_BMEditSelSeq *self, Py_ssize
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (keynum < 0) {
|
||||
ese = BLI_rfindlink(&self->bm->selected, -1 - keynum);
|
||||
ese = static_cast<BMEditSelection *>(BLI_rfindlink(&self->bm->selected, -1 - keynum));
|
||||
}
|
||||
else {
|
||||
ese = BLI_findlink(&self->bm->selected, keynum);
|
||||
ese = static_cast<BMEditSelection *>(BLI_findlink(&self->bm->selected, keynum));
|
||||
}
|
||||
|
||||
if (ese) {
|
||||
@@ -182,7 +182,7 @@ static PyObject *bpy_bmeditselseq_subscript_int(BPy_BMEditSelSeq *self, Py_ssize
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_IndexError, "BMElemSeq[index]: index %d out of range", keynum);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
||||
@@ -199,7 +199,7 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
||||
list = PyList_New(0);
|
||||
|
||||
/* First loop up-until the start. */
|
||||
for (ese = self->bm->selected.first; ese; ese = ese->next) {
|
||||
for (ese = static_cast<BMEditSelection *>(self->bm->selected.first); ese; ese = ese->next) {
|
||||
if (count == start) {
|
||||
break;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
||||
if (PyIndex_Check(key)) {
|
||||
const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return bpy_bmeditselseq_subscript_int(self, i);
|
||||
}
|
||||
@@ -233,11 +233,11 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
||||
Py_ssize_t step = 1;
|
||||
|
||||
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (step != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->start == Py_None && key_slice->stop == Py_None) {
|
||||
return bpy_bmeditselseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
|
||||
@@ -247,10 +247,10 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
||||
|
||||
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
|
||||
if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (start < 0 || stop < 0) {
|
||||
@@ -274,7 +274,7 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
|
||||
@@ -293,22 +293,22 @@ static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
|
||||
|
||||
static PySequenceMethods bpy_bmeditselseq_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)bpy_bmeditselseq_length,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/* Only set this so `PySequence_Check()` returns True. */
|
||||
/*sq_item*/ (ssizeargfunc)bpy_bmeditselseq_subscript_int,
|
||||
/*sq_slice */ NULL,
|
||||
/*sq_ass_item */ NULL,
|
||||
/*was_sq_ass_slice*/ NULL,
|
||||
/*sq_slice */ nullptr,
|
||||
/*sq_ass_item */ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr,
|
||||
/*sq_contains*/ (objobjproc)bpy_bmeditselseq_contains,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods bpy_bmeditselseq_as_mapping = {
|
||||
/*mp_length*/ (lenfunc)bpy_bmeditselseq_length,
|
||||
/*mp_subscript*/ (binaryfunc)bpy_bmeditselseq_subscript,
|
||||
/*mp_ass_subscript*/ (objobjargproc)NULL,
|
||||
/*mp_ass_subscript*/ (objobjargproc) nullptr,
|
||||
};
|
||||
|
||||
/* Iterator
|
||||
@@ -320,16 +320,16 @@ static PyObject *bpy_bmeditselseq_iter(BPy_BMEditSelSeq *self)
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
py_iter = (BPy_BMEditSelIter *)BPy_BMEditSelIter_CreatePyObject(self->bm);
|
||||
py_iter->ese = self->bm->selected.first;
|
||||
py_iter->ese = static_cast<BMEditSelection *>(self->bm->selected.first);
|
||||
return (PyObject *)py_iter;
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self)
|
||||
{
|
||||
BMEditSelection *ese = self->ese;
|
||||
if (ese == NULL) {
|
||||
if (ese == nullptr) {
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
self->ese = ese->next;
|
||||
@@ -363,17 +363,17 @@ void BPy_BM_init_types_select(void)
|
||||
BPy_BMEditSelSeq_Type.tp_name = "BMEditSelSeq";
|
||||
BPy_BMEditSelIter_Type.tp_name = "BMEditSelIter";
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_doc = NULL; /* todo */
|
||||
BPy_BMEditSelIter_Type.tp_doc = NULL;
|
||||
BPy_BMEditSelSeq_Type.tp_doc = nullptr; /* todo */
|
||||
BPy_BMEditSelIter_Type.tp_doc = nullptr;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMEditSelIter_Type.tp_repr = (reprfunc)NULL;
|
||||
BPy_BMEditSelSeq_Type.tp_repr = (reprfunc) nullptr;
|
||||
BPy_BMEditSelIter_Type.tp_repr = (reprfunc) nullptr;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_getset = bpy_bmeditselseq_getseters;
|
||||
BPy_BMEditSelIter_Type.tp_getset = NULL;
|
||||
BPy_BMEditSelIter_Type.tp_getset = nullptr;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_methods = bpy_bmeditselseq_methods;
|
||||
BPy_BMEditSelIter_Type.tp_methods = NULL;
|
||||
BPy_BMEditSelIter_Type.tp_methods = nullptr;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_as_sequence = &bpy_bmeditselseq_as_sequence;
|
||||
|
||||
@@ -384,8 +384,8 @@ void BPy_BM_init_types_select(void)
|
||||
/* Only 1 iterator so far. */
|
||||
BPy_BMEditSelIter_Type.tp_iternext = (iternextfunc)bpy_bmeditseliter_next;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_dealloc = NULL; //(destructor)bpy_bmeditselseq_dealloc;
|
||||
BPy_BMEditSelIter_Type.tp_dealloc = NULL; //(destructor)bpy_bmvert_dealloc;
|
||||
BPy_BMEditSelSeq_Type.tp_dealloc = nullptr; //(destructor)bpy_bmeditselseq_dealloc;
|
||||
BPy_BMEditSelIter_Type.tp_dealloc = nullptr; //(destructor)bpy_bmvert_dealloc;
|
||||
|
||||
BPy_BMEditSelSeq_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
BPy_BMEditSelIter_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
@@ -401,23 +401,23 @@ int BPy_BMEditSel_Assign(BPy_BMesh *self, PyObject *value)
|
||||
BMesh *bm;
|
||||
Py_ssize_t value_len;
|
||||
Py_ssize_t i;
|
||||
BMElem **value_array = NULL;
|
||||
BMElem **value_array = nullptr;
|
||||
|
||||
BPY_BM_CHECK_INT(self);
|
||||
|
||||
bm = self->bm;
|
||||
|
||||
value_array = BPy_BMElem_PySeq_As_Array(&bm,
|
||||
value,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&value_len,
|
||||
BM_VERT | BM_EDGE | BM_FACE,
|
||||
true,
|
||||
true,
|
||||
"BMesh.select_history = value");
|
||||
value_array = static_cast<BMElem **>(BPy_BMElem_PySeq_As_Array(&bm,
|
||||
value,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&value_len,
|
||||
BM_VERT | BM_EDGE | BM_FACE,
|
||||
true,
|
||||
true,
|
||||
"BMesh.select_history = value"));
|
||||
|
||||
if (value_array == NULL) {
|
||||
if (value_array == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct BPy_BMesh;
|
||||
|
||||
extern PyTypeObject BPy_BMEditSelSeq_Type;
|
||||
@@ -35,3 +39,7 @@ 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
|
||||
|
||||
@@ -36,18 +36,18 @@ PyDoc_STRVAR(bpy_bm_utils_vert_collapse_edge_doc,
|
||||
" :type edge: :class:`bmesh.types.BMEdge`\n"
|
||||
" :return: The resulting edge from the collapse operation.\n"
|
||||
" :rtype: :class:`bmesh.types.BMEdge`\n");
|
||||
static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMEdge *py_edge;
|
||||
BPy_BMVert *py_vert;
|
||||
|
||||
BMesh *bm;
|
||||
BMEdge *e_new = NULL;
|
||||
BMEdge *e_new = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O!O!:vert_collapse_edge", &BPy_BMVert_Type, &py_vert, &BPy_BMEdge_Type, &py_edge))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_edge);
|
||||
@@ -57,13 +57,13 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec
|
||||
if (!(py_edge->e->v1 == py_vert->v || py_edge->e->v2 == py_vert->v)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_edge(vert, edge): the vertex is not found in the edge");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BM_vert_edge_count_is_over(py_vert->v, 2)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_edge(vert, edge): vert has more than 2 connected edges");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = py_edge->bm;
|
||||
@@ -76,7 +76,7 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_edge(vert, edge): no new edge created, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_vert_collapse_faces_doc,
|
||||
@@ -96,7 +96,7 @@ PyDoc_STRVAR(bpy_bm_utils_vert_collapse_faces_doc,
|
||||
" :type join_faces: bool\n"
|
||||
" :return: The resulting edge from the collapse operation.\n"
|
||||
" :rtype: :class:`bmesh.types.BMEdge`\n");
|
||||
static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMEdge *py_edge;
|
||||
BPy_BMVert *py_vert;
|
||||
@@ -105,7 +105,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
||||
int do_join_faces;
|
||||
|
||||
BMesh *bm;
|
||||
BMEdge *e_new = NULL;
|
||||
BMEdge *e_new = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
"O!O!fi:vert_collapse_faces",
|
||||
@@ -116,7 +116,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
||||
&fac,
|
||||
&do_join_faces))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_edge);
|
||||
@@ -126,13 +126,13 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
||||
if (!(py_edge->e->v1 == py_vert->v || py_edge->e->v2 == py_vert->v)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_faces(vert, edge): the vertex is not found in the edge");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BM_vert_edge_count_is_over(py_vert->v, 2)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_faces(vert, edge): vert has more than 2 connected edges");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = py_edge->bm;
|
||||
@@ -146,7 +146,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"vert_collapse_faces(vert, edge): no new edge created, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_vert_dissolve_doc,
|
||||
@@ -158,14 +158,14 @@ PyDoc_STRVAR(bpy_bm_utils_vert_dissolve_doc,
|
||||
" :type vert: :class:`bmesh.types.BMVert`\n"
|
||||
" :return: True when the vertex dissolve is successful.\n"
|
||||
" :rtype: boolean\n");
|
||||
static PyObject *bpy_bm_utils_vert_dissolve(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_vert_dissolve(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMVert *py_vert;
|
||||
|
||||
BMesh *bm;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!:vert_dissolve", &BPy_BMVert_Type, &py_vert)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_vert);
|
||||
@@ -186,7 +186,7 @@ PyDoc_STRVAR(bpy_bm_utils_vert_splice_doc,
|
||||
" :type vert_target: :class:`bmesh.types.BMVert`\n"
|
||||
"\n"
|
||||
" .. note:: The verts mustn't share an edge or face.\n");
|
||||
static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_vert_splice(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMVert *py_vert;
|
||||
BPy_BMVert *py_vert_target;
|
||||
@@ -198,7 +198,7 @@ static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O!O!:vert_splice", &BPy_BMVert_Type, &py_vert, &BPy_BMVert_Type, &py_vert_target))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_vert);
|
||||
@@ -209,17 +209,17 @@ static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args
|
||||
|
||||
if (py_vert->v == py_vert_target->v) {
|
||||
PyErr_SetString(PyExc_ValueError, "vert_splice(...): vert arguments match");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BM_edge_exists(py_vert->v, py_vert_target->v)) {
|
||||
PyErr_SetString(PyExc_ValueError, "vert_splice(...): verts can't share an edge");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (BM_vert_pair_share_face_check(py_vert->v, py_vert_target->v)) {
|
||||
PyErr_SetString(PyExc_ValueError, "vert_splice(...): verts can't share a face");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* should always succeed */
|
||||
@@ -241,7 +241,7 @@ PyDoc_STRVAR(bpy_bm_utils_vert_separate_doc,
|
||||
" :type edges: :class:`bmesh.types.BMEdge`\n"
|
||||
" :return: The newly separated verts (including the vertex passed).\n"
|
||||
" :rtype: tuple of :class:`bmesh.types.BMVert`\n");
|
||||
static PyObject *bpy_bm_utils_vert_separate(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_vert_separate(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMVert *py_vert;
|
||||
PyObject *edge_seq;
|
||||
@@ -257,25 +257,25 @@ static PyObject *bpy_bm_utils_vert_separate(PyObject *UNUSED(self), PyObject *ar
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O:vert_separate", &BPy_BMVert_Type, &py_vert, &edge_seq)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_vert);
|
||||
|
||||
bm = py_vert->bm;
|
||||
|
||||
edge_array = BPy_BMElem_PySeq_As_Array(&bm,
|
||||
edge_seq,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&edge_array_len,
|
||||
BM_EDGE,
|
||||
true,
|
||||
true,
|
||||
"vert_separate(...)");
|
||||
edge_array = static_cast<BMEdge **>(BPy_BMElem_PySeq_As_Array(&bm,
|
||||
edge_seq,
|
||||
0,
|
||||
PY_SSIZE_T_MAX,
|
||||
&edge_array_len,
|
||||
BM_EDGE,
|
||||
true,
|
||||
true,
|
||||
"vert_separate(...)"));
|
||||
|
||||
if (edge_array == NULL) {
|
||||
return NULL;
|
||||
if (edge_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BM_vert_separate(bm, py_vert->v, edge_array, edge_array_len, false, &elem, &elem_len);
|
||||
@@ -301,20 +301,20 @@ PyDoc_STRVAR(bpy_bm_utils_edge_split_doc,
|
||||
" :type fac: float\n"
|
||||
" :return: The newly created (edge, vert) pair.\n"
|
||||
" :rtype: tuple\n");
|
||||
static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_edge_split(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMEdge *py_edge;
|
||||
BPy_BMVert *py_vert;
|
||||
float fac;
|
||||
|
||||
BMesh *bm;
|
||||
BMVert *v_new = NULL;
|
||||
BMEdge *e_new = NULL;
|
||||
BMVert *v_new = nullptr;
|
||||
BMEdge *e_new = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O!O!f:edge_split", &BPy_BMEdge_Type, &py_edge, &BPy_BMVert_Type, &py_vert, &fac))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_edge);
|
||||
@@ -324,7 +324,7 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
|
||||
if (!(py_edge->e->v1 == py_vert->v || py_edge->e->v2 == py_vert->v)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"edge_split(edge, vert): the vertex is not found in the edge");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = py_edge->bm;
|
||||
@@ -340,7 +340,7 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"edge_split(edge, vert): couldn't split the edge, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_edge_rotate_doc,
|
||||
@@ -355,18 +355,18 @@ PyDoc_STRVAR(bpy_bm_utils_edge_rotate_doc,
|
||||
" :type ccw: boolean\n"
|
||||
" :return: The newly rotated edge.\n"
|
||||
" :rtype: :class:`bmesh.types.BMEdge`\n");
|
||||
static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_edge_rotate(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMEdge *py_edge;
|
||||
bool do_ccw = false;
|
||||
|
||||
BMesh *bm;
|
||||
BMEdge *e_new = NULL;
|
||||
BMEdge *e_new = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O!|O&:edge_rotate", &BPy_BMEdge_Type, &py_edge, PyC_ParseBool, &do_ccw))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_edge);
|
||||
@@ -403,26 +403,26 @@ PyDoc_STRVAR(
|
||||
" :type example: :class:`bmesh.types.BMEdge`\n"
|
||||
" :return: The newly created face or None on failure.\n"
|
||||
" :rtype: (:class:`bmesh.types.BMFace`, :class:`bmesh.types.BMLoop`) pair\n");
|
||||
static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *bpy_bm_utils_face_split(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {
|
||||
"face", "vert_a", "vert_b", "coords", "use_exist", "example", NULL};
|
||||
"face", "vert_a", "vert_b", "coords", "use_exist", "example", nullptr};
|
||||
|
||||
BPy_BMFace *py_face;
|
||||
BPy_BMVert *py_vert_a;
|
||||
BPy_BMVert *py_vert_b;
|
||||
|
||||
/* optional */
|
||||
PyObject *py_coords = NULL;
|
||||
PyObject *py_coords = nullptr;
|
||||
bool edge_exists = true;
|
||||
BPy_BMEdge *py_edge_example = NULL;
|
||||
BPy_BMEdge *py_edge_example = nullptr;
|
||||
|
||||
float *coords;
|
||||
int ncoords = 0;
|
||||
|
||||
BMesh *bm;
|
||||
BMFace *f_new = NULL;
|
||||
BMLoop *l_new = NULL;
|
||||
BMFace *f_new = nullptr;
|
||||
BMLoop *l_new = nullptr;
|
||||
BMLoop *l_a, *l_b;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -441,7 +441,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
||||
&BPy_BMEdge_Type,
|
||||
&py_edge_example))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_face);
|
||||
@@ -461,24 +461,24 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"face_split(...): one of the verts passed is not found in the face");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (py_vert_a->v == py_vert_b->v) {
|
||||
PyErr_SetString(PyExc_ValueError, "face_split(...): vert arguments must differ");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (py_coords) {
|
||||
ncoords = mathutils_array_parse_alloc_v(&coords, 3, py_coords, "face_split(...): ");
|
||||
if (ncoords == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (BM_loop_is_adjacent(l_a, l_b)) {
|
||||
PyErr_SetString(PyExc_ValueError, "face_split(...): verts are adjacent in the face");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
||||
(float(*)[3])coords,
|
||||
ncoords,
|
||||
&l_new,
|
||||
py_edge_example ? py_edge_example->e : NULL);
|
||||
py_edge_example ? py_edge_example->e : nullptr);
|
||||
PyMem_Free(coords);
|
||||
}
|
||||
else {
|
||||
@@ -502,7 +502,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
||||
l_a,
|
||||
l_b,
|
||||
&l_new,
|
||||
py_edge_example ? py_edge_example->e : NULL,
|
||||
py_edge_example ? py_edge_example->e : nullptr,
|
||||
edge_exists);
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, "face_split(...): couldn't split the face, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_split_edgenet_doc,
|
||||
@@ -535,11 +535,9 @@ PyDoc_STRVAR(bpy_bm_utils_face_split_edgenet_doc,
|
||||
"\n"
|
||||
" Regions defined by edges need to connect to the face, otherwise they're "
|
||||
"ignored as loose edges.\n");
|
||||
static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self),
|
||||
PyObject *args,
|
||||
PyObject *kw)
|
||||
static PyObject *bpy_bm_utils_face_split_edgenet(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"face", "edgenet", NULL};
|
||||
static const char *kwlist[] = {"face", "edgenet", nullptr};
|
||||
|
||||
BPy_BMFace *py_face;
|
||||
PyObject *edge_seq;
|
||||
@@ -561,25 +559,25 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self),
|
||||
&py_face,
|
||||
&edge_seq))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(py_face);
|
||||
|
||||
bm = py_face->bm;
|
||||
|
||||
edge_array = BPy_BMElem_PySeq_As_Array(&bm,
|
||||
edge_seq,
|
||||
1,
|
||||
PY_SSIZE_T_MAX,
|
||||
&edge_array_len,
|
||||
BM_EDGE,
|
||||
true,
|
||||
true,
|
||||
"face_split_edgenet(...)");
|
||||
edge_array = static_cast<BMEdge **>(BPy_BMElem_PySeq_As_Array(&bm,
|
||||
edge_seq,
|
||||
1,
|
||||
PY_SSIZE_T_MAX,
|
||||
&edge_array_len,
|
||||
BM_EDGE,
|
||||
true,
|
||||
true,
|
||||
"face_split_edgenet(...)"));
|
||||
|
||||
if (edge_array == NULL) {
|
||||
return NULL;
|
||||
if (edge_array == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* --- main function body --- */
|
||||
@@ -598,7 +596,7 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self),
|
||||
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"face_split_edgenet(...): couldn't split the face, internal error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_utils_face_join_doc,
|
||||
@@ -612,9 +610,9 @@ PyDoc_STRVAR(bpy_bm_utils_face_join_doc,
|
||||
" :type remove: boolean\n"
|
||||
" :return: The newly created face or None on failure.\n"
|
||||
" :rtype: :class:`bmesh.types.BMFace`\n");
|
||||
static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_face_join(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BMesh *bm = NULL;
|
||||
BMesh *bm = nullptr;
|
||||
PyObject *py_face_array;
|
||||
BMFace **face_array;
|
||||
Py_ssize_t face_seq_len = 0;
|
||||
@@ -622,14 +620,21 @@ static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *args)
|
||||
bool do_remove = true;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O&:face_join", &py_face_array, PyC_ParseBool, &do_remove)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
face_array = BPy_BMElem_PySeq_As_Array(
|
||||
&bm, py_face_array, 2, PY_SSIZE_T_MAX, &face_seq_len, BM_FACE, true, true, "face_join(...)");
|
||||
face_array = static_cast<BMFace **>(BPy_BMElem_PySeq_As_Array(&bm,
|
||||
py_face_array,
|
||||
2,
|
||||
PY_SSIZE_T_MAX,
|
||||
&face_seq_len,
|
||||
BM_FACE,
|
||||
true,
|
||||
true,
|
||||
"face_join(...)"));
|
||||
|
||||
if (face_array == NULL) {
|
||||
return NULL; /* error will be set */
|
||||
if (face_array == nullptr) {
|
||||
return nullptr; /* error will be set */
|
||||
}
|
||||
|
||||
/* Go ahead and join the face!
|
||||
@@ -661,7 +666,7 @@ PyDoc_STRVAR(
|
||||
" .. note::\n"
|
||||
"\n"
|
||||
" This is the same as loop_separate, and has only been added for convenience.\n");
|
||||
static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *bpy_bm_utils_face_vert_separate(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
BPy_BMFace *py_face;
|
||||
BPy_BMVert *py_vert;
|
||||
@@ -673,7 +678,7 @@ static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObjec
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O!O!:face_vert_separate", &BPy_BMFace_Type, &py_face, &BPy_BMVert_Type, &py_vert))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = py_face->bm;
|
||||
@@ -683,9 +688,9 @@ static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObjec
|
||||
|
||||
l = BM_face_vert_share_loop(py_face->f, py_vert->v);
|
||||
|
||||
if (l == NULL) {
|
||||
if (l == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "vertex not found in face");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_old = l->v;
|
||||
@@ -705,13 +710,13 @@ PyDoc_STRVAR(bpy_bm_utils_face_flip_doc,
|
||||
"\n"
|
||||
" :arg face: Face to flip.\n"
|
||||
" :type face: :class:`bmesh.types.BMFace`\n");
|
||||
static PyObject *bpy_bm_utils_face_flip(PyObject *UNUSED(self), BPy_BMFace *value)
|
||||
static PyObject *bpy_bm_utils_face_flip(PyObject * /*self*/, BPy_BMFace *value)
|
||||
{
|
||||
if (!BPy_BMFace_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"face_flip(face): BMFace expected, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(value);
|
||||
@@ -730,7 +735,7 @@ PyDoc_STRVAR(bpy_bm_utils_loop_separate_doc,
|
||||
" :type loop: :class:`bmesh.types.BMLoop`\n"
|
||||
" :return vert: The newly created vertex or None on failure.\n"
|
||||
" :rtype vert: :class:`bmesh.types.BMVert`\n");
|
||||
static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop *value)
|
||||
static PyObject *bpy_bm_utils_loop_separate(PyObject * /*self*/, BPy_BMLoop *value)
|
||||
{
|
||||
BMesh *bm;
|
||||
BMLoop *l;
|
||||
@@ -740,7 +745,7 @@ static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop *
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"loop_separate(loop): BMLoop expected, not '%.200s'",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BPY_BM_CHECK_OBJ(value);
|
||||
@@ -805,7 +810,7 @@ static PyMethodDef BPy_BM_utils_methods[] = {
|
||||
(PyCFunction)bpy_bm_utils_loop_separate,
|
||||
METH_O,
|
||||
bpy_bm_utils_loop_separate_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_BM_utils_doc, "This module provides access to blenders bmesh data structures.");
|
||||
@@ -815,10 +820,10 @@ static PyModuleDef BPy_BM_utils_module_def = {
|
||||
/*m_doc*/ BPy_BM_utils_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ BPy_BM_utils_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_bmesh_utils(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *BPyInit_bmesh_utils(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,15 +14,15 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
bgl.c
|
||||
bl_math_py_api.c
|
||||
blf_py_api.c
|
||||
bpy_threads.c
|
||||
idprop_py_api.c
|
||||
idprop_py_ui_api.c
|
||||
imbuf_py_api.c
|
||||
py_capi_rna.c
|
||||
py_capi_utils.c
|
||||
bgl.cc
|
||||
bl_math_py_api.cc
|
||||
blf_py_api.cc
|
||||
bpy_threads.cc
|
||||
idprop_py_api.cc
|
||||
idprop_py_ui_api.cc
|
||||
imbuf_py_api.cc
|
||||
py_capi_rna.cc
|
||||
py_capi_utils.cc
|
||||
|
||||
bgl.h
|
||||
bl_math_py_api.h
|
||||
|
||||
@@ -167,10 +167,10 @@ static void report_deprecated_call_to_user(void)
|
||||
# define GLclampfP_def(number) Buffer *bgl_buffer##number
|
||||
#endif
|
||||
|
||||
typedef struct BufferOrOffset {
|
||||
struct BufferOrOffset {
|
||||
Buffer *buffer;
|
||||
void *offset;
|
||||
} BufferOrOffset;
|
||||
};
|
||||
|
||||
#define GLvoidP_str "O&"
|
||||
#define GLvoidP_var(number) \
|
||||
@@ -462,7 +462,7 @@ typedef struct BufferOrOffset {
|
||||
} \
|
||||
\
|
||||
PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -549,15 +549,15 @@ static bool compare_dimensions(int ndim, const int *dim1, const Py_ssize_t *dim2
|
||||
|
||||
static PySequenceMethods Buffer_SeqMethods = {
|
||||
/*sq_length*/ (lenfunc)Buffer_len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ (ssizeargfunc)Buffer_item,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. Handled by #Buffer_item. */
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. Handled by #Buffer_item. */
|
||||
/*sq_ass_item*/ (ssizeobjargproc)Buffer_ass_item,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. Handled by #Buffer_ass_item. */
|
||||
/*sq_contains*/ NULL,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. Handled by #Buffer_ass_item. */
|
||||
/*sq_contains*/ nullptr,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods Buffer_AsMapping = {
|
||||
@@ -602,7 +602,7 @@ static PyObject *Buffer_to_list_recursive(Buffer *self)
|
||||
return list;
|
||||
}
|
||||
|
||||
static PyObject *Buffer_dimensions(Buffer *self, void *UNUSED(arg))
|
||||
static PyObject *Buffer_dimensions(Buffer *self, void * /*arg*/)
|
||||
{
|
||||
PyObject *list = PyList_New(self->ndimensions);
|
||||
int i;
|
||||
@@ -616,64 +616,64 @@ static PyObject *Buffer_dimensions(Buffer *self, void *UNUSED(arg))
|
||||
|
||||
static PyMethodDef Buffer_methods[] = {
|
||||
{"to_list", (PyCFunction)Buffer_to_list_recursive, METH_NOARGS, "return the buffer as a list"},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyGetSetDef Buffer_getseters[] = {
|
||||
{"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
{"dimensions", (getter)Buffer_dimensions, nullptr, nullptr, nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr},
|
||||
};
|
||||
|
||||
PyTypeObject BGL_bufferType = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "bgl.Buffer",
|
||||
/*tp_basicsize*/ sizeof(Buffer),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)Buffer_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)Buffer_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ &Buffer_SeqMethods,
|
||||
/*tp_as_mapping*/ &Buffer_AsMapping,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ Buffer_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ Buffer_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ Buffer_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
static Buffer *BGL_MakeBuffer_FromData(
|
||||
@@ -684,7 +684,8 @@ static Buffer *BGL_MakeBuffer_FromData(
|
||||
Py_XINCREF(parent);
|
||||
buffer->parent = parent;
|
||||
buffer->ndimensions = ndimensions;
|
||||
buffer->dimensions = MEM_mallocN(ndimensions * sizeof(int), "Buffer dimensions");
|
||||
buffer->dimensions = static_cast<int *>(
|
||||
MEM_mallocN(ndimensions * sizeof(int), "Buffer dimensions"));
|
||||
memcpy(buffer->dimensions, dimensions, ndimensions * sizeof(int));
|
||||
buffer->type = type;
|
||||
buffer->buf.asvoid = buf;
|
||||
@@ -695,7 +696,7 @@ static Buffer *BGL_MakeBuffer_FromData(
|
||||
Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuffer)
|
||||
{
|
||||
Buffer *buffer;
|
||||
void *buf = NULL;
|
||||
void *buf = nullptr;
|
||||
int i, size = BGL_typeSize(type);
|
||||
|
||||
for (i = 0; i < ndimensions; i++) {
|
||||
@@ -704,7 +705,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
|
||||
|
||||
buf = MEM_mallocN(size, __func__);
|
||||
|
||||
buffer = BGL_MakeBuffer_FromData(NULL, type, ndimensions, dimensions, buf);
|
||||
buffer = BGL_MakeBuffer_FromData(nullptr, type, ndimensions, dimensions, buf);
|
||||
|
||||
if (initbuffer) {
|
||||
memcpy(buffer->buf.asvoid, initbuffer, size);
|
||||
@@ -716,14 +717,14 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
|
||||
}
|
||||
|
||||
#ifdef WITH_OPENGL_BACKEND
|
||||
/* Custom converter function so we can support a buffer, an integer or NULL.
|
||||
/* Custom converter function so we can support a buffer, an integer or nullptr.
|
||||
* Many OpenGL API functions can accept both an actual pointer or an offset
|
||||
* into a buffer that is already bound. */
|
||||
static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
|
||||
{
|
||||
if (object == Py_None) {
|
||||
buffer->buffer = NULL;
|
||||
buffer->offset = NULL;
|
||||
buffer->buffer = nullptr;
|
||||
buffer->offset = nullptr;
|
||||
return 1;
|
||||
}
|
||||
if (PyNumber_Check(object)) {
|
||||
@@ -732,13 +733,13 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer->buffer = NULL;
|
||||
buffer->buffer = nullptr;
|
||||
buffer->offset = (void *)offset;
|
||||
return 1;
|
||||
}
|
||||
if (PyObject_TypeCheck(object, &BGL_bufferType)) {
|
||||
buffer->buffer = (Buffer *)object;
|
||||
buffer->offset = NULL;
|
||||
buffer->offset = nullptr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -748,10 +749,10 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
|
||||
#endif
|
||||
|
||||
#define MAX_DIMENSIONS 256
|
||||
static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *Buffer_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *length_ob = NULL, *init = NULL;
|
||||
Buffer *buffer = NULL;
|
||||
PyObject *length_ob = nullptr, *init = nullptr;
|
||||
Buffer *buffer = nullptr;
|
||||
int dimensions[MAX_DIMENSIONS];
|
||||
|
||||
int type;
|
||||
@@ -759,17 +760,17 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError, "bgl.Buffer(): takes no keyword args");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO|O: bgl.Buffer", &type, &length_ob, &init)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (!ELEM(type, GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE)) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"invalid first argument type, should be one of "
|
||||
"GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT or GL_DOUBLE");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyLong_Check(length_ob)) {
|
||||
@@ -777,7 +778,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
if ((dimensions[0] = PyLong_AsLong(length_ob)) < 1) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"dimensions must be between 1 and " STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (PySequence_Check(length_ob)) {
|
||||
@@ -785,11 +786,11 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
if (ndimensions > MAX_DIMENSIONS) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"too many dimensions, max is " STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (ndimensions < 1) {
|
||||
PyErr_SetString(PyExc_AttributeError, "sequence must have at least one dimension");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
for (i = 0; i < ndimensions; i++) {
|
||||
PyObject *ob = PySequence_GetItem(length_ob, i);
|
||||
@@ -805,7 +806,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
if (dimensions[i] < 1) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"dimensions must be between 1 and " STRINGIFY(MAX_DIMENSIONS));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -814,7 +815,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
"invalid second argument expected a sequence "
|
||||
"or an int, not a %.200s",
|
||||
Py_TYPE(length_ob)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (init && PyObject_CheckBuffer(init)) {
|
||||
@@ -822,7 +823,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
|
||||
if (PyObject_GetBuffer(init, &pybuffer, PyBUF_ND | PyBUF_FORMAT) == -1) {
|
||||
/* PyObject_GetBuffer raise a PyExc_BufferError */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (type != gl_buffer_type_from_py_buffer(&pybuffer)) {
|
||||
@@ -842,10 +843,10 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
|
||||
PyBuffer_Release(&pybuffer);
|
||||
}
|
||||
else {
|
||||
buffer = BGL_MakeBuffer(type, ndimensions, dimensions, NULL);
|
||||
buffer = BGL_MakeBuffer(type, ndimensions, dimensions, nullptr);
|
||||
if (init && Buffer_ass_slice(buffer, 0, dimensions[0], init)) {
|
||||
Py_DECREF(buffer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,7 +864,7 @@ static PyObject *Buffer_item(Buffer *self, Py_ssize_t i)
|
||||
{
|
||||
if (i >= self->dimensions[0] || i < 0) {
|
||||
PyErr_SetString(PyExc_IndexError, "array index out of range");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (self->ndimensions == 1) {
|
||||
@@ -894,7 +895,7 @@ static PyObject *Buffer_item(Buffer *self, Py_ssize_t i)
|
||||
self->buf.asbyte + offset);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *Buffer_slice(Buffer *self, Py_ssize_t begin, Py_ssize_t end)
|
||||
@@ -1010,7 +1011,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
|
||||
Py_ssize_t i;
|
||||
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (i < 0) {
|
||||
i += self->dimensions[0];
|
||||
@@ -1021,7 +1022,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (slicelength <= 0) {
|
||||
@@ -1032,12 +1033,12 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
|
||||
@@ -1127,13 +1128,13 @@ static PyObject *Buffer_repr(Buffer *self)
|
||||
|
||||
#ifdef WITH_OPENGL_BACKEND
|
||||
# define BGL_Wrap(funcname, ret, arg_list) \
|
||||
static PyObject *Method_##funcname(PyObject *UNUSED(self), PyObject *args) \
|
||||
static PyObject *Method_##funcname(PyObject * /*self*/, PyObject *args) \
|
||||
{ \
|
||||
arg_def arg_list; \
|
||||
ret_def_##ret; \
|
||||
report_deprecated_call(#funcname); \
|
||||
if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
const bool has_opengl_backend = GPU_backend_get_type() == GPU_BACKEND_OPENGL; \
|
||||
if (has_opengl_backend) { \
|
||||
@@ -1154,11 +1155,11 @@ static void bgl_no_opengl_error(void)
|
||||
}
|
||||
|
||||
# define BGL_Wrap(funcname, ret, arg_list) \
|
||||
static PyObject *Method_##funcname(PyObject *UNUSED(self), PyObject *args) \
|
||||
static PyObject *Method_##funcname(PyObject * /*self*/, PyObject *args) \
|
||||
{ \
|
||||
(void)args; \
|
||||
bgl_no_opengl_error(); \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1445,13 +1446,13 @@ BGL_Wrap(TexImage3DMultisample,
|
||||
static PyModuleDef BGL_module_def = {
|
||||
/*m_base*/ PyModuleDef_HEAD_INIT,
|
||||
/*m_name*/ "bgl",
|
||||
/*m_doc*/ NULL,
|
||||
/*m_doc*/ nullptr,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
static void py_module_dict_add_int(PyObject *dict, const char *name, int value)
|
||||
@@ -1475,7 +1476,7 @@ static void py_module_dict_add_method(PyObject *submodule,
|
||||
{
|
||||
if (is_valid) {
|
||||
PyObject *m;
|
||||
m = PyCFunction_NewEx(method_def, NULL, submodule);
|
||||
m = PyCFunction_NewEx(method_def, nullptr, submodule);
|
||||
PyDict_SetItemString(dict, method_def->ml_name, m);
|
||||
Py_DECREF(m);
|
||||
}
|
||||
@@ -1484,7 +1485,7 @@ static void py_module_dict_add_method(PyObject *submodule,
|
||||
}
|
||||
}
|
||||
|
||||
/* needed since some function pointers won't be NULL */
|
||||
/* needed since some function pointers won't be nullptr */
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Waddress"
|
||||
#endif
|
||||
@@ -1493,7 +1494,7 @@ static void py_module_dict_add_method(PyObject *submodule,
|
||||
# define PY_MOD_ADD_METHOD(func) \
|
||||
{ \
|
||||
static PyMethodDef method_def = {"gl" #func, Method_##func, METH_VARARGS}; \
|
||||
py_module_dict_add_method(submodule, dict, &method_def, (gl##func != NULL)); \
|
||||
py_module_dict_add_method(submodule, dict, &method_def, (gl##func != nullptr)); \
|
||||
} \
|
||||
((void)0)
|
||||
#else
|
||||
@@ -1776,7 +1777,7 @@ static void init_bgl_version_3_2_methods(PyObject *submodule, PyObject *dict)
|
||||
PY_MOD_ADD_METHOD(TexImage2DMultisample);
|
||||
PY_MOD_ADD_METHOD(TexImage3DMultisample);
|
||||
}
|
||||
static void init_bgl_version_3_3_methods(PyObject *UNUSED(submodule), PyObject *UNUSED(dict))
|
||||
static void init_bgl_version_3_3_methods(PyObject * /*submodule*/, PyObject * /*dict*/)
|
||||
{
|
||||
/* GL_VERSION_3_3 */
|
||||
}
|
||||
@@ -2270,8 +2271,8 @@ static void init_bgl_version_3_0_constants(PyObject *dict)
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE4);
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE5);
|
||||
#if 0
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE6);
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE7);
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE6);
|
||||
PY_DICT_ADD_INT(GL_CLIP_DISTANCE7);
|
||||
#endif
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT0);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT1);
|
||||
@@ -2290,22 +2291,22 @@ static void init_bgl_version_3_0_constants(PyObject *dict)
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT14);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT15);
|
||||
#if 0
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT16);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT17);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT18);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT19);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT20);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT21);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT22);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT23);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT24);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT25);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT26);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT27);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT28);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT29);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT30);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT31);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT16);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT17);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT18);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT19);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT20);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT21);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT22);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT23);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT24);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT25);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT26);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT27);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT28);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT29);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT30);
|
||||
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT31);
|
||||
#endif
|
||||
PY_DICT_ADD_INT(GL_COMPARE_REF_TO_TEXTURE);
|
||||
PY_DICT_ADD_INT(GL_COMPRESSED_RED);
|
||||
@@ -2654,13 +2655,13 @@ PyObject *BPyInit_bgl(void)
|
||||
dict = PyModule_GetDict(submodule);
|
||||
|
||||
if (PyType_Ready(&BGL_bufferType) < 0) {
|
||||
return NULL; /* should never happen */
|
||||
return nullptr; /* should never happen */
|
||||
}
|
||||
|
||||
/* Building as a Python module loads all modules
|
||||
* (see code comment around #PyImport_ExtendInittab usage).
|
||||
* The result of this is the `bgl` warning would always show when importing `bpy`.
|
||||
* In the case of Blender as a Python module, suppress the warning. */
|
||||
/* Building as a Python module loads all modules
|
||||
* (see code comment around #PyImport_ExtendInittab usage).
|
||||
* The result of this is the `bgl` warning would always show when importing `bpy`.
|
||||
* In the case of Blender as a Python module, suppress the warning. */
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
if (GPU_backend_get_type() != GPU_BACKEND_OPENGL) {
|
||||
CLOG_WARN(&LOG,
|
||||
@@ -2700,21 +2701,21 @@ PyObject *BPyInit_bgl(void)
|
||||
return submodule;
|
||||
}
|
||||
|
||||
static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *Method_ShaderSource(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
uint shader;
|
||||
const char *source;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Is", &shader, &source)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef WITH_OPENGL
|
||||
glShaderSource(shader, 1, (const char **)&source, NULL);
|
||||
glShaderSource(shader, 1, (const char **)&source, nullptr);
|
||||
Py_RETURN_NONE;
|
||||
#else
|
||||
bgl_no_opengl_error();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -44,18 +44,18 @@ PyDoc_STRVAR(py_bl_math_clamp_doc,
|
||||
" :type max: float\n"
|
||||
" :return: The clamped value.\n"
|
||||
" :rtype: float\n");
|
||||
static PyObject *py_bl_math_clamp(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_bl_math_clamp(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
double x, minv = 0.0, maxv = 1.0;
|
||||
|
||||
if (PyTuple_Size(args) <= 1) {
|
||||
if (!PyArg_ParseTuple(args, "d:clamp", &x)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!PyArg_ParseTuple(args, "ddd:clamp", &x, &minv, &maxv)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ PyDoc_STRVAR(py_bl_math_lerp_doc,
|
||||
" :type factor: float\n"
|
||||
" :return: The interpolated value.\n"
|
||||
" :rtype: float\n");
|
||||
static PyObject *py_bl_math_lerp(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_bl_math_lerp(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
double a, b, x;
|
||||
if (!PyArg_ParseTuple(args, "ddd:lerp", &a, &b, &x)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(a * (1.0 - x) + b * x);
|
||||
@@ -102,11 +102,11 @@ PyDoc_STRVAR(py_bl_math_smoothstep_doc,
|
||||
" :type factor: float\n"
|
||||
" :return: The interpolated value in [0.0, 1.0].\n"
|
||||
" :rtype: float\n");
|
||||
static PyObject *py_bl_math_smoothstep(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_bl_math_smoothstep(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
double a, b, x;
|
||||
if (!PyArg_ParseTuple(args, "ddd:smoothstep", &a, &b, &x)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double t = (x - a) / (b - a);
|
||||
@@ -126,7 +126,7 @@ static PyMethodDef M_bl_math_methods[] = {
|
||||
{"clamp", (PyCFunction)py_bl_math_clamp, METH_VARARGS, py_bl_math_clamp_doc},
|
||||
{"lerp", (PyCFunction)py_bl_math_lerp, METH_VARARGS, py_bl_math_lerp_doc},
|
||||
{"smoothstep", (PyCFunction)py_bl_math_smoothstep, METH_VARARGS, py_bl_math_smoothstep_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyModuleDef M_bl_math_module_def = {
|
||||
@@ -135,10 +135,10 @@ static PyModuleDef M_bl_math_module_def = {
|
||||
/*m_doc*/ M_bl_math_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ M_bl_math_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC BPyInit_bl_math(void)
|
||||
@@ -9,4 +9,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyMODINIT_FUNC BPyInit_bl_math(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,13 +35,13 @@ PyDoc_STRVAR(py_blf_position_doc,
|
||||
" :arg z: Z axis position to draw the text.\n"
|
||||
" :type z: float\n");
|
||||
|
||||
static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_position(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int fontid;
|
||||
float x, y, z;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_position(fontid, x, y, z);
|
||||
@@ -59,13 +59,13 @@ PyDoc_STRVAR(py_blf_size_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg size: Point size of the font.\n"
|
||||
" :type size: float\n");
|
||||
static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_size(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int fontid;
|
||||
float size;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "if:blf.size", &fontid, &size)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_size(fontid, size);
|
||||
@@ -83,13 +83,13 @@ PyDoc_STRVAR(py_blf_aspect_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg aspect: The aspect ratio for text drawing to use.\n"
|
||||
" :type aspect: float\n");
|
||||
static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_aspect(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
float aspect;
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_aspect(fontid, aspect, aspect, 1.0);
|
||||
@@ -113,14 +113,14 @@ PyDoc_STRVAR(py_blf_color_doc,
|
||||
" :type b: float\n"
|
||||
" :arg a: alpha channel 0.0 - 1.0.\n"
|
||||
" :type a: float\n");
|
||||
static PyObject *py_blf_color(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_color(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int fontid;
|
||||
float rgba[4];
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_color4fv(fontid, rgba);
|
||||
@@ -139,12 +139,12 @@ PyDoc_STRVAR(py_blf_blur_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg radius: The radius for blurring text (in pixels).\n"
|
||||
" :type radius: int\n");
|
||||
static PyObject *py_blf_blur(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_blur(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int blur, fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_blur(fontid, blur);
|
||||
@@ -163,14 +163,14 @@ PyDoc_STRVAR(py_blf_draw_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg text: the text to draw.\n"
|
||||
" :type text: string\n");
|
||||
static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_draw(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
const char *text;
|
||||
Py_ssize_t text_length;
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "is#:blf.draw", &fontid, &text, &text_length)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_draw(fontid, text, (uint)text_length);
|
||||
@@ -190,7 +190,7 @@ PyDoc_STRVAR(py_blf_dimensions_doc,
|
||||
" :type text: string\n"
|
||||
" :return: the width and height of the text.\n"
|
||||
" :rtype: tuple of 2 floats\n");
|
||||
static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_dimensions(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
const char *text;
|
||||
float r_width, r_height;
|
||||
@@ -198,7 +198,7 @@ static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_width_and_height(fontid, text, INT_MAX, &r_width, &r_height);
|
||||
@@ -224,13 +224,13 @@ PyDoc_STRVAR(py_blf_clipping_doc,
|
||||
" :type xmax: float\n"
|
||||
" :arg ymax: Clip the drawing area by these bounds.\n"
|
||||
" :type ymax: float\n");
|
||||
static PyObject *py_blf_clipping(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_clipping(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
float xmin, ymin, xmax, ymax;
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_clipping(fontid, xmin, ymin, xmax, ymax);
|
||||
@@ -248,13 +248,13 @@ PyDoc_STRVAR(py_blf_word_wrap_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg wrap_width: The width (in pixels) to wrap words at.\n"
|
||||
" :type wrap_width: int\n");
|
||||
static PyObject *py_blf_word_wrap(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_word_wrap(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int wrap_width;
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:blf.word_wrap", &fontid, &wrap_width)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_wordwrap(fontid, wrap_width);
|
||||
@@ -272,12 +272,12 @@ PyDoc_STRVAR(py_blf_disable_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
|
||||
" :type option: int\n");
|
||||
static PyObject *py_blf_disable(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_disable(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int option, fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_disable(fontid, option);
|
||||
@@ -295,12 +295,12 @@ PyDoc_STRVAR(py_blf_enable_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
|
||||
" :type option: int\n");
|
||||
static PyObject *py_blf_enable(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_enable(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int option, fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_enable(fontid, option);
|
||||
@@ -318,13 +318,13 @@ PyDoc_STRVAR(py_blf_rotation_doc,
|
||||
" :type fontid: int\n"
|
||||
" :arg angle: The angle for text drawing to use.\n"
|
||||
" :type angle: float\n");
|
||||
static PyObject *py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_rotation(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
float angle;
|
||||
int fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_rotation(fontid, angle);
|
||||
@@ -350,7 +350,7 @@ PyDoc_STRVAR(py_blf_shadow_doc,
|
||||
" :type b: float\n"
|
||||
" :arg a: Shadow color (alpha channel 0.0 - 1.0).\n"
|
||||
" :type a: float\n");
|
||||
static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_shadow(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int level, fontid;
|
||||
float rgba[4];
|
||||
@@ -358,12 +358,12 @@ static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ELEM(level, 0, 3, 5)) {
|
||||
PyErr_SetString(PyExc_TypeError, "blf.shadow expected arg to be in (0, 3, 5)");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_shadow(fontid, level, rgba);
|
||||
@@ -383,12 +383,12 @@ PyDoc_STRVAR(py_blf_shadow_offset_doc,
|
||||
" :type x: float\n"
|
||||
" :arg y: Horizontal shadow offset value in pixels.\n"
|
||||
" :type y: float\n");
|
||||
static PyObject *py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_shadow_offset(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int x, y, fontid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_shadow_offset(fontid, x, y);
|
||||
@@ -405,12 +405,12 @@ PyDoc_STRVAR(py_blf_load_doc,
|
||||
" :type filepath: string\n"
|
||||
" :return: the new font's fontid or -1 if there was an error.\n"
|
||||
" :rtype: integer\n");
|
||||
static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_load(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
const char *filepath;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:blf.load", &filepath)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyLong_FromLong(BLF_load(filepath));
|
||||
@@ -423,12 +423,12 @@ PyDoc_STRVAR(py_blf_unload_doc,
|
||||
"\n"
|
||||
" :arg filepath: the filepath of the font.\n"
|
||||
" :type filepath: string\n");
|
||||
static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *py_blf_unload(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
const char *filepath;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:blf.unload", &filepath)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLF_unload(filepath);
|
||||
@@ -456,7 +456,7 @@ static PyMethodDef BLF_methods[] = {
|
||||
{"color", (PyCFunction)py_blf_color, METH_VARARGS, py_blf_color_doc},
|
||||
{"load", (PyCFunction)py_blf_load, METH_VARARGS, py_blf_load_doc},
|
||||
{"unload", (PyCFunction)py_blf_unload, METH_VARARGS, py_blf_unload_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BLF_doc, "This module provides access to Blender's text drawing functions.");
|
||||
@@ -466,10 +466,10 @@ static PyModuleDef BLF_module_def = {
|
||||
/*m_doc*/ BLF_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ BLF_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_blf(void)
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* This file contains wrapper functions related to global interpreter lock.
|
||||
* these functions are slightly different from the original Python API,
|
||||
* don't throw SIGABRT even if the thread state is NULL. */
|
||||
* don't throw SIGABRT even if the thread state is nullptr. */
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
BPy_ThreadStatePtr BPY_thread_save(void)
|
||||
{
|
||||
/* Use `_PyThreadState_UncheckedGet()` instead of `PyThreadState_Get()`, to avoid a fatal error
|
||||
* issued when a thread state is NULL (the thread state can be NULL when quitting Blender).
|
||||
* issued when a thread state is nullptr (the thread state can be nullptr when quitting Blender).
|
||||
*
|
||||
* `PyEval_SaveThread()` will release the GIL, so this thread has to have the GIL to begin with
|
||||
* or badness will ensue. */
|
||||
if (_PyThreadState_UncheckedGet() && PyGILState_Check()) {
|
||||
return (BPy_ThreadStatePtr)PyEval_SaveThread();
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BPY_thread_restore(BPy_ThreadStatePtr tstate)
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
#include "python_utildefines.h"
|
||||
|
||||
extern bool pyrna_id_FromPyObject(PyObject *obj, ID **id);
|
||||
extern PyObject *pyrna_id_CreatePyObject(ID *id);
|
||||
extern bool pyrna_id_CheckPyObject(PyObject *obj);
|
||||
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);
|
||||
|
||||
/* Currently there is no need to expose this publicly. */
|
||||
static PyObject *BPy_IDGroup_IterKeys_CreatePyObject(BPy_IDProperty *group, const bool reversed);
|
||||
@@ -56,7 +56,7 @@ static PyObject *idprop_py_from_idp_string(const IDProperty *prop)
|
||||
}
|
||||
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromBytesAndSize(IDP_Array(prop), prop->len - 1);
|
||||
return PyC_UnicodeFromBytesAndSize(static_cast<const char *>(IDP_Array(prop)), prop->len - 1);
|
||||
#else
|
||||
return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1);
|
||||
#endif
|
||||
@@ -87,13 +87,13 @@ static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty *
|
||||
BPy_IDProperty *group = PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
|
||||
group->owner_id = id;
|
||||
group->prop = prop;
|
||||
group->parent = parent; /* can be NULL */
|
||||
group->parent = parent; /* can be nullptr */
|
||||
return (PyObject *)group;
|
||||
}
|
||||
|
||||
static PyObject *idprop_py_from_idp_id(IDProperty *prop)
|
||||
{
|
||||
return pyrna_id_CreatePyObject(prop->data.pointer);
|
||||
return pyrna_id_CreatePyObject(static_cast<ID *>(prop->data.pointer));
|
||||
}
|
||||
|
||||
static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop)
|
||||
@@ -113,16 +113,16 @@ static PyObject *idprop_py_from_idp_idparray(ID *id, IDProperty *prop)
|
||||
if (!seq) {
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: IDP_IDPARRAY: PyList_New(%d) failed", __func__, prop->len);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (i = 0; i < prop->len; i++) {
|
||||
PyObject *wrap = BPy_IDGroup_WrapData(id, array++, prop);
|
||||
|
||||
/* BPy_IDGroup_MapDataToPy sets the error */
|
||||
if (UNLIKELY(wrap == NULL)) {
|
||||
if (UNLIKELY(wrap == nullptr)) {
|
||||
Py_DECREF(seq);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyList_SET_ITEM(seq, i, wrap);
|
||||
@@ -188,11 +188,11 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
|
||||
PyErr_SetString(PyExc_TypeError, "expected a string!");
|
||||
return -1;
|
||||
}
|
||||
/* NOTE: if this code is enabled, bytes support needs to be added */
|
||||
/* NOTE: if this code is enabled, bytes support needs to be added */
|
||||
# ifdef USE_STRING_COERCE
|
||||
{
|
||||
int alloc_len;
|
||||
PyObject *value_coerce = NULL;
|
||||
PyObject *value_coerce = nullptr;
|
||||
|
||||
st = (char *)PyC_UnicodeAsBytes(value, &value_coerce);
|
||||
alloc_len = strlen(st) + 1;
|
||||
@@ -247,12 +247,12 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void *UNUSED(closure))
|
||||
static PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void * /*closure*/)
|
||||
{
|
||||
return PyUnicode_FromString(self->prop->name);
|
||||
}
|
||||
|
||||
static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUSED(closure))
|
||||
static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
const char *name;
|
||||
Py_ssize_t name_len;
|
||||
@@ -285,8 +285,8 @@ static PyGetSetDef BPy_IDGroup_getseters[] = {
|
||||
(getter)BPy_IDGroup_GetName,
|
||||
(setter)BPy_IDGroup_SetName,
|
||||
"The name of this Group.",
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static Py_ssize_t BPy_IDGroup_Map_Len(BPy_IDProperty *self)
|
||||
@@ -306,27 +306,27 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
|
||||
|
||||
if (self->prop->type != IDP_GROUP) {
|
||||
PyErr_SetString(PyExc_TypeError, "unsubscriptable object");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
name = PyUnicode_AsUTF8(item);
|
||||
|
||||
if (name == NULL) {
|
||||
if (name == nullptr) {
|
||||
PyErr_SetString(PyExc_TypeError, "only strings are allowed as keys of ID properties");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
idprop = IDP_GetPropertyFromGroup(self->prop, name);
|
||||
|
||||
if (idprop == NULL) {
|
||||
if (idprop == nullptr) {
|
||||
PyErr_SetString(PyExc_KeyError, "key not in subgroup dict");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPy_IDGroup_WrapData(self->owner_id, idprop, self->prop);
|
||||
}
|
||||
|
||||
/* returns NULL on success, error string on failure */
|
||||
/* returns nullptr on success, error string on failure */
|
||||
static char idp_sequence_type(PyObject *seq_fast)
|
||||
{
|
||||
PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
|
||||
@@ -370,22 +370,22 @@ static char idp_sequence_type(PyObject *seq_fast)
|
||||
|
||||
static const char *idp_try_read_name(PyObject *name_obj)
|
||||
{
|
||||
const char *name = NULL;
|
||||
const char *name = nullptr;
|
||||
if (name_obj) {
|
||||
Py_ssize_t name_len;
|
||||
name = PyUnicode_AsUTF8AndSize(name_obj, &name_len);
|
||||
|
||||
if (name == NULL) {
|
||||
if (name == nullptr) {
|
||||
PyErr_Format(PyExc_KeyError,
|
||||
"invalid id-property key, expected a string, not a %.200s",
|
||||
Py_TYPE(name_obj)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!(name_len < MAX_IDPROP_NAME)) {
|
||||
PyErr_SetString(PyExc_KeyError,
|
||||
"the length of IDProperty names is limited to 63 characters");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -402,7 +402,7 @@ static const char *idp_try_read_name(PyObject *name_obj)
|
||||
|
||||
/**
|
||||
* The 'idp_from_Py*' functions expect that the input type has been checked before
|
||||
* and return NULL if the IDProperty can't be created.
|
||||
* and return nullptr if the IDProperty can't be created.
|
||||
*/
|
||||
|
||||
static IDProperty *idp_from_PyFloat(const char *name, PyObject *ob)
|
||||
@@ -424,7 +424,7 @@ static IDProperty *idp_from_PyLong(const char *name, PyObject *ob)
|
||||
IDPropertyTemplate val = {0};
|
||||
val.i = PyC_Long_AsI32(ob);
|
||||
if (val.i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return IDP_New(IDP_INT, &val, name);
|
||||
}
|
||||
@@ -435,7 +435,7 @@ static IDProperty *idp_from_PyUnicode(const char *name, PyObject *ob)
|
||||
IDPropertyTemplate val = {0};
|
||||
#ifdef USE_STRING_COERCE
|
||||
Py_ssize_t value_len;
|
||||
PyObject *value_coerce = NULL;
|
||||
PyObject *value_coerce = nullptr;
|
||||
val.string.str = PyC_UnicodeAsBytesAndSize(ob, &value_len, &value_coerce);
|
||||
val.string.len = (int)value_len + 1;
|
||||
val.string.subtype = IDP_STRING_SUB_UTF8;
|
||||
@@ -492,7 +492,7 @@ static const char *idp_format_from_array_type(int type)
|
||||
if (type == IDP_BOOLEAN) {
|
||||
return "b";
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static IDProperty *idp_from_PySequence_Buffer(const char *name, Py_buffer *buffer)
|
||||
@@ -503,7 +503,7 @@ static IDProperty *idp_from_PySequence_Buffer(const char *name, Py_buffer *buffe
|
||||
const int id_type = idp_array_type_from_formatstr_and_size(buffer->format, buffer->itemsize);
|
||||
if (id_type == -1) {
|
||||
/* should never happen as the type has been checked before */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
val.array.type = id_type;
|
||||
@@ -528,7 +528,7 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
|
||||
if ((val.array.type = idp_sequence_type(ob)) == (char)-1) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"only floats, ints and dicts are allowed in ID property arrays");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* validate sequence and derive type.
|
||||
@@ -541,12 +541,12 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
|
||||
case IDP_DOUBLE: {
|
||||
double *prop_data;
|
||||
prop = IDP_New(IDP_ARRAY, &val, name);
|
||||
prop_data = IDP_Array(prop);
|
||||
prop_data = static_cast<double *>(IDP_Array(prop));
|
||||
for (i = 0; i < val.array.len; i++) {
|
||||
item = ob_seq_fast_items[i];
|
||||
if (((prop_data[i] = PyFloat_AsDouble(item)) == -1.0) && PyErr_Occurred()) {
|
||||
IDP_FreeProperty(prop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -554,12 +554,12 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
|
||||
case IDP_INT: {
|
||||
int *prop_data;
|
||||
prop = IDP_New(IDP_ARRAY, &val, name);
|
||||
prop_data = IDP_Array(prop);
|
||||
prop_data = static_cast<int *>(IDP_Array(prop));
|
||||
for (i = 0; i < val.array.len; i++) {
|
||||
item = ob_seq_fast_items[i];
|
||||
if (((prop_data[i] = PyC_Long_AsI32(item)) == -1) && PyErr_Occurred()) {
|
||||
IDP_FreeProperty(prop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -568,22 +568,22 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
|
||||
prop = IDP_NewIDPArray(name);
|
||||
for (i = 0; i < val.array.len; i++) {
|
||||
item = ob_seq_fast_items[i];
|
||||
if (BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item) == false) {
|
||||
if (BPy_IDProperty_Map_ValidateAndCreate(nullptr, prop, item) == false) {
|
||||
IDP_FreeProperty(prop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDP_BOOLEAN: {
|
||||
prop = IDP_New(IDP_ARRAY, &val, name);
|
||||
bool *prop_data = IDP_Array(prop);
|
||||
bool *prop_data = static_cast<bool *>(IDP_Array(prop));
|
||||
for (i = 0; i < val.array.len; i++) {
|
||||
item = ob_seq_fast_items[i];
|
||||
const int value = PyC_Long_AsBool(item);
|
||||
if ((value == -1) && PyErr_Occurred()) {
|
||||
IDP_FreeProperty(prop);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
prop_data[i] = (value != 0);
|
||||
}
|
||||
@@ -592,7 +592,7 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
|
||||
default:
|
||||
/* should never happen */
|
||||
PyErr_SetString(PyExc_RuntimeError, "internal error with idp array.type");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
@@ -628,13 +628,13 @@ static IDProperty *idp_from_PySequence(const char *name, PyObject *ob)
|
||||
}
|
||||
|
||||
PyObject *ob_seq_fast = PySequence_Fast(ob, "py -> idprop");
|
||||
if (ob_seq_fast != NULL) {
|
||||
if (ob_seq_fast != nullptr) {
|
||||
IDProperty *prop = idp_from_PySequence_Fast(name, ob_seq_fast);
|
||||
Py_DECREF(ob_seq_fast);
|
||||
return prop;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
|
||||
@@ -662,7 +662,7 @@ static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
|
||||
Py_XDECREF(key);
|
||||
Py_XDECREF(pval);
|
||||
/* error is already set */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_XDECREF(key);
|
||||
Py_XDECREF(pval);
|
||||
@@ -682,8 +682,8 @@ static IDProperty *idp_from_DatablockPointer(const char *name, PyObject *ob)
|
||||
static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob)
|
||||
{
|
||||
const char *name = idp_try_read_name(name_obj);
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
if (name == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyFloat_Check(ob)) {
|
||||
@@ -713,7 +713,7 @@ static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob)
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "invalid id-property type %.200s not supported", Py_TYPE(ob)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -725,7 +725,7 @@ static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob)
|
||||
bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob)
|
||||
{
|
||||
IDProperty *prop = idp_from_PyObject(name_obj, ob);
|
||||
if (prop == NULL) {
|
||||
if (prop == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group,
|
||||
/* avoid freeing when types match in case they are referenced by the UI, see: #37073
|
||||
* obviously this isn't a complete solution, but helps for common cases. */
|
||||
prop_exist = IDP_GetPropertyFromGroup(group, prop->name);
|
||||
if ((prop_exist != NULL) && (prop_exist->type == prop->type) &&
|
||||
if ((prop_exist != nullptr) && (prop_exist->type == prop->type) &&
|
||||
(prop_exist->subtype == prop->subtype))
|
||||
{
|
||||
/* Preserve prev/next links!!! See #42593. */
|
||||
@@ -750,7 +750,7 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group,
|
||||
|
||||
/* Don't free and reset the existing property's UI data, since this only assigns a value. */
|
||||
IDPropertyUIData *ui_data = prop_exist->ui_data;
|
||||
prop_exist->ui_data = NULL;
|
||||
prop_exist->ui_data = nullptr;
|
||||
IDP_FreePropertyContent(prop_exist);
|
||||
*prop_exist = *prop;
|
||||
prop_exist->ui_data = ui_data;
|
||||
@@ -777,11 +777,11 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (val == NULL) { /* del idprop[key] */
|
||||
if (val == nullptr) { /* del idprop[key] */
|
||||
IDProperty *pkey;
|
||||
const char *name = PyUnicode_AsUTF8(key);
|
||||
|
||||
if (name == NULL) {
|
||||
if (name == nullptr) {
|
||||
PyErr_Format(PyExc_KeyError, "expected a string, not %.200s", Py_TYPE(key)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
@@ -820,7 +820,7 @@ static PyObject *BPy_IDGroup_iter(BPy_IDProperty *self)
|
||||
Py_DECREF(iterable);
|
||||
}
|
||||
else {
|
||||
ret = NULL;
|
||||
ret = nullptr;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -847,7 +847,7 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
if (!seq) {
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: IDP_ARRAY: PyList_New(%d) failed", __func__, prop->len);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (prop->subtype) {
|
||||
@@ -883,7 +883,7 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: invalid/corrupt array type '%d'!", __func__, prop->subtype);
|
||||
Py_DECREF(seq);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return seq;
|
||||
@@ -896,16 +896,16 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
if (!seq) {
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: IDP_IDPARRAY: PyList_New(%d) failed", __func__, prop->len);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (i = 0; i < prop->len; i++) {
|
||||
PyObject *wrap = BPy_IDGroup_MapDataToPy(array++);
|
||||
|
||||
/* BPy_IDGroup_MapDataToPy sets the error */
|
||||
if (UNLIKELY(wrap == NULL)) {
|
||||
if (UNLIKELY(wrap == nullptr)) {
|
||||
Py_DECREF(seq);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyList_SET_ITEM(seq, i, wrap);
|
||||
@@ -916,13 +916,13 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
PyObject *dict = _PyDict_NewPresized(prop->len);
|
||||
IDProperty *loop;
|
||||
|
||||
for (loop = prop->data.group.first; loop; loop = loop->next) {
|
||||
for (loop = static_cast<IDProperty *>(prop->data.group.first); loop; loop = loop->next) {
|
||||
PyObject *wrap = BPy_IDGroup_MapDataToPy(loop);
|
||||
|
||||
/* BPy_IDGroup_MapDataToPy sets the error */
|
||||
if (UNLIKELY(wrap == NULL)) {
|
||||
if (UNLIKELY(wrap == nullptr)) {
|
||||
Py_DECREF(dict);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyDict_SetItemString(dict, loop->name, wrap);
|
||||
@@ -937,7 +937,7 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
__func__,
|
||||
prop->name,
|
||||
prop->type);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -948,7 +948,7 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
|
||||
static PyObject *BPy_IDGroup_Iter_repr(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return PyUnicode_FromFormat("<%s>", Py_TYPE(self)->tp_name);
|
||||
}
|
||||
return PyUnicode_FromFormat("<%s \"%s\">", Py_TYPE(self)->tp_name, self->group->prop->name);
|
||||
@@ -956,7 +956,7 @@ static PyObject *BPy_IDGroup_Iter_repr(BPy_IDGroup_Iter *self)
|
||||
|
||||
static void BPy_IDGroup_Iter_dealloc(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
if (self->group != NULL) {
|
||||
if (self->group != nullptr) {
|
||||
PyObject_GC_UnTrack(self);
|
||||
}
|
||||
Py_CLEAR(self->group);
|
||||
@@ -977,7 +977,7 @@ static int BPy_IDGroup_Iter_clear(BPy_IDGroup_Iter *self)
|
||||
|
||||
static int BPy_IDGroup_Iter_is_gc(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
return (self->group != NULL);
|
||||
return (self->group != nullptr);
|
||||
}
|
||||
|
||||
static bool BPy_Group_Iter_same_size_or_raise_error(BPy_IDGroup_Iter *self)
|
||||
@@ -991,40 +991,40 @@ static bool BPy_Group_Iter_same_size_or_raise_error(BPy_IDGroup_Iter *self)
|
||||
|
||||
static PyObject *BPy_Group_IterKeys_next(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
if (self->cur != NULL) {
|
||||
/* When `cur` is set, `group` cannot be NULL. */
|
||||
if (self->cur != nullptr) {
|
||||
/* When `cur` is set, `group` cannot be nullptr. */
|
||||
if (!BPy_Group_Iter_same_size_or_raise_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
IDProperty *cur = self->cur;
|
||||
self->cur = self->reversed ? self->cur->prev : self->cur->next;
|
||||
return PyUnicode_FromString(cur->name);
|
||||
}
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *BPy_Group_IterValues_next(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
if (self->cur != NULL) {
|
||||
/* When `cur` is set, `group` cannot be NULL. */
|
||||
if (self->cur != nullptr) {
|
||||
/* When `cur` is set, `group` cannot be nullptr. */
|
||||
if (!BPy_Group_Iter_same_size_or_raise_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
IDProperty *cur = self->cur;
|
||||
self->cur = self->reversed ? self->cur->prev : self->cur->next;
|
||||
return BPy_IDGroup_WrapData(self->group->owner_id, cur, self->group->prop);
|
||||
}
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *BPy_Group_IterItems_next(BPy_IDGroup_Iter *self)
|
||||
{
|
||||
if (self->cur != NULL) {
|
||||
/* When `cur` is set, `group` cannot be NULL. */
|
||||
if (self->cur != nullptr) {
|
||||
/* When `cur` is set, `group` cannot be nullptr. */
|
||||
if (!BPy_Group_Iter_same_size_or_raise_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
IDProperty *cur = self->cur;
|
||||
self->cur = self->reversed ? self->cur->prev : self->cur->next;
|
||||
@@ -1035,12 +1035,12 @@ static PyObject *BPy_Group_IterItems_next(BPy_IDGroup_Iter *self)
|
||||
return ret;
|
||||
}
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyTypeObject BPy_IDGroup_IterKeys_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_IterValues_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_IterItems_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_IterKeys_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
PyTypeObject BPy_IDGroup_IterValues_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
PyTypeObject BPy_IDGroup_IterItems_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
|
||||
/* ID Property Group Iterator. */
|
||||
static void IDGroup_Iter_init_type(void)
|
||||
@@ -1085,15 +1085,16 @@ static PyObject *IDGroup_Iter_New_WithType(BPy_IDProperty *group,
|
||||
BPy_IDGroup_Iter *iter = PyObject_GC_New(BPy_IDGroup_Iter, type);
|
||||
iter->reversed = reversed;
|
||||
iter->group = group;
|
||||
if (group != NULL) {
|
||||
if (group != nullptr) {
|
||||
Py_INCREF(group);
|
||||
BLI_assert(!PyObject_GC_IsTracked((PyObject *)iter));
|
||||
PyObject_GC_Track(iter);
|
||||
iter->cur = (reversed ? group->prop->data.group.last : group->prop->data.group.first);
|
||||
iter->cur = static_cast<IDProperty *>(
|
||||
(reversed ? group->prop->data.group.last : group->prop->data.group.first));
|
||||
iter->len_init = group->prop->len;
|
||||
}
|
||||
else {
|
||||
iter->cur = NULL;
|
||||
iter->cur = nullptr;
|
||||
iter->len_init = 0;
|
||||
}
|
||||
return (PyObject *)iter;
|
||||
@@ -1132,7 +1133,7 @@ static PyObject *BPy_IDGroup_IterItems_CreatePyObject(BPy_IDProperty *group, con
|
||||
|
||||
static PyObject *BPy_IDGroup_View_repr(BPy_IDGroup_View *self)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return PyUnicode_FromFormat("<%s>", Py_TYPE(self)->tp_name);
|
||||
}
|
||||
return PyUnicode_FromFormat("<%s \"%s\">", Py_TYPE(self)->tp_name, self->group->prop->name);
|
||||
@@ -1140,7 +1141,7 @@ static PyObject *BPy_IDGroup_View_repr(BPy_IDGroup_View *self)
|
||||
|
||||
static void BPy_IDGroup_View_dealloc(BPy_IDGroup_View *self)
|
||||
{
|
||||
if (self->group != NULL) {
|
||||
if (self->group != nullptr) {
|
||||
PyObject_GC_UnTrack(self);
|
||||
}
|
||||
Py_CLEAR(self->group);
|
||||
@@ -1161,7 +1162,7 @@ static int BPy_IDGroup_View_clear(BPy_IDGroup_View *self)
|
||||
|
||||
static int BPy_IDGroup_View_is_gc(BPy_IDGroup_View *self)
|
||||
{
|
||||
return (self->group != NULL);
|
||||
return (self->group != nullptr);
|
||||
}
|
||||
|
||||
/* View Specific API's (Key/Value/Items). */
|
||||
@@ -1183,7 +1184,7 @@ static PyObject *BPy_Group_ViewItems_iter(BPy_IDGroup_View *self)
|
||||
|
||||
static Py_ssize_t BPy_Group_View_len(BPy_IDGroup_View *self)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return self->group->prop->len;
|
||||
@@ -1191,7 +1192,7 @@ static Py_ssize_t BPy_Group_View_len(BPy_IDGroup_View *self)
|
||||
|
||||
static int BPy_Group_ViewKeys_Contains(BPy_IDGroup_View *self, PyObject *value)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return BPy_IDGroup_Contains(self->group, value);
|
||||
@@ -1199,7 +1200,7 @@ static int BPy_Group_ViewKeys_Contains(BPy_IDGroup_View *self, PyObject *value)
|
||||
|
||||
static int BPy_Group_ViewValues_Contains(BPy_IDGroup_View *self, PyObject *value)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
/* TODO: implement this without first converting to a list. */
|
||||
@@ -1211,7 +1212,7 @@ static int BPy_Group_ViewValues_Contains(BPy_IDGroup_View *self, PyObject *value
|
||||
|
||||
static int BPy_Group_ViewItems_Contains(BPy_IDGroup_View *self, PyObject *value)
|
||||
{
|
||||
if (self->group == NULL) {
|
||||
if (self->group == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
/* TODO: implement this without first converting to a list. */
|
||||
@@ -1223,34 +1224,34 @@ static int BPy_Group_ViewItems_Contains(BPy_IDGroup_View *self, PyObject *value)
|
||||
|
||||
static PySequenceMethods BPy_IDGroup_ViewKeys_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)BPy_Group_View_len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_item*/ NULL,
|
||||
/*was_sq_slice*/ NULL,
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ nullptr,
|
||||
/*was_sq_slice*/ nullptr,
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr,
|
||||
/*sq_contains*/ (objobjproc)BPy_Group_ViewKeys_Contains,
|
||||
};
|
||||
|
||||
static PySequenceMethods BPy_IDGroup_ViewValues_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)BPy_Group_View_len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_item*/ NULL,
|
||||
/*was_sq_slice*/ NULL,
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ nullptr,
|
||||
/*was_sq_slice*/ nullptr,
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr,
|
||||
/*sq_contains*/ (objobjproc)BPy_Group_ViewValues_Contains,
|
||||
};
|
||||
|
||||
static PySequenceMethods BPy_IDGroup_ViewItems_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)BPy_Group_View_len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_item*/ NULL,
|
||||
/*was_sq_slice*/ NULL,
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ nullptr,
|
||||
/*was_sq_slice*/ nullptr,
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr,
|
||||
/*sq_contains*/ (objobjproc)BPy_Group_ViewItems_Contains,
|
||||
};
|
||||
|
||||
@@ -1259,7 +1260,7 @@ static PySequenceMethods BPy_IDGroup_ViewItems_as_sequence = {
|
||||
PyDoc_STRVAR(BPy_IDGroup_View_reversed_doc,
|
||||
"Return a reverse iterator over the ID Property keys values or items.");
|
||||
|
||||
static PyObject *BPy_IDGroup_View_reversed(BPy_IDGroup_View *self, PyObject *UNUSED(ignored))
|
||||
static PyObject *BPy_IDGroup_View_reversed(BPy_IDGroup_View *self, PyObject * /*ignored*/)
|
||||
{
|
||||
BPy_IDGroup_View *result = IDGroup_View_New_WithType(self->group, Py_TYPE(self));
|
||||
result->reversed = !self->reversed;
|
||||
@@ -1271,12 +1272,12 @@ static PyMethodDef BPy_IDGroup_View_methods[] = {
|
||||
(PyCFunction)(void (*)(void))BPy_IDGroup_View_reversed,
|
||||
METH_NOARGS,
|
||||
BPy_IDGroup_View_reversed_doc},
|
||||
{NULL, NULL},
|
||||
{nullptr, nullptr},
|
||||
};
|
||||
|
||||
PyTypeObject BPy_IDGroup_ViewKeys_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_ViewValues_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_ViewItems_Type = {PyVarObject_HEAD_INIT(NULL, 0)};
|
||||
PyTypeObject BPy_IDGroup_ViewKeys_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
PyTypeObject BPy_IDGroup_ViewValues_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
PyTypeObject BPy_IDGroup_ViewItems_Type = {PyVarObject_HEAD_INIT(nullptr, 0)};
|
||||
|
||||
/* ID Property Group View. */
|
||||
static void IDGroup_View_init_type(void)
|
||||
@@ -1298,7 +1299,7 @@ static void IDGroup_View_init_type(void)
|
||||
v_ty->tp_as_sequence = &BPy_IDGroup_ViewValues_as_sequence;
|
||||
i_ty->tp_as_sequence = &BPy_IDGroup_ViewItems_as_sequence;
|
||||
|
||||
/* Shared members. */
|
||||
/* Shared members. */
|
||||
#define SHARED_MEMBER_SET(member, value) \
|
||||
{ \
|
||||
k_ty->member = v_ty->member = i_ty->member = value; \
|
||||
@@ -1341,26 +1342,26 @@ static PyObject *BPy_IDGroup_pop(BPy_IDProperty *self, PyObject *args)
|
||||
PyObject *pyform;
|
||||
|
||||
char *key;
|
||||
PyObject *def = NULL;
|
||||
PyObject *def = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
idprop = IDP_GetPropertyFromGroup(self->prop, key);
|
||||
if (idprop == NULL) {
|
||||
if (def == NULL) {
|
||||
if (idprop == nullptr) {
|
||||
if (def == nullptr) {
|
||||
PyErr_SetString(PyExc_KeyError, "item not in group");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return Py_INCREF_RET(def);
|
||||
}
|
||||
|
||||
pyform = BPy_IDGroup_MapDataToPy(idprop);
|
||||
if (pyform == NULL) {
|
||||
if (pyform == nullptr) {
|
||||
/* Ok something bad happened with the #PyObject, so don't remove the prop from the group.
|
||||
* if `pyform` is NULL, then it already should have raised an exception. */
|
||||
return NULL;
|
||||
* if `pyform` is nullptr, then it already should have raised an exception. */
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IDP_FreeFromGroup(self->prop, idprop);
|
||||
@@ -1389,7 +1390,9 @@ PyObject *BPy_Wrap_GetKeys(IDProperty *prop)
|
||||
IDProperty *loop;
|
||||
int i;
|
||||
|
||||
for (i = 0, loop = prop->data.group.first; loop && (i < prop->len); loop = loop->next, i++) {
|
||||
for (i = 0, loop = static_cast<IDProperty *>(prop->data.group.first); loop && (i < prop->len);
|
||||
loop = loop->next, i++)
|
||||
{
|
||||
PyList_SET_ITEM(list, i, PyUnicode_FromString(loop->name));
|
||||
}
|
||||
|
||||
@@ -1414,7 +1417,8 @@ PyObject *BPy_Wrap_GetValues(ID *id, IDProperty *prop)
|
||||
IDProperty *loop;
|
||||
int i;
|
||||
|
||||
for (i = 0, loop = prop->data.group.first; loop; loop = loop->next, i++) {
|
||||
for (i = 0, loop = static_cast<IDProperty *>(prop->data.group.first); loop;
|
||||
loop = loop->next, i++) {
|
||||
PyList_SET_ITEM(list, i, BPy_IDGroup_WrapData(id, loop, prop));
|
||||
}
|
||||
|
||||
@@ -1434,7 +1438,8 @@ PyObject *BPy_Wrap_GetItems(ID *id, IDProperty *prop)
|
||||
IDProperty *loop;
|
||||
int i;
|
||||
|
||||
for (i = 0, loop = prop->data.group.first; loop; loop = loop->next, i++) {
|
||||
for (i = 0, loop = static_cast<IDProperty *>(prop->data.group.first); loop;
|
||||
loop = loop->next, i++) {
|
||||
PyObject *item = PyTuple_New(2);
|
||||
PyTuple_SET_ITEMS(
|
||||
item, PyUnicode_FromString(loop->name), BPy_IDGroup_WrapData(id, loop, prop));
|
||||
@@ -1453,7 +1458,7 @@ PyObject *BPy_Wrap_GetItems(ID *id, IDProperty *prop)
|
||||
|
||||
PyObject *BPy_Wrap_GetKeys_View_WithID(ID *id, IDProperty *prop)
|
||||
{
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, NULL) : NULL;
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, nullptr) : nullptr;
|
||||
PyObject *ret = BPy_IDGroup_ViewKeys_CreatePyObject((BPy_IDProperty *)self);
|
||||
Py_XDECREF(self); /* Owned by `ret`. */
|
||||
return ret;
|
||||
@@ -1461,7 +1466,7 @@ PyObject *BPy_Wrap_GetKeys_View_WithID(ID *id, IDProperty *prop)
|
||||
|
||||
PyObject *BPy_Wrap_GetValues_View_WithID(ID *id, IDProperty *prop)
|
||||
{
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, NULL) : NULL;
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, nullptr) : nullptr;
|
||||
PyObject *ret = BPy_IDGroup_ViewValues_CreatePyObject((BPy_IDProperty *)self);
|
||||
Py_XDECREF(self); /* Owned by `ret`. */
|
||||
return ret;
|
||||
@@ -1469,7 +1474,7 @@ PyObject *BPy_Wrap_GetValues_View_WithID(ID *id, IDProperty *prop)
|
||||
|
||||
PyObject *BPy_Wrap_GetItems_View_WithID(ID *id, IDProperty *prop)
|
||||
{
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, NULL) : NULL;
|
||||
PyObject *self = prop ? idprop_py_from_idp_group(id, prop, nullptr) : nullptr;
|
||||
PyObject *ret = BPy_IDGroup_ViewItems_CreatePyObject((BPy_IDProperty *)self);
|
||||
Py_XDECREF(self); /* Owned by `ret`. */
|
||||
return ret;
|
||||
@@ -1539,7 +1544,7 @@ static PyObject *BPy_IDGroup_update(BPy_IDProperty *self, PyObject *value)
|
||||
while (PyDict_Next(value, &i, &pkey, &pval)) {
|
||||
BPy_IDGroup_Map_SetItem(self, pkey, pval);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1547,7 +1552,7 @@ static PyObject *BPy_IDGroup_update(BPy_IDProperty *self, PyObject *value)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected a dict or an IDPropertyGroup type, not a %.200s",
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -1583,7 +1588,7 @@ static PyObject *BPy_IDGroup_get(BPy_IDProperty *self, PyObject *args)
|
||||
PyObject *def = Py_None;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
idprop = IDP_GetPropertyFromGroup(self->prop, key);
|
||||
@@ -1607,7 +1612,7 @@ static PyMethodDef BPy_IDGroup_methods[] = {
|
||||
{"get", (PyCFunction)BPy_IDGroup_get, METH_VARARGS, BPy_IDGroup_get_doc},
|
||||
{"to_dict", (PyCFunction)BPy_IDGroup_to_dict, METH_NOARGS, BPy_IDGroup_to_dict_doc},
|
||||
{"clear", (PyCFunction)BPy_IDGroup_clear, METH_NOARGS, BPy_IDGroup_clear_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -1618,16 +1623,16 @@ static PyMethodDef BPy_IDGroup_methods[] = {
|
||||
|
||||
static PySequenceMethods BPy_IDGroup_Seq = {
|
||||
/*sq_length*/ (lenfunc)BPy_IDGroup_Map_Len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/* TODO: setting this will allow `PySequence_Check()` to return True. */
|
||||
/*sq_item*/ NULL,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ NULL,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_item*/ nullptr,
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ nullptr,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_contains*/ (objobjproc)BPy_IDGroup_Contains,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods BPy_IDGroup_Mapping = {
|
||||
@@ -1637,56 +1642,56 @@ static PyMappingMethods BPy_IDGroup_Mapping = {
|
||||
};
|
||||
|
||||
PyTypeObject BPy_IDGroup_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/* For printing, in format `<module>.<name>`. */
|
||||
/*tp_name*/ "IDPropertyGroup",
|
||||
/*tp_basicsize*/ sizeof(BPy_IDProperty),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ NULL,
|
||||
/*tp_dealloc*/ nullptr,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)BPy_IDGroup_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ &BPy_IDGroup_Seq,
|
||||
/*tp_as_mapping*/ &BPy_IDGroup_Mapping,
|
||||
/*tp_hash*/ (hashfunc)BPy_IDGroup_hash,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ (getiterfunc)BPy_IDGroup_iter,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ BPy_IDGroup_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ BPy_IDGroup_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -1712,7 +1717,7 @@ static PyTypeObject *idp_array_py_type(BPy_IDArray *self, size_t *elem_size)
|
||||
return &PyLong_Type;
|
||||
default:
|
||||
*elem_size = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1739,17 +1744,17 @@ static PyObject *BPy_IDArray_get_typecode(BPy_IDArray *self)
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: invalid/corrupt array type '%d'!", __func__, self->prop->subtype);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyGetSetDef BPy_IDArray_getseters[] = {
|
||||
/* matches pythons array.typecode */
|
||||
{"typecode",
|
||||
(getter)BPy_IDArray_get_typecode,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
BPy_IDArray_get_typecode_doc,
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_IDArray_to_list_doc,
|
||||
@@ -1763,7 +1768,7 @@ static PyObject *BPy_IDArray_to_list(BPy_IDArray *self)
|
||||
|
||||
static PyMethodDef BPy_IDArray_methods[] = {
|
||||
{"to_list", (PyCFunction)BPy_IDArray_to_list, METH_NOARGS, BPy_IDArray_to_list_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static Py_ssize_t BPy_IDArray_Len(BPy_IDArray *self)
|
||||
@@ -1775,7 +1780,7 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, Py_ssize_t index)
|
||||
{
|
||||
if (index < 0 || index >= self->prop->len) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range!");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (self->prop->subtype) {
|
||||
@@ -1792,7 +1797,7 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, Py_ssize_t index)
|
||||
PyErr_Format(
|
||||
PyExc_RuntimeError, "%s: invalid/corrupt array type '%d'!", __func__, self->prop->subtype);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int BPy_IDArray_SetItem(BPy_IDArray *self, Py_ssize_t index, PyObject *value)
|
||||
@@ -1843,15 +1848,15 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, Py_ssize_t index, PyObject *va
|
||||
|
||||
static PySequenceMethods BPy_IDArray_Seq = {
|
||||
/*sq_length*/ (lenfunc)BPy_IDArray_Len,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ (ssizeargfunc)BPy_IDArray_GetItem,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. */
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_ass_item*/ (ssizeobjargproc)BPy_IDArray_SetItem,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. */
|
||||
/*sq_contains*/ NULL,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. */
|
||||
/*sq_contains*/ nullptr,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
/* sequence slice (get): idparr[a:b] */
|
||||
@@ -1940,7 +1945,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
|
||||
Py_ssize_t i;
|
||||
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (i < 0) {
|
||||
i += self->prop->len;
|
||||
@@ -1951,7 +1956,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (slicelength <= 0) {
|
||||
@@ -1962,14 +1967,14 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"vector indices must be integers, not %.200s",
|
||||
__func__,
|
||||
Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject *value)
|
||||
@@ -2040,14 +2045,14 @@ static int BPy_IDArray_getbuffer(BPy_IDArray *self, Py_buffer *view, int flags)
|
||||
view->itemsize = itemsize;
|
||||
view->format = (char *)idp_format_from_array_type(prop->subtype);
|
||||
|
||||
Py_ssize_t *shape = MEM_mallocN(sizeof(Py_ssize_t), __func__);
|
||||
Py_ssize_t *shape = static_cast<Py_ssize_t *>(MEM_mallocN(sizeof(Py_ssize_t), __func__));
|
||||
shape[0] = prop->len;
|
||||
view->shape = shape;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void BPy_IDArray_releasebuffer(BPy_IDArray *UNUSED(self), Py_buffer *view)
|
||||
static void BPy_IDArray_releasebuffer(BPy_IDArray * /*self*/, Py_buffer *view)
|
||||
{
|
||||
MEM_freeN(view->shape);
|
||||
}
|
||||
@@ -2064,56 +2069,56 @@ static PyBufferProcs BPy_IDArray_Buffer = {
|
||||
* \{ */
|
||||
|
||||
PyTypeObject BPy_IDArray_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/* For printing, in format `<module>.<name>`. */
|
||||
/*tp_name*/ "IDPropertyArray",
|
||||
/*tp_basicsize*/ sizeof(BPy_IDArray),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ NULL,
|
||||
/*tp_dealloc*/ nullptr,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)BPy_IDArray_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ &BPy_IDArray_Seq,
|
||||
/*tp_as_mapping*/ &BPy_IDArray_AsMapping,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ &BPy_IDArray_Buffer,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ BPy_IDArray_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ BPy_IDArray_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -2140,10 +2145,10 @@ void IDProp_Init_Types(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \note `group` may be NULL, unlike most other uses of this argument.
|
||||
* \note `group` may be nullptr, unlike most other uses of this argument.
|
||||
* This is supported so RNA keys/values/items methods returns an iterator with the expected type:
|
||||
* - Without having ID-properties.
|
||||
* - Without supporting #BPy_IDProperty.prop being NULL, which would incur many more checks.
|
||||
* - Without supporting #BPy_IDProperty.prop being nullptr, which would incur many more checks.
|
||||
* Python's own dictionary-views also works this way too.
|
||||
*/
|
||||
static BPy_IDGroup_View *IDGroup_View_New_WithType(BPy_IDProperty *group, PyTypeObject *type)
|
||||
@@ -2152,7 +2157,7 @@ static BPy_IDGroup_View *IDGroup_View_New_WithType(BPy_IDProperty *group, PyType
|
||||
BPy_IDGroup_View *iter = PyObject_GC_New(BPy_IDGroup_View, type);
|
||||
iter->reversed = false;
|
||||
iter->group = group;
|
||||
if (group != NULL) {
|
||||
if (group != nullptr) {
|
||||
Py_INCREF(group);
|
||||
BLI_assert(!PyObject_GC_IsTracked((PyObject *)iter));
|
||||
PyObject_GC_Track(iter);
|
||||
@@ -2184,13 +2189,13 @@ static PyObject *BPy_IDGroup_ViewItems_CreatePyObject(BPy_IDProperty *group)
|
||||
static PyModuleDef IDProp_types_module_def = {
|
||||
/*m_base*/ PyModuleDef_HEAD_INIT,
|
||||
/*m_name*/ "idprop.types",
|
||||
/*m_doc*/ NULL,
|
||||
/*m_doc*/ nullptr,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
static PyObject *BPyInit_idprop_types(void)
|
||||
@@ -2225,7 +2230,7 @@ static PyObject *BPyInit_idprop_types(void)
|
||||
* \{ */
|
||||
|
||||
static PyMethodDef IDProp_methods[] = {
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(IDProp_module_doc,
|
||||
@@ -2236,10 +2241,10 @@ static PyModuleDef IDProp_module_def = {
|
||||
/*m_doc*/ IDProp_module_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ IDProp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_idprop(void)
|
||||
@@ -37,9 +37,9 @@
|
||||
|
||||
static bool args_contain_key(PyObject *kwargs, const char *name)
|
||||
{
|
||||
if (kwargs == NULL) {
|
||||
/* When a function gets called without any kwargs, Python just passes NULL instead.
|
||||
* PyDict_Contains() is not NULL-safe, though. */
|
||||
if (kwargs == nullptr) {
|
||||
/* When a function gets called without any kwargs, Python just passes nullptr instead.
|
||||
* PyDict_Contains() is not nullptr-safe, though. */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ static bool args_contain_key(PyObject *kwargs, const char *name)
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_base(IDPropertyUIData *ui_data,
|
||||
const char *rna_subtype,
|
||||
const char *description)
|
||||
{
|
||||
if (rna_subtype != NULL) {
|
||||
if (rna_subtype != nullptr) {
|
||||
if (pyrna_enum_value_from_id(rna_enum_property_subtype_items,
|
||||
rna_subtype,
|
||||
&ui_data->rna_subtype,
|
||||
@@ -66,7 +66,7 @@ static bool idprop_ui_data_update_base(IDPropertyUIData *ui_data,
|
||||
}
|
||||
}
|
||||
|
||||
if (description != NULL) {
|
||||
if (description != nullptr) {
|
||||
ui_data->description = BLI_strdup(description);
|
||||
}
|
||||
|
||||
@@ -113,16 +113,16 @@ static bool idprop_ui_data_update_int_default(IDProperty *idprop,
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *rna_subtype = NULL;
|
||||
const char *description = NULL;
|
||||
const char *rna_subtype = nullptr;
|
||||
const char *description = nullptr;
|
||||
int min, max, soft_min, soft_max, step;
|
||||
PyObject *default_value = NULL;
|
||||
PyObject *default_value = nullptr;
|
||||
const char *kwlist[] = {
|
||||
"min", "max", "soft_min", "soft_max", "step", "default", "subtype", "description", NULL};
|
||||
"min", "max", "soft_min", "soft_max", "step", "default", "subtype", "description", nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
kwargs,
|
||||
"|$iiiiiOzz:update",
|
||||
@@ -172,7 +172,7 @@ static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObje
|
||||
ui_data.step = step;
|
||||
}
|
||||
|
||||
if (!ELEM(default_value, NULL, Py_None)) {
|
||||
if (!ELEM(default_value, nullptr, Py_None)) {
|
||||
if (!idprop_ui_data_update_int_default(idprop, &ui_data, default_value)) {
|
||||
IDP_ui_data_free_unique_contents(
|
||||
&ui_data.base, IDP_ui_data_type(idprop), &ui_data_orig->base);
|
||||
@@ -229,14 +229,14 @@ static bool idprop_ui_data_update_bool_default(IDProperty *idprop,
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_bool(IDProperty *idprop, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *rna_subtype = NULL;
|
||||
const char *description = NULL;
|
||||
PyObject *default_value = NULL;
|
||||
const char *kwlist[] = {"default", "subtype", "description", NULL};
|
||||
const char *rna_subtype = nullptr;
|
||||
const char *description = nullptr;
|
||||
PyObject *default_value = nullptr;
|
||||
const char *kwlist[] = {"default", "subtype", "description", nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
kwargs,
|
||||
"|$Ozz:update",
|
||||
@@ -257,7 +257,7 @@ static bool idprop_ui_data_update_bool(IDProperty *idprop, PyObject *args, PyObj
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ELEM(default_value, NULL, Py_None)) {
|
||||
if (!ELEM(default_value, nullptr, Py_None)) {
|
||||
if (!idprop_ui_data_update_bool_default(idprop, &ui_data, default_value)) {
|
||||
IDP_ui_data_free_unique_contents(
|
||||
&ui_data.base, IDP_ui_data_type(idprop), &ui_data_orig->base);
|
||||
@@ -314,15 +314,15 @@ static bool idprop_ui_data_update_float_default(IDProperty *idprop,
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *rna_subtype = NULL;
|
||||
const char *description = NULL;
|
||||
const char *rna_subtype = nullptr;
|
||||
const char *description = nullptr;
|
||||
int precision;
|
||||
double min, max, soft_min, soft_max, step;
|
||||
PyObject *default_value = NULL;
|
||||
PyObject *default_value = nullptr;
|
||||
const char *kwlist[] = {"min",
|
||||
"max",
|
||||
"soft_min",
|
||||
@@ -332,7 +332,7 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
|
||||
"default",
|
||||
"subtype",
|
||||
"description",
|
||||
NULL};
|
||||
nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
kwargs,
|
||||
"|$dddddiOzz:update",
|
||||
@@ -386,7 +386,7 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
|
||||
ui_data.precision = precision;
|
||||
}
|
||||
|
||||
if (!ELEM(default_value, NULL, Py_None)) {
|
||||
if (!ELEM(default_value, nullptr, Py_None)) {
|
||||
if (!idprop_ui_data_update_float_default(idprop, &ui_data, default_value)) {
|
||||
IDP_ui_data_free_unique_contents(
|
||||
&ui_data.base, IDP_ui_data_type(idprop), &ui_data_orig->base);
|
||||
@@ -401,14 +401,14 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *rna_subtype = NULL;
|
||||
const char *description = NULL;
|
||||
const char *rna_subtype = nullptr;
|
||||
const char *description = nullptr;
|
||||
const char *default_value;
|
||||
const char *kwlist[] = {"default", "subtype", "description", NULL};
|
||||
const char *kwlist[] = {"default", "subtype", "description", nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(args,
|
||||
kwargs,
|
||||
"|$zzz:update",
|
||||
@@ -429,7 +429,7 @@ static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyO
|
||||
return false;
|
||||
}
|
||||
|
||||
if (default_value != NULL) {
|
||||
if (default_value != nullptr) {
|
||||
ui_data.default_value = BLI_strdup(default_value);
|
||||
}
|
||||
|
||||
@@ -440,13 +440,13 @@ static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyO
|
||||
}
|
||||
|
||||
/**
|
||||
* \return False when parsing fails, in which case caller should return NULL.
|
||||
* \return False when parsing fails, in which case caller should return nullptr.
|
||||
*/
|
||||
static bool idprop_ui_data_update_id(IDProperty *idprop, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *rna_subtype = NULL;
|
||||
const char *description = NULL;
|
||||
const char *kwlist[] = {"subtype", "description", NULL};
|
||||
const char *rna_subtype = nullptr;
|
||||
const char *description = nullptr;
|
||||
const char *kwlist[] = {"subtype", "description", nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwargs, "|$zz:update", (char **)kwlist, &rna_subtype, &description))
|
||||
{
|
||||
@@ -494,36 +494,36 @@ static PyObject *BPy_IDPropertyUIManager_update(BPy_IDPropertyUIManager *self,
|
||||
case IDP_UI_DATA_TYPE_INT:
|
||||
IDP_ui_data_ensure(property);
|
||||
if (!idprop_ui_data_update_int(property, args, kwargs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
case IDP_UI_DATA_TYPE_BOOLEAN:
|
||||
IDP_ui_data_ensure(property);
|
||||
if (!idprop_ui_data_update_bool(property, args, kwargs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
case IDP_UI_DATA_TYPE_FLOAT:
|
||||
IDP_ui_data_ensure(property);
|
||||
if (!idprop_ui_data_update_float(property, args, kwargs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
case IDP_UI_DATA_TYPE_STRING:
|
||||
IDP_ui_data_ensure(property);
|
||||
if (!idprop_ui_data_update_string(property, args, kwargs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
case IDP_UI_DATA_TYPE_ID:
|
||||
IDP_ui_data_ensure(property);
|
||||
if (!idprop_ui_data_update_id(property, args, kwargs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
case IDP_UI_DATA_TYPE_UNSUPPORTED:
|
||||
PyErr_Format(PyExc_TypeError, "IDProperty \"%s\" does not support RNA data", property->name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLI_assert_unreachable();
|
||||
@@ -620,7 +620,7 @@ static void idprop_ui_data_to_dict_string(IDProperty *property, PyObject *dict)
|
||||
IDPropertyUIDataString *ui_data = (IDPropertyUIDataString *)property->ui_data;
|
||||
PyObject *item;
|
||||
|
||||
const char *default_value = (ui_data->default_value == NULL) ? "" : ui_data->default_value;
|
||||
const char *default_value = (ui_data->default_value == nullptr) ? "" : ui_data->default_value;
|
||||
|
||||
PyDict_SetItemString(dict, "default", item = PyUnicode_FromString(default_value));
|
||||
Py_DECREF(item);
|
||||
@@ -642,7 +642,7 @@ static PyObject *BPy_IDIDPropertyUIManager_as_dict(BPy_IDPropertyUIManager *self
|
||||
|
||||
/* RNA subtype. */
|
||||
{
|
||||
const char *subtype_id = NULL;
|
||||
const char *subtype_id = nullptr;
|
||||
RNA_enum_identifier(rna_enum_property_subtype_items, ui_data->rna_subtype, &subtype_id);
|
||||
PyObject *item = PyUnicode_FromString(subtype_id);
|
||||
PyDict_SetItemString(dict, "subtype", item);
|
||||
@@ -650,7 +650,7 @@ static PyObject *BPy_IDIDPropertyUIManager_as_dict(BPy_IDPropertyUIManager *self
|
||||
}
|
||||
|
||||
/* Description. */
|
||||
if (ui_data->description != NULL) {
|
||||
if (ui_data->description != nullptr) {
|
||||
PyObject *item = PyUnicode_FromString(ui_data->description);
|
||||
PyDict_SetItemString(dict, "description", item);
|
||||
Py_DECREF(item);
|
||||
@@ -695,13 +695,13 @@ static PyObject *BPy_IDPropertyUIManager_clear(BPy_IDPropertyUIManager *self)
|
||||
IDProperty *property = self->property;
|
||||
BLI_assert(IDP_ui_data_supported(property));
|
||||
|
||||
if (property == NULL) {
|
||||
if (property == nullptr) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "IDPropertyUIManager missing property");
|
||||
BLI_assert_unreachable();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (property->ui_data != NULL) {
|
||||
if (property->ui_data != nullptr) {
|
||||
IDP_ui_data_free(property);
|
||||
}
|
||||
|
||||
@@ -729,10 +729,10 @@ static PyObject *BPy_IDPropertyUIManager_update_from(BPy_IDPropertyUIManager *se
|
||||
|
||||
BPy_IDPropertyUIManager *ui_manager_src;
|
||||
if (!PyArg_ParseTuple(args, "O!:update_from", &BPy_IDPropertyUIManager_Type, &ui_manager_src)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (property->ui_data != NULL) {
|
||||
if (property->ui_data != nullptr) {
|
||||
IDP_ui_data_free(property);
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ static PyMethodDef BPy_IDPropertyUIManager_methods[] = {
|
||||
(PyCFunction)BPy_IDPropertyUIManager_update_from,
|
||||
METH_VARARGS,
|
||||
BPy_IDPropertyUIManager_update_from_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyObject *BPy_IDPropertyUIManager_repr(BPy_IDPropertyUIManager *self)
|
||||
@@ -781,56 +781,56 @@ static Py_hash_t BPy_IDPropertyUIManager_hash(BPy_IDPropertyUIManager *self)
|
||||
}
|
||||
|
||||
PyTypeObject BPy_IDPropertyUIManager_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/* For printing, in format `<module>.<name>`. */
|
||||
/*tp_name*/ "IDPropertyUIManager",
|
||||
/*tp_basicsize*/ sizeof(BPy_IDPropertyUIManager),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ NULL,
|
||||
/*tp_dealloc*/ nullptr,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)BPy_IDPropertyUIManager_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ (hashfunc)BPy_IDPropertyUIManager_hash,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ BPy_IDPropertyUIManager_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
void IDPropertyUIData_Init_Types(void)
|
||||
@@ -36,11 +36,11 @@ static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf);
|
||||
/** \name Type & Utilities
|
||||
* \{ */
|
||||
|
||||
typedef struct Py_ImBuf {
|
||||
struct Py_ImBuf {
|
||||
PyObject_VAR_HEAD
|
||||
/* can be NULL */
|
||||
/* can be nullptr */
|
||||
ImBuf *ibuf;
|
||||
} Py_ImBuf;
|
||||
};
|
||||
|
||||
static int py_imbuf_valid_check(Py_ImBuf *self)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ static int py_imbuf_valid_check(Py_ImBuf *self)
|
||||
|
||||
#define PY_IMBUF_CHECK_OBJ(obj) \
|
||||
if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
((void)0)
|
||||
#define PY_IMBUF_CHECK_INT(obj) \
|
||||
@@ -89,11 +89,11 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
|
||||
const struct PyC_StringEnumItems method_items[] = {
|
||||
{FAST, "FAST"},
|
||||
{BILINEAR, "BILINEAR"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
struct PyC_StringEnum method = {method_items, FAST};
|
||||
|
||||
static const char *_keywords[] = {"size", "method", NULL};
|
||||
static const char *_keywords[] = {"size", "method", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"(ii)" /* `size` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -105,11 +105,11 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (size[0] <= 0 || size[1] <= 0) {
|
||||
PyErr_Format(PyExc_ValueError, "resize: Image size cannot be below 1 (%d, %d)", UNPACK2(size));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (method.value_found == FAST) {
|
||||
@@ -139,7 +139,7 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
|
||||
|
||||
rcti crop;
|
||||
|
||||
static const char *_keywords[] = {"min", "max", NULL};
|
||||
static const char *_keywords[] = {"min", "max", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"(II)" /* `min` */
|
||||
"(II)" /* `max` */
|
||||
@@ -150,7 +150,7 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (/* X range. */
|
||||
@@ -163,7 +163,7 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
|
||||
!(crop.ymin <= crop.ymax))
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, "ImBuf crop min/max not in range");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
IMB_rect_crop(self->ibuf, &crop);
|
||||
Py_RETURN_NONE;
|
||||
@@ -179,11 +179,11 @@ static PyObject *py_imbuf_copy(Py_ImBuf *self)
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *ibuf_copy = IMB_dupImBuf(self->ibuf);
|
||||
|
||||
if (UNLIKELY(ibuf_copy == NULL)) {
|
||||
if (UNLIKELY(ibuf_copy == nullptr)) {
|
||||
PyErr_SetString(PyExc_MemoryError,
|
||||
"ImBuf.copy(): "
|
||||
"failed to allocate memory");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return Py_ImBuf_CreatePyObject(ibuf_copy);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ static PyObject *py_imbuf_copy(Py_ImBuf *self)
|
||||
static PyObject *py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
|
||||
{
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return py_imbuf_copy(self);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ static PyObject *py_imbuf_free(Py_ImBuf *self)
|
||||
{
|
||||
if (self->ibuf) {
|
||||
IMB_freeImBuf(self->ibuf);
|
||||
self->ibuf = NULL;
|
||||
self->ibuf = nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ static PyMethodDef Py_ImBuf_methods[] = {
|
||||
{"copy", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc},
|
||||
{"__copy__", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc},
|
||||
{"__deepcopy__", (PyCFunction)py_imbuf_deepcopy, METH_VARARGS, py_imbuf_copy_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -226,22 +226,22 @@ static PyMethodDef Py_ImBuf_methods[] = {
|
||||
* \{ */
|
||||
|
||||
PyDoc_STRVAR(py_imbuf_size_doc, "size of the image in pixels.\n\n:type: pair of ints");
|
||||
static PyObject *py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
static PyObject *py_imbuf_size_get(Py_ImBuf *self, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *ibuf = self->ibuf;
|
||||
return PyC_Tuple_Pack_I32(ibuf->x, ibuf->y);
|
||||
return PyC_Tuple_Pack_I32({ibuf->x, ibuf->y});
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(py_imbuf_ppm_doc, "pixels per meter.\n\n:type: pair of floats");
|
||||
static PyObject *py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
static PyObject *py_imbuf_ppm_get(Py_ImBuf *self, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *ibuf = self->ibuf;
|
||||
return PyC_Tuple_Pack_F64(ibuf->ppm[0], ibuf->ppm[1]);
|
||||
return PyC_Tuple_Pack_F64({ibuf->ppm[0], ibuf->ppm[1]});
|
||||
}
|
||||
|
||||
static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
|
||||
static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_INT(self);
|
||||
double ppm[2];
|
||||
@@ -262,14 +262,14 @@ static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closur
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(py_imbuf_filepath_doc, "filepath associated with this image.\n\n:type: string");
|
||||
static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *ibuf = self->ibuf;
|
||||
return PyC_UnicodeFromBytes(ibuf->filepath);
|
||||
}
|
||||
|
||||
static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
|
||||
static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_INT(self);
|
||||
|
||||
@@ -291,7 +291,7 @@ static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(c
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(py_imbuf_planes_doc, "Number of bits associated with this image.\n\n:type: int");
|
||||
static PyObject *py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
static PyObject *py_imbuf_planes_get(Py_ImBuf *self, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *imbuf = self->ibuf;
|
||||
@@ -299,7 +299,7 @@ static PyObject *py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(py_imbuf_channels_doc, "Number of bit-planes.\n\n:type: int");
|
||||
static PyObject *py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
static PyObject *py_imbuf_channels_get(Py_ImBuf *self, void * /*closure*/)
|
||||
{
|
||||
PY_IMBUF_CHECK_OBJ(self);
|
||||
ImBuf *imbuf = self->ibuf;
|
||||
@@ -307,16 +307,16 @@ static PyObject *py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure))
|
||||
}
|
||||
|
||||
static PyGetSetDef Py_ImBuf_getseters[] = {
|
||||
{"size", (getter)py_imbuf_size_get, (setter)NULL, py_imbuf_size_doc, NULL},
|
||||
{"ppm", (getter)py_imbuf_ppm_get, (setter)py_imbuf_ppm_set, py_imbuf_ppm_doc, NULL},
|
||||
{"size", (getter)py_imbuf_size_get, (setter) nullptr, py_imbuf_size_doc, nullptr},
|
||||
{"ppm", (getter)py_imbuf_ppm_get, (setter)py_imbuf_ppm_set, py_imbuf_ppm_doc, nullptr},
|
||||
{"filepath",
|
||||
(getter)py_imbuf_filepath_get,
|
||||
(setter)py_imbuf_filepath_set,
|
||||
py_imbuf_filepath_doc,
|
||||
NULL},
|
||||
{"planes", (getter)py_imbuf_planes_get, NULL, py_imbuf_planes_doc, NULL},
|
||||
{"channels", (getter)py_imbuf_channels_get, NULL, py_imbuf_channels_doc, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
nullptr},
|
||||
{"planes", (getter)py_imbuf_planes_get, nullptr, py_imbuf_planes_doc, nullptr},
|
||||
{"channels", (getter)py_imbuf_channels_get, nullptr, py_imbuf_channels_doc, nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -328,9 +328,9 @@ static PyGetSetDef Py_ImBuf_getseters[] = {
|
||||
static void py_imbuf_dealloc(Py_ImBuf *self)
|
||||
{
|
||||
ImBuf *ibuf = self->ibuf;
|
||||
if (ibuf != NULL) {
|
||||
if (ibuf != nullptr) {
|
||||
IMB_freeImBuf(self->ibuf);
|
||||
self->ibuf = NULL;
|
||||
self->ibuf = nullptr;
|
||||
}
|
||||
PyObject_DEL(self);
|
||||
}
|
||||
@@ -338,7 +338,7 @@ static void py_imbuf_dealloc(Py_ImBuf *self)
|
||||
static PyObject *py_imbuf_repr(Py_ImBuf *self)
|
||||
{
|
||||
const ImBuf *ibuf = self->ibuf;
|
||||
if (ibuf != NULL) {
|
||||
if (ibuf != nullptr) {
|
||||
return PyUnicode_FromFormat("<imbuf: address=%p, filepath='%s', size=(%d, %d)>",
|
||||
ibuf,
|
||||
ibuf->filepath,
|
||||
@@ -355,55 +355,55 @@ static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
|
||||
}
|
||||
|
||||
PyTypeObject Py_ImBuf_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "ImBuf",
|
||||
/*tp_basicsize*/ sizeof(Py_ImBuf),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)py_imbuf_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)py_imbuf_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ (hashfunc)py_imbuf_hash,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ Py_ImBuf_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ Py_ImBuf_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf)
|
||||
@@ -428,10 +428,10 @@ PyDoc_STRVAR(M_imbuf_new_doc,
|
||||
" :type size: pair of ints\n"
|
||||
" :return: the newly loaded image.\n"
|
||||
" :rtype: :class:`ImBuf`\n");
|
||||
static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *M_imbuf_new(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
int size[2];
|
||||
static const char *_keywords[] = {"size", NULL};
|
||||
static const char *_keywords[] = {"size", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"(ii)" /* `size` */
|
||||
":new",
|
||||
@@ -439,11 +439,11 @@ static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *k
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &size[0], &size[1])) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (size[0] <= 0 || size[1] <= 0) {
|
||||
PyErr_Format(PyExc_ValueError, "new: Image size cannot be below 1 (%d, %d)", UNPACK2(size));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* TODO: make options. */
|
||||
@@ -451,9 +451,9 @@ static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *k
|
||||
const uint flags = IB_rect;
|
||||
|
||||
ImBuf *ibuf = IMB_allocImBuf(UNPACK2(size), planes, flags);
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError, "new: Unable to create image (%d, %d)", UNPACK2(size));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return Py_ImBuf_CreatePyObject(ibuf);
|
||||
}
|
||||
@@ -467,11 +467,11 @@ PyDoc_STRVAR(M_imbuf_load_doc,
|
||||
" :type filepath: string\n"
|
||||
" :return: the newly loaded image.\n"
|
||||
" :rtype: :class:`ImBuf`\n");
|
||||
static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *M_imbuf_load(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
const char *filepath;
|
||||
|
||||
static const char *_keywords[] = {"filepath", NULL};
|
||||
static const char *_keywords[] = {"filepath", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"s" /* `filepath` */
|
||||
":load",
|
||||
@@ -479,23 +479,23 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
|
||||
if (file == -1) {
|
||||
PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", strerror(errno), filepath);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ImBuf *ibuf = IMB_loadifffile(file, IB_rect, NULL, filepath);
|
||||
ImBuf *ibuf = IMB_loadifffile(file, IB_rect, nullptr, filepath);
|
||||
|
||||
close(file);
|
||||
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError, "load: Unable to recognize image format for file '%s'", filepath);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
STRNCPY(ibuf->filepath, filepath);
|
||||
@@ -513,12 +513,12 @@ PyDoc_STRVAR(
|
||||
" :type image: :class:`ImBuf`\n"
|
||||
" :arg filepath: Optional filepath of the image (fallback to the images file path).\n"
|
||||
" :type filepath: string\n");
|
||||
static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
|
||||
static PyObject *M_imbuf_write(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
||||
{
|
||||
Py_ImBuf *py_imb;
|
||||
const char *filepath = NULL;
|
||||
const char *filepath = nullptr;
|
||||
|
||||
static const char *_keywords[] = {"image", "filepath", NULL};
|
||||
static const char *_keywords[] = {"image", "filepath", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O!" /* `image` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -528,10 +528,10 @@ static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &Py_ImBuf_Type, &py_imb, &filepath)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (filepath == NULL) {
|
||||
if (filepath == nullptr) {
|
||||
filepath = py_imb->ibuf->filepath;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject
|
||||
if (ok == false) {
|
||||
PyErr_Format(
|
||||
PyExc_IOError, "write: Unable to write image file (%s) '%s'", strerror(errno), filepath);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -555,7 +555,7 @@ static PyMethodDef IMB_methods[] = {
|
||||
{"new", (PyCFunction)M_imbuf_new, METH_VARARGS | METH_KEYWORDS, M_imbuf_new_doc},
|
||||
{"load", (PyCFunction)M_imbuf_load, METH_VARARGS | METH_KEYWORDS, M_imbuf_load_doc},
|
||||
{"write", (PyCFunction)M_imbuf_write, METH_VARARGS | METH_KEYWORDS, M_imbuf_write_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(IMB_doc,
|
||||
@@ -569,10 +569,10 @@ static PyModuleDef IMB_module_def = {
|
||||
/*m_doc*/ IMB_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ IMB_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_imbuf(void)
|
||||
@@ -612,11 +612,11 @@ static PyModuleDef IMB_types_module_def = {
|
||||
/*m_name*/ "imbuf.types",
|
||||
/*m_doc*/ IMB_types_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_imbuf_types(void)
|
||||
@@ -624,7 +624,7 @@ PyObject *BPyInit_imbuf_types(void)
|
||||
PyObject *submodule = PyModule_Create(&IMB_types_module_def);
|
||||
|
||||
if (PyType_Ready(&Py_ImBuf_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyModule_AddType(submodule, &Py_ImBuf_Type);
|
||||
@@ -85,7 +85,7 @@ BLI_bitmap *pyrna_enum_bitmap_from_set(const EnumPropertyItem *items,
|
||||
|
||||
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
|
||||
const char *param = PyUnicode_AsUTF8(key);
|
||||
if (param == NULL) {
|
||||
if (param == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s expected a string, not %.200s",
|
||||
error_prefix,
|
||||
@@ -129,7 +129,7 @@ BLI_bitmap *pyrna_enum_bitmap_from_set(const EnumPropertyItem *items,
|
||||
|
||||
error:
|
||||
MEM_freeN(bitmap);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items,
|
||||
@@ -150,7 +150,7 @@ int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items,
|
||||
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
|
||||
const char *param = PyUnicode_AsUTF8(key);
|
||||
|
||||
if (param == NULL) {
|
||||
if (param == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s expected a string, not %.200s",
|
||||
error_prefix,
|
||||
@@ -171,7 +171,7 @@ int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items,
|
||||
|
||||
PyObject *pyrna_enum_bitfield_as_set(const EnumPropertyItem *items, int value)
|
||||
{
|
||||
PyObject *ret = PySet_New(NULL);
|
||||
PyObject *ret = PySet_New(nullptr);
|
||||
const char *identifier[RNA_ENUM_BITFLAG_SIZE + 1];
|
||||
|
||||
if (RNA_enum_bitflag_identifiers(items, value, identifier)) {
|
||||
@@ -196,11 +196,11 @@ PyObject *pyrna_enum_bitfield_as_set(const EnumPropertyItem *items, int value)
|
||||
int pyrna_enum_value_parse_string(PyObject *o, void *p)
|
||||
{
|
||||
const char *identifier = PyUnicode_AsUTF8(o);
|
||||
if (identifier == NULL) {
|
||||
if (identifier == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError, "expected a string enum, not %.200s", Py_TYPE(o)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
struct BPy_EnumProperty_Parse *parse_data = p;
|
||||
struct BPy_EnumProperty_Parse *parse_data = static_cast<BPy_EnumProperty_Parse *>(p);
|
||||
if (pyrna_enum_value_from_id(
|
||||
parse_data->items, identifier, &parse_data->value, "enum identifier") == -1)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ int pyrna_enum_bitfield_parse_set(PyObject *o, void *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct BPy_EnumProperty_Parse *parse_data = p;
|
||||
struct BPy_EnumProperty_Parse *parse_data = static_cast<BPy_EnumProperty_Parse *>(p);
|
||||
if (pyrna_enum_bitfield_from_set(
|
||||
parse_data->items, o, &parse_data->value, "enum identifier set") == -1)
|
||||
{
|
||||
@@ -70,14 +70,14 @@ int PyC_AsArray_FAST(void *array,
|
||||
if (type == &PyFloat_Type) {
|
||||
switch (array_item_size) {
|
||||
case sizeof(double): {
|
||||
double *array_double = array;
|
||||
double *array_double = static_cast<double *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_double[i] = PyFloat_AsDouble(value_fast_items[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(float): {
|
||||
float *array_float = array;
|
||||
float *array_float = static_cast<float *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_float[i] = PyFloat_AsDouble(value_fast_items[i]);
|
||||
}
|
||||
@@ -92,28 +92,28 @@ int PyC_AsArray_FAST(void *array,
|
||||
else if (type == &PyLong_Type) {
|
||||
switch (array_item_size) {
|
||||
case sizeof(int64_t): {
|
||||
int64_t *array_int = array;
|
||||
int64_t *array_int = static_cast<int64_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_int[i] = PyC_Long_AsI64(value_fast_items[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int32_t): {
|
||||
int32_t *array_int = array;
|
||||
int32_t *array_int = static_cast<int32_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_int[i] = PyC_Long_AsI32(value_fast_items[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int16_t): {
|
||||
int16_t *array_int = array;
|
||||
int16_t *array_int = static_cast<int16_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_int[i] = PyC_Long_AsI16(value_fast_items[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int8_t): {
|
||||
int8_t *array_int = array;
|
||||
int8_t *array_int = static_cast<int8_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_int[i] = PyC_Long_AsI8(value_fast_items[i]);
|
||||
}
|
||||
@@ -128,28 +128,28 @@ int PyC_AsArray_FAST(void *array,
|
||||
else if (type == &PyBool_Type) {
|
||||
switch (array_item_size) {
|
||||
case sizeof(int64_t): {
|
||||
int64_t *array_bool = array;
|
||||
int64_t *array_bool = static_cast<int64_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_bool[i] = (PyLong_AsLong(value_fast_items[i]) != 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int32_t): {
|
||||
int32_t *array_bool = array;
|
||||
int32_t *array_bool = static_cast<int32_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_bool[i] = (PyLong_AsLong(value_fast_items[i]) != 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int16_t): {
|
||||
int16_t *array_bool = array;
|
||||
int16_t *array_bool = static_cast<int16_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_bool[i] = (PyLong_AsLong(value_fast_items[i]) != 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sizeof(int8_t): {
|
||||
int8_t *array_bool = array;
|
||||
int8_t *array_bool = static_cast<int8_t *>(array);
|
||||
for (i = 0; i < length; i++) {
|
||||
array_bool[i] = (PyLong_AsLong(value_fast_items[i]) != 0);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ void PyC_List_Fill(PyObject *list, PyObject *value)
|
||||
|
||||
int PyC_ParseBool(PyObject *o, void *p)
|
||||
{
|
||||
bool *bool_p = p;
|
||||
bool *bool_p = static_cast<bool *>(p);
|
||||
long value;
|
||||
if (((value = PyLong_AsLong(o)) == -1) || !ELEM(value, 0, 1)) {
|
||||
PyErr_Format(PyExc_ValueError, "expected a bool or int (0/1), got %s", Py_TYPE(o)->tp_name);
|
||||
@@ -502,9 +502,9 @@ int PyC_ParseBool(PyObject *o, void *p)
|
||||
|
||||
int PyC_ParseStringEnum(PyObject *o, void *p)
|
||||
{
|
||||
struct PyC_StringEnum *e = p;
|
||||
struct PyC_StringEnum *e = static_cast<PyC_StringEnum *>(p);
|
||||
const char *value = PyUnicode_AsUTF8(o);
|
||||
if (value == NULL) {
|
||||
if (value == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError, "expected a string, got %s", Py_TYPE(o)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
@@ -536,7 +536,7 @@ const char *PyC_StringEnum_FindIDFromValue(const struct PyC_StringEnumItems *ite
|
||||
return items[i].id;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int PyC_CheckArgs_DeepCopy(PyObject *args)
|
||||
@@ -559,7 +559,7 @@ void PyC_ObSpit(const char *name, PyObject *var)
|
||||
{
|
||||
const char *null_str = "<null>";
|
||||
fprintf(stderr, "<%s> : ", name);
|
||||
if (var == NULL) {
|
||||
if (var == nullptr) {
|
||||
fprintf(stderr, "%s\n", null_str);
|
||||
}
|
||||
else {
|
||||
@@ -577,13 +577,13 @@ void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
|
||||
{
|
||||
/* No name, creator of string can manage that. */
|
||||
const char *null_str = "<null>";
|
||||
if (var == NULL) {
|
||||
if (var == nullptr) {
|
||||
BLI_snprintf(result, result_maxncpy, "%s", null_str);
|
||||
}
|
||||
else {
|
||||
const PyTypeObject *type = Py_TYPE(var);
|
||||
PyObject *var_str = PyObject_Repr(var);
|
||||
if (var_str == NULL) {
|
||||
if (var_str == nullptr) {
|
||||
/* We could print error here,
|
||||
* but this may be used for generating errors - so don't for now. */
|
||||
PyErr_Clear();
|
||||
@@ -595,7 +595,7 @@ void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
|
||||
(void *)var,
|
||||
type ? type->tp_name : null_str,
|
||||
var_str ? PyUnicode_AsUTF8(var_str) : "<error>");
|
||||
if (var_str != NULL) {
|
||||
if (var_str != nullptr) {
|
||||
Py_DECREF(var_str);
|
||||
}
|
||||
}
|
||||
@@ -645,7 +645,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
|
||||
PyCodeObject *code;
|
||||
|
||||
if (r_filename) {
|
||||
*r_filename = NULL;
|
||||
*r_filename = nullptr;
|
||||
}
|
||||
if (r_lineno) {
|
||||
*r_lineno = -1;
|
||||
@@ -664,7 +664,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
|
||||
}
|
||||
|
||||
/* when executing a module */
|
||||
if (r_filename && *r_filename == NULL) {
|
||||
if (r_filename && *r_filename == nullptr) {
|
||||
/* try an alternative method to get the r_filename - module based
|
||||
* references below are all borrowed (double checked) */
|
||||
PyObject *mod_name = PyDict_GetItemString(PyEval_GetGlobals(), "__name__");
|
||||
@@ -682,7 +682,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
|
||||
}
|
||||
|
||||
/* unlikely, fallback */
|
||||
if (*r_filename == NULL) {
|
||||
if (*r_filename == nullptr) {
|
||||
*r_filename = PyUnicode_AsUTF8(mod_name);
|
||||
}
|
||||
}
|
||||
@@ -748,7 +748,7 @@ PyObject *PyC_FrozenSetFromStrings(const char **strings)
|
||||
const char **str;
|
||||
PyObject *ret;
|
||||
|
||||
ret = PyFrozenSet_New(NULL);
|
||||
ret = PyFrozenSet_New(nullptr);
|
||||
|
||||
for (str = strings; *str; str++) {
|
||||
PyObject *py_str = PyUnicode_FromString(*str);
|
||||
@@ -771,7 +771,7 @@ PyObject *PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *for
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
error_value_prefix = PyUnicode_FromFormatV(format, args); /* can fail and be NULL */
|
||||
error_value_prefix = PyUnicode_FromFormatV(format, args); /* can fail and be nullptr */
|
||||
va_end(args);
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
@@ -795,8 +795,8 @@ PyObject *PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *for
|
||||
|
||||
Py_XDECREF(error_value_prefix);
|
||||
|
||||
/* dumb to always return NULL but matches PyErr_Format */
|
||||
return NULL;
|
||||
/* dumb to always return nullptr but matches PyErr_Format */
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *PyC_Err_SetString_Prefix(PyObject *exception_type_prefix, const char *str)
|
||||
@@ -858,49 +858,56 @@ static void pyc_exception_buffer_handle_system_exit(PyObject *error_type,
|
||||
/* returns the exception string as a new PyUnicode object, depends on external traceback module */
|
||||
# if 0
|
||||
|
||||
|
||||
/* this version uses traceback module but somehow fails on UI errors */
|
||||
|
||||
|
||||
PyObject *PyC_ExceptionBuffer(void)
|
||||
{
|
||||
PyObject *traceback_mod = NULL;
|
||||
PyObject *format_tb_func = NULL;
|
||||
PyObject *ret = NULL;
|
||||
PyObject *traceback_mod = nullptr;
|
||||
PyObject *format_tb_func = nullptr;
|
||||
PyObject *ret = nullptr;
|
||||
|
||||
if (!(traceback_mod = PyImport_ImportModule("traceback"))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (!(format_tb_func = PyObject_GetAttrString(traceback_mod, "format_exc"))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
ret = PyObject_CallObject(format_tb_func, NULL);
|
||||
if (!(traceback_mod = PyImport_ImportModule("traceback"))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (!(format_tb_func = PyObject_GetAttrString(traceback_mod, "format_exc"))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
|
||||
ret = PyObject_CallObject(format_tb_func, nullptr);
|
||||
|
||||
|
||||
if (ret == Py_None) {
|
||||
Py_DECREF(ret);
|
||||
ret = nullptr;
|
||||
}
|
||||
|
||||
if (ret == Py_None) {
|
||||
Py_DECREF(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
error_cleanup:
|
||||
/* could not import the module so print the error and close */
|
||||
Py_XDECREF(traceback_mod);
|
||||
Py_XDECREF(format_tb_func);
|
||||
/* could not import the module so print the error and close */
|
||||
Py_XDECREF(traceback_mod);
|
||||
Py_XDECREF(format_tb_func);
|
||||
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
# else /* verbose, non-threadsafe version */
|
||||
PyObject *PyC_ExceptionBuffer(void)
|
||||
{
|
||||
PyObject *stdout_backup = PySys_GetObject("stdout"); /* borrowed */
|
||||
PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */
|
||||
PyObject *string_io = NULL;
|
||||
PyObject *string_io_buf = NULL;
|
||||
PyObject *string_io_mod = NULL;
|
||||
PyObject *string_io_getvalue = NULL;
|
||||
PyObject *string_io = nullptr;
|
||||
PyObject *string_io_buf = nullptr;
|
||||
PyObject *string_io_mod = nullptr;
|
||||
PyObject *string_io_getvalue = nullptr;
|
||||
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
|
||||
if (!PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
@@ -914,7 +921,7 @@ PyObject *PyC_ExceptionBuffer(void)
|
||||
if (!(string_io_mod = PyImport_ImportModule("io"))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (!(string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) {
|
||||
else if (!(string_io = PyObject_CallMethod(string_io_mod, "StringIO", nullptr))) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
else if (!(string_io_getvalue = PyObject_GetAttrString(string_io, "getvalue"))) {
|
||||
@@ -937,7 +944,7 @@ PyObject *PyC_ExceptionBuffer(void)
|
||||
PyErr_Print(); /* print the error */
|
||||
PyErr_Clear();
|
||||
|
||||
string_io_buf = PyObject_CallObject(string_io_getvalue, NULL);
|
||||
string_io_buf = PyObject_CallObject(string_io_getvalue, nullptr);
|
||||
|
||||
PySys_SetObject("stdout", stdout_backup);
|
||||
PySys_SetObject("stderr", stderr_backup);
|
||||
@@ -962,17 +969,17 @@ error_cleanup:
|
||||
PyErr_Print(); /* print the error */
|
||||
PyErr_Restore(error_type, error_value, error_traceback);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
# endif
|
||||
|
||||
PyObject *PyC_ExceptionBuffer_Simple(void)
|
||||
{
|
||||
if (!PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *string_io_buf = NULL;
|
||||
PyObject *string_io_buf = nullptr;
|
||||
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
|
||||
@@ -992,12 +999,12 @@ PyObject *PyC_ExceptionBuffer_Simple(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (string_io_buf == NULL) {
|
||||
if (string_io_buf == nullptr) {
|
||||
string_io_buf = PyObject_Str(error_value);
|
||||
}
|
||||
|
||||
/* Python does this too */
|
||||
if (UNLIKELY(string_io_buf == NULL)) {
|
||||
if (UNLIKELY(string_io_buf == nullptr)) {
|
||||
string_io_buf = PyUnicode_FromFormat("<unprintable %s object>", Py_TYPE(error_value)->tp_name);
|
||||
}
|
||||
|
||||
@@ -1038,7 +1045,7 @@ const char *PyC_UnicodeAsBytesAndSize(PyObject *py_str, Py_ssize_t *r_size, PyOb
|
||||
}
|
||||
|
||||
/* leave error raised from EncodeFS */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *PyC_UnicodeAsBytes(PyObject *py_str, PyObject **r_coerce)
|
||||
@@ -1063,7 +1070,7 @@ const char *PyC_UnicodeAsBytes(PyObject *py_str, PyObject **r_coerce)
|
||||
}
|
||||
|
||||
/* leave error raised from EncodeFS */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromBytesAndSize(const char *str, Py_ssize_t size)
|
||||
@@ -1114,7 +1121,7 @@ bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[])
|
||||
{
|
||||
for (int i = 0; imports[i]; i++) {
|
||||
PyObject *name = PyUnicode_FromString(imports[i]);
|
||||
PyObject *mod = PyImport_ImportModuleLevelObject(name, NULL, NULL, 0, 0);
|
||||
PyObject *mod = PyImport_ImportModuleLevelObject(name, nullptr, nullptr, 0, 0);
|
||||
bool ok = false;
|
||||
if (mod) {
|
||||
PyDict_SetItem(py_dict, name, mod);
|
||||
@@ -1147,7 +1154,7 @@ void PyC_MainModule_Restore(PyObject *main_mod)
|
||||
bool PyC_IsInterpreterActive(void)
|
||||
{
|
||||
/* instead of PyThreadState_Get, which calls Py_FatalError */
|
||||
return (PyThreadState_GetDict() != NULL);
|
||||
return (PyThreadState_GetDict() != nullptr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1168,7 +1175,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
|
||||
va_list vargs;
|
||||
|
||||
Py_ssize_t *sizes = PyMem_MALLOC(sizeof(*sizes) * (n / 2));
|
||||
Py_ssize_t *sizes = static_cast<Py_ssize_t *>(PyMem_MALLOC(sizeof(*sizes) * (n / 2)));
|
||||
int i;
|
||||
|
||||
PyObject *py_dict = PyC_DefaultNameSpace(filepath);
|
||||
@@ -1196,7 +1203,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
ret = PyObject_CallFunction(unpack, "sy#", format, (char *)ptr, sizes[i]);
|
||||
}
|
||||
|
||||
if (ret == NULL) {
|
||||
if (ret == nullptr) {
|
||||
printf("%s error, line:%d\n", __func__, __LINE__);
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
@@ -1237,7 +1244,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
|
||||
/* don't use the result */
|
||||
Py_DECREF(py_result);
|
||||
py_result = NULL;
|
||||
py_result = nullptr;
|
||||
|
||||
/* now get the values back */
|
||||
va_start(vargs, n);
|
||||
@@ -1264,7 +1271,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
|
||||
item_new = Py_BuildValue("sO", format, item);
|
||||
}
|
||||
|
||||
ret = PyObject_Call(pack, item_new, NULL);
|
||||
ret = PyObject_Call(pack, item_new, nullptr);
|
||||
|
||||
if (ret) {
|
||||
/* copy the bytes back into memory */
|
||||
@@ -1311,18 +1318,18 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
|
||||
PyObject *pointer;
|
||||
|
||||
if (STREQ(Py_TYPE(value)->tp_name, type_name) &&
|
||||
(as_pointer = PyObject_GetAttrString(value, "as_pointer")) != NULL &&
|
||||
(as_pointer = PyObject_GetAttrString(value, "as_pointer")) != nullptr &&
|
||||
PyCallable_Check(as_pointer))
|
||||
{
|
||||
void *result = NULL;
|
||||
void *result = nullptr;
|
||||
|
||||
/* must be a 'type_name' object */
|
||||
pointer = PyObject_CallObject(as_pointer, NULL);
|
||||
pointer = PyObject_CallObject(as_pointer, nullptr);
|
||||
Py_DECREF(as_pointer);
|
||||
|
||||
if (!pointer) {
|
||||
PyErr_SetString(PyExc_SystemError, "value.as_pointer() failed");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
result = PyLong_AsVoidPtr(pointer);
|
||||
Py_DECREF(pointer);
|
||||
@@ -1337,7 +1344,7 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
|
||||
"expected '%.200s' type found '%.200s' instead",
|
||||
type_name,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1413,7 +1420,7 @@ int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items,
|
||||
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
|
||||
const char *param = PyUnicode_AsUTF8(key);
|
||||
|
||||
if (param == NULL) {
|
||||
if (param == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s set must contain strings, not %.200s",
|
||||
error_prefix,
|
||||
@@ -1434,7 +1441,7 @@ int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items,
|
||||
|
||||
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
|
||||
{
|
||||
PyObject *ret = PySet_New(NULL);
|
||||
PyObject *ret = PySet_New(nullptr);
|
||||
PyObject *pystr;
|
||||
|
||||
for (; items->identifier; items++) {
|
||||
@@ -1461,7 +1468,7 @@ bool PyC_RunString_AsNumber(const char *imports[],
|
||||
{
|
||||
PyObject *py_dict, *mod, *retval;
|
||||
bool ok = true;
|
||||
PyObject *main_mod = NULL;
|
||||
PyObject *main_mod = nullptr;
|
||||
|
||||
PyC_MainModule_Backup(&main_mod);
|
||||
|
||||
@@ -1480,7 +1487,7 @@ bool PyC_RunString_AsNumber(const char *imports[],
|
||||
if (imports && !PyC_NameSpace_ImportArray(py_dict, imports)) {
|
||||
ok = false;
|
||||
}
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == NULL) {
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == nullptr) {
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
@@ -1529,7 +1536,7 @@ bool PyC_RunString_AsIntPtr(const char *imports[],
|
||||
{
|
||||
PyObject *py_dict, *retval;
|
||||
bool ok = true;
|
||||
PyObject *main_mod = NULL;
|
||||
PyObject *main_mod = nullptr;
|
||||
|
||||
PyC_MainModule_Backup(&main_mod);
|
||||
|
||||
@@ -1538,7 +1545,7 @@ bool PyC_RunString_AsIntPtr(const char *imports[],
|
||||
if (imports && !PyC_NameSpace_ImportArray(py_dict, imports)) {
|
||||
ok = false;
|
||||
}
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == NULL) {
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == nullptr) {
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
@@ -1568,7 +1575,7 @@ bool PyC_RunString_AsStringAndSize(const char *imports[],
|
||||
{
|
||||
PyObject *py_dict, *retval;
|
||||
bool ok = true;
|
||||
PyObject *main_mod = NULL;
|
||||
PyObject *main_mod = nullptr;
|
||||
|
||||
PyC_MainModule_Backup(&main_mod);
|
||||
|
||||
@@ -1577,7 +1584,7 @@ bool PyC_RunString_AsStringAndSize(const char *imports[],
|
||||
if (imports && !PyC_NameSpace_ImportArray(py_dict, imports)) {
|
||||
ok = false;
|
||||
}
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == NULL) {
|
||||
else if ((retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict)) == nullptr) {
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
@@ -1585,11 +1592,11 @@ bool PyC_RunString_AsStringAndSize(const char *imports[],
|
||||
Py_ssize_t val_len;
|
||||
|
||||
val = PyUnicode_AsUTF8AndSize(retval, &val_len);
|
||||
if (val == NULL && PyErr_Occurred()) {
|
||||
if (val == nullptr && PyErr_Occurred()) {
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
char *val_alloc = MEM_mallocN(val_len + 1, __func__);
|
||||
char *val_alloc = static_cast<char *>(MEM_mallocN(val_len + 1, __func__));
|
||||
memcpy(val_alloc, val, val_len + 1);
|
||||
*r_value = val_alloc;
|
||||
*r_value_size = val_len;
|
||||
@@ -15,25 +15,25 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
gpu_py.c
|
||||
gpu_py_api.c
|
||||
gpu_py_batch.c
|
||||
gpu_py_buffer.c
|
||||
gpu_py_capabilities.c
|
||||
gpu_py_element.c
|
||||
gpu_py_framebuffer.c
|
||||
gpu_py_matrix.c
|
||||
gpu_py_offscreen.c
|
||||
gpu_py_platform.c
|
||||
gpu_py_select.c
|
||||
gpu_py_shader.c
|
||||
gpu_py.cc
|
||||
gpu_py_api.cc
|
||||
gpu_py_batch.cc
|
||||
gpu_py_buffer.cc
|
||||
gpu_py_capabilities.cc
|
||||
gpu_py_element.cc
|
||||
gpu_py_framebuffer.cc
|
||||
gpu_py_matrix.cc
|
||||
gpu_py_offscreen.cc
|
||||
gpu_py_platform.cc
|
||||
gpu_py_select.cc
|
||||
gpu_py_shader.cc
|
||||
gpu_py_shader_create_info.cc
|
||||
gpu_py_state.c
|
||||
gpu_py_texture.c
|
||||
gpu_py_types.c
|
||||
gpu_py_uniformbuffer.c
|
||||
gpu_py_vertex_buffer.c
|
||||
gpu_py_vertex_format.c
|
||||
gpu_py_state.cc
|
||||
gpu_py_texture.cc
|
||||
gpu_py_types.cc
|
||||
gpu_py_uniformbuffer.cc
|
||||
gpu_py_vertex_buffer.cc
|
||||
gpu_py_vertex_format.cc
|
||||
|
||||
gpu_py.h
|
||||
gpu_py_api.h
|
||||
|
||||
@@ -34,7 +34,7 @@ struct PyC_StringEnumItems bpygpu_primtype_items[] = {
|
||||
{GPU_PRIM_LINES_ADJ, "LINES_ADJ"},
|
||||
{GPU_PRIM_TRIS_ADJ, "TRIS_ADJ"},
|
||||
{GPU_PRIM_LINE_STRIP_ADJ, "LINE_STRIP_ADJ"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
|
||||
@@ -44,7 +44,7 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
|
||||
{GPU_DATA_UBYTE, "UBYTE"},
|
||||
{GPU_DATA_UINT_24_8, "UINT_24_8"},
|
||||
{GPU_DATA_10_11_11_REV, "10_11_11_REV"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -55,30 +55,30 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
|
||||
|
||||
static const char g_error[] = "GPU API is not available in background mode";
|
||||
|
||||
static PyObject *py_error__ml_meth(PyObject *UNUSED(self), PyObject *UNUSED(args))
|
||||
static PyObject *py_error__ml_meth(PyObject * /*self*/, PyObject * /*args*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, g_error);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *py_error__getter(PyObject *UNUSED(self), void *UNUSED(type))
|
||||
static PyObject *py_error__getter(PyObject * /*self*/, void * /*type*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, g_error);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int py_error__setter(PyObject *UNUSED(self), PyObject *UNUSED(value), void *UNUSED(type))
|
||||
static int py_error__setter(PyObject * /*self*/, PyObject * /*value*/, void * /*type*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, g_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyObject *py_error__tp_new(PyTypeObject *UNUSED(type),
|
||||
PyObject *UNUSED(args),
|
||||
PyObject *UNUSED(kwds))
|
||||
static PyObject *py_error__tp_new(PyTypeObject * /*type*/,
|
||||
PyObject * /*args*/,
|
||||
PyObject * /*kwds*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, g_error);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *bpygpu_create_module(PyModuleDef *module_type)
|
||||
@@ -10,8 +10,16 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct PyC_StringEnumItems bpygpu_primtype_items[];
|
||||
extern struct PyC_StringEnumItems bpygpu_dataformat_items[];
|
||||
|
||||
PyObject *bpygpu_create_module(PyModuleDef *module_type);
|
||||
int bpygpu_finalize_type(PyTypeObject *py_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,11 +38,11 @@ static PyModuleDef pygpu_module_def = {
|
||||
/*m_name*/ "gpu",
|
||||
/*m_doc*/ pygpu_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *BPyInit_gpu(void)
|
||||
@@ -46,15 +46,15 @@ static bool pygpu_batch_is_program_or_error(BPyGPUBatch *self)
|
||||
/** \name GPUBatch Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_batch__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
const char *exc_str_missing_arg = "GPUBatch.__new__() missing required argument '%s' (pos %d)";
|
||||
|
||||
struct PyC_StringEnum prim_type = {bpygpu_primtype_items, GPU_PRIM_NONE};
|
||||
BPyGPUVertBuf *py_vertbuf = NULL;
|
||||
BPyGPUIndexBuf *py_indexbuf = NULL;
|
||||
BPyGPUVertBuf *py_vertbuf = nullptr;
|
||||
BPyGPUIndexBuf *py_indexbuf = nullptr;
|
||||
|
||||
static const char *_keywords[] = {"type", "buf", "elem", NULL};
|
||||
static const char *_keywords[] = {"type", "buf", "elem", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
"O&" /* `type` */
|
||||
@@ -74,7 +74,7 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args,
|
||||
&BPyGPUIndexBuf_Type,
|
||||
&py_indexbuf))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLI_assert(prim_type.value_found != GPU_PRIM_NONE);
|
||||
@@ -91,13 +91,14 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args,
|
||||
1);
|
||||
}
|
||||
|
||||
if (py_vertbuf == NULL) {
|
||||
if (py_vertbuf == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError, exc_str_missing_arg, _keywords[1], 2);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUBatch *batch = GPU_batch_create(
|
||||
prim_type.value_found, py_vertbuf->buf, py_indexbuf ? py_indexbuf->elem : NULL);
|
||||
GPUBatch *batch = GPU_batch_create(GPUPrimType(prim_type.value_found),
|
||||
py_vertbuf->buf,
|
||||
py_indexbuf ? py_indexbuf->elem : nullptr);
|
||||
|
||||
BPyGPUBatch *ret = (BPyGPUBatch *)BPyGPUBatch_CreatePyObject(batch);
|
||||
|
||||
@@ -106,7 +107,7 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args,
|
||||
PyList_SET_ITEM(ret->references, 0, (PyObject *)py_vertbuf);
|
||||
Py_INCREF(py_vertbuf);
|
||||
|
||||
if (py_indexbuf != NULL) {
|
||||
if (py_indexbuf != nullptr) {
|
||||
PyList_SET_ITEM(ret->references, 1, (PyObject *)py_indexbuf);
|
||||
Py_INCREF(py_indexbuf);
|
||||
}
|
||||
@@ -118,8 +119,7 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args,
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc,
|
||||
".. method:: vertbuf_add(buf)\n"
|
||||
PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc, ".. method:: vertbuf_add(buf)\n"
|
||||
"\n"
|
||||
" Add another vertex buffer to the Batch.\n"
|
||||
" It is not possible to add more vertices to the batch using this method.\n"
|
||||
@@ -135,7 +135,7 @@ static PyObject *pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_bu
|
||||
{
|
||||
if (!BPyGPUVertBuf_Check(py_buf)) {
|
||||
PyErr_Format(PyExc_TypeError, "Expected a GPUVertBuf, got %s", Py_TYPE(py_buf)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (GPU_vertbuf_get_vertex_len(self->batch->verts[0]) != GPU_vertbuf_get_vertex_len(py_buf->buf))
|
||||
@@ -144,14 +144,14 @@ static PyObject *pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_bu
|
||||
"Expected %d length, got %d",
|
||||
GPU_vertbuf_get_vertex_len(self->batch->verts[0]),
|
||||
GPU_vertbuf_get_vertex_len(py_buf->buf));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (self->batch->verts[GPU_BATCH_VBO_MAX_LEN - 1] != NULL) {
|
||||
if (self->batch->verts[GPU_BATCH_VBO_MAX_LEN - 1] != nullptr) {
|
||||
PyErr_SetString(
|
||||
PyExc_RuntimeError,
|
||||
"Maximum number of vertex buffers exceeded: " STRINGIFY(GPU_BATCH_VBO_MAX_LEN));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
@@ -178,7 +178,7 @@ static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_sha
|
||||
{
|
||||
if (!BPyGPUShader_Check(py_shader)) {
|
||||
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUShader *shader = py_shader->shader;
|
||||
@@ -215,14 +215,14 @@ PyDoc_STRVAR(pygpu_batch_draw_doc,
|
||||
" :type program: :class:`gpu.types.GPUShader`\n");
|
||||
static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
|
||||
{
|
||||
BPyGPUShader *py_program = NULL;
|
||||
BPyGPUShader *py_program = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!:GPUBatch.draw", &BPyGPUShader_Type, &py_program)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (py_program == NULL) {
|
||||
if (py_program == nullptr) {
|
||||
if (!pygpu_batch_is_program_or_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (self->batch->shader != py_program->shader) {
|
||||
@@ -251,11 +251,11 @@ PyDoc_STRVAR(
|
||||
" :type instance_count: int\n");
|
||||
static PyObject *pygpu_batch_draw_instanced(BPyGPUBatch *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
BPyGPUShader *py_program = NULL;
|
||||
BPyGPUShader *py_program = nullptr;
|
||||
int instance_start = 0;
|
||||
int instance_count = 0;
|
||||
|
||||
static const char *_keywords[] = {"program", "instance_start", "instance_count", NULL};
|
||||
static const char *_keywords[] = {"program", "instance_start", "instance_count", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O!" /* `program` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -268,7 +268,7 @@ static PyObject *pygpu_batch_draw_instanced(BPyGPUBatch *self, PyObject *args, P
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kw, &_parser, &BPyGPUShader_Type, &py_program, &instance_start, &instance_count))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_batch_set_shader(self->batch, py_program->shader);
|
||||
@@ -293,11 +293,11 @@ PyDoc_STRVAR(pygpu_batch_draw_range_doc,
|
||||
" :type elem_count: int\n");
|
||||
static PyObject *pygpu_batch_draw_range(BPyGPUBatch *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
BPyGPUShader *py_program = NULL;
|
||||
BPyGPUShader *py_program = nullptr;
|
||||
int elem_start = 0;
|
||||
int elem_count = 0;
|
||||
|
||||
static const char *_keywords[] = {"program", "elem_start", "elem_count", NULL};
|
||||
static const char *_keywords[] = {"program", "elem_start", "elem_count", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O!" /* `program` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -310,7 +310,7 @@ static PyObject *pygpu_batch_draw_range(BPyGPUBatch *self, PyObject *args, PyObj
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kw, &_parser, &BPyGPUShader_Type, &py_program, &elem_start, &elem_count))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_batch_set_shader(self->batch, py_program->shader);
|
||||
@@ -321,7 +321,7 @@ static PyObject *pygpu_batch_draw_range(BPyGPUBatch *self, PyObject *args, PyObj
|
||||
static PyObject *pygpu_batch_program_use_begin(BPyGPUBatch *self)
|
||||
{
|
||||
if (!pygpu_batch_is_program_or_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_shader_bind(self->batch->shader);
|
||||
Py_RETURN_NONE;
|
||||
@@ -330,7 +330,7 @@ static PyObject *pygpu_batch_program_use_begin(BPyGPUBatch *self)
|
||||
static PyObject *pygpu_batch_program_use_end(BPyGPUBatch *self)
|
||||
{
|
||||
if (!pygpu_batch_is_program_or_error(self)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_shader_unbind();
|
||||
Py_RETURN_NONE;
|
||||
@@ -350,7 +350,7 @@ static PyMethodDef pygpu_batch__tp_methods[] = {
|
||||
pygpu_batch_draw_range_doc},
|
||||
{"_program_use_begin", (PyCFunction)pygpu_batch_program_use_begin, METH_NOARGS, ""},
|
||||
{"_program_use_end", (PyCFunction)pygpu_batch_program_use_end, METH_NOARGS, ""},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
@@ -369,7 +369,7 @@ static int pygpu_batch__tp_clear(BPyGPUBatch *self)
|
||||
|
||||
static int pygpu_batch__tp_is_gc(BPyGPUBatch *self)
|
||||
{
|
||||
return self->references != NULL;
|
||||
return self->references != nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -404,25 +404,25 @@ PyDoc_STRVAR(
|
||||
" :arg elem: An optional index buffer.\n"
|
||||
" :type elem: :class:`gpu.types.GPUIndexBuf`\n");
|
||||
PyTypeObject BPyGPUBatch_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUBatch",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUBatch),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_batch__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
||||
#else
|
||||
@@ -432,43 +432,43 @@ PyTypeObject BPyGPUBatch_Type = {
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
/*tp_traverse*/ (traverseproc)pygpu_batch__tp_traverse,
|
||||
#else
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
#endif
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
/*tp_clear*/ (inquiry)pygpu_batch__tp_clear,
|
||||
#else
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_clear*/ nullptr,
|
||||
#endif
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_batch__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_batch__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
/*tp_is_gc*/ (inquiry)pygpu_batch__tp_is_gc,
|
||||
#else
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
#endif
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -483,7 +483,7 @@ PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch)
|
||||
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type);
|
||||
self->references = NULL;
|
||||
self->references = nullptr;
|
||||
#else
|
||||
self = PyObject_New(BPyGPUBatch, &BPyGPUBatch_Type);
|
||||
#endif
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define USE_GPU_PY_REFERENCES
|
||||
|
||||
extern PyTypeObject BPyGPUBatch_Type;
|
||||
@@ -27,3 +31,7 @@ typedef struct BPyGPUBatch {
|
||||
} BPyGPUBatch;
|
||||
|
||||
PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -129,7 +129,7 @@ static const char *pygpu_buffer_formatstr(eGPUDataFormat data_format)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -146,10 +146,11 @@ static BPyGPUBuffer *pygpu_buffer_make_from_data(PyObject *parent,
|
||||
{
|
||||
BPyGPUBuffer *buffer = (BPyGPUBuffer *)_PyObject_GC_New(&BPyGPU_BufferType);
|
||||
|
||||
buffer->parent = NULL;
|
||||
buffer->parent = nullptr;
|
||||
buffer->format = format;
|
||||
buffer->shape_len = shape_len;
|
||||
buffer->shape = MEM_mallocN(shape_len * sizeof(*buffer->shape), "BPyGPUBuffer shape");
|
||||
buffer->shape = static_cast<Py_ssize_t *>(
|
||||
MEM_mallocN(shape_len * sizeof(*buffer->shape), "BPyGPUBuffer shape"));
|
||||
memcpy(buffer->shape, shape, shape_len * sizeof(*buffer->shape));
|
||||
buffer->buf.as_void = buf;
|
||||
|
||||
@@ -166,10 +167,10 @@ static PyObject *pygpu_buffer__sq_item(BPyGPUBuffer *self, Py_ssize_t i)
|
||||
{
|
||||
if (i >= self->shape[0] || i < 0) {
|
||||
PyErr_SetString(PyExc_IndexError, "array index out of range");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *formatstr = pygpu_buffer_formatstr(self->format);
|
||||
const char *formatstr = pygpu_buffer_formatstr(eGPUDataFormat(self->format));
|
||||
|
||||
if (self->shape_len == 1) {
|
||||
switch (self->format) {
|
||||
@@ -186,19 +187,19 @@ static PyObject *pygpu_buffer__sq_item(BPyGPUBuffer *self, Py_ssize_t i)
|
||||
}
|
||||
}
|
||||
else {
|
||||
int offset = i * GPU_texture_dataformat_size(self->format);
|
||||
int offset = i * GPU_texture_dataformat_size(eGPUDataFormat(self->format));
|
||||
for (int j = 1; j < self->shape_len; j++) {
|
||||
offset *= self->shape[j];
|
||||
}
|
||||
|
||||
return (PyObject *)pygpu_buffer_make_from_data((PyObject *)self,
|
||||
self->format,
|
||||
eGPUDataFormat(self->format),
|
||||
self->shape_len - 1,
|
||||
self->shape + 1,
|
||||
self->buf.as_byte + offset);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PyObject *pygpu_buffer_to_list(BPyGPUBuffer *self)
|
||||
@@ -237,7 +238,7 @@ static PyObject *pygpu_buffer_to_list_recursive(BPyGPUBuffer *self)
|
||||
return list;
|
||||
}
|
||||
|
||||
static PyObject *pygpu_buffer_dimensions_get(BPyGPUBuffer *self, void *UNUSED(arg))
|
||||
static PyObject *pygpu_buffer_dimensions_get(BPyGPUBuffer *self, void * /*arg*/)
|
||||
{
|
||||
PyObject *list = PyList_New(self->shape_len);
|
||||
int i;
|
||||
@@ -249,7 +250,7 @@ static PyObject *pygpu_buffer_dimensions_get(BPyGPUBuffer *self, void *UNUSED(ar
|
||||
return list;
|
||||
}
|
||||
|
||||
static int pygpu_buffer_dimensions_set(BPyGPUBuffer *self, PyObject *value, void *UNUSED(type))
|
||||
static int pygpu_buffer_dimensions_set(BPyGPUBuffer *self, PyObject *value, void * /*type*/)
|
||||
{
|
||||
Py_ssize_t shape[MAX_DIMENSIONS];
|
||||
Py_ssize_t shape_len = 0;
|
||||
@@ -265,7 +266,7 @@ static int pygpu_buffer_dimensions_set(BPyGPUBuffer *self, PyObject *value, void
|
||||
size_t size = shape_len * sizeof(*self->shape);
|
||||
if (shape_len != self->shape_len) {
|
||||
MEM_freeN(self->shape);
|
||||
self->shape = MEM_mallocN(size, __func__);
|
||||
self->shape = static_cast<Py_ssize_t *>(MEM_mallocN(size, __func__));
|
||||
}
|
||||
|
||||
self->shape_len = shape_len;
|
||||
@@ -283,7 +284,7 @@ static int pygpu_buffer__tp_clear(BPyGPUBuffer *self)
|
||||
{
|
||||
if (self->parent) {
|
||||
Py_CLEAR(self->parent);
|
||||
self->buf.as_void = NULL;
|
||||
self->buf.as_void = nullptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -370,28 +371,28 @@ static int pygpu_buffer_ass_slice(BPyGPUBuffer *self,
|
||||
return err;
|
||||
}
|
||||
|
||||
static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_buffer__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *length_ob, *init = NULL;
|
||||
BPyGPUBuffer *buffer = NULL;
|
||||
PyObject *length_ob, *init = nullptr;
|
||||
BPyGPUBuffer *buffer = nullptr;
|
||||
Py_ssize_t shape[MAX_DIMENSIONS];
|
||||
|
||||
Py_ssize_t shape_len = 0;
|
||||
|
||||
if (kwds && PyDict_Size(kwds)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Buffer(): takes no keyword args");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_DATA_FLOAT};
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "O&O|O: Buffer", PyC_ParseStringEnum, &pygpu_dataformat, &length_ob, &init))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!pygpu_buffer_pyobj_as_shape(length_ob, shape, &shape_len)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (init && PyObject_CheckBuffer(init)) {
|
||||
@@ -399,7 +400,7 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
|
||||
if (PyObject_GetBuffer(init, &pybuffer, PyBUF_ND | PyBUF_FORMAT) == -1) {
|
||||
/* PyObject_GetBuffer raise a PyExc_BufferError */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_ssize_t *pybuffer_shape = pybuffer.shape;
|
||||
@@ -411,16 +412,16 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
|
||||
if (pygpu_buffer_dimensions_tot_len_compare(shape, shape_len, pybuffer_shape, pybuffer_ndim)) {
|
||||
buffer = pygpu_buffer_make_from_data(
|
||||
init, pygpu_dataformat.value_found, shape_len, shape, pybuffer.buf);
|
||||
init, eGPUDataFormat(pygpu_dataformat.value_found), shape_len, shape, pybuffer.buf);
|
||||
}
|
||||
|
||||
PyBuffer_Release(&pybuffer);
|
||||
}
|
||||
else {
|
||||
buffer = BPyGPU_Buffer_CreatePyObject(pygpu_dataformat.value_found, shape, shape_len, NULL);
|
||||
buffer = BPyGPU_Buffer_CreatePyObject(pygpu_dataformat.value_found, shape, shape_len, nullptr);
|
||||
if (init && pygpu_buffer_ass_slice(buffer, 0, shape[0], init)) {
|
||||
Py_DECREF(buffer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +430,7 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
|
||||
static int pygpu_buffer__tp_is_gc(BPyGPUBuffer *self)
|
||||
{
|
||||
return self->parent != NULL;
|
||||
return self->parent != nullptr;
|
||||
}
|
||||
|
||||
/* BPyGPUBuffer sequence methods */
|
||||
@@ -503,7 +504,7 @@ static PyObject *pygpu_buffer__mp_subscript(BPyGPUBuffer *self, PyObject *item)
|
||||
Py_ssize_t i;
|
||||
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (i < 0) {
|
||||
i += self->shape[0];
|
||||
@@ -514,7 +515,7 @@ static PyObject *pygpu_buffer__mp_subscript(BPyGPUBuffer *self, PyObject *item)
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx(item, self->shape[0], &start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (slicelength <= 0) {
|
||||
@@ -525,12 +526,12 @@ static PyObject *pygpu_buffer__mp_subscript(BPyGPUBuffer *self, PyObject *item)
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int pygpu_buffer__mp_ass_subscript(BPyGPUBuffer *self, PyObject *item, PyObject *value)
|
||||
@@ -570,29 +571,29 @@ static PyMethodDef pygpu_buffer__tp_methods[] = {
|
||||
(PyCFunction)pygpu_buffer_to_list_recursive,
|
||||
METH_NOARGS,
|
||||
"return the buffer as a list"},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static PyGetSetDef pygpu_buffer_getseters[] = {
|
||||
{"dimensions",
|
||||
(getter)pygpu_buffer_dimensions_get,
|
||||
(setter)pygpu_buffer_dimensions_set,
|
||||
NULL,
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
nullptr,
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static PySequenceMethods pygpu_buffer__tp_as_sequence = {
|
||||
/*sq_length*/ (lenfunc)pygpu_buffer__sq_length,
|
||||
/*sq_concat*/ NULL,
|
||||
/*sq_repeat*/ NULL,
|
||||
/*sq_concat*/ nullptr,
|
||||
/*sq_repeat*/ nullptr,
|
||||
/*sq_item*/ (ssizeargfunc)pygpu_buffer__sq_item,
|
||||
/*was_sq_slice*/ NULL, /* DEPRECATED. Handled by #pygpu_buffer__sq_item. */
|
||||
/*was_sq_slice*/ nullptr, /* DEPRECATED. Handled by #pygpu_buffer__sq_item. */
|
||||
/*sq_ass_item*/ (ssizeobjargproc)pygpu_buffer__sq_ass_item,
|
||||
/*was_sq_ass_slice*/ NULL, /* DEPRECATED. Handled by #pygpu_buffer__sq_ass_item. */
|
||||
/*sq_contains*/ NULL,
|
||||
/*sq_inplace_concat*/ NULL,
|
||||
/*sq_inplace_repeat*/ NULL,
|
||||
/*was_sq_ass_slice*/ nullptr, /* DEPRECATED. Handled by #pygpu_buffer__sq_ass_item. */
|
||||
/*sq_contains*/ nullptr,
|
||||
/*sq_inplace_concat*/ nullptr,
|
||||
/*sq_inplace_repeat*/ nullptr,
|
||||
};
|
||||
|
||||
static PyMappingMethods pygpu_buffer__tp_as_mapping = {
|
||||
@@ -616,8 +617,8 @@ static void pygpu_buffer_strides_calc(const eGPUDataFormat format,
|
||||
/* Here is the buffer interface function */
|
||||
static int pygpu_buffer__bf_getbuffer(BPyGPUBuffer *self, Py_buffer *view, int flags)
|
||||
{
|
||||
if (view == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "NULL view in getbuffer");
|
||||
if (view == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "nullptr view in getbuffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -627,26 +628,28 @@ static int pygpu_buffer__bf_getbuffer(BPyGPUBuffer *self, Py_buffer *view, int f
|
||||
view->buf = (void *)self->buf.as_void;
|
||||
view->len = bpygpu_Buffer_size(self);
|
||||
view->readonly = 0;
|
||||
view->itemsize = GPU_texture_dataformat_size(self->format);
|
||||
view->itemsize = GPU_texture_dataformat_size(eGPUDataFormat(self->format));
|
||||
if (flags & PyBUF_FORMAT) {
|
||||
view->format = (char *)pygpu_buffer_formatstr(self->format);
|
||||
view->format = (char *)pygpu_buffer_formatstr(eGPUDataFormat(self->format));
|
||||
}
|
||||
if (flags & PyBUF_ND) {
|
||||
view->ndim = self->shape_len;
|
||||
view->shape = self->shape;
|
||||
}
|
||||
if (flags & PyBUF_STRIDES) {
|
||||
view->strides = MEM_mallocN(view->ndim * sizeof(*view->strides), "BPyGPUBuffer strides");
|
||||
pygpu_buffer_strides_calc(self->format, view->ndim, view->shape, view->strides);
|
||||
view->strides = static_cast<Py_ssize_t *>(
|
||||
MEM_mallocN(view->ndim * sizeof(*view->strides), "BPyGPUBuffer strides"));
|
||||
pygpu_buffer_strides_calc(
|
||||
eGPUDataFormat(self->format), view->ndim, view->shape, view->strides);
|
||||
}
|
||||
view->suboffsets = NULL;
|
||||
view->internal = NULL;
|
||||
view->suboffsets = nullptr;
|
||||
view->internal = nullptr;
|
||||
|
||||
Py_INCREF(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pygpu_buffer__bf_releasebuffer(PyObject *UNUSED(exporter), Py_buffer *view)
|
||||
static void pygpu_buffer__bf_releasebuffer(PyObject * /*exporter*/, Py_buffer *view)
|
||||
{
|
||||
MEM_SAFE_FREE(view->strides);
|
||||
}
|
||||
@@ -671,66 +674,67 @@ PyDoc_STRVAR(
|
||||
" :arg data: Optional data array.\n"
|
||||
" :type data: sequence\n");
|
||||
PyTypeObject BPyGPU_BufferType = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "Buffer",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUBuffer),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_buffer__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_compare*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_compare*/ nullptr,
|
||||
/*tp_repr*/ (reprfunc)pygpu_buffer__tp_repr,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ &pygpu_buffer__tp_as_sequence,
|
||||
/*tp_as_mapping*/ &pygpu_buffer__tp_as_mapping,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
#ifdef PYGPU_BUFFER_PROTOCOL
|
||||
/*tp_as_buffer*/ &pygpu_buffer__tp_as_buffer,
|
||||
#else
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
#endif
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
||||
/*tp_doc*/ pygpu_buffer__tp_doc,
|
||||
/*tp_traverse*/ (traverseproc)pygpu_buffer__tp_traverse,
|
||||
/*tp_clear*/ (inquiry)pygpu_buffer__tp_clear,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_buffer__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_buffer_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_buffer__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ (inquiry)pygpu_buffer__tp_is_gc,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
static size_t pygpu_buffer_calc_size(const int format,
|
||||
const int shape_len,
|
||||
const Py_ssize_t *shape)
|
||||
{
|
||||
return pygpu_buffer_dimensions_tot_elem(shape, shape_len) * GPU_texture_dataformat_size(format);
|
||||
return pygpu_buffer_dimensions_tot_elem(shape, shape_len) *
|
||||
GPU_texture_dataformat_size(eGPUDataFormat(format));
|
||||
}
|
||||
|
||||
size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer)
|
||||
@@ -743,12 +747,12 @@ BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(const int format,
|
||||
const int shape_len,
|
||||
void *buffer)
|
||||
{
|
||||
if (buffer == NULL) {
|
||||
if (buffer == nullptr) {
|
||||
size_t size = pygpu_buffer_calc_size(format, shape_len, shape);
|
||||
buffer = MEM_callocN(size, "BPyGPUBuffer buffer");
|
||||
}
|
||||
|
||||
return pygpu_buffer_make_from_data(NULL, format, shape_len, shape, buffer);
|
||||
return pygpu_buffer_make_from_data(nullptr, eGPUDataFormat(format), shape_len, shape, buffer);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPU_BufferType;
|
||||
|
||||
#define BPyGPU_Buffer_Check(v) (Py_TYPE(v) == &BPyGPU_BufferType)
|
||||
@@ -47,3 +51,7 @@ BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(int format,
|
||||
const Py_ssize_t *shape,
|
||||
int shape_len,
|
||||
void *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ PyDoc_STRVAR(pygpu_max_texture_size_get_doc,
|
||||
"\n"
|
||||
" :return: Texture size.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_texture_size_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_texture_size_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_texture_size());
|
||||
}
|
||||
@@ -41,7 +41,7 @@ PyDoc_STRVAR(pygpu_max_texture_layers_get_doc,
|
||||
"\n"
|
||||
" :return: Number of layers.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_texture_layers_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_texture_layers_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_texture_layers());
|
||||
}
|
||||
@@ -55,7 +55,7 @@ PyDoc_STRVAR(pygpu_max_textures_get_doc,
|
||||
"\n"
|
||||
" :return: Texture image units.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_textures_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_textures_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_textures());
|
||||
}
|
||||
@@ -68,7 +68,7 @@ PyDoc_STRVAR(pygpu_max_textures_vert_get_doc,
|
||||
"\n"
|
||||
" :return: Texture image units.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_textures_vert_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_textures_vert_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_textures_vert());
|
||||
}
|
||||
@@ -81,7 +81,7 @@ PyDoc_STRVAR(pygpu_max_textures_geom_get_doc,
|
||||
"\n"
|
||||
" :return: Texture image units.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_textures_geom_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_textures_geom_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_textures_geom());
|
||||
}
|
||||
@@ -94,7 +94,7 @@ PyDoc_STRVAR(pygpu_max_textures_frag_get_doc,
|
||||
"\n"
|
||||
" :return: Texture image units.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_textures_frag_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_textures_frag_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_textures_frag());
|
||||
}
|
||||
@@ -107,7 +107,7 @@ PyDoc_STRVAR(pygpu_max_uniforms_vert_get_doc,
|
||||
"\n"
|
||||
" :return: Number of values.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_uniforms_vert_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_uniforms_vert_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_uniforms_vert());
|
||||
}
|
||||
@@ -120,7 +120,7 @@ PyDoc_STRVAR(pygpu_max_uniforms_frag_get_doc,
|
||||
"\n"
|
||||
" :return: Number of values.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_uniforms_frag_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_uniforms_frag_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_uniforms_frag());
|
||||
}
|
||||
@@ -132,7 +132,7 @@ PyDoc_STRVAR(pygpu_max_batch_indices_get_doc,
|
||||
"\n"
|
||||
" :return: Number of indices.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_batch_indices_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_batch_indices_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_batch_indices());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ PyDoc_STRVAR(pygpu_max_batch_vertices_get_doc,
|
||||
"\n"
|
||||
" :return: Number of vertices.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_batch_vertices_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_batch_vertices_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_batch_vertices());
|
||||
}
|
||||
@@ -157,7 +157,7 @@ PyDoc_STRVAR(pygpu_max_vertex_attribs_get_doc,
|
||||
"\n"
|
||||
" :return: Number of attributes.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_vertex_attribs_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_vertex_attribs_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_vertex_attribs());
|
||||
}
|
||||
@@ -170,7 +170,7 @@ PyDoc_STRVAR(pygpu_max_varying_floats_get_doc,
|
||||
"\n"
|
||||
" :return: Number of variables.\n"
|
||||
" :rtype: int\n");
|
||||
static PyObject *pygpu_max_varying_floats_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_max_varying_floats_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_max_varying_floats());
|
||||
}
|
||||
@@ -182,7 +182,7 @@ PyDoc_STRVAR(pygpu_extensions_get_doc,
|
||||
"\n"
|
||||
" :return: Extensions.\n"
|
||||
" :rtype: tuple of string\n");
|
||||
static PyObject *pygpu_extensions_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_extensions_get(PyObject * /*self*/)
|
||||
{
|
||||
int extensions_len = GPU_extensions_len();
|
||||
PyObject *ret = PyTuple_New(extensions_len);
|
||||
@@ -201,7 +201,7 @@ PyDoc_STRVAR(pygpu_compute_shader_support_get_doc,
|
||||
"\n"
|
||||
" :return: True when supported, False when not supported.\n"
|
||||
" :rtype: bool\n");
|
||||
static PyObject *pygpu_compute_shader_support_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_compute_shader_support_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyBool_FromLong(GPU_compute_shader_support());
|
||||
}
|
||||
@@ -213,7 +213,7 @@ PyDoc_STRVAR(pygpu_shader_storage_buffer_objects_support_get_doc,
|
||||
"\n"
|
||||
" :return: True when supported, False when not supported.\n"
|
||||
" :rtype: bool\n");
|
||||
static PyObject *pygpu_shader_storage_buffer_objects_support_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_shader_storage_buffer_objects_support_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyBool_FromLong(GPU_shader_storage_buffer_objects_support());
|
||||
}
|
||||
@@ -224,7 +224,7 @@ PyDoc_STRVAR(pygpu_shader_image_load_store_support_get_doc,
|
||||
"\n"
|
||||
" :return: True when supported, False when not supported.\n"
|
||||
" :rtype: bool\n");
|
||||
static PyObject *pygpu_shader_image_load_store_support_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_shader_image_load_store_support_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyBool_FromLong(GPU_shader_image_load_store_support());
|
||||
}
|
||||
@@ -298,7 +298,7 @@ static PyMethodDef pygpu_capabilities__tp_methods[] = {
|
||||
METH_NOARGS,
|
||||
pygpu_shader_image_load_store_support_get_doc},
|
||||
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_capabilities__tp_doc, "This module provides access to the GPU capabilities.");
|
||||
@@ -308,10 +308,10 @@ static PyModuleDef pygpu_capabilities_module_def = {
|
||||
/*m_doc*/ pygpu_capabilities__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_capabilities__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_capabilities_init(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_capabilities_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/** \name IndexBuf Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
const char *error_prefix = "IndexBuf.__new__";
|
||||
bool ok = true;
|
||||
@@ -38,7 +38,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
uint index_len;
|
||||
GPUIndexBufBuilder builder;
|
||||
|
||||
static const char *_keywords[] = {"type", "seq", NULL};
|
||||
static const char *_keywords[] = {"type", "seq", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"$O" /* `type` */
|
||||
"&O" /* `seq` */
|
||||
@@ -48,15 +48,15 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, PyC_ParseStringEnum, &prim_type, &seq)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
verts_per_prim = GPU_indexbuf_primitive_len(prim_type.value_found);
|
||||
verts_per_prim = GPU_indexbuf_primitive_len(GPUPrimType(prim_type.value_found));
|
||||
if (verts_per_prim == -1) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"The argument 'type' must be "
|
||||
"'POINTS', 'LINES', 'TRIS' or 'LINES_ADJ'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_CheckBuffer(seq)) {
|
||||
@@ -64,13 +64,13 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
|
||||
if (PyObject_GetBuffer(seq, &pybuffer, PyBUF_FORMAT | PyBUF_ND) == -1) {
|
||||
/* PyObject_GetBuffer already handles error messages. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (pybuffer.ndim != 1 && pybuffer.shape[1] != verts_per_prim) {
|
||||
PyErr_Format(PyExc_ValueError, "Each primitive must exactly %d indices", verts_per_prim);
|
||||
PyBuffer_Release(&pybuffer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (pybuffer.itemsize != 4 ||
|
||||
@@ -78,7 +78,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
{
|
||||
PyErr_Format(PyExc_ValueError, "Each index must be an 4-bytes integer value");
|
||||
PyBuffer_Release(&pybuffer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index_len = pybuffer.shape[0];
|
||||
@@ -89,9 +89,9 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
/* The `vertex_len` parameter is only used for asserts in the Debug build. */
|
||||
/* Not very useful in python since scripts are often tested in Release build. */
|
||||
/* Use `INT_MAX` instead of the actual number of vertices. */
|
||||
GPU_indexbuf_init(&builder, prim_type.value_found, index_len, INT_MAX);
|
||||
GPU_indexbuf_init(&builder, GPUPrimType(prim_type.value_found), index_len, INT_MAX);
|
||||
|
||||
uint *buf = pybuffer.buf;
|
||||
uint *buf = static_cast<uint *>(pybuffer.buf);
|
||||
for (uint i = index_len; i--; buf++) {
|
||||
GPU_indexbuf_add_generic_vert(&builder, *buf);
|
||||
}
|
||||
@@ -101,8 +101,8 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
else {
|
||||
PyObject *seq_fast = PySequence_Fast(seq, error_prefix);
|
||||
|
||||
if (seq_fast == NULL) {
|
||||
return false;
|
||||
if (seq_fast == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast);
|
||||
@@ -114,7 +114,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
/* The `vertex_len` parameter is only used for asserts in the Debug build. */
|
||||
/* Not very useful in python since scripts are often tested in Release build. */
|
||||
/* Use `INT_MAX` instead of the actual number of vertices. */
|
||||
GPU_indexbuf_init(&builder, prim_type.value_found, index_len, INT_MAX);
|
||||
GPU_indexbuf_init(&builder, GPUPrimType(prim_type.value_found), index_len, INT_MAX);
|
||||
|
||||
if (verts_per_prim == 1) {
|
||||
for (uint i = 0; i < seq_len; i++) {
|
||||
@@ -125,7 +125,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
int values[4];
|
||||
for (uint i = 0; i < seq_len; i++) {
|
||||
PyObject *seq_fast_item = PySequence_Fast(seq_items[i], error_prefix);
|
||||
if (seq_fast_item == NULL) {
|
||||
if (seq_fast_item == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s: expected a sequence, got %s",
|
||||
error_prefix,
|
||||
@@ -161,7 +161,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
|
||||
|
||||
if (ok == false) {
|
||||
MEM_freeN(builder.data);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUIndexBuf_CreatePyObject(GPU_indexbuf_build(&builder));
|
||||
@@ -186,55 +186,55 @@ PyDoc_STRVAR(pygpu_IndexBuf__tp_doc,
|
||||
" Optionally the sequence can support the buffer protocol.\n"
|
||||
" :type seq: 1D or 2D sequence\n");
|
||||
PyTypeObject BPyGPUIndexBuf_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUIndexBuf",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUIndexBuf),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_IndexBuf__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_IndexBuf__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_methods*/ NULL,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ nullptr,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_IndexBuf__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUIndexBuf_Type;
|
||||
|
||||
#define BPyGPUIndexBuf_Check(v) (Py_TYPE(v) == &BPyGPUIndexBuf_Type)
|
||||
@@ -18,3 +22,7 @@ typedef struct BPyGPUIndexBuf {
|
||||
} BPyGPUIndexBuf;
|
||||
|
||||
PyObject *BPyGPUIndexBuf_CreatePyObject(struct GPUIndexBuf *elem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
static int pygpu_framebuffer_valid_check(BPyGPUFrameBuffer *bpygpu_fb)
|
||||
{
|
||||
if (UNLIKELY(bpygpu_fb->fb == NULL)) {
|
||||
if (UNLIKELY(bpygpu_fb->fb == nullptr)) {
|
||||
PyErr_SetString(PyExc_ReferenceError, "GPU framebuffer was freed, no further access is valid");
|
||||
return -1;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ static int pygpu_framebuffer_valid_check(BPyGPUFrameBuffer *bpygpu_fb)
|
||||
#define PYGPU_FRAMEBUFFER_CHECK_OBJ(bpygpu) \
|
||||
{ \
|
||||
if (UNLIKELY(pygpu_framebuffer_valid_check(bpygpu) == -1)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -62,14 +62,14 @@ static void pygpu_framebuffer_free_safe(BPyGPUFrameBuffer *self)
|
||||
{
|
||||
if (self->fb) {
|
||||
#ifndef GPU_NO_USE_PY_REFERENCES
|
||||
GPU_framebuffer_py_reference_set(self->fb, NULL);
|
||||
GPU_framebuffer_py_reference_set(self->fb, nullptr);
|
||||
if (!self->shared_reference)
|
||||
#endif
|
||||
{
|
||||
pygpu_framebuffer_free_if_possible(self->fb);
|
||||
}
|
||||
|
||||
self->fb = NULL;
|
||||
self->fb = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,11 +115,11 @@ static bool pygpu_framebuffer_stack_pop_and_restore_or_error(GPUFrameBuffer *fb)
|
||||
*
|
||||
* \{ */
|
||||
|
||||
typedef struct {
|
||||
struct PyFrameBufferStackContext {
|
||||
PyObject_HEAD /* Required Python macro. */
|
||||
BPyGPUFrameBuffer *py_fb;
|
||||
int level;
|
||||
} PyFrameBufferStackContext;
|
||||
};
|
||||
|
||||
static void pygpu_framebuffer_stack_context__tp_dealloc(PyFrameBufferStackContext *self)
|
||||
{
|
||||
@@ -134,11 +134,11 @@ static PyObject *pygpu_framebuffer_stack_context_enter(PyFrameBufferStackContext
|
||||
/* sanity - should never happen */
|
||||
if (self->level != -1) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Already in use");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!pygpu_framebuffer_stack_push_and_bind_or_error(self->py_fb->fb)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
self->level = GPU_framebuffer_stack_level_get();
|
||||
@@ -146,14 +146,14 @@ static PyObject *pygpu_framebuffer_stack_context_enter(PyFrameBufferStackContext
|
||||
}
|
||||
|
||||
static PyObject *pygpu_framebuffer_stack_context_exit(PyFrameBufferStackContext *self,
|
||||
PyObject *UNUSED(args))
|
||||
PyObject * /*args*/)
|
||||
{
|
||||
PYGPU_FRAMEBUFFER_CHECK_OBJ(self->py_fb);
|
||||
|
||||
/* sanity - should never happen */
|
||||
if (self->level == -1) {
|
||||
fprintf(stderr, "Not yet in use\n");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int level = GPU_framebuffer_stack_level_get();
|
||||
@@ -162,7 +162,7 @@ static PyObject *pygpu_framebuffer_stack_context_exit(PyFrameBufferStackContext
|
||||
}
|
||||
|
||||
if (!pygpu_framebuffer_stack_pop_and_restore_or_error(self->py_fb->fb)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -170,59 +170,59 @@ static PyObject *pygpu_framebuffer_stack_context_exit(PyFrameBufferStackContext
|
||||
static PyMethodDef pygpu_framebuffer_stack_context__tp_methods[] = {
|
||||
{"__enter__", (PyCFunction)pygpu_framebuffer_stack_context_enter, METH_NOARGS},
|
||||
{"__exit__", (PyCFunction)pygpu_framebuffer_stack_context_exit, METH_VARARGS},
|
||||
{NULL},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
static PyTypeObject FramebufferStackContext_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUFrameBufferStackContext",
|
||||
/*tp_basicsize*/ sizeof(PyFrameBufferStackContext),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_framebuffer_stack_context__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_framebuffer_stack_context__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_framebuffer_bind_doc,
|
||||
@@ -246,10 +246,9 @@ static PyObject *pygpu_framebuffer_bind(BPyGPUFrameBuffer *self)
|
||||
* \{ */
|
||||
|
||||
/* Fill in the GPUAttachment according to the PyObject parameter.
|
||||
* PyObject *o can be NULL, Py_None, BPyGPUTexture or a dictionary containing the keyword "texture"
|
||||
* and the optional keywords "layer" and "mip".
|
||||
* Returns false on error. In this case, a python message will be raised and GPUAttachment will not
|
||||
* be touched. */
|
||||
* PyObject *o can be nullptr, Py_None, BPyGPUTexture or a dictionary containing the keyword
|
||||
* "texture" and the optional keywords "layer" and "mip". Returns false on error. In this case, a
|
||||
* python message will be raised and GPUAttachment will not be touched. */
|
||||
static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach)
|
||||
{
|
||||
GPUAttachment tmp_attach = GPU_ATTACHMENT_NONE;
|
||||
@@ -276,14 +275,14 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach
|
||||
|
||||
if (c_texture && _PyUnicode_EqualToASCIIString(key, c_texture)) {
|
||||
/* Compare only once. */
|
||||
c_texture = NULL;
|
||||
c_texture = nullptr;
|
||||
if (!bpygpu_ParseTexture(value, &tmp_attach.tex)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (c_layer && _PyUnicode_EqualToASCIIString(key, c_layer)) {
|
||||
/* Compare only once. */
|
||||
c_layer = NULL;
|
||||
c_layer = nullptr;
|
||||
tmp_attach.layer = PyLong_AsLong(value);
|
||||
if (tmp_attach.layer == -1 && PyErr_Occurred()) {
|
||||
return false;
|
||||
@@ -291,7 +290,7 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach
|
||||
}
|
||||
else if (c_mip && _PyUnicode_EqualToASCIIString(key, c_mip)) {
|
||||
/* Compare only once. */
|
||||
c_mip = NULL;
|
||||
c_mip = nullptr;
|
||||
tmp_attach.mip = PyLong_AsLong(value);
|
||||
if (tmp_attach.mip == -1 && PyErr_Occurred()) {
|
||||
return false;
|
||||
@@ -309,18 +308,16 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach
|
||||
return true;
|
||||
}
|
||||
|
||||
static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
static PyObject *pygpu_framebuffer__tp_new(PyTypeObject * /*self*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if (!GPU_context_active_get()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "No active GPU context found");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *depth_attachment = NULL;
|
||||
PyObject *color_attachements = NULL;
|
||||
static const char *_keywords[] = {"depth_slot", "color_slots", NULL};
|
||||
PyObject *depth_attachment = nullptr;
|
||||
PyObject *color_attachements = nullptr;
|
||||
static const char *_keywords[] = {"depth_slot", "color_slots", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
"O" /* `depth_slot` */
|
||||
@@ -332,21 +329,21 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, &depth_attachment, &color_attachements))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Keep in sync with #GPU_FB_MAX_COLOR_ATTACHMENT.
|
||||
* TODO: share the define. */
|
||||
/* Keep in sync with #GPU_FB_MAX_COLOR_ATTACHMENT.
|
||||
* TODO: share the define. */
|
||||
#define BPYGPU_FB_MAX_COLOR_ATTACHMENT 6
|
||||
|
||||
GPUAttachment config[BPYGPU_FB_MAX_COLOR_ATTACHMENT + 1];
|
||||
|
||||
if (!pygpu_framebuffer_new_parse_arg(depth_attachment, &config[0])) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (config[0].tex && !GPU_texture_has_depth_format(config[0].tex)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Depth texture with incompatible format");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int color_attachements_len = 0;
|
||||
@@ -357,7 +354,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
PyErr_SetString(
|
||||
PyExc_AttributeError,
|
||||
"too many attachements, max is " STRINGIFY(BPYGPU_FB_MAX_COLOR_ATTACHMENT));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < color_attachements_len; i++) {
|
||||
@@ -365,13 +362,13 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
bool ok = pygpu_framebuffer_new_parse_arg(o, &config[i + 1]);
|
||||
Py_DECREF(o);
|
||||
if (!ok) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!pygpu_framebuffer_new_parse_arg(color_attachements, &config[1])) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
color_attachements_len = 1;
|
||||
}
|
||||
@@ -385,7 +382,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
|
||||
PyDoc_STRVAR(pygpu_framebuffer_is_bound_doc,
|
||||
"Checks if this is the active framebuffer in the context.");
|
||||
static PyObject *pygpu_framebuffer_is_bound(BPyGPUFrameBuffer *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_framebuffer_is_bound(BPyGPUFrameBuffer *self, void * /*type*/)
|
||||
{
|
||||
PYGPU_FRAMEBUFFER_CHECK_OBJ(self);
|
||||
return PyBool_FromLong(GPU_framebuffer_bound(self->fb));
|
||||
@@ -408,14 +405,14 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
|
||||
PYGPU_FRAMEBUFFER_CHECK_OBJ(self);
|
||||
|
||||
if (!GPU_framebuffer_bound(self->fb)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *py_col = NULL;
|
||||
PyObject *py_depth = NULL;
|
||||
PyObject *py_stencil = NULL;
|
||||
PyObject *py_col = nullptr;
|
||||
PyObject *py_depth = nullptr;
|
||||
PyObject *py_stencil = nullptr;
|
||||
|
||||
static const char *_keywords[] = {"color", "depth", "stencil", NULL};
|
||||
static const char *_keywords[] = {"color", "depth", "stencil", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
"O" /* `color` */
|
||||
@@ -426,10 +423,10 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &py_col, &py_depth, &py_stencil)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
eGPUFrameBufferBits buffers = 0;
|
||||
eGPUFrameBufferBits buffers = eGPUFrameBufferBits(0);
|
||||
float col[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
float depth = 1.0f;
|
||||
uint stencil = 0;
|
||||
@@ -437,7 +434,7 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
|
||||
if (py_col && py_col != Py_None) {
|
||||
if (mathutils_array_parse(col, 3, 4, py_col, "GPUFrameBuffer.clear(), invalid 'color' arg") ==
|
||||
-1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
buffers |= GPU_COLOR_BIT;
|
||||
}
|
||||
@@ -445,14 +442,14 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
|
||||
if (py_depth && py_depth != Py_None) {
|
||||
depth = PyFloat_AsDouble(py_depth);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
buffers |= GPU_DEPTH_BIT;
|
||||
}
|
||||
|
||||
if (py_stencil && py_stencil != Py_None) {
|
||||
if ((stencil = PyC_Long_AsU32(py_stencil)) == (uint)-1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
buffers |= GPU_STENCIL_BIT;
|
||||
}
|
||||
@@ -473,11 +470,11 @@ PyDoc_STRVAR(pygpu_framebuffer_viewport_set_doc,
|
||||
" :type xsize, ysize: int\n");
|
||||
static PyObject *pygpu_framebuffer_viewport_set(BPyGPUFrameBuffer *self,
|
||||
PyObject *args,
|
||||
void *UNUSED(type))
|
||||
void * /*type*/)
|
||||
{
|
||||
int x, y, xsize, ysize;
|
||||
if (!PyArg_ParseTuple(args, "iiii:viewport_set", &x, &y, &xsize, &ysize)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_framebuffer_viewport_set(self->fb, x, y, xsize, ysize);
|
||||
@@ -488,7 +485,7 @@ PyDoc_STRVAR(pygpu_framebuffer_viewport_get_doc,
|
||||
".. function:: viewport_get()\n"
|
||||
"\n"
|
||||
" Returns position and dimension to current viewport.\n");
|
||||
static PyObject *pygpu_framebuffer_viewport_get(BPyGPUFrameBuffer *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_framebuffer_viewport_get(BPyGPUFrameBuffer *self, void * /*type*/)
|
||||
{
|
||||
PYGPU_FRAMEBUFFER_CHECK_OBJ(self);
|
||||
int viewport[4];
|
||||
@@ -531,10 +528,10 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
|
||||
int x, y, w, h, channels;
|
||||
uint slot;
|
||||
struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_RGBA8};
|
||||
BPyGPUBuffer *py_buffer = NULL;
|
||||
BPyGPUBuffer *py_buffer = nullptr;
|
||||
|
||||
static const char *_keywords[] = {
|
||||
"x", "y", "xsize", "ysize", "channels", "slot", "format", "data", NULL};
|
||||
"x", "y", "xsize", "ysize", "channels", "slot", "format", "data", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"i" /* `x` */
|
||||
"i" /* `y` */
|
||||
@@ -563,38 +560,39 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
|
||||
&BPyGPU_BufferType,
|
||||
&py_buffer))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!IN_RANGE_INCL(channels, 1, 4)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "Color channels must be 1, 2, 3 or 4");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (slot >= BPYGPU_FB_MAX_COLOR_ATTACHMENT) {
|
||||
PyErr_SetString(PyExc_ValueError, "slot overflow");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (py_buffer) {
|
||||
if (pygpu_dataformat.value_found != py_buffer->format) {
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"the format of the buffer is different from that specified");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t size_curr = bpygpu_Buffer_size(py_buffer);
|
||||
size_t size_expected = w * h * channels *
|
||||
GPU_texture_dataformat_size(pygpu_dataformat.value_found);
|
||||
GPU_texture_dataformat_size(
|
||||
eGPUDataFormat(pygpu_dataformat.value_found));
|
||||
if (size_curr < size_expected) {
|
||||
PyErr_SetString(PyExc_BufferError, "the buffer size is smaller than expected");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_INCREF(py_buffer);
|
||||
}
|
||||
else {
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(
|
||||
pygpu_dataformat.value_found, (Py_ssize_t[3]){h, w, channels}, 3, NULL);
|
||||
const Py_ssize_t shape[3] = {h, w, channels};
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(pygpu_dataformat.value_found, shape, 3, nullptr);
|
||||
BLI_assert(bpygpu_Buffer_size(py_buffer) ==
|
||||
w * h * channels * GPU_texture_dataformat_size(pygpu_dataformat.value_found));
|
||||
}
|
||||
@@ -606,7 +604,7 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
|
||||
h,
|
||||
channels,
|
||||
(int)slot,
|
||||
pygpu_dataformat.value_found,
|
||||
eGPUDataFormat(pygpu_dataformat.value_found),
|
||||
py_buffer->buf.as_void);
|
||||
|
||||
return (PyObject *)py_buffer;
|
||||
@@ -631,9 +629,9 @@ static PyObject *pygpu_framebuffer_read_depth(BPyGPUFrameBuffer *self,
|
||||
{
|
||||
PYGPU_FRAMEBUFFER_CHECK_OBJ(self);
|
||||
int x, y, w, h;
|
||||
BPyGPUBuffer *py_buffer = NULL;
|
||||
BPyGPUBuffer *py_buffer = nullptr;
|
||||
|
||||
static const char *_keywords[] = {"x", "y", "xsize", "ysize", "data", NULL};
|
||||
static const char *_keywords[] = {"x", "y", "xsize", "ysize", "data", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"i" /* `x` */
|
||||
"i" /* `y` */
|
||||
@@ -648,25 +646,26 @@ static PyObject *pygpu_framebuffer_read_depth(BPyGPUFrameBuffer *self,
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, &x, &y, &w, &h, &BPyGPU_BufferType, &py_buffer))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (py_buffer) {
|
||||
if (py_buffer->format != GPU_DATA_FLOAT) {
|
||||
PyErr_SetString(PyExc_AttributeError, "the format of the buffer must be 'GPU_DATA_FLOAT'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t size_curr = bpygpu_Buffer_size(py_buffer);
|
||||
size_t size_expected = w * h * GPU_texture_dataformat_size(GPU_DATA_FLOAT);
|
||||
if (size_curr < size_expected) {
|
||||
PyErr_SetString(PyExc_BufferError, "the buffer size is smaller than expected");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Py_INCREF(py_buffer);
|
||||
}
|
||||
else {
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(GPU_DATA_FLOAT, (Py_ssize_t[]){h, w}, 2, NULL);
|
||||
const Py_ssize_t shape[2] = {h, w};
|
||||
py_buffer = BPyGPU_Buffer_CreatePyObject(GPU_DATA_FLOAT, shape, 2, nullptr);
|
||||
BLI_assert(bpygpu_Buffer_size(py_buffer) ==
|
||||
w * h * GPU_texture_dataformat_size(GPU_DATA_FLOAT));
|
||||
}
|
||||
@@ -699,10 +698,10 @@ static void BPyGPUFrameBuffer__tp_dealloc(BPyGPUFrameBuffer *self)
|
||||
static PyGetSetDef pygpu_framebuffer__tp_getseters[] = {
|
||||
{"is_bound",
|
||||
(getter)pygpu_framebuffer_is_bound,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
pygpu_framebuffer_is_bound_doc,
|
||||
NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyMethodDef pygpu_framebuffer__tp_methods[] = {
|
||||
@@ -730,7 +729,7 @@ static PyMethodDef pygpu_framebuffer__tp_methods[] = {
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
{"free", (PyCFunction)pygpu_framebuffer_free, METH_NOARGS, pygpu_framebuffer_free_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_framebuffer__tp_doc,
|
||||
@@ -748,55 +747,55 @@ PyDoc_STRVAR(pygpu_framebuffer__tp_doc,
|
||||
"containing keywords: 'texture', 'layer' and 'mip'.\n"
|
||||
" :type color_slots: tuple or Nonetype\n");
|
||||
PyTypeObject BPyGPUFrameBuffer_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUFrameBuffer",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUFrameBuffer),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)BPyGPUFrameBuffer__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_framebuffer__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_framebuffer__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_framebuffer__tp_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_framebuffer__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -830,7 +829,7 @@ PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_refer
|
||||
#ifndef GPU_NO_USE_PY_REFERENCES
|
||||
self->shared_reference = shared_reference;
|
||||
|
||||
BLI_assert(GPU_framebuffer_py_reference_get(fb) == NULL);
|
||||
BLI_assert(GPU_framebuffer_py_reference_get(fb) == nullptr);
|
||||
GPU_framebuffer_py_reference_set(fb, (void **)&self->fb);
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUFrameBuffer_Type;
|
||||
|
||||
#define BPyGPUFrameBuffer_Check(v) (Py_TYPE(v) == &BPyGPUFrameBuffer_Type)
|
||||
@@ -25,3 +29,7 @@ typedef struct BPyGPUFrameBuffer {
|
||||
|
||||
PyObject *BPyGPUFrameBuffer_CreatePyObject(struct GPUFrameBuffer *fb, bool shared_reference)
|
||||
ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -83,10 +83,10 @@ PyDoc_STRVAR(pygpu_matrix_push_doc,
|
||||
".. function:: push()\n"
|
||||
"\n"
|
||||
" Add to the model-view matrix stack.\n");
|
||||
static PyObject *pygpu_matrix_push(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_push(PyObject * /*self*/)
|
||||
{
|
||||
if (!pygpu_stack_is_push_model_view_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_push();
|
||||
Py_RETURN_NONE;
|
||||
@@ -96,10 +96,10 @@ PyDoc_STRVAR(pygpu_matrix_pop_doc,
|
||||
".. function:: pop()\n"
|
||||
"\n"
|
||||
" Remove the last model-view matrix from the stack.\n");
|
||||
static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_pop(PyObject * /*self*/)
|
||||
{
|
||||
if (!pygpu_stack_is_pop_model_view_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_pop();
|
||||
Py_RETURN_NONE;
|
||||
@@ -109,10 +109,10 @@ PyDoc_STRVAR(pygpu_matrix_push_projection_doc,
|
||||
".. function:: push_projection()\n"
|
||||
"\n"
|
||||
" Add to the projection matrix stack.\n");
|
||||
static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_push_projection(PyObject * /*self*/)
|
||||
{
|
||||
if (!pygpu_stack_is_push_projection_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_push_projection();
|
||||
Py_RETURN_NONE;
|
||||
@@ -122,10 +122,10 @@ PyDoc_STRVAR(pygpu_matrix_pop_projection_doc,
|
||||
".. function:: pop_projection()\n"
|
||||
"\n"
|
||||
" Remove the last projection matrix from the stack.\n");
|
||||
static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_pop_projection(PyObject * /*self*/)
|
||||
{
|
||||
if (!pygpu_stack_is_pop_projection_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_pop_projection();
|
||||
Py_RETURN_NONE;
|
||||
@@ -140,11 +140,11 @@ static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
|
||||
*
|
||||
* \{ */
|
||||
|
||||
typedef struct {
|
||||
struct BPyGPU_MatrixStackContext {
|
||||
PyObject_HEAD /* Required Python macro. */
|
||||
int type;
|
||||
int level;
|
||||
} BPyGPU_MatrixStackContext;
|
||||
};
|
||||
|
||||
enum {
|
||||
PYGPU_MATRIX_TYPE_MODEL_VIEW = 1,
|
||||
@@ -157,59 +157,59 @@ static PyObject *pygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self
|
||||
static PyMethodDef pygpu_matrix_stack_context__tp_methods[] = {
|
||||
{"__enter__", (PyCFunction)pygpu_matrix_stack_context_enter, METH_NOARGS},
|
||||
{"__exit__", (PyCFunction)pygpu_matrix_stack_context_exit, METH_VARARGS},
|
||||
{NULL},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
static PyTypeObject PyGPUMatrixStackContext_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUMatrixStackContext",
|
||||
/*tp_basicsize*/ sizeof(BPyGPU_MatrixStackContext),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ NULL,
|
||||
/*tp_dealloc*/ nullptr,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_matrix_stack_context__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
static PyObject *pygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
|
||||
@@ -217,19 +217,19 @@ static PyObject *pygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *sel
|
||||
/* sanity - should never happen */
|
||||
if (self->level != -1) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Already in use");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) {
|
||||
if (!pygpu_stack_is_push_model_view_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_push();
|
||||
self->level = GPU_matrix_stack_level_get_model_view();
|
||||
}
|
||||
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
|
||||
if (!pygpu_stack_is_push_projection_ok_or_error()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_push_projection();
|
||||
self->level = GPU_matrix_stack_level_get_projection();
|
||||
@@ -241,7 +241,7 @@ static PyObject *pygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *sel
|
||||
}
|
||||
|
||||
static PyObject *pygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self,
|
||||
PyObject *UNUSED(args))
|
||||
PyObject * /*args*/)
|
||||
{
|
||||
/* sanity - should never happen */
|
||||
if (self->level == -1) {
|
||||
@@ -288,7 +288,7 @@ PyDoc_STRVAR(
|
||||
".. function:: push_pop()\n"
|
||||
"\n"
|
||||
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
|
||||
static PyObject *pygpu_matrix_push_pop(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_push_pop(PyObject * /*self*/)
|
||||
{
|
||||
return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ PyDoc_STRVAR(
|
||||
".. function:: push_pop_projection()\n"
|
||||
"\n"
|
||||
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
|
||||
static PyObject *pygpu_matrix_push_pop_projection(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_push_pop_projection(PyObject * /*self*/)
|
||||
{
|
||||
return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION);
|
||||
}
|
||||
@@ -316,11 +316,11 @@ PyDoc_STRVAR(pygpu_matrix_multiply_matrix_doc,
|
||||
"\n"
|
||||
" :arg matrix: A 4x4 matrix.\n"
|
||||
" :type matrix: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_multiply_matrix(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
MatrixObject *pymat;
|
||||
if (!Matrix_Parse4x4(value, &pymat)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_mul(pymat->matrix);
|
||||
Py_RETURN_NONE;
|
||||
@@ -333,14 +333,14 @@ PyDoc_STRVAR(pygpu_matrix_scale_doc,
|
||||
"\n"
|
||||
" :arg scale: Scale the current stack matrix.\n"
|
||||
" :type scale: sequence of 2 or 3 floats\n");
|
||||
static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_scale(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
float scale[3];
|
||||
int len;
|
||||
if ((len = mathutils_array_parse(
|
||||
scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (len == 2) {
|
||||
GPU_matrix_scale_2fv(scale);
|
||||
@@ -356,12 +356,12 @@ PyDoc_STRVAR(pygpu_matrix_scale_uniform_doc,
|
||||
"\n"
|
||||
" :arg scale: Scale the current stack matrix.\n"
|
||||
" :type scale: float\n");
|
||||
static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_scale_uniform(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
float scalar;
|
||||
if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError, "expected a number, not %.200s", Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_scale_1f(scalar);
|
||||
Py_RETURN_NONE;
|
||||
@@ -374,14 +374,14 @@ PyDoc_STRVAR(pygpu_matrix_translate_doc,
|
||||
"\n"
|
||||
" :arg offset: Translate the current stack matrix.\n"
|
||||
" :type offset: sequence of 2 or 3 floats\n");
|
||||
static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_translate(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
float offset[3];
|
||||
int len;
|
||||
if ((len = mathutils_array_parse(
|
||||
offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (len == 2) {
|
||||
GPU_matrix_translate_2fv(offset);
|
||||
@@ -402,7 +402,7 @@ PyDoc_STRVAR(pygpu_matrix_reset_doc,
|
||||
".. function:: reset()\n"
|
||||
"\n"
|
||||
" Empty stack and set to identity.\n");
|
||||
static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_reset(PyObject * /*self*/)
|
||||
{
|
||||
GPU_matrix_reset();
|
||||
Py_RETURN_NONE;
|
||||
@@ -412,7 +412,7 @@ PyDoc_STRVAR(pygpu_matrix_load_identity_doc,
|
||||
".. function:: load_identity()\n"
|
||||
"\n"
|
||||
" Empty stack and set to identity.\n");
|
||||
static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_load_identity(PyObject * /*self*/)
|
||||
{
|
||||
GPU_matrix_identity_set();
|
||||
Py_RETURN_NONE;
|
||||
@@ -425,11 +425,11 @@ PyDoc_STRVAR(pygpu_matrix_load_matrix_doc,
|
||||
"\n"
|
||||
" :arg matrix: A 4x4 matrix.\n"
|
||||
" :type matrix: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_load_matrix(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
MatrixObject *pymat;
|
||||
if (!Matrix_Parse4x4(value, &pymat)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_set(pymat->matrix);
|
||||
Py_RETURN_NONE;
|
||||
@@ -442,11 +442,11 @@ PyDoc_STRVAR(pygpu_matrix_load_projection_matrix_doc,
|
||||
"\n"
|
||||
" :arg matrix: A 4x4 matrix.\n"
|
||||
" :type matrix: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_matrix_load_projection_matrix(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
MatrixObject *pymat;
|
||||
if (!Matrix_Parse4x4(value, &pymat)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_matrix_projection_set(pymat->matrix);
|
||||
Py_RETURN_NONE;
|
||||
@@ -465,11 +465,11 @@ PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc,
|
||||
"\n"
|
||||
" :return: A 4x4 projection matrix.\n"
|
||||
" :rtype: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_get_projection_matrix(PyObject * /*self*/)
|
||||
{
|
||||
float matrix[4][4];
|
||||
GPU_matrix_projection_get(matrix);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_matrix_get_model_view_matrix_doc,
|
||||
@@ -479,11 +479,11 @@ PyDoc_STRVAR(pygpu_matrix_get_model_view_matrix_doc,
|
||||
"\n"
|
||||
" :return: A 4x4 view matrix.\n"
|
||||
" :rtype: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_get_model_view_matrix(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_get_model_view_matrix(PyObject * /*self*/)
|
||||
{
|
||||
float matrix[4][4];
|
||||
GPU_matrix_model_view_get(matrix);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
|
||||
@@ -493,11 +493,11 @@ PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
|
||||
"\n"
|
||||
" :return: A 3x3 normal matrix.\n"
|
||||
" :rtype: :class:`mathutils.Matrix`\n");
|
||||
static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_matrix_get_normal_matrix(PyObject * /*self*/)
|
||||
{
|
||||
float matrix[3][3];
|
||||
GPU_matrix_normal_get(matrix);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 3, 3, NULL);
|
||||
return Matrix_CreatePyObject(&matrix[0][0], 3, 3, nullptr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -572,7 +572,7 @@ static PyMethodDef pygpu_matrix__tp_methods[] = {
|
||||
METH_NOARGS,
|
||||
pygpu_matrix_get_normal_matrix_doc},
|
||||
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_matrix__tp_doc, "This module provides access to the matrix stack.");
|
||||
@@ -582,10 +582,10 @@ static PyModuleDef pygpu_matrix_module_def = {
|
||||
/*m_doc*/ pygpu_matrix__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_matrix__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_matrix_init(void)
|
||||
@@ -595,7 +595,7 @@ PyObject *bpygpu_matrix_init(void)
|
||||
submodule = bpygpu_create_module(&pygpu_matrix_module_def);
|
||||
|
||||
if (bpygpu_finalize_type(&PyGPUMatrixStackContext_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return submodule;
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_matrix_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,12 +53,12 @@ static const struct PyC_StringEnumItems pygpu_framebuffer_color_texture_formats[
|
||||
{GPU_RGBA16, "RGBA16"},
|
||||
{GPU_RGBA16F, "RGBA16F"},
|
||||
{GPU_RGBA32F, "RGBA32F"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
|
||||
{
|
||||
if (UNLIKELY(py_ofs->ofs == NULL)) {
|
||||
if (UNLIKELY(py_ofs->ofs == nullptr)) {
|
||||
PyErr_SetString(PyExc_ReferenceError,
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
"GPU offscreen was freed, no further access is valid"
|
||||
@@ -74,7 +74,7 @@ static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
|
||||
#define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \
|
||||
{ \
|
||||
if (UNLIKELY(pygpu_offscreen_valid_check(bpygpu) == -1)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -88,12 +88,12 @@ static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
|
||||
*
|
||||
* \{ */
|
||||
|
||||
typedef struct {
|
||||
struct OffScreenStackContext {
|
||||
PyObject_HEAD /* Required Python macro. */
|
||||
BPyGPUOffScreen *py_offscreen;
|
||||
int level;
|
||||
bool is_explicitly_bound; /* Bound by "bind" method. */
|
||||
} OffScreenStackContext;
|
||||
};
|
||||
|
||||
static void pygpu_offscreen_stack_context__tp_dealloc(OffScreenStackContext *self)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static PyObject *pygpu_offscreen_stack_context_enter(OffScreenStackContext *self
|
||||
if (!self->is_explicitly_bound) {
|
||||
if (self->level != -1) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Already in use");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_offscreen_bind(self->py_offscreen->ofs, true);
|
||||
@@ -119,13 +119,13 @@ static PyObject *pygpu_offscreen_stack_context_enter(OffScreenStackContext *self
|
||||
}
|
||||
|
||||
static PyObject *pygpu_offscreen_stack_context_exit(OffScreenStackContext *self,
|
||||
PyObject *UNUSED(args))
|
||||
PyObject * /*args*/)
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self->py_offscreen);
|
||||
|
||||
if (self->level == -1) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Not yet in use\n");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int level = GPU_framebuffer_stack_level_get();
|
||||
@@ -141,59 +141,59 @@ static PyObject *pygpu_offscreen_stack_context_exit(OffScreenStackContext *self,
|
||||
static PyMethodDef pygpu_offscreen_stack_context__tp_methods[] = {
|
||||
{"__enter__", (PyCFunction)pygpu_offscreen_stack_context_enter, METH_NOARGS},
|
||||
{"__exit__", (PyCFunction)pygpu_offscreen_stack_context_exit, METH_VARARGS},
|
||||
{NULL},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
static PyTypeObject PyGPUOffscreenStackContext_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUFrameBufferStackContext",
|
||||
/*tp_basicsize*/ sizeof(OffScreenStackContext),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_offscreen_stack_context__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_offscreen_stack_context__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_new*/ NULL,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ nullptr,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen_bind_doc,
|
||||
@@ -229,7 +229,7 @@ static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, P
|
||||
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
|
||||
static const char *_keywords[] = {"restore", NULL};
|
||||
static const char *_keywords[] = {"restore", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
"O&" /* `restore` */
|
||||
@@ -238,7 +238,7 @@ static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, P
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &restore)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_offscreen_unbind(self->ofs, restore);
|
||||
@@ -252,16 +252,14 @@ static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, P
|
||||
/** \name GPUOffscreen Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self),
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
static PyObject *pygpu_offscreen__tp_new(PyTypeObject * /*self*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
GPUOffScreen *ofs = NULL;
|
||||
GPUOffScreen *ofs = nullptr;
|
||||
int width, height;
|
||||
struct PyC_StringEnum pygpu_textureformat = {pygpu_framebuffer_color_texture_formats, GPU_RGBA8};
|
||||
char err_out[256];
|
||||
|
||||
static const char *_keywords[] = {"width", "height", "format", NULL};
|
||||
static const char *_keywords[] = {"width", "height", "format", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"i" /* `width` */
|
||||
"i" /* `height` */
|
||||
@@ -274,14 +272,14 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self),
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (GPU_context_active_get()) {
|
||||
ofs = GPU_offscreen_create(width,
|
||||
height,
|
||||
true,
|
||||
pygpu_textureformat.value_found,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_HOST_READ,
|
||||
err_out);
|
||||
}
|
||||
@@ -289,25 +287,25 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self),
|
||||
STRNCPY(err_out, "No active GPU context found");
|
||||
}
|
||||
|
||||
if (ofs == NULL) {
|
||||
if (ofs == nullptr) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"gpu.offscreen.new(...) failed with '%s'",
|
||||
err_out[0] ? err_out : "unknown error");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUOffScreen_CreatePyObject(ofs);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen_width_doc, "Width of the texture.\n\n:type: `int`");
|
||||
static PyObject *pygpu_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_offscreen_width_get(BPyGPUOffScreen *self, void * /*type*/)
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
return PyLong_FromLong(GPU_offscreen_width(self->ofs));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen_height_doc, "Height of the texture.\n\n:type: `int`");
|
||||
static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void * /*type*/)
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
return PyLong_FromLong(GPU_offscreen_height(self->ofs));
|
||||
@@ -315,7 +313,7 @@ static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen_color_texture_doc,
|
||||
"OpenGL bindcode for the color texture.\n\n:type: `int`");
|
||||
static PyObject *pygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void * /*type*/)
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
|
||||
@@ -326,7 +324,7 @@ PyDoc_STRVAR(pygpu_offscreen_texture_color_doc,
|
||||
"The color texture attached.\n"
|
||||
"\n"
|
||||
":type: :class:`gpu.types.GPUTexture`");
|
||||
static PyObject *pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void * /*type*/)
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
|
||||
@@ -381,7 +379,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
|
||||
"projection_matrix",
|
||||
"do_color_management",
|
||||
"draw_background",
|
||||
NULL,
|
||||
nullptr,
|
||||
};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O" /* `scene` */
|
||||
@@ -412,12 +410,12 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
|
||||
&do_color_management,
|
||||
PyC_ParseBool,
|
||||
&draw_background) ||
|
||||
(!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) ||
|
||||
!(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) ||
|
||||
!(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
|
||||
!(region = PyC_RNA_AsPointer(py_region, "Region"))))
|
||||
(!(scene = static_cast<Scene *>(PyC_RNA_AsPointer(py_scene, "Scene"))) ||
|
||||
!(view_layer = static_cast<ViewLayer *>(PyC_RNA_AsPointer(py_view_layer, "ViewLayer"))) ||
|
||||
!(v3d = static_cast<View3D *>(PyC_RNA_AsPointer(py_view3d, "SpaceView3D"))) ||
|
||||
!(region = static_cast<ARegion *>(PyC_RNA_AsPointer(py_region, "Region")))))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BLI_assert(BKE_id_is_in_global_main(&scene->id));
|
||||
@@ -443,7 +441,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
|
||||
|
||||
ED_view3d_draw_offscreen(depsgraph,
|
||||
scene,
|
||||
v3d->shading.type,
|
||||
eDrawType(v3d->shading.type),
|
||||
v3d,
|
||||
region,
|
||||
GPU_offscreen_width(self->ofs),
|
||||
@@ -479,11 +477,11 @@ static PyObject *pygpu_offscreen_free(BPyGPUOffScreen *self)
|
||||
|
||||
if (self->viewport) {
|
||||
GPU_viewport_free(self->viewport);
|
||||
self->viewport = NULL;
|
||||
self->viewport = nullptr;
|
||||
}
|
||||
|
||||
GPU_offscreen_free(self->ofs);
|
||||
self->ofs = NULL;
|
||||
self->ofs = nullptr;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif
|
||||
@@ -502,17 +500,25 @@ static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self)
|
||||
static PyGetSetDef pygpu_offscreen__tp_getseters[] = {
|
||||
{"color_texture",
|
||||
(getter)pygpu_offscreen_color_texture_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
pygpu_offscreen_color_texture_doc,
|
||||
NULL},
|
||||
nullptr},
|
||||
{"texture_color",
|
||||
(getter)pygpu_offscreen_texture_color_get,
|
||||
(setter)NULL,
|
||||
(setter) nullptr,
|
||||
pygpu_offscreen_texture_color_doc,
|
||||
NULL},
|
||||
{"width", (getter)pygpu_offscreen_width_get, (setter)NULL, pygpu_offscreen_width_doc, NULL},
|
||||
{"height", (getter)pygpu_offscreen_height_get, (setter)NULL, pygpu_offscreen_height_doc, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
nullptr},
|
||||
{"width",
|
||||
(getter)pygpu_offscreen_width_get,
|
||||
(setter) nullptr,
|
||||
pygpu_offscreen_width_doc,
|
||||
nullptr},
|
||||
{"height",
|
||||
(getter)pygpu_offscreen_height_get,
|
||||
(setter) nullptr,
|
||||
pygpu_offscreen_height_doc,
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyMethodDef pygpu_offscreen__tp_methods[] = {
|
||||
@@ -528,7 +534,7 @@ static PyMethodDef pygpu_offscreen__tp_methods[] = {
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
{"free", (PyCFunction)pygpu_offscreen_free, METH_NOARGS, pygpu_offscreen_free_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen__tp_doc,
|
||||
@@ -548,55 +554,55 @@ PyDoc_STRVAR(pygpu_offscreen__tp_doc,
|
||||
" `RGBA32F`,\n"
|
||||
" :type format: str\n");
|
||||
PyTypeObject BPyGPUOffScreen_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUOffScreen",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUOffScreen),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)BPyGPUOffScreen__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_compare*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_compare*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_offscreen__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_offscreen__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_offscreen__tp_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_offscreen__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -611,7 +617,7 @@ PyObject *BPyGPUOffScreen_CreatePyObject(GPUOffScreen *ofs)
|
||||
|
||||
self = PyObject_New(BPyGPUOffScreen, &BPyGPUOffScreen_Type);
|
||||
self->ofs = ofs;
|
||||
self->viewport = NULL;
|
||||
self->viewport = nullptr;
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUOffScreen_Type;
|
||||
|
||||
#define BPyGPUOffScreen_Check(v) (Py_TYPE(v) == &BPyGPUOffScreen_Type)
|
||||
@@ -23,3 +27,7 @@ typedef struct BPyGPUOffScreen {
|
||||
} BPyGPUOffScreen;
|
||||
|
||||
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@ PyDoc_STRVAR(pygpu_platform_vendor_get_doc,
|
||||
"\n"
|
||||
" :return: Vendor name.\n"
|
||||
" :rtype: str\n");
|
||||
static PyObject *pygpu_platform_vendor_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_platform_vendor_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyUnicode_FromString(GPU_platform_vendor());
|
||||
}
|
||||
@@ -42,7 +42,7 @@ PyDoc_STRVAR(pygpu_platform_renderer_get_doc,
|
||||
"\n"
|
||||
" :return: GPU name.\n"
|
||||
" :rtype: str\n");
|
||||
static PyObject *pygpu_platform_renderer_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_platform_renderer_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyUnicode_FromString(GPU_platform_renderer());
|
||||
}
|
||||
@@ -54,7 +54,7 @@ PyDoc_STRVAR(pygpu_platform_version_get_doc,
|
||||
"\n"
|
||||
" :return: Driver version.\n"
|
||||
" :rtype: str\n");
|
||||
static PyObject *pygpu_platform_version_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_platform_version_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyUnicode_FromString(GPU_platform_version());
|
||||
}
|
||||
@@ -67,7 +67,7 @@ PyDoc_STRVAR(
|
||||
"\n"
|
||||
" :return: Device type ('APPLE', 'NVIDIA', 'AMD', 'INTEL', 'SOFTWARE', 'UNKNOWN').\n"
|
||||
" :rtype: str\n");
|
||||
static PyObject *pygpu_platform_device_type_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_platform_device_type_get(PyObject * /*self*/)
|
||||
{
|
||||
if (GPU_type_matches(GPU_DEVICE_APPLE, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
||||
return PyUnicode_FromString("APPLE");
|
||||
@@ -94,7 +94,7 @@ PyDoc_STRVAR(pygpu_platform_backend_type_get_doc,
|
||||
"\n"
|
||||
" :return: Backend type ('OPENGL', 'VULKAN', 'METAL', 'NONE', 'UNKNOWN').\n"
|
||||
" :rtype: str\n");
|
||||
static PyObject *pygpu_platform_backend_type_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_platform_backend_type_get(PyObject * /*self*/)
|
||||
{
|
||||
switch (GPU_backend_get_type()) {
|
||||
case GPU_BACKEND_VULKAN:
|
||||
@@ -138,7 +138,7 @@ static PyMethodDef pygpu_platform__tp_methods[] = {
|
||||
(PyCFunction)pygpu_platform_backend_type_get,
|
||||
METH_NOARGS,
|
||||
pygpu_platform_backend_type_get_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_platform__tp_doc, "This module provides access to GPU Platform definitions.");
|
||||
@@ -148,10 +148,10 @@ static PyModuleDef pygpu_platform_module_def = {
|
||||
/*m_doc*/ pygpu_platform__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_platform__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_platform_init(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_platform_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,11 +36,11 @@ PyDoc_STRVAR(pygpu_select_load_id_doc,
|
||||
"\n"
|
||||
" :arg id: Number (32-bit uint).\n"
|
||||
" :type select: int\n");
|
||||
static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_select_load_id(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
uint id;
|
||||
if ((id = PyC_Long_AsU32(value)) == (uint)-1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_select_load_id(id);
|
||||
Py_RETURN_NONE;
|
||||
@@ -55,7 +55,7 @@ static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyMethodDef pygpu_select__tp_methods[] = {
|
||||
/* Manage Stack */
|
||||
{"load_id", (PyCFunction)pygpu_select_load_id, METH_O, pygpu_select_load_id_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_select__tp_doc, "This module provides access to selection.");
|
||||
@@ -65,10 +65,10 @@ static PyModuleDef pygpu_select_module_def = {
|
||||
/*m_doc*/ pygpu_select__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_select__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_select_init(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_select_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -67,13 +67,13 @@ static const struct PyC_StringEnumItems pygpu_shader_builtin_items[] = {
|
||||
{GPU_SHADER_3D_POLYLINE_FLAT_COLOR, "POLYLINE_FLAT_COLOR"},
|
||||
{GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR, "POLYLINE_SMOOTH_COLOR"},
|
||||
{GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, "POLYLINE_UNIFORM_COLOR"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static const struct PyC_StringEnumItems pygpu_shader_config_items[] = {
|
||||
{GPU_SHADER_CFG_DEFAULT, "DEFAULT"},
|
||||
{GPU_SHADER_CFG_CLIPPED, "CLIPPED"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static int pygpu_shader_uniform_location_get(GPUShader *shader,
|
||||
@@ -95,7 +95,7 @@ static int pygpu_shader_uniform_location_get(GPUShader *shader,
|
||||
/** \name Shader Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_shader__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
struct {
|
||||
const char *vertexcode;
|
||||
@@ -107,7 +107,7 @@ static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
} params = {0};
|
||||
|
||||
static const char *_keywords[] = {
|
||||
"vertexcode", "fragcode", "geocode", "libcode", "defines", "name", NULL};
|
||||
"vertexcode", "fragcode", "geocode", "libcode", "defines", "name", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"s" /* `vertexcode` */
|
||||
"s" /* `fragcode` */
|
||||
@@ -130,7 +130,7 @@ static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
¶ms.defines,
|
||||
¶ms.name))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUShader *shader = GPU_shader_create_from_python(params.vertexcode,
|
||||
@@ -140,9 +140,9 @@ static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args
|
||||
params.defines,
|
||||
params.name);
|
||||
|
||||
if (shader == NULL) {
|
||||
if (shader == nullptr) {
|
||||
PyErr_SetString(PyExc_Exception, "Shader Compile Error, see console for more details");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUShader_CreatePyObject(shader, false);
|
||||
@@ -171,15 +171,15 @@ PyDoc_STRVAR(pygpu_shader_uniform_from_name_doc,
|
||||
static PyObject *pygpu_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg)
|
||||
{
|
||||
const char *name = PyUnicode_AsUTF8(arg);
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
if (name == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int uniform = pygpu_shader_uniform_location_get(
|
||||
self->shader, name, "GPUShader.get_uniform");
|
||||
|
||||
if (uniform == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyLong_FromLong(uniform);
|
||||
@@ -197,15 +197,15 @@ PyDoc_STRVAR(pygpu_shader_uniform_block_from_name_doc,
|
||||
static PyObject *pygpu_shader_uniform_block_from_name(BPyGPUShader *self, PyObject *arg)
|
||||
{
|
||||
const char *name = PyUnicode_AsUTF8(arg);
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
if (name == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int uniform = GPU_shader_get_uniform_block(self->shader, name);
|
||||
|
||||
if (uniform == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "GPUShader.get_uniform_block: uniform %.32s not found", name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyLong_FromLong(uniform);
|
||||
@@ -269,11 +269,12 @@ static PyObject *pygpu_shader_uniform_vector_float(BPyGPUShader *self, PyObject
|
||||
|
||||
if (!pygpu_shader_uniform_vector_impl(
|
||||
args, sizeof(float), &location, &length, &count, &pybuffer)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
GPU_shader_uniform_float_ex(self->shader, location, length, count, pybuffer.buf);
|
||||
GPU_shader_uniform_float_ex(
|
||||
self->shader, location, length, count, static_cast<const float *>(pybuffer.buf));
|
||||
|
||||
PyBuffer_Release(&pybuffer);
|
||||
|
||||
@@ -292,11 +293,12 @@ static PyObject *pygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *a
|
||||
|
||||
if (!pygpu_shader_uniform_vector_impl(args, sizeof(int), &location, &length, &count, &pybuffer))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
GPU_shader_uniform_int_ex(self->shader, location, length, count, pybuffer.buf);
|
||||
GPU_shader_uniform_int_ex(
|
||||
self->shader, location, length, count, static_cast<const int *>(pybuffer.buf));
|
||||
|
||||
PyBuffer_Release(&pybuffer);
|
||||
|
||||
@@ -322,7 +324,7 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
|
||||
} params;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:GPUShader.uniform_bool", ¶ms.id, ¶ms.seq)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int values[4];
|
||||
@@ -330,7 +332,7 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
|
||||
int ret = -1;
|
||||
if (PySequence_Check(params.seq)) {
|
||||
PyObject *seq_fast = PySequence_Fast(params.seq, error_prefix);
|
||||
if (seq_fast == NULL) {
|
||||
if (seq_fast == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s: expected a sequence, got %s",
|
||||
error_prefix,
|
||||
@@ -361,13 +363,13 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (ret == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
|
||||
|
||||
if (location == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
@@ -395,7 +397,7 @@ static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
|
||||
} params;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:GPUShader.uniform_float", ¶ms.id, ¶ms.seq)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float values[16];
|
||||
@@ -412,11 +414,11 @@ static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
|
||||
else if (MatrixObject_Check(params.seq)) {
|
||||
MatrixObject *mat = (MatrixObject *)params.seq;
|
||||
if (BaseMath_ReadCallback(mat) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if ((mat->row_num != mat->col_num) || !ELEM(mat->row_num, 3, 4)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Expected 3x3 or 4x4 matrix");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
length = mat->row_num * mat->col_num;
|
||||
memcpy(values, mat->matrix, sizeof(float) * length);
|
||||
@@ -424,20 +426,20 @@ static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
|
||||
else {
|
||||
length = mathutils_array_parse(values, 2, 16, params.seq, "");
|
||||
if (length == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ELEM(length, 1, 2, 3, 4, 9, 16)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Expected a single float or a sequence of floats of length 1..4, 9 or 16.");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
|
||||
|
||||
if (location == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
@@ -465,7 +467,7 @@ static PyObject *pygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
|
||||
} params;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:GPUShader.uniform_int", ¶ms.id, ¶ms.seq)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int values[4];
|
||||
@@ -479,7 +481,7 @@ static PyObject *pygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
|
||||
}
|
||||
else {
|
||||
PyObject *seq_fast = PySequence_Fast(params.seq, error_prefix);
|
||||
if (seq_fast == NULL) {
|
||||
if (seq_fast == nullptr) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%s: expected a sequence, got %s",
|
||||
error_prefix,
|
||||
@@ -503,13 +505,13 @@ static PyObject *pygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
|
||||
}
|
||||
}
|
||||
if (ret == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
|
||||
|
||||
if (location == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
@@ -534,7 +536,7 @@ static PyObject *pygpu_shader_uniform_sampler(BPyGPUShader *self, PyObject *args
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "sO!:GPUShader.uniform_sampler", &name, &BPyGPUTexture_Type, &py_texture))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
@@ -561,7 +563,7 @@ static PyObject *pygpu_shader_uniform_block(BPyGPUShader *self, PyObject *args)
|
||||
BPyGPUUniformBuf *py_ubo;
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "sO!:GPUShader.uniform_block", &name, &BPyGPUUniformBuf_Type, &py_ubo)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int binding = GPU_shader_get_ubo_binding(self->shader, name);
|
||||
@@ -569,7 +571,7 @@ static PyObject *pygpu_shader_uniform_block(BPyGPUShader *self, PyObject *args)
|
||||
PyErr_SetString(
|
||||
PyExc_BufferError,
|
||||
"GPUShader.uniform_block: uniform block not found, make sure the name is correct");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_shader_bind(self->shader);
|
||||
@@ -590,15 +592,15 @@ PyDoc_STRVAR(pygpu_shader_attr_from_name_doc,
|
||||
static PyObject *pygpu_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
|
||||
{
|
||||
const char *name = PyUnicode_AsUTF8(arg);
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
if (name == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int attr = GPU_shader_get_attribute(self->shader, name);
|
||||
|
||||
if (attr == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "GPUShader.attr_from_name: attribute %.32s not found", name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyLong_FromLong(attr);
|
||||
@@ -611,9 +613,9 @@ PyDoc_STRVAR(pygpu_shader_format_calc_doc,
|
||||
"\n"
|
||||
" :return: vertex attribute format for the shader\n"
|
||||
" :rtype: :class:`gpu.types.GPUVertFormat`\n");
|
||||
static PyObject *pygpu_shader_format_calc(BPyGPUShader *self, PyObject *UNUSED(arg))
|
||||
static PyObject *pygpu_shader_format_calc(BPyGPUShader *self, PyObject * /*arg*/)
|
||||
{
|
||||
BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL);
|
||||
BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(nullptr);
|
||||
GPU_vertformat_from_shader(&ret->fmt, self->shader);
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
@@ -626,7 +628,7 @@ PyDoc_STRVAR(
|
||||
"\n"
|
||||
" :return: tuples containing information about the attributes in order (name, type)\n"
|
||||
" :rtype: tuple\n");
|
||||
static PyObject *pygpu_shader_attrs_info_get(BPyGPUShader *self, PyObject *UNUSED(arg))
|
||||
static PyObject *pygpu_shader_attrs_info_get(BPyGPUShader *self, PyObject * /*arg*/)
|
||||
{
|
||||
uint attr_len = GPU_shader_get_attribute_len(self->shader);
|
||||
int location_test = 0, attrs_added = 0;
|
||||
@@ -706,7 +708,7 @@ static PyMethodDef pygpu_shader__tp_methods[] = {
|
||||
(PyCFunction)pygpu_shader_attrs_info_get,
|
||||
METH_NOARGS,
|
||||
pygpu_shader_attrs_info_get_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_shader_name_doc,
|
||||
@@ -719,15 +721,19 @@ static PyObject *pygpu_shader_name(BPyGPUShader *self)
|
||||
PyDoc_STRVAR(
|
||||
pygpu_shader_program_doc,
|
||||
"The name of the program object for use by the OpenGL API (read-only).\n\n:type: int");
|
||||
static PyObject *pygpu_shader_program_get(BPyGPUShader *self, void *UNUSED(closure))
|
||||
static PyObject *pygpu_shader_program_get(BPyGPUShader *self, void * /*closure*/)
|
||||
{
|
||||
return PyLong_FromLong(GPU_shader_get_program(self->shader));
|
||||
}
|
||||
|
||||
static PyGetSetDef pygpu_shader__tp_getseters[] = {
|
||||
{"program", (getter)pygpu_shader_program_get, (setter)NULL, pygpu_shader_program_doc, NULL},
|
||||
{"name", (getter)pygpu_shader_name, (setter)NULL, pygpu_shader_name_doc, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{"program",
|
||||
(getter)pygpu_shader_program_get,
|
||||
(setter) nullptr,
|
||||
pygpu_shader_program_doc,
|
||||
nullptr},
|
||||
{"name", (getter)pygpu_shader_name, (setter) nullptr, pygpu_shader_name_doc, nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static void pygpu_shader__tp_dealloc(BPyGPUShader *self)
|
||||
@@ -771,55 +777,55 @@ PyDoc_STRVAR(
|
||||
" :arg name: Name of shader code, for debugging purposes.\n"
|
||||
" :type value: str\n");
|
||||
PyTypeObject BPyGPUShader_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUShader",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUShader),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_shader__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_shader__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_shader__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_shader__tp_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_shader__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -832,7 +838,7 @@ PyDoc_STRVAR(pygpu_shader_unbind_doc,
|
||||
".. function:: unbind()\n"
|
||||
"\n"
|
||||
" Unbind the bound shader object.\n");
|
||||
static PyObject *pygpu_shader_unbind(BPyGPUShader *UNUSED(self))
|
||||
static PyObject *pygpu_shader_unbind(BPyGPUShader * /*self*/)
|
||||
{
|
||||
GPU_shader_unbind();
|
||||
Py_RETURN_NONE;
|
||||
@@ -859,12 +865,12 @@ PyDoc_STRVAR(
|
||||
" :type config: str\n"
|
||||
" :return: Shader object corresponding to the given name.\n"
|
||||
" :rtype: :class:`bpy.types.GPUShader`\n");
|
||||
static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_shader_from_builtin(PyObject * /*self*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
struct PyC_StringEnum pygpu_bultinshader = {pygpu_shader_builtin_items};
|
||||
struct PyC_StringEnum pygpu_config = {pygpu_shader_config_items, GPU_SHADER_CFG_DEFAULT};
|
||||
|
||||
static const char *_keywords[] = {"shader_name", "config", NULL};
|
||||
static const char *_keywords[] = {"shader_name", "config", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O&" /* `shader_name` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -881,11 +887,12 @@ static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg
|
||||
PyC_ParseStringEnum,
|
||||
&pygpu_config))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader_with_config(pygpu_bultinshader.value_found,
|
||||
pygpu_config.value_found);
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader_with_config(
|
||||
eGPUBuiltinShader(pygpu_bultinshader.value_found),
|
||||
eGPUShaderConfig(pygpu_config.value_found));
|
||||
|
||||
return BPyGPUShader_CreatePyObject(shader, true);
|
||||
}
|
||||
@@ -899,24 +906,23 @@ PyDoc_STRVAR(pygpu_shader_create_from_info_doc,
|
||||
" :type shader_info: :class:`bpy.types.GPUShaderCreateInfo`\n"
|
||||
" :return: Shader object corresponding to the given name.\n"
|
||||
" :rtype: :class:`bpy.types.GPUShader`\n");
|
||||
static PyObject *pygpu_shader_create_from_info(BPyGPUShader *UNUSED(self),
|
||||
BPyGPUShaderCreateInfo *o)
|
||||
static PyObject *pygpu_shader_create_from_info(BPyGPUShader * /*self*/, BPyGPUShaderCreateInfo *o)
|
||||
{
|
||||
if (!BPyGPUShaderCreateInfo_Check(o)) {
|
||||
PyErr_Format(PyExc_TypeError, "Expected a GPUShaderCreateInfo, got %s", Py_TYPE(o)->tp_name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char error[128];
|
||||
if (!GPU_shader_create_info_check_error(o->info, error)) {
|
||||
PyErr_SetString(PyExc_Exception, error);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUShader *shader = GPU_shader_create_from_info(o->info);
|
||||
if (!shader) {
|
||||
PyErr_SetString(PyExc_Exception, "Shader Compile Error, see console for more details");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUShader_CreatePyObject(shader, false);
|
||||
@@ -932,7 +938,7 @@ static PyMethodDef pygpu_shader_module__tp_methods[] = {
|
||||
(PyCFunction)pygpu_shader_create_from_info,
|
||||
METH_O,
|
||||
pygpu_shader_create_from_info_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_shader_module__tp_doc,
|
||||
@@ -952,10 +958,10 @@ static PyModuleDef pygpu_shader_module_def = {
|
||||
/*m_doc*/ pygpu_shader_module__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_shader_module__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -12,6 +12,10 @@
|
||||
# include "../generic/py_capi_utils.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Make sure that there is always a reference count for PyObjects of type String as the strings are
|
||||
* passed by reference in the #GPUStageInterfaceInfo and #GPUShaderCreateInfo APIs. */
|
||||
#define USE_GPU_PY_REFERENCES
|
||||
@@ -31,10 +35,6 @@ typedef struct BPyGPUShader {
|
||||
PyObject *BPyGPUShader_CreatePyObject(struct GPUShader *shader, bool is_builtin);
|
||||
PyObject *bpygpu_shader_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* gpu_py_shader_create_info.cc */
|
||||
|
||||
extern const struct PyC_StringEnumItems pygpu_attrtype_items[];
|
||||
|
||||
@@ -42,7 +42,7 @@ static const struct PyC_StringEnumItems pygpu_state_blend_items[] = {
|
||||
* {GPU_BLEND_BACKGROUND, "BACKGROUND"},
|
||||
* {GPU_BLEND_CUSTOM, "CUSTOM"},
|
||||
*/
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static const struct PyC_StringEnumItems pygpu_state_depthtest_items[] = {
|
||||
@@ -53,14 +53,14 @@ static const struct PyC_StringEnumItems pygpu_state_depthtest_items[] = {
|
||||
{GPU_DEPTH_EQUAL, "EQUAL"},
|
||||
{GPU_DEPTH_GREATER, "GREATER"},
|
||||
{GPU_DEPTH_GREATER_EQUAL, "GREATER_EQUAL"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static const struct PyC_StringEnumItems pygpu_state_faceculling_items[] = {
|
||||
{GPU_CULL_NONE, "NONE"},
|
||||
{GPU_CULL_FRONT, "FRONT"},
|
||||
{GPU_CULL_BACK, "BACK"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -91,13 +91,13 @@ PyDoc_STRVAR(
|
||||
//" * ``BACKGROUND`` .\n"
|
||||
//" * ``CUSTOM`` .\n"
|
||||
" :type mode: str\n");
|
||||
static PyObject *pygpu_state_blend_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_blend_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
struct PyC_StringEnum pygpu_blend = {pygpu_state_blend_items};
|
||||
if (!PyC_ParseStringEnum(value, &pygpu_blend)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_blend(pygpu_blend.value_found);
|
||||
GPU_blend(eGPUBlend(pygpu_blend.value_found));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ PyDoc_STRVAR(pygpu_state_blend_get_doc,
|
||||
"\n"
|
||||
" Current blending equation.\n"
|
||||
"\n");
|
||||
static PyObject *pygpu_state_blend_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_state_blend_get(PyObject * /*self*/)
|
||||
{
|
||||
eGPUBlend blend = GPU_blend_get();
|
||||
return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_blend_items, blend));
|
||||
@@ -119,11 +119,11 @@ PyDoc_STRVAR(pygpu_state_clip_distances_set_doc,
|
||||
"\n"
|
||||
" :arg distances_enabled: Number of clip distances enabled.\n"
|
||||
" :type distances_enabled: int\n");
|
||||
static PyObject *pygpu_state_clip_distances_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_clip_distances_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
int distances_enabled = (int)PyLong_AsUnsignedLong(value);
|
||||
if (distances_enabled == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (distances_enabled > 6) {
|
||||
@@ -143,13 +143,13 @@ PyDoc_STRVAR(pygpu_state_depth_test_set_doc,
|
||||
" Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, "
|
||||
"`GREATER` and `GREATER_EQUAL`.\n"
|
||||
" :type mode: str\n");
|
||||
static PyObject *pygpu_state_depth_test_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_depth_test_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
struct PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items};
|
||||
if (!PyC_ParseStringEnum(value, &pygpu_depth_test)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_depth_test(pygpu_depth_test.value_found);
|
||||
GPU_depth_test(eGPUDepthTest(pygpu_depth_test.value_found));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ PyDoc_STRVAR(pygpu_state_depth_test_get_doc,
|
||||
"\n"
|
||||
" Current depth_test equation.\n"
|
||||
"\n");
|
||||
static PyObject *pygpu_state_depth_test_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_state_depth_test_get(PyObject * /*self*/)
|
||||
{
|
||||
eGPUDepthTest test = GPU_depth_test_get();
|
||||
return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_depthtest_items, test));
|
||||
@@ -171,11 +171,11 @@ PyDoc_STRVAR(pygpu_state_depth_mask_set_doc,
|
||||
"\n"
|
||||
" :arg value: True for writing to the depth component.\n"
|
||||
" :type near: bool\n");
|
||||
static PyObject *pygpu_state_depth_mask_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_depth_mask_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
bool write_to_depth;
|
||||
if (!PyC_ParseBool(value, &write_to_depth)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
GPU_depth_mask(write_to_depth);
|
||||
Py_RETURN_NONE;
|
||||
@@ -185,7 +185,7 @@ PyDoc_STRVAR(pygpu_state_depth_mask_get_doc,
|
||||
".. function:: depth_mask_get()\n"
|
||||
"\n"
|
||||
" Writing status in the depth component.\n");
|
||||
static PyObject *pygpu_state_depth_mask_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_state_depth_mask_get(PyObject * /*self*/)
|
||||
{
|
||||
return PyBool_FromLong(GPU_depth_mask_get());
|
||||
}
|
||||
@@ -200,11 +200,11 @@ PyDoc_STRVAR(pygpu_state_viewport_set_doc,
|
||||
" :type x, y: int\n"
|
||||
" :arg xsize, ysize: width and height of the viewport_set.\n"
|
||||
" :type xsize, ysize: int\n");
|
||||
static PyObject *pygpu_state_viewport_set(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *pygpu_state_viewport_set(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int x, y, xsize, ysize;
|
||||
if (!PyArg_ParseTuple(args, "iiii:viewport_set", &x, &y, &xsize, &ysize)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_viewport(x, y, xsize, ysize);
|
||||
@@ -215,7 +215,7 @@ PyDoc_STRVAR(pygpu_state_viewport_get_doc,
|
||||
".. function:: viewport_get()\n"
|
||||
"\n"
|
||||
" Viewport of the active framebuffer.\n");
|
||||
static PyObject *pygpu_state_viewport_get(PyObject *UNUSED(self), PyObject *UNUSED(args))
|
||||
static PyObject *pygpu_state_viewport_get(PyObject * /*self*/, PyObject * /*args*/)
|
||||
{
|
||||
int viewport[4];
|
||||
GPU_viewport_size_get_i(viewport);
|
||||
@@ -239,11 +239,11 @@ PyDoc_STRVAR(pygpu_state_scissor_set_doc,
|
||||
" :type x, y: int\n"
|
||||
" :arg xsize, ysize: width and height of the scissor rectangle.\n"
|
||||
" :type xsize, ysize: int\n");
|
||||
static PyObject *pygpu_state_scissor_set(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *pygpu_state_scissor_set(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int x, y, xsize, ysize;
|
||||
if (!PyArg_ParseTuple(args, "iiii:scissor_set", &x, &y, &xsize, &ysize)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_scissor(x, y, xsize, ysize);
|
||||
@@ -261,7 +261,7 @@ PyDoc_STRVAR(pygpu_state_scissor_get_doc,
|
||||
" x, y: lower left corner of the scissor rectangle, in pixels.\n"
|
||||
" xsize, ysize: width and height of the scissor rectangle.\n"
|
||||
" :rtype: tuple(int, int, int, int)\n");
|
||||
static PyObject *pygpu_state_scissor_get(PyObject *UNUSED(self), PyObject *UNUSED(args))
|
||||
static PyObject *pygpu_state_scissor_get(PyObject * /*self*/, PyObject * /*args*/)
|
||||
{
|
||||
int scissor[4];
|
||||
GPU_scissor_get(scissor);
|
||||
@@ -284,11 +284,11 @@ PyDoc_STRVAR(pygpu_state_scissor_test_set_doc,
|
||||
" True - enable scissor testing.\n"
|
||||
" False - disable scissor testing.\n"
|
||||
" :type enable: bool\n");
|
||||
static PyObject *pygpu_state_scissor_test_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_scissor_test_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
bool enabled;
|
||||
if (!PyC_ParseBool(value, &enabled)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_scissor_test(enabled);
|
||||
@@ -302,11 +302,11 @@ PyDoc_STRVAR(pygpu_state_line_width_set_doc,
|
||||
"\n"
|
||||
" :arg size: New width.\n"
|
||||
" :type mode: float\n");
|
||||
static PyObject *pygpu_state_line_width_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_line_width_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
float width = (float)PyFloat_AsDouble(value);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_line_width(width);
|
||||
@@ -317,7 +317,7 @@ PyDoc_STRVAR(pygpu_state_line_width_get_doc,
|
||||
".. function:: line_width_get()\n"
|
||||
"\n"
|
||||
" Current width of rasterized lines.\n");
|
||||
static PyObject *pygpu_state_line_width_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_state_line_width_get(PyObject * /*self*/)
|
||||
{
|
||||
float width = GPU_line_width_get();
|
||||
return PyFloat_FromDouble((double)width);
|
||||
@@ -330,11 +330,11 @@ PyDoc_STRVAR(pygpu_state_point_size_set_doc,
|
||||
"\n"
|
||||
" :arg size: New diameter.\n"
|
||||
" :type mode: float\n");
|
||||
static PyObject *pygpu_state_point_size_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_point_size_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
float size = (float)PyFloat_AsDouble(value);
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_point_size(size);
|
||||
@@ -348,11 +348,11 @@ PyDoc_STRVAR(pygpu_state_color_mask_set_doc,
|
||||
"\n"
|
||||
" :arg r, g, b, a: components red, green, blue, and alpha.\n"
|
||||
" :type r, g, b, a: bool\n");
|
||||
static PyObject *pygpu_state_color_mask_set(PyObject *UNUSED(self), PyObject *args)
|
||||
static PyObject *pygpu_state_color_mask_set(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
int r, g, b, a;
|
||||
if (!PyArg_ParseTuple(args, "pppp:color_mask_set", &r, &g, &b, &a)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_color_mask((bool)r, (bool)g, (bool)b, (bool)a);
|
||||
@@ -366,14 +366,14 @@ PyDoc_STRVAR(pygpu_state_face_culling_set_doc,
|
||||
"\n"
|
||||
" :arg mode: `NONE`, `FRONT` or `BACK`.\n"
|
||||
" :type mode: str\n");
|
||||
static PyObject *pygpu_state_face_culling_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_face_culling_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
struct PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items};
|
||||
if (!PyC_ParseStringEnum(value, &pygpu_faceculling)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_face_culling(pygpu_faceculling.value_found);
|
||||
GPU_face_culling(eGPUFaceCullTest(pygpu_faceculling.value_found));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -384,11 +384,11 @@ PyDoc_STRVAR(pygpu_state_front_facing_set_doc,
|
||||
"\n"
|
||||
" :arg invert: True for clockwise polygons as front-facing.\n"
|
||||
" :type mode: bool\n");
|
||||
static PyObject *pygpu_state_front_facing_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_front_facing_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
bool invert;
|
||||
if (!PyC_ParseBool(value, &invert)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_front_facing(invert);
|
||||
@@ -403,11 +403,11 @@ PyDoc_STRVAR(pygpu_state_program_point_size_set_doc,
|
||||
"\n"
|
||||
" :arg enable: True for shader builtin gl_PointSize.\n"
|
||||
" :type enable: bool\n");
|
||||
static PyObject *pygpu_state_program_point_size_set(PyObject *UNUSED(self), PyObject *value)
|
||||
static PyObject *pygpu_state_program_point_size_set(PyObject * /*self*/, PyObject *value)
|
||||
{
|
||||
bool enable;
|
||||
if (!PyC_ParseBool(value, &enable)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_program_point_size(enable);
|
||||
@@ -418,7 +418,7 @@ PyDoc_STRVAR(pygpu_state_framebuffer_active_get_doc,
|
||||
".. function:: framebuffer_active_get(enable)\n"
|
||||
"\n"
|
||||
" Return the active frame-buffer in context.\n");
|
||||
static PyObject *pygpu_state_framebuffer_active_get(PyObject *UNUSED(self))
|
||||
static PyObject *pygpu_state_framebuffer_active_get(PyObject * /*self*/)
|
||||
{
|
||||
GPUFrameBuffer *fb = GPU_framebuffer_active_get();
|
||||
return BPyGPUFrameBuffer_CreatePyObject(fb, true);
|
||||
@@ -506,7 +506,7 @@ static PyMethodDef pygpu_state__tp_methods[] = {
|
||||
(PyCFunction)pygpu_state_framebuffer_active_get,
|
||||
METH_NOARGS,
|
||||
pygpu_state_framebuffer_active_get_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_state__tp_doc, "This module provides access to the gpu state.");
|
||||
@@ -516,10 +516,10 @@ static PyModuleDef pygpu_state_module_def = {
|
||||
/*m_doc*/ pygpu_state__tp_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_state__tp_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_state_init(void)
|
||||
@@ -8,4 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_state_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -78,12 +78,12 @@ static const struct PyC_StringEnumItems pygpu_textureformat_items[] = {
|
||||
{GPU_DEPTH_COMPONENT32F, "DEPTH_COMPONENT32F"},
|
||||
{GPU_DEPTH_COMPONENT24, "DEPTH_COMPONENT24"},
|
||||
{GPU_DEPTH_COMPONENT16, "DEPTH_COMPONENT16"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static int pygpu_texture_valid_check(BPyGPUTexture *bpygpu_tex)
|
||||
{
|
||||
if (UNLIKELY(bpygpu_tex->tex == NULL)) {
|
||||
if (UNLIKELY(bpygpu_tex->tex == nullptr)) {
|
||||
PyErr_SetString(PyExc_ReferenceError,
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
"GPU texture was freed, no further access is valid"
|
||||
@@ -100,7 +100,7 @@ static int pygpu_texture_valid_check(BPyGPUTexture *bpygpu_tex)
|
||||
#define BPYGPU_TEXTURE_CHECK_OBJ(bpygpu) \
|
||||
{ \
|
||||
if (UNLIKELY(pygpu_texture_valid_check(bpygpu) == -1)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -111,17 +111,17 @@ static int pygpu_texture_valid_check(BPyGPUTexture *bpygpu_tex)
|
||||
/** \name GPUTexture Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_texture__tp_new(PyTypeObject * /*self*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *py_size;
|
||||
int size[3] = {1, 1, 1};
|
||||
int layers = 0;
|
||||
int is_cubemap = false;
|
||||
struct PyC_StringEnum pygpu_textureformat = {pygpu_textureformat_items, GPU_RGBA8};
|
||||
BPyGPUBuffer *pybuffer_obj = NULL;
|
||||
BPyGPUBuffer *pybuffer_obj = nullptr;
|
||||
char err_out[256] = "unknown error. See console";
|
||||
|
||||
static const char *_keywords[] = {"size", "layers", "is_cubemap", "format", "data", NULL};
|
||||
static const char *_keywords[] = {"size", "layers", "is_cubemap", "format", "data", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O" /* `size` */
|
||||
"|$" /* Optional keyword only arguments. */
|
||||
@@ -144,7 +144,7 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
||||
&BPyGPU_BufferType,
|
||||
&pybuffer_obj))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int len = 1;
|
||||
@@ -154,10 +154,10 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"GPUTexture.__new__: \"size\" must be between 1 and 3 in length (got %d)",
|
||||
len);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (PyC_AsArray(size, sizeof(*size), py_size, len, &PyLong_Type, "GPUTexture.__new__") == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (PyLong_Check(py_size)) {
|
||||
@@ -165,18 +165,19 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "GPUTexture.__new__: Expected an int or tuple as first arg");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *data = NULL;
|
||||
void *data = nullptr;
|
||||
if (pybuffer_obj) {
|
||||
if (pybuffer_obj->format != GPU_DATA_FLOAT) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"GPUTexture.__new__: Only Buffer of format `FLOAT` is currently supported");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int component_len = GPU_texture_component_len(pygpu_textureformat.value_found);
|
||||
int component_len = GPU_texture_component_len(
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found));
|
||||
int component_size_expected = sizeof(float);
|
||||
size_t data_space_expected = (size_t)size[0] * size[1] * size[2] * max_ii(1, layers) *
|
||||
component_len * component_size_expected;
|
||||
@@ -186,12 +187,12 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
||||
|
||||
if (bpygpu_Buffer_size(pybuffer_obj) < data_space_expected) {
|
||||
PyErr_SetString(PyExc_ValueError, "GPUTexture.__new__: Buffer size smaller than requested");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
data = pybuffer_obj->buf.as_void;
|
||||
}
|
||||
|
||||
GPUTexture *tex = NULL;
|
||||
GPUTexture *tex = nullptr;
|
||||
if (is_cubemap && len != 1) {
|
||||
STRNCPY(err_out,
|
||||
"In cubemaps the same dimension represents height, width and depth. No tuple needed");
|
||||
@@ -210,61 +211,97 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
if (is_cubemap) {
|
||||
if (layers) {
|
||||
tex = GPU_texture_create_cube_array(
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_cube_array(name,
|
||||
size[0],
|
||||
layers,
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_cube(
|
||||
name, size[0], 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_cube(name,
|
||||
size[0],
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
}
|
||||
else if (layers) {
|
||||
if (len == 2) {
|
||||
tex = GPU_texture_create_2d_array(
|
||||
name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_2d_array(name,
|
||||
size[0],
|
||||
size[1],
|
||||
layers,
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_1d_array(
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_1d_array(name,
|
||||
size[0],
|
||||
layers,
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
}
|
||||
else if (len == 3) {
|
||||
tex = GPU_texture_create_3d(
|
||||
name, size[0], size[1], size[2], 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_3d(name,
|
||||
size[0],
|
||||
size[1],
|
||||
size[2],
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
data);
|
||||
}
|
||||
else if (len == 2) {
|
||||
tex = GPU_texture_create_2d(
|
||||
name, size[0], size[1], 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_2d(name,
|
||||
size[0],
|
||||
size[1],
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_1d(name, size[0], 1, pygpu_textureformat.value_found, usage, data);
|
||||
tex = GPU_texture_create_1d(name,
|
||||
size[0],
|
||||
1,
|
||||
eGPUTextureFormat(pygpu_textureformat.value_found),
|
||||
usage,
|
||||
static_cast<const float *>(data));
|
||||
}
|
||||
}
|
||||
|
||||
if (tex == NULL) {
|
||||
if (tex == nullptr) {
|
||||
PyErr_Format(PyExc_RuntimeError, "gpu.texture.new(...) failed with '%s'", err_out);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUTexture_CreatePyObject(tex, false);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_texture_width_doc, "Width of the texture.\n\n:type: `int`");
|
||||
static PyObject *pygpu_texture_width_get(BPyGPUTexture *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_texture_width_get(BPyGPUTexture *self, void * /*type*/)
|
||||
{
|
||||
BPYGPU_TEXTURE_CHECK_OBJ(self);
|
||||
return PyLong_FromLong(GPU_texture_width(self->tex));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_texture_height_doc, "Height of the texture.\n\n:type: `int`");
|
||||
static PyObject *pygpu_texture_height_get(BPyGPUTexture *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_texture_height_get(BPyGPUTexture *self, void * /*type*/)
|
||||
{
|
||||
BPYGPU_TEXTURE_CHECK_OBJ(self);
|
||||
return PyLong_FromLong(GPU_texture_height(self->tex));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_texture_format_doc, "Format of the texture.\n\n:type: `str`");
|
||||
static PyObject *pygpu_texture_format_get(BPyGPUTexture *self, void *UNUSED(type))
|
||||
static PyObject *pygpu_texture_format_get(BPyGPUTexture *self, void * /*type*/)
|
||||
{
|
||||
BPYGPU_TEXTURE_CHECK_OBJ(self);
|
||||
eGPUTextureFormat format = GPU_texture_format(self->tex);
|
||||
@@ -294,7 +331,7 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
|
||||
PyObject *py_values;
|
||||
|
||||
static const char *_keywords[] = {"format", "value", NULL};
|
||||
static const char *_keywords[] = {"format", "value", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"$" /* Keyword only arguments. */
|
||||
"O&" /* `format` */
|
||||
@@ -306,24 +343,24 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_dataformat, &py_values))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int shape = PySequence_Size(py_values);
|
||||
if (shape == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (shape > 4) {
|
||||
PyErr_SetString(PyExc_AttributeError, "too many dimensions, max is 4");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (shape != 1 && ELEM(pygpu_dataformat.value_found, GPU_DATA_UINT_24_8, GPU_DATA_10_11_11_REV))
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"`UINT_24_8` and `10_11_11_REV` only support single values");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
memset(&values, 0, sizeof(values));
|
||||
@@ -335,7 +372,7 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
(pygpu_dataformat.value_found == GPU_DATA_FLOAT) ? &PyFloat_Type : &PyLong_Type,
|
||||
"clear") == -1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (pygpu_dataformat.value_found == GPU_DATA_UBYTE) {
|
||||
@@ -346,7 +383,7 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
values.c[3] = values.i[3];
|
||||
}
|
||||
|
||||
GPU_texture_clear(self->tex, pygpu_dataformat.value_found, &values);
|
||||
GPU_texture_clear(self->tex, eGPUDataFormat(pygpu_dataformat.value_found), &values);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -401,7 +438,7 @@ static PyObject *pygpu_texture_read(BPyGPUTexture *self)
|
||||
void *buf = GPU_texture_read(self->tex, best_data_format, 0);
|
||||
const Py_ssize_t shape[3] = {GPU_texture_height(self->tex),
|
||||
GPU_texture_width(self->tex),
|
||||
GPU_texture_component_len(tex_format)};
|
||||
Py_ssize_t(GPU_texture_component_len(tex_format))};
|
||||
|
||||
int shape_len = (shape[2] == 1) ? 2 : 3;
|
||||
return (PyObject *)BPyGPU_Buffer_CreatePyObject(best_data_format, shape, shape_len, buf);
|
||||
@@ -418,7 +455,7 @@ static PyObject *pygpu_texture_free(BPyGPUTexture *self)
|
||||
BPYGPU_TEXTURE_CHECK_OBJ(self);
|
||||
|
||||
GPU_texture_free(self->tex);
|
||||
self->tex = NULL;
|
||||
self->tex = nullptr;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif
|
||||
@@ -427,7 +464,7 @@ static void BPyGPUTexture__tp_dealloc(BPyGPUTexture *self)
|
||||
{
|
||||
if (self->tex) {
|
||||
#ifndef GPU_NO_USE_PY_REFERENCES
|
||||
GPU_texture_py_reference_set(self->tex, NULL);
|
||||
GPU_texture_py_reference_set(self->tex, nullptr);
|
||||
#endif
|
||||
GPU_texture_free(self->tex);
|
||||
}
|
||||
@@ -435,10 +472,18 @@ static void BPyGPUTexture__tp_dealloc(BPyGPUTexture *self)
|
||||
}
|
||||
|
||||
static PyGetSetDef pygpu_texture__tp_getseters[] = {
|
||||
{"width", (getter)pygpu_texture_width_get, (setter)NULL, pygpu_texture_width_doc, NULL},
|
||||
{"height", (getter)pygpu_texture_height_get, (setter)NULL, pygpu_texture_height_doc, NULL},
|
||||
{"format", (getter)pygpu_texture_format_get, (setter)NULL, pygpu_texture_format_doc, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{"width", (getter)pygpu_texture_width_get, (setter) nullptr, pygpu_texture_width_doc, nullptr},
|
||||
{"height",
|
||||
(getter)pygpu_texture_height_get,
|
||||
(setter) nullptr,
|
||||
pygpu_texture_height_doc,
|
||||
nullptr},
|
||||
{"format",
|
||||
(getter)pygpu_texture_format_get,
|
||||
(setter) nullptr,
|
||||
pygpu_texture_format_doc,
|
||||
nullptr},
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyMethodDef pygpu_texture__tp_methods[] = {
|
||||
@@ -450,7 +495,7 @@ static PyMethodDef pygpu_texture__tp_methods[] = {
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
{"free", (PyCFunction)pygpu_texture_free, METH_NOARGS, pygpu_texture_free_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -514,55 +559,55 @@ PyDoc_STRVAR(
|
||||
" :arg data: Buffer object to fill the texture.\n"
|
||||
" :type data: :class:`gpu.types.Buffer`\n");
|
||||
PyTypeObject BPyGPUTexture_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUTexture",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUTexture),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)BPyGPUTexture__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_texture__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_texture__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_texture__tp_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_texture__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -583,23 +628,23 @@ PyDoc_STRVAR(pygpu_texture_from_image_doc,
|
||||
" :type image: :class:`bpy.types.Image`\n"
|
||||
" :return: The GPUTexture used by the image.\n"
|
||||
" :rtype: :class:`gpu.types.GPUTexture`\n");
|
||||
static PyObject *pygpu_texture_from_image(PyObject *UNUSED(self), PyObject *arg)
|
||||
static PyObject *pygpu_texture_from_image(PyObject * /*self*/, PyObject *arg)
|
||||
{
|
||||
Image *ima = PyC_RNA_AsPointer(arg, "Image");
|
||||
if (ima == NULL) {
|
||||
return NULL;
|
||||
Image *ima = static_cast<Image *>(PyC_RNA_AsPointer(arg, "Image"));
|
||||
if (ima == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ImageUser iuser;
|
||||
BKE_imageuser_default(&iuser);
|
||||
GPUTexture *tex = BKE_image_get_gpu_texture(ima, &iuser, NULL);
|
||||
GPUTexture *tex = BKE_image_get_gpu_texture(ima, &iuser, nullptr);
|
||||
|
||||
return BPyGPUTexture_CreatePyObject(tex, true);
|
||||
}
|
||||
|
||||
static PyMethodDef pygpu_texture__m_methods[] = {
|
||||
{"from_image", (PyCFunction)pygpu_texture_from_image, METH_O, pygpu_texture_from_image_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_texture__m_doc, "This module provides utils for textures.");
|
||||
@@ -609,10 +654,10 @@ static PyModuleDef pygpu_texture_module_def = {
|
||||
/*m_doc*/ pygpu_texture__m_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ pygpu_texture__m_methods,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -624,7 +669,7 @@ static PyModuleDef pygpu_texture_module_def = {
|
||||
int bpygpu_ParseTexture(PyObject *o, void *p)
|
||||
{
|
||||
if (o == Py_None) {
|
||||
*(GPUTexture **)p = NULL;
|
||||
*(GPUTexture **)p = nullptr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -679,7 +724,7 @@ PyObject *BPyGPUTexture_CreatePyObject(GPUTexture *tex, bool shared_reference)
|
||||
self->tex = tex;
|
||||
|
||||
#ifndef GPU_NO_USE_PY_REFERENCES
|
||||
BLI_assert(GPU_texture_py_reference_get(tex) == NULL);
|
||||
BLI_assert(GPU_texture_py_reference_get(tex) == nullptr);
|
||||
GPU_texture_py_reference_set(tex, (void **)&self->tex);
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUTexture_Type;
|
||||
|
||||
#define BPyGPUTexture_Check(v) (Py_TYPE(v) == &BPyGPUTexture_Type)
|
||||
@@ -24,3 +28,7 @@ PyObject *bpygpu_texture_init(void);
|
||||
|
||||
PyObject *BPyGPUTexture_CreatePyObject(struct GPUTexture *tex, bool shared_reference)
|
||||
ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
static PyModuleDef pygpu_types_module_def = {
|
||||
/*m_base*/ PyModuleDef_HEAD_INIT,
|
||||
/*m_name*/ "gpu.types",
|
||||
/*m_doc*/ NULL,
|
||||
/*m_doc*/ nullptr,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyObject *bpygpu_types_init(void)
|
||||
@@ -39,40 +39,40 @@ PyObject *bpygpu_types_init(void)
|
||||
submodule = bpygpu_create_module(&pygpu_types_module_def);
|
||||
|
||||
if (bpygpu_finalize_type(&BPyGPU_BufferType) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUVertFormat_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUVertBuf_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUIndexBuf_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUBatch_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUOffScreen_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUShader_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUTexture_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUFrameBuffer_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUUniformBuf_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUShaderCreateInfo_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (bpygpu_finalize_type(&BPyGPUStageInterfaceInfo_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyModule_AddType(submodule, &BPyGPU_BufferType);
|
||||
@@ -20,4 +20,12 @@
|
||||
#include "gpu_py_vertex_buffer.h"
|
||||
#include "gpu_py_vertex_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyObject *bpygpu_types_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub)
|
||||
{
|
||||
if (UNLIKELY(bpygpu_ub->ubo == NULL)) {
|
||||
if (UNLIKELY(bpygpu_ub->ubo == nullptr)) {
|
||||
PyErr_SetString(PyExc_ReferenceError,
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
"GPU uniform buffer was freed, no further access is valid");
|
||||
@@ -46,7 +46,7 @@ static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub)
|
||||
#define BPYGPU_UNIFORMBUF_CHECK_OBJ(bpygpu) \
|
||||
{ \
|
||||
if (UNLIKELY(pygpu_uniformbuffer_valid_check(bpygpu) == -1)) { \
|
||||
return NULL; \
|
||||
return nullptr; \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -57,15 +57,15 @@ static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub)
|
||||
/** \name GPUUniformBuf Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject * /*self*/,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
GPUUniformBuf *ubo = NULL;
|
||||
GPUUniformBuf *ubo = nullptr;
|
||||
PyObject *pybuffer_obj;
|
||||
char err_out[256] = "unknown error. See console";
|
||||
|
||||
static const char *_keywords[] = {"data", NULL};
|
||||
static const char *_keywords[] = {"data", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O" /* `data` */
|
||||
":GPUUniformBuf.__new__",
|
||||
@@ -73,7 +73,7 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &pybuffer_obj)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!GPU_context_active_get()) {
|
||||
@@ -83,7 +83,7 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
Py_buffer pybuffer;
|
||||
if (PyObject_GetBuffer(pybuffer_obj, &pybuffer, PyBUF_SIMPLE) == -1) {
|
||||
/* PyObject_GetBuffer raise a PyExc_BufferError */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((pybuffer.len % 16) != 0) {
|
||||
@@ -95,9 +95,9 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
|
||||
PyBuffer_Release(&pybuffer);
|
||||
}
|
||||
|
||||
if (ubo == NULL) {
|
||||
if (ubo == nullptr) {
|
||||
PyErr_Format(PyExc_RuntimeError, "GPUUniformBuf.__new__(...) failed with '%s'", err_out);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BPyGPUUniformBuf_CreatePyObject(ubo);
|
||||
@@ -114,7 +114,7 @@ static PyObject *pygpu_uniformbuffer_update(BPyGPUUniformBuf *self, PyObject *ob
|
||||
Py_buffer pybuffer;
|
||||
if (PyObject_GetBuffer(obj, &pybuffer, PyBUF_SIMPLE) == -1) {
|
||||
/* PyObject_GetBuffer raise a PyExc_BufferError */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPU_uniformbuf_update(self->ubo, pybuffer.buf);
|
||||
@@ -133,7 +133,7 @@ static PyObject *pygpu_uniformbuffer_free(BPyGPUUniformBuf *self)
|
||||
BPYGPU_UNIFORMBUF_CHECK_OBJ(self);
|
||||
|
||||
GPU_uniformbuf_free(self->ubo);
|
||||
self->ubo = NULL;
|
||||
self->ubo = nullptr;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif
|
||||
@@ -147,7 +147,7 @@ static void BPyGPUUniformBuf__tp_dealloc(BPyGPUUniformBuf *self)
|
||||
}
|
||||
|
||||
static PyGetSetDef pygpu_uniformbuffer__tp_getseters[] = {
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyMethodDef pygpu_uniformbuffer__tp_methods[] = {
|
||||
@@ -155,7 +155,7 @@ static PyMethodDef pygpu_uniformbuffer__tp_methods[] = {
|
||||
#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
|
||||
{"free", (PyCFunction)pygpu_uniformbuffer_free, METH_NOARGS, pygpu_uniformbuffer_free_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(pygpu_uniformbuffer__tp_doc,
|
||||
@@ -166,55 +166,55 @@ PyDoc_STRVAR(pygpu_uniformbuffer__tp_doc,
|
||||
" :arg data: Data to fill the buffer.\n"
|
||||
" :type data: object exposing buffer interface\n");
|
||||
PyTypeObject BPyGPUUniformBuf_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUUniformBuf",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUUniformBuf),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)BPyGPUUniformBuf__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_uniformbuffer__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_uniformbuffer__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ pygpu_uniformbuffer__tp_getseters,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_uniformbuffer__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUUniformBuf_Type;
|
||||
|
||||
#define BPyGPUUniformBuf_Check(v) (Py_TYPE(v) == &BPyGPUUniformBuf_Type)
|
||||
@@ -20,3 +24,7 @@ typedef struct BPyGPUUniformBuf {
|
||||
} BPyGPUUniformBuf;
|
||||
|
||||
PyObject *BPyGPUUniformBuf_CreatePyObject(struct GPUUniformBuf *ubo) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -68,7 +68,7 @@ static void pygpu_fill_format_elem(void *data_dst_void, PyObject *py_src, const
|
||||
{
|
||||
#define PY_AS_NATIVE(ty_dst, py_as_native) \
|
||||
{ \
|
||||
ty_dst *data_dst = data_dst_void; \
|
||||
ty_dst *data_dst = static_cast<ty_dst *>(data_dst_void); \
|
||||
*data_dst = py_as_native(py_src); \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -90,7 +90,7 @@ static void pygpu_fill_format_sequence(void *data_dst_void,
|
||||
* Args are constants, so range checks will be optimized out if they're no-op's.
|
||||
*/
|
||||
#define PY_AS_NATIVE(ty_dst, py_as_native) \
|
||||
ty_dst *data_dst = data_dst_void; \
|
||||
ty_dst *data_dst = static_cast<ty_dst *>(data_dst_void); \
|
||||
for (uint i = 0; i < len; i++) { \
|
||||
data_dst[i] = py_as_native(value_fast_items[i]); \
|
||||
} \
|
||||
@@ -146,7 +146,7 @@ static bool pygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
|
||||
GPU_vertbuf_attr_get_raw_data(vbo, data_id, &data_step);
|
||||
|
||||
PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill");
|
||||
if (seq_fast == NULL) {
|
||||
if (seq_fast == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ static bool pygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
|
||||
uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step);
|
||||
PyObject *seq_fast_item = PySequence_Fast(seq_items[i], error_prefix);
|
||||
|
||||
if (seq_fast_item == NULL) {
|
||||
if (seq_fast_item == nullptr) {
|
||||
ok = false;
|
||||
goto finally;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ static int pygpu_vertbuf_fill(GPUVertBuf *buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (GPU_vertbuf_get_data(buf) == NULL) {
|
||||
if (GPU_vertbuf_get_data(buf) == nullptr) {
|
||||
PyErr_SetString(PyExc_ValueError, "Can't fill, static buffer already in use");
|
||||
return 0;
|
||||
}
|
||||
@@ -230,14 +230,14 @@ static int pygpu_vertbuf_fill(GPUVertBuf *buf,
|
||||
/** \name VertBuf Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_vertbuf__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
|
||||
static PyObject *pygpu_vertbuf__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
struct {
|
||||
PyObject *py_fmt;
|
||||
uint len;
|
||||
} params;
|
||||
|
||||
static const char *_keywords[] = {"format", "len", NULL};
|
||||
static const char *_keywords[] = {"format", "len", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O!" /* `format` */
|
||||
"I" /* `len` */
|
||||
@@ -248,7 +248,7 @@ static PyObject *pygpu_vertbuf__tp_new(PyTypeObject *UNUSED(type), PyObject *arg
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(
|
||||
args, kwds, &_parser, &BPyGPUVertFormat_Type, ¶ms.py_fmt, ¶ms.len))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GPUVertFormat *fmt = &((BPyGPUVertFormat *)params.py_fmt)->fmt;
|
||||
@@ -273,7 +273,7 @@ static PyObject *pygpu_vertbuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, Py
|
||||
PyObject *data;
|
||||
PyObject *identifier;
|
||||
|
||||
static const char *_keywords[] = {"id", "data", NULL};
|
||||
static const char *_keywords[] = {"id", "data", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"O" /* `id` */
|
||||
"O" /* `data` */
|
||||
@@ -282,7 +282,7 @@ static PyObject *pygpu_vertbuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, Py
|
||||
0,
|
||||
};
|
||||
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &identifier, &data)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int id;
|
||||
@@ -296,16 +296,16 @@ static PyObject *pygpu_vertbuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, Py
|
||||
id = GPU_vertformat_attr_id_get(format, name);
|
||||
if (id == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "Unknown attribute '%s'", name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "expected int or str type as identifier");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!pygpu_vertbuf_fill(self->buf, id, data, "GPUVertBuf.attr_fill")) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -316,7 +316,7 @@ static PyMethodDef pygpu_vertbuf__tp_methods[] = {
|
||||
(PyCFunction)pygpu_vertbuf_attr_fill,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
pygpu_vertbuf_attr_fill_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static void pygpu_vertbuf__tp_dealloc(BPyGPUVertBuf *self)
|
||||
@@ -335,55 +335,55 @@ PyDoc_STRVAR(pygpu_vertbuf__tp_doc,
|
||||
" :arg len: Amount of vertices that will fit into this buffer.\n"
|
||||
" :type len: int\n");
|
||||
PyTypeObject BPyGPUVertBuf_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUVertBuf",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUVertBuf),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_vertbuf__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_vertbuf__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_vertbuf__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_vertbuf__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUVertBuf_Type;
|
||||
|
||||
#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type)
|
||||
@@ -21,3 +25,7 @@ typedef struct BPyGPUVertBuf {
|
||||
} BPyGPUVertBuf;
|
||||
|
||||
PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *buf) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ static struct PyC_StringEnumItems pygpu_vertcomptype_items[] = {
|
||||
{GPU_COMP_U32, "U32"},
|
||||
{GPU_COMP_F32, "F32"},
|
||||
{GPU_COMP_I10, "I10"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
static struct PyC_StringEnumItems pygpu_vertfetchmode_items[] = {
|
||||
@@ -39,7 +39,7 @@ static struct PyC_StringEnumItems pygpu_vertfetchmode_items[] = {
|
||||
{GPU_FETCH_INT, "INT"},
|
||||
{GPU_FETCH_INT_TO_FLOAT_UNIT, "INT_TO_FLOAT_UNIT"},
|
||||
{GPU_FETCH_INT_TO_FLOAT, "INT_TO_FLOAT"},
|
||||
{0, NULL},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -48,15 +48,13 @@ static struct PyC_StringEnumItems pygpu_vertfetchmode_items[] = {
|
||||
/** \name VertFormat Type
|
||||
* \{ */
|
||||
|
||||
static PyObject *pygpu_vertformat__tp_new(PyTypeObject *UNUSED(type),
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
static PyObject *pygpu_vertformat__tp_new(PyTypeObject * /*type*/, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
|
||||
PyErr_SetString(PyExc_ValueError, "This function takes no arguments");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return BPyGPUVertFormat_CreatePyObject(NULL);
|
||||
return BPyGPUVertFormat_CreatePyObject(nullptr);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
@@ -88,10 +86,10 @@ static PyObject *pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *arg
|
||||
|
||||
if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) {
|
||||
PyErr_SetString(PyExc_ValueError, "Maximum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char *_keywords[] = {"id", "comp_type", "len", "fetch_mode", NULL};
|
||||
static const char *_keywords[] = {"id", "comp_type", "len", "fetch_mode", nullptr};
|
||||
static _PyArg_Parser _parser = {
|
||||
"$" /* Keyword only arguments. */
|
||||
"s" /* `id` */
|
||||
@@ -112,11 +110,14 @@ static PyObject *pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *arg
|
||||
PyC_ParseStringEnum,
|
||||
&fetch_mode))
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint attr_id = GPU_vertformat_attr_add(
|
||||
&self->fmt, id, comp_type.value_found, len, fetch_mode.value_found);
|
||||
uint attr_id = GPU_vertformat_attr_add(&self->fmt,
|
||||
id,
|
||||
GPUVertCompType(comp_type.value_found),
|
||||
len,
|
||||
GPUVertFetchMode(fetch_mode.value_found));
|
||||
return PyLong_FromLong(attr_id);
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ static PyMethodDef pygpu_vertformat__tp_methods[] = {
|
||||
(PyCFunction)pygpu_vertformat_attr_add,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
pygpu_vertformat_attr_add_doc},
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
static void pygpu_vertformat__tp_dealloc(BPyGPUVertFormat *self)
|
||||
@@ -138,55 +139,55 @@ PyDoc_STRVAR(pygpu_vertformat__tp_doc,
|
||||
"\n"
|
||||
" This object contains information about the structure of a vertex buffer.\n");
|
||||
PyTypeObject BPyGPUVertFormat_Type = {
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "GPUVertFormat",
|
||||
/*tp_basicsize*/ sizeof(BPyGPUVertFormat),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)pygpu_vertformat__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ pygpu_vertformat__tp_doc,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ pygpu_vertformat__tp_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_alloc*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ nullptr,
|
||||
/*tp_new*/ pygpu_vertformat__tp_new,
|
||||
/*tp_free*/ NULL,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ NULL,
|
||||
/*tp_free*/ nullptr,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "GPU_vertex_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPyGPUVertFormat_Type;
|
||||
|
||||
#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type)
|
||||
@@ -20,3 +24,7 @@ typedef struct BPyGPUVertFormat {
|
||||
} BPyGPUVertFormat;
|
||||
|
||||
PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user