Cleanup: various non-functional changes for C++ (python, makesrna)

- Remove redundant void, struct.
- Use function style casts.
This commit is contained in:
Campbell Barton
2023-07-22 11:33:36 +10:00
parent 81ee130063
commit d1aac3b08c
37 changed files with 154 additions and 155 deletions

View File

@@ -196,7 +196,7 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
/* Only the directory (base-name). */
SNPRINTF(from_path,
"%.*s%s",
(int)(makesrna_source_filename - makesrna_source_filepath),
int(makesrna_source_filename - makesrna_source_filepath),
makesrna_source_filepath,
dep_files[pass]);
/* Account for build dependencies, if `makesrna.cc` (this file) is newer. */
@@ -634,7 +634,7 @@ static void rna_float_print(FILE *f, float num)
else if (num == FLT_MAX) {
fprintf(f, "FLT_MAX");
}
else if ((fabsf(num) < (float)INT64_MAX) && ((int64_t)num == num)) {
else if ((fabsf(num) < float(INT64_MAX)) && (int64_t(num) == num)) {
fprintf(f, "%.1ff", num);
}
else {
@@ -674,7 +674,7 @@ static void rna_int_print(FILE *f, int64_t num)
fprintf(f, "%" PRId64 "LL", num);
}
else {
fprintf(f, "%d", (int)num);
fprintf(f, "%d", int(num));
}
}
@@ -3291,7 +3291,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
dfunc->gencall = funcname;
}
static void rna_auto_types(void)
static void rna_auto_types()
{
StructDefRNA *ds;
PropertyDefRNA *dp;
@@ -4290,7 +4290,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, ", ");
rna_float_print(f, fprop->step);
fprintf(f, ", ");
rna_int_print(f, (int)fprop->precision);
rna_int_print(f, int(fprop->precision));
fprintf(f, ", ");
rna_float_print(f, fprop->defaultvalue);
fprintf(f, ", ");
@@ -4313,7 +4313,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(sprop->length_ex),
rna_function_string(sprop->set_ex),
rna_function_string(sprop->search),
(int)sprop->search_flag,
int(sprop->search_flag),
sprop->maxlength);
rna_print_c_string(f, sprop->defaultvalue);
fprintf(f, "\n");

View File

@@ -678,7 +678,7 @@ void RNA_identifier_sanitize(char *identifier, int property)
/* Blender Data Definition */
BlenderRNA *RNA_create(void)
BlenderRNA *RNA_create()
{
BlenderRNA *brna;
@@ -1706,17 +1706,17 @@ void RNA_def_property_ui_range(
switch (prop->type) {
case PROP_INT: {
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
iprop->softmin = (int)min;
iprop->softmax = (int)max;
iprop->step = (int)step;
iprop->softmin = int(min);
iprop->softmax = int(max);
iprop->step = int(step);
break;
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
fprop->softmin = (float)min;
fprop->softmax = (float)max;
fprop->step = (float)step;
fprop->precision = (int)precision;
fprop->softmin = float(min);
fprop->softmax = float(max);
fprop->step = float(step);
fprop->precision = int(precision);
break;
}
default:
@@ -1763,18 +1763,18 @@ void RNA_def_property_range(PropertyRNA *prop, double min, double max)
switch (prop->type) {
case PROP_INT: {
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
iprop->hardmin = (int)min;
iprop->hardmax = (int)max;
iprop->softmin = MAX2((int)min, iprop->hardmin);
iprop->softmax = MIN2((int)max, iprop->hardmax);
iprop->hardmin = int(min);
iprop->hardmax = int(max);
iprop->softmin = MAX2(int(min), iprop->hardmin);
iprop->softmax = MIN2(int(max), iprop->hardmax);
break;
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
fprop->hardmin = (float)min;
fprop->hardmax = (float)max;
fprop->softmin = MAX2((float)min, fprop->hardmin);
fprop->softmax = MIN2((float)max, fprop->hardmax);
fprop->hardmin = float(min);
fprop->hardmax = float(max);
fprop->softmin = MAX2(float(min), fprop->hardmin);
fprop->softmax = MIN2(float(max), fprop->hardmax);
break;
}
default:
@@ -2587,7 +2587,7 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons
fprop->defaultvalue = *(const float *)default_data;
}
else if (STREQ(dp->dnatype, "char")) {
fprop->defaultvalue = (float)*(const char *)default_data * (1.0f / 255.0f);
fprop->defaultvalue = float(*(const char *)default_data) * (1.0f / 255.0f);
}
else {
has_default = false;

View File

@@ -176,7 +176,7 @@ static PyModuleDef BPy_BM_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_bmesh(void)
PyObject *BPyInit_bmesh()
{
PyObject *mod;
PyObject *submodule;

View File

@@ -73,7 +73,7 @@ static PyModuleDef BPy_BM_geometry_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_bmesh_geometry(void)
PyObject *BPyInit_bmesh_geometry()
{
PyObject *submodule;

View File

@@ -255,7 +255,7 @@ static PyModuleDef BPy_BM_ops_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_bmesh_ops(void)
PyObject *BPyInit_bmesh_ops()
{
PyObject *submodule = PyModule_Create(&BPy_BM_ops_module_def);

View File

@@ -611,7 +611,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
item = PyLong_FromLong(BMO_SLOT_AS_INT(slot));
break;
case BMO_OP_SLOT_FLT:
item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(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, nullptr);

View File

@@ -96,7 +96,7 @@ PyDoc_STRVAR(bpy_bm_elem_seam_doc, "Seam for UV unwrapping.\n\n:type: boolean");
static PyObject *bpy_bm_elem_hflag_get(BPy_BMElem *self, void *flag)
{
const char hflag = (char)POINTER_AS_INT(flag);
const char hflag = char(POINTER_AS_INT(flag));
BPY_BM_CHECK_OBJ(self);
@@ -105,7 +105,7 @@ static PyObject *bpy_bm_elem_hflag_get(BPy_BMElem *self, void *flag)
static int bpy_bm_elem_hflag_set(BPy_BMElem *self, PyObject *value, void *flag)
{
const char hflag = (char)POINTER_AS_INT(flag);
const char hflag = char(POINTER_AS_INT(flag));
int param;
BPY_BM_CHECK_INT(self);
@@ -467,7 +467,7 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value, void
return -1;
}
self->f->mat_nr = (short)param;
self->f->mat_nr = short(param);
return 0;
}
@@ -1044,7 +1044,7 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
bm = self->bm;
struct Main *bmain = nullptr;
Main *bmain = nullptr;
BMeshToMeshParams params{};
params.update_shapekey_indices = true;
if (me->id.tag & LIB_TAG_NO_MAIN) {
@@ -1089,7 +1089,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
PyObject *py_depsgraph;
Object *ob, *ob_eval;
Depsgraph *depsgraph;
struct Scene *scene_eval;
Scene *scene_eval;
const Mesh *me_eval;
BMesh *bm;
bool use_cage = false;
@@ -1345,7 +1345,7 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
}
}
else {
const char filter_flags_ch = (char)filter_flags;
const char filter_flags_ch = char(filter_flags);
BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, filter_flags_ch)) {
mul_m4_v3((float(*)[4])mat_ptr, eve->co);
@@ -3608,7 +3608,7 @@ PyTypeObject BPy_BMFaceSeq_Type;
PyTypeObject BPy_BMLoopSeq_Type;
PyTypeObject BPy_BMIter_Type;
void BPy_BM_init_types(void)
void BPy_BM_init_types()
{
BPy_BMesh_Type.tp_basicsize = sizeof(BPy_BMesh);
BPy_BMVert_Type.tp_basicsize = sizeof(BPy_BMVert);
@@ -3777,7 +3777,7 @@ static PyModuleDef BPy_BM_types_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_bmesh_types(void)
PyObject *BPyInit_bmesh_types()
{
PyObject *submodule;

View File

@@ -105,7 +105,7 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__freestyle_face_doc,
static PyObject *bpy_bmlayeraccess_collection_get(BPy_BMLayerAccess *self, void *flag)
{
const int type = (int)POINTER_AS_INT(flag);
const int type = int(POINTER_AS_INT(flag));
BPY_BM_CHECK_OBJ(self);
@@ -978,7 +978,7 @@ PyObject *BPy_BMLayerItem_CreatePyObject(BMesh *bm, const char htype, int type,
return (PyObject *)self;
}
void BPy_BM_init_types_customdata(void)
void BPy_BM_init_types_customdata()
{
BPy_BMLayerAccessVert_Type.tp_basicsize = sizeof(BPy_BMLayerAccess);
BPy_BMLayerAccessEdge_Type.tp_basicsize = sizeof(BPy_BMLayerAccess);

View File

@@ -169,7 +169,7 @@ static PyGetSetDef bpy_bmloopuv_getseters[] = {
PyTypeObject BPy_BMLoopUV_Type; /* bm.loops.layers.uv.active */
static void bm_init_types_bmloopuv(void)
static void bm_init_types_bmloopuv()
{
BPy_BMLoopUV_Type.tp_basicsize = sizeof(BPy_BMLoopUV);
@@ -307,7 +307,7 @@ static PyGetSetDef bpy_bmvertskin_getseters[] = {
static PyTypeObject BPy_BMVertSkin_Type; /* bm.loops.layers.skin.active */
static void bm_init_types_bmvertskin(void)
static void bm_init_types_bmvertskin()
{
BPy_BMVertSkin_Type.tp_basicsize = sizeof(BPy_BMVertSkin);
@@ -414,7 +414,7 @@ static Mathutils_Callback mathutils_bmloopcol_cb = {
mathutils_bmloopcol_set_index,
};
static void bm_init_types_bmloopcol(void)
static void bm_init_types_bmloopcol()
{
/* pass */
mathutils_bmloopcol_cb_index = Mathutils_RegisterCallback(&mathutils_bmloopcol_cb);
@@ -727,7 +727,7 @@ static PyMethodDef bpy_bmdeformvert_methods[] = {
PyTypeObject BPy_BMDeformVert_Type; /* bm.loops.layers.uv.active */
static void bm_init_types_bmdvert(void)
static void bm_init_types_bmdvert()
{
BPy_BMDeformVert_Type.tp_basicsize = sizeof(BPy_BMDeformVert);
@@ -768,7 +768,7 @@ PyObject *BPy_BMDeformVert_CreatePyObject(MDeformVert *dvert)
/* --- End Mesh Deform Vert --- */
void BPy_BM_init_types_meshdata(void)
void BPy_BM_init_types_meshdata()
{
bm_init_types_bmloopuv();
bm_init_types_bmloopcol();

View File

@@ -364,7 +364,7 @@ PyObject *BPy_BMEditSelIter_CreatePyObject(BMesh *bm)
return (PyObject *)self;
}
void BPy_BM_init_types_select(void)
void BPy_BM_init_types_select()
{
BPy_BMEditSelSeq_Type.tp_basicsize = sizeof(BPy_BMEditSelSeq);
BPy_BMEditSelIter_Type.tp_basicsize = sizeof(BPy_BMEditSelIter);

View File

@@ -639,7 +639,7 @@ static PyObject *bpy_bm_utils_face_join(PyObject * /*self*/, PyObject *args)
/* Go ahead and join the face!
* --------------------------- */
f_new = BM_faces_join(bm, face_array, (int)face_seq_len, do_remove);
f_new = BM_faces_join(bm, face_array, int(face_seq_len), do_remove);
PyMem_FREE(face_array);
@@ -835,7 +835,7 @@ static PyModuleDef BPy_BM_utils_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_bmesh_utils(void)
PyObject *BPyInit_bmesh_utils()
{
PyObject *submodule;

View File

@@ -59,7 +59,7 @@ static void report_deprecated_call(const char *function_name)
times++;
}
static void report_deprecated_call_to_user(void)
static void report_deprecated_call_to_user()
{
/* Only report the first deprecated usage. */
if (G.opengl_deprecation_usage_detected) {
@@ -1158,7 +1158,7 @@ static PyObject *Buffer_repr(Buffer *self)
}
#else
static void bgl_no_opengl_error(void)
static void bgl_no_opengl_error()
{
PyErr_SetString(PyExc_RuntimeError, "Built without OpenGL support");
}
@@ -2657,7 +2657,7 @@ static void init_bgl_version_3_3_constants(PyObject *dict)
PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR);
}
PyObject *BPyInit_bgl(void)
PyObject *BPyInit_bgl()
{
PyObject *submodule, *dict;
submodule = PyModule_Create(&BGL_module_def);

View File

@@ -141,7 +141,7 @@ static PyModuleDef M_bl_math_module_def = {
/*m_free*/ nullptr,
};
PyMODINIT_FUNC BPyInit_bl_math(void)
PyMODINIT_FUNC BPyInit_bl_math()
{
PyObject *submodule = PyModule_Create(&M_bl_math_module_def);
return submodule;

View File

@@ -173,7 +173,7 @@ static PyObject *py_blf_draw(PyObject * /*self*/, PyObject *args)
return nullptr;
}
BLF_draw(fontid, text, (uint)text_length);
BLF_draw(fontid, text, uint(text_length));
Py_RETURN_NONE;
}
@@ -472,7 +472,7 @@ static PyModuleDef BLF_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_blf(void)
PyObject *BPyInit_blf()
{
PyObject *submodule;

View File

@@ -14,7 +14,7 @@
#include "../BPY_extern.h"
#include "BLI_utildefines.h"
BPy_ThreadStatePtr BPY_thread_save(void)
BPy_ThreadStatePtr BPY_thread_save()
{
/* Use `_PyThreadState_UncheckedGet()` instead of `PyThreadState_Get()`, to avoid a fatal error
* issued when a thread state is nullptr (the thread state can be nullptr when quitting Blender).

View File

@@ -64,12 +64,12 @@ static PyObject *idprop_py_from_idp_string(const IDProperty *prop)
static PyObject *idprop_py_from_idp_int(const IDProperty *prop)
{
return PyLong_FromLong((long)IDP_Int(prop));
return PyLong_FromLong(long(IDP_Int(prop)));
}
static PyObject *idprop_py_from_idp_float(const IDProperty *prop)
{
return PyFloat_FromDouble((double)IDP_Float(prop));
return PyFloat_FromDouble(double(IDP_Float(prop)));
}
static PyObject *idprop_py_from_idp_double(const IDProperty *prop)
@@ -437,7 +437,7 @@ static IDProperty *idp_from_PyUnicode(const char *name, PyObject *ob)
Py_ssize_t value_len;
PyObject *value_coerce = nullptr;
val.string.str = PyC_UnicodeAsBytesAndSize(ob, &value_len, &value_coerce);
val.string.len = (int)value_len + 1;
val.string.len = int(value_len) + 1;
val.string.subtype = IDP_STRING_SUB_UTF8;
prop = IDP_New(IDP_STRING, &val, name);
Py_XDECREF(value_coerce);
@@ -525,7 +525,7 @@ static IDProperty *idp_from_PySequence_Fast(const char *name, PyObject *ob)
ob_seq_fast_items = PySequence_Fast_ITEMS(ob);
if ((val.array.type = idp_sequence_type(ob)) == (char)-1) {
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 nullptr;
@@ -1043,7 +1043,7 @@ 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)
static void IDGroup_Iter_init_type()
{
#define SHARED_MEMBER_SET(member, value) \
{ \
@@ -1280,7 +1280,7 @@ 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)
static void IDGroup_View_init_type()
{
PyTypeObject *k_ty = &BPy_IDGroup_ViewKeys_Type;
PyTypeObject *v_ty = &BPy_IDGroup_ViewValues_Type;
@@ -1827,7 +1827,7 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, Py_ssize_t index, PyObject *va
switch (self->prop->subtype) {
case IDP_FLOAT: {
const float f = (float)PyFloat_AsDouble(value);
const float f = float(PyFloat_AsDouble(value));
if (f == -1 && PyErr_Occurred()) {
return -1;
}
@@ -1918,7 +1918,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
case IDP_BOOLEAN: {
const int8_t *array = (const int8_t *)IDP_Array(prop);
for (count = begin; count < end; count++) {
PyTuple_SET_ITEM(tuple, count - begin, PyBool_FromLong((long)array[count]));
PyTuple_SET_ITEM(tuple, count - begin, PyBool_FromLong(long(array[count])));
}
break;
}
@@ -2145,7 +2145,7 @@ PyTypeObject BPy_IDArray_Type = {
/** \name Initialize Types
* \{ */
void IDProp_Init_Types(void)
void IDProp_Init_Types()
{
IDGroup_Iter_init_type();
IDGroup_View_init_type();
@@ -2216,7 +2216,7 @@ static PyModuleDef IDProp_types_module_def = {
/*m_free*/ nullptr,
};
static PyObject *BPyInit_idprop_types(void)
static PyObject *BPyInit_idprop_types()
{
PyObject *submodule;
@@ -2265,7 +2265,7 @@ static PyModuleDef IDProp_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_idprop(void)
PyObject *BPyInit_idprop()
{
PyObject *mod;
PyObject *submodule;

View File

@@ -380,7 +380,7 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb
ui_data.soft_min = MIN2(ui_data.soft_min, ui_data.soft_max);
}
if (args_contain_key(kwargs, "step")) {
ui_data.step = (float)step;
ui_data.step = float(step);
}
if (args_contain_key(kwargs, "precision")) {
ui_data.precision = precision;
@@ -597,9 +597,9 @@ static void idprop_ui_data_to_dict_float(IDProperty *property, PyObject *dict)
Py_DECREF(item);
PyDict_SetItemString(dict, "soft_max", item = PyFloat_FromDouble(ui_data->soft_max));
Py_DECREF(item);
PyDict_SetItemString(dict, "step", item = PyFloat_FromDouble((double)ui_data->step));
PyDict_SetItemString(dict, "step", item = PyFloat_FromDouble(double(ui_data->step)));
Py_DECREF(item);
PyDict_SetItemString(dict, "precision", item = PyLong_FromDouble((double)ui_data->precision));
PyDict_SetItemString(dict, "precision", item = PyLong_FromDouble(double(ui_data->precision)));
Py_DECREF(item);
if (property->type == IDP_ARRAY) {
PyObject *list = PyList_New(ui_data->default_array_len);
@@ -842,7 +842,7 @@ PyTypeObject BPy_IDPropertyUIManager_Type = {
/*tp_vectorcall*/ nullptr,
};
void IDPropertyUIData_Init_Types(void)
void IDPropertyUIData_Init_Types()
{
PyType_Ready(&BPy_IDPropertyUIManager_Type);
}

View File

@@ -86,12 +86,12 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
int size[2];
enum { FAST, BILINEAR };
const struct PyC_StringEnumItems method_items[] = {
const PyC_StringEnumItems method_items[] = {
{FAST, "FAST"},
{BILINEAR, "BILINEAR"},
{0, nullptr},
};
struct PyC_StringEnum method = {method_items, FAST};
PyC_StringEnum method = {method_items, FAST};
static const char *_keywords[] = {"size", "method", nullptr};
static _PyArg_Parser _parser = {
@@ -593,7 +593,7 @@ static PyModuleDef IMB_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_imbuf(void)
PyObject *BPyInit_imbuf()
{
PyObject *mod;
PyObject *submodule;
@@ -637,7 +637,7 @@ static PyModuleDef IMB_types_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_imbuf_types(void)
PyObject *BPyInit_imbuf_types()
{
PyObject *submodule = PyModule_Create(&IMB_types_module_def);

View File

@@ -106,7 +106,7 @@ BLI_bitmap *pyrna_enum_bitmap_from_set(const EnumPropertyItem *items,
ushort as_unsigned;
} ret_convert;
ret_convert.as_signed = (signed short)ret;
index = (int)ret_convert.as_unsigned;
index = int(ret_convert.as_unsigned);
}
else if (type_size == 1) {
union {
@@ -114,7 +114,7 @@ BLI_bitmap *pyrna_enum_bitmap_from_set(const EnumPropertyItem *items,
uchar as_unsigned;
} ret_convert;
ret_convert.as_signed = (signed char)ret;
index = (int)ret_convert.as_unsigned;
index = int(ret_convert.as_unsigned);
}
else {
BLI_assert_unreachable();
@@ -199,7 +199,7 @@ int pyrna_enum_value_parse_string(PyObject *o, void *p)
PyErr_Format(PyExc_TypeError, "expected a string enum, not %.200s", Py_TYPE(o)->tp_name);
return 0;
}
struct BPy_EnumProperty_Parse *parse_data = static_cast<BPy_EnumProperty_Parse *>(p);
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)
{
@@ -218,7 +218,7 @@ int pyrna_enum_bitfield_parse_set(PyObject *o, void *p)
return 0;
}
struct BPy_EnumProperty_Parse *parse_data = static_cast<BPy_EnumProperty_Parse *>(p);
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)
{

View File

@@ -502,7 +502,7 @@ int PyC_ParseBool(PyObject *o, void *p)
int PyC_ParseStringEnum(PyObject *o, void *p)
{
struct PyC_StringEnum *e = static_cast<PyC_StringEnum *>(p);
PyC_StringEnum *e = static_cast<PyC_StringEnum *>(p);
const char *value = PyUnicode_AsUTF8(o);
if (value == nullptr) {
PyErr_Format(PyExc_ValueError, "expected a string, got %s", Py_TYPE(o)->tp_name);
@@ -528,8 +528,7 @@ int PyC_ParseStringEnum(PyObject *o, void *p)
return 0;
}
const char *PyC_StringEnum_FindIDFromValue(const struct PyC_StringEnumItems *items,
const int value)
const char *PyC_StringEnum_FindIDFromValue(const PyC_StringEnumItems *items, const int value)
{
for (int i = 0; items[i].id; i++) {
if (items[i].value == value) {
@@ -567,7 +566,7 @@ void PyC_ObSpit(const char *name, PyObject *var)
const PyTypeObject *type = Py_TYPE(var);
fprintf(stderr,
" ref:%d, ptr:%p, type: %s\n",
(int)var->ob_refcnt,
int(var->ob_refcnt),
(void *)var,
type ? type->tp_name : null_str);
}
@@ -591,7 +590,7 @@ void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
BLI_snprintf(result,
result_maxncpy,
" ref=%d, ptr=%p, type=%s, value=%.200s",
(int)var->ob_refcnt,
int(var->ob_refcnt),
(void *)var,
type ? type->tp_name : null_str,
var_str ? PyUnicode_AsUTF8(var_str) : "<error>");
@@ -601,7 +600,7 @@ void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
}
}
void PyC_LineSpit(void)
void PyC_LineSpit()
{
const char *filename;
@@ -619,7 +618,7 @@ void PyC_LineSpit(void)
fprintf(stderr, "%s:%d\n", filename, lineno);
}
void PyC_StackSpit(void)
void PyC_StackSpit()
{
/* NOTE: allow calling from outside python (RNA). */
if (!PyC_IsInterpreterActive()) {
@@ -862,7 +861,7 @@ static void pyc_exception_buffer_handle_system_exit(PyObject *error_type,
/* this version uses traceback module but somehow fails on UI errors */
PyObject *PyC_ExceptionBuffer(void)
PyObject *PyC_ExceptionBuffer()
{
PyObject *traceback_mod = nullptr;
PyObject *format_tb_func = nullptr;
@@ -895,7 +894,7 @@ Py_XDECREF(format_tb_func);
return ret;
}
# else /* verbose, non-threadsafe version */
PyObject *PyC_ExceptionBuffer(void)
PyObject *PyC_ExceptionBuffer()
{
PyObject *stdout_backup = PySys_GetObject("stdout"); /* borrowed */
PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */
@@ -973,7 +972,7 @@ error_cleanup:
}
# endif
PyObject *PyC_ExceptionBuffer_Simple(void)
PyObject *PyC_ExceptionBuffer_Simple()
{
if (!PyErr_Occurred()) {
return nullptr;
@@ -1151,7 +1150,7 @@ void PyC_MainModule_Restore(PyObject *main_mod)
Py_XDECREF(main_mod);
}
bool PyC_IsInterpreterActive(void)
bool PyC_IsInterpreterActive()
{
/* instead of PyThreadState_Get, which calls Py_FatalError */
return (PyThreadState_GetDict() != nullptr);
@@ -1551,7 +1550,7 @@ bool PyC_RunString_AsIntPtr(const char *imports[],
else {
intptr_t val;
val = (intptr_t)PyLong_AsVoidPtr(retval);
val = intptr_t(PyLong_AsVoidPtr(retval));
if (val == 0 && PyErr_Occurred()) {
ok = false;
}
@@ -1642,7 +1641,7 @@ int PyC_Long_AsBool(PyObject *value)
if (UNLIKELY(test == -1 && PyErr_Occurred())) {
return -1;
}
if (UNLIKELY((uint)test > 1)) {
if (UNLIKELY(uint(test) > 1)) {
PyErr_SetString(PyExc_TypeError, "Python number not a bool (0/1)");
return -1;
}
@@ -1659,7 +1658,7 @@ int8_t PyC_Long_AsI8(PyObject *value)
PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C int8");
return -1;
}
return (int8_t)test;
return int8_t(test);
}
int16_t PyC_Long_AsI16(PyObject *value)
@@ -1672,7 +1671,7 @@ int16_t PyC_Long_AsI16(PyObject *value)
PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C int16");
return -1;
}
return (int16_t)test;
return int16_t(test);
}
/* Inlined in header:
@@ -1683,40 +1682,40 @@ int16_t PyC_Long_AsI16(PyObject *value)
uint8_t PyC_Long_AsU8(PyObject *value)
{
const ulong test = PyLong_AsUnsignedLong(value);
if (UNLIKELY(test == (ulong)-1 && PyErr_Occurred())) {
return (uint8_t)-1;
if (UNLIKELY(test == ulong(-1) && PyErr_Occurred())) {
return uint8_t(-1);
}
if (UNLIKELY(test > UINT8_MAX)) {
PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C uint8");
return (uint8_t)-1;
return uint8_t(-1);
}
return (uint8_t)test;
return uint8_t(test);
}
uint16_t PyC_Long_AsU16(PyObject *value)
{
const ulong test = PyLong_AsUnsignedLong(value);
if (UNLIKELY(test == (ulong)-1 && PyErr_Occurred())) {
return (uint16_t)-1;
if (UNLIKELY(test == ulong(-1) && PyErr_Occurred())) {
return uint16_t(-1);
}
if (UNLIKELY(test > UINT16_MAX)) {
PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C uint16");
return (uint16_t)-1;
return uint16_t(-1);
}
return (uint16_t)test;
return uint16_t(test);
}
uint32_t PyC_Long_AsU32(PyObject *value)
{
const ulong test = PyLong_AsUnsignedLong(value);
if (UNLIKELY(test == (ulong)-1 && PyErr_Occurred())) {
return (uint32_t)-1;
if (UNLIKELY(test == ulong(-1) && PyErr_Occurred())) {
return uint32_t(-1);
}
if (UNLIKELY(test > UINT32_MAX)) {
PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C uint32");
return (uint32_t)-1;
return uint32_t(-1);
}
return (uint32_t)test;
return uint32_t(test);
}
/* Inlined in header:

View File

@@ -23,7 +23,7 @@
/** \name GPU Enums
* \{ */
struct PyC_StringEnumItems bpygpu_primtype_items[] = {
PyC_StringEnumItems bpygpu_primtype_items[] = {
{GPU_PRIM_POINTS, "POINTS"},
{GPU_PRIM_LINES, "LINES"},
{GPU_PRIM_TRIS, "TRIS"},
@@ -37,7 +37,7 @@ struct PyC_StringEnumItems bpygpu_primtype_items[] = {
{0, nullptr},
};
struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
PyC_StringEnumItems bpygpu_dataformat_items[] = {
{GPU_DATA_FLOAT, "FLOAT"},
{GPU_DATA_INT, "INT"},
{GPU_DATA_UINT, "UINT"},

View File

@@ -45,7 +45,7 @@ static PyModuleDef pygpu_module_def = {
/*m_free*/ nullptr,
};
PyObject *BPyInit_gpu(void)
PyObject *BPyInit_gpu()
{
PyObject *sys_modules = PyImport_GetModuleDict();
PyObject *submodule;

View File

@@ -50,7 +50,7 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject * /*type*/, PyObject *args, Py
{
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};
PyC_StringEnum prim_type = {bpygpu_primtype_items, GPU_PRIM_NONE};
BPyGPUVertBuf *py_vertbuf = nullptr;
BPyGPUIndexBuf *py_indexbuf = nullptr;

View File

@@ -384,7 +384,7 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject * /*type*/, PyObject *args, P
return nullptr;
}
const struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_DATA_FLOAT};
const 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))
{

View File

@@ -323,7 +323,7 @@ static PyModuleDef pygpu_capabilities_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_capabilities_init(void)
PyObject *bpygpu_capabilities_init()
{
PyObject *submodule;

View File

@@ -31,7 +31,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject * /*type*/, PyObject *args,
const char *error_prefix = "IndexBuf.__new__";
bool ok = true;
struct PyC_StringEnum prim_type = {bpygpu_primtype_items, GPU_PRIM_NONE};
PyC_StringEnum prim_type = {bpygpu_primtype_items, GPU_PRIM_NONE};
PyObject *seq;
uint verts_per_prim;

View File

@@ -457,7 +457,7 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
}
if (py_stencil && py_stencil != Py_None) {
if ((stencil = PyC_Long_AsU32(py_stencil)) == (uint)-1) {
if ((stencil = PyC_Long_AsU32(py_stencil)) == uint(-1)) {
return nullptr;
}
buffers |= GPU_STENCIL_BIT;
@@ -536,7 +536,7 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
PYGPU_FRAMEBUFFER_CHECK_OBJ(self);
int x, y, w, h, channels;
uint slot;
struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_RGBA8};
PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_RGBA8};
BPyGPUBuffer *py_buffer = nullptr;
static const char *_keywords[] = {
@@ -613,7 +613,7 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
w,
h,
channels,
(int)slot,
int(slot),
eGPUDataFormat(pygpu_dataformat.value_found),
py_buffer->buf.as_void);

View File

@@ -33,7 +33,7 @@
/** \name Helper Functions
* \{ */
static bool pygpu_stack_is_push_model_view_ok_or_error(void)
static bool pygpu_stack_is_push_model_view_ok_or_error()
{
if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString(
@@ -44,7 +44,7 @@ static bool pygpu_stack_is_push_model_view_ok_or_error(void)
return true;
}
static bool pygpu_stack_is_push_projection_ok_or_error(void)
static bool pygpu_stack_is_push_projection_ok_or_error()
{
if (GPU_matrix_stack_level_get_projection() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString(
@@ -55,7 +55,7 @@ static bool pygpu_stack_is_push_projection_ok_or_error(void)
return true;
}
static bool pygpu_stack_is_pop_model_view_ok_or_error(void)
static bool pygpu_stack_is_pop_model_view_ok_or_error()
{
if (GPU_matrix_stack_level_get_model_view() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum model-view stack depth reached");
@@ -64,7 +64,7 @@ static bool pygpu_stack_is_pop_model_view_ok_or_error(void)
return true;
}
static bool pygpu_stack_is_pop_projection_ok_or_error(void)
static bool pygpu_stack_is_pop_projection_ok_or_error()
{
if (GPU_matrix_stack_level_get_projection() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum projection stack depth reached");
@@ -606,7 +606,7 @@ static PyModuleDef pygpu_matrix_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_matrix_init(void)
PyObject *bpygpu_matrix_init()
{
PyObject *submodule;

View File

@@ -48,7 +48,7 @@
/** \name GPUOffScreen Common Utilities
* \{ */
static const struct PyC_StringEnumItems pygpu_framebuffer_color_texture_formats[] = {
static const PyC_StringEnumItems pygpu_framebuffer_color_texture_formats[] = {
{GPU_RGBA8, "RGBA8"},
{GPU_RGBA16, "RGBA16"},
{GPU_RGBA16F, "RGBA16F"},
@@ -265,7 +265,7 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject * /*self*/, PyObject *args
{
GPUOffScreen *ofs = nullptr;
int width, height;
struct PyC_StringEnum pygpu_textureformat = {pygpu_framebuffer_color_texture_formats, GPU_RGBA8};
PyC_StringEnum pygpu_textureformat = {pygpu_framebuffer_color_texture_formats, GPU_RGBA8};
char err_out[256];
static const char *_keywords[] = {"width", "height", "format", nullptr};
@@ -368,7 +368,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
MatrixObject *py_mat_view, *py_mat_projection;
PyObject *py_scene, *py_view_layer, *py_region, *py_view3d;
struct Depsgraph *depsgraph;
Depsgraph *depsgraph;
Scene *scene;
ViewLayer *view_layer;
View3D *v3d;

View File

@@ -163,7 +163,7 @@ static PyModuleDef pygpu_platform_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_platform_init(void)
PyObject *bpygpu_platform_init()
{
PyObject *submodule;

View File

@@ -39,7 +39,7 @@ PyDoc_STRVAR(pygpu_select_load_id_doc,
static PyObject *pygpu_select_load_id(PyObject * /*self*/, PyObject *value)
{
uint id;
if ((id = PyC_Long_AsU32(value)) == (uint)-1) {
if ((id = PyC_Long_AsU32(value)) == uint(-1)) {
return nullptr;
}
GPU_select_load_id(id);
@@ -71,7 +71,7 @@ static PyModuleDef pygpu_select_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_select_init(void)
PyObject *bpygpu_select_init()
{
PyObject *submodule;

View File

@@ -58,7 +58,7 @@
" :Attributes: vec3 pos\n" \
" :Uniforms: vec2 viewportSize, float lineWidth\n"
static const struct PyC_StringEnumItems pygpu_shader_builtin_items[] = {
static const PyC_StringEnumItems pygpu_shader_builtin_items[] = {
{GPU_SHADER_3D_FLAT_COLOR, "FLAT_COLOR"},
{GPU_SHADER_3D_IMAGE, "IMAGE"},
{GPU_SHADER_3D_IMAGE_COLOR, "IMAGE_COLOR"},
@@ -70,7 +70,7 @@ static const struct PyC_StringEnumItems pygpu_shader_builtin_items[] = {
{0, nullptr},
};
static const struct PyC_StringEnumItems pygpu_shader_config_items[] = {
static const PyC_StringEnumItems pygpu_shader_config_items[] = {
{GPU_SHADER_CFG_DEFAULT, "DEFAULT"},
{GPU_SHADER_CFG_CLIPPED, "CLIPPED"},
{0, nullptr},
@@ -353,7 +353,7 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
Py_DECREF(seq_fast);
}
}
else if (((values[0] = (int)PyLong_AsLong(params.seq)) != -1) && ELEM(values[0], 0, 1)) {
else if (((values[0] = int(PyLong_AsLong(params.seq))) != -1) && ELEM(values[0], 0, 1)) {
length = 1;
ret = 0;
}
@@ -404,11 +404,11 @@ static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
int length;
if (PyFloat_Check(params.seq)) {
values[0] = (float)PyFloat_AsDouble(params.seq);
values[0] = float(PyFloat_AsDouble(params.seq));
length = 1;
}
else if (PyLong_Check(params.seq)) {
values[0] = (float)PyLong_AsDouble(params.seq);
values[0] = float(PyLong_AsDouble(params.seq));
length = 1;
}
else if (MatrixObject_Check(params.seq)) {
@@ -876,8 +876,8 @@ PyDoc_STRVAR(
" :rtype: :class:`bpy.types.GPUShader`\n");
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};
PyC_StringEnum pygpu_bultinshader = {pygpu_shader_builtin_items};
PyC_StringEnum pygpu_config = {pygpu_shader_config_items, GPU_SHADER_CFG_DEFAULT};
static const char *_keywords[] = {"shader_name", "config", nullptr};
static _PyArg_Parser _parser = {
@@ -999,7 +999,7 @@ PyObject *BPyGPUShader_CreatePyObject(GPUShader *shader, bool is_builtin)
return (PyObject *)self;
}
PyObject *bpygpu_shader_init(void)
PyObject *bpygpu_shader_init()
{
PyObject *submodule;

View File

@@ -27,7 +27,7 @@
/** \name Helper Functions
* \{ */
static const struct PyC_StringEnumItems pygpu_state_blend_items[] = {
static const PyC_StringEnumItems pygpu_state_blend_items[] = {
{GPU_BLEND_NONE, "NONE"},
{GPU_BLEND_ALPHA, "ALPHA"},
{GPU_BLEND_ALPHA_PREMULT, "ALPHA_PREMULT"},
@@ -45,7 +45,7 @@ static const struct PyC_StringEnumItems pygpu_state_blend_items[] = {
{0, nullptr},
};
static const struct PyC_StringEnumItems pygpu_state_depthtest_items[] = {
static const PyC_StringEnumItems pygpu_state_depthtest_items[] = {
{GPU_DEPTH_NONE, "NONE"},
{GPU_DEPTH_ALWAYS, "ALWAYS"},
{GPU_DEPTH_LESS, "LESS"},
@@ -56,7 +56,7 @@ static const struct PyC_StringEnumItems pygpu_state_depthtest_items[] = {
{0, nullptr},
};
static const struct PyC_StringEnumItems pygpu_state_faceculling_items[] = {
static const PyC_StringEnumItems pygpu_state_faceculling_items[] = {
{GPU_CULL_NONE, "NONE"},
{GPU_CULL_FRONT, "FRONT"},
{GPU_CULL_BACK, "BACK"},
@@ -93,7 +93,7 @@ PyDoc_STRVAR(
" :type mode: str\n");
static PyObject *pygpu_state_blend_set(PyObject * /*self*/, PyObject *value)
{
struct PyC_StringEnum pygpu_blend = {pygpu_state_blend_items};
PyC_StringEnum pygpu_blend = {pygpu_state_blend_items};
if (!PyC_ParseStringEnum(value, &pygpu_blend)) {
return nullptr;
}
@@ -121,7 +121,7 @@ PyDoc_STRVAR(pygpu_state_clip_distances_set_doc,
" :type distances_enabled: int\n");
static PyObject *pygpu_state_clip_distances_set(PyObject * /*self*/, PyObject *value)
{
int distances_enabled = (int)PyLong_AsUnsignedLong(value);
int distances_enabled = int(PyLong_AsUnsignedLong(value));
if (distances_enabled == -1) {
return nullptr;
}
@@ -145,7 +145,7 @@ PyDoc_STRVAR(pygpu_state_depth_test_set_doc,
" :type mode: str\n");
static PyObject *pygpu_state_depth_test_set(PyObject * /*self*/, PyObject *value)
{
struct PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items};
PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items};
if (!PyC_ParseStringEnum(value, &pygpu_depth_test)) {
return nullptr;
}
@@ -304,7 +304,7 @@ PyDoc_STRVAR(pygpu_state_line_width_set_doc,
" :type mode: float\n");
static PyObject *pygpu_state_line_width_set(PyObject * /*self*/, PyObject *value)
{
float width = (float)PyFloat_AsDouble(value);
float width = float(PyFloat_AsDouble(value));
if (PyErr_Occurred()) {
return nullptr;
}
@@ -320,7 +320,7 @@ PyDoc_STRVAR(pygpu_state_line_width_get_doc,
static PyObject *pygpu_state_line_width_get(PyObject * /*self*/)
{
float width = GPU_line_width_get();
return PyFloat_FromDouble((double)width);
return PyFloat_FromDouble(double(width));
}
PyDoc_STRVAR(pygpu_state_point_size_set_doc,
@@ -332,7 +332,7 @@ PyDoc_STRVAR(pygpu_state_point_size_set_doc,
" :type mode: float\n");
static PyObject *pygpu_state_point_size_set(PyObject * /*self*/, PyObject *value)
{
float size = (float)PyFloat_AsDouble(value);
float size = float(PyFloat_AsDouble(value));
if (PyErr_Occurred()) {
return nullptr;
}
@@ -355,7 +355,7 @@ static PyObject *pygpu_state_color_mask_set(PyObject * /*self*/, PyObject *args)
return nullptr;
}
GPU_color_mask((bool)r, (bool)g, (bool)b, (bool)a);
GPU_color_mask(bool(r), bool(g), bool(b), bool(a));
Py_RETURN_NONE;
}
@@ -368,7 +368,7 @@ PyDoc_STRVAR(pygpu_state_face_culling_set_doc,
" :type mode: str\n");
static PyObject *pygpu_state_face_culling_set(PyObject * /*self*/, PyObject *value)
{
struct PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items};
PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items};
if (!PyC_ParseStringEnum(value, &pygpu_faceculling)) {
return nullptr;
}
@@ -531,7 +531,7 @@ static PyModuleDef pygpu_state_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_state_init(void)
PyObject *bpygpu_state_init()
{
PyObject *submodule;

View File

@@ -33,7 +33,7 @@
/** \name GPUTexture Common Utilities
* \{ */
static const struct PyC_StringEnumItems pygpu_textureformat_items[] = {
static const PyC_StringEnumItems pygpu_textureformat_items[] = {
{GPU_RGBA8UI, "RGBA8UI"},
{GPU_RGBA8I, "RGBA8I"},
{GPU_RGBA8, "RGBA8"},
@@ -117,7 +117,7 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject * /*self*/, PyObject *args,
int size[3] = {1, 1, 1};
int layers = 0;
int is_cubemap = false;
struct PyC_StringEnum pygpu_textureformat = {pygpu_textureformat_items, GPU_RGBA8};
PyC_StringEnum pygpu_textureformat = {pygpu_textureformat_items, GPU_RGBA8};
BPyGPUBuffer *pybuffer_obj = nullptr;
char err_out[256] = "unknown error. See console";
@@ -179,7 +179,7 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject * /*self*/, PyObject *args,
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) *
size_t data_space_expected = size_t(size[0]) * size[1] * size[2] * max_ii(1, layers) *
component_len * component_size_expected;
if (is_cubemap) {
data_space_expected *= 6 * size[0];
@@ -322,7 +322,7 @@ PyDoc_STRVAR(
static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObject *kwds)
{
BPYGPU_TEXTURE_CHECK_OBJ(self);
struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items};
PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items};
union {
int i[4];
float f[4];
@@ -696,7 +696,7 @@ int bpygpu_ParseTexture(PyObject *o, void *p)
return 1;
}
PyObject *bpygpu_texture_init(void)
PyObject *bpygpu_texture_init()
{
PyObject *submodule;
submodule = bpygpu_create_module(&pygpu_texture_module_def);

View File

@@ -32,7 +32,7 @@ static PyModuleDef pygpu_types_module_def = {
/*m_free*/ nullptr,
};
PyObject *bpygpu_types_init(void)
PyObject *bpygpu_types_init()
{
PyObject *submodule;

View File

@@ -124,7 +124,7 @@ static bool pygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
return false;
}
const uint comp_len = pybuffer.ndim == 1 ? 1 : (uint)pybuffer.shape[1];
const uint comp_len = pybuffer.ndim == 1 ? 1 : uint(pybuffer.shape[1]);
if (pybuffer.shape[0] != vert_len) {
PyErr_Format(
@@ -217,7 +217,7 @@ static int pygpu_vertbuf_fill(GPUVertBuf *buf,
return 0;
}
if (!pygpu_vertbuf_fill_impl(buf, (uint)id, py_seq_data, error_prefix)) {
if (!pygpu_vertbuf_fill_impl(buf, uint(id), py_seq_data, error_prefix)) {
return 0;
}

View File

@@ -22,7 +22,7 @@
* Use with PyArg_ParseTuple's "O&" formatting.
* \{ */
static struct PyC_StringEnumItems pygpu_vertcomptype_items[] = {
static PyC_StringEnumItems pygpu_vertcomptype_items[] = {
{GPU_COMP_I8, "I8"},
{GPU_COMP_U8, "U8"},
{GPU_COMP_I16, "I16"},
@@ -34,7 +34,7 @@ static struct PyC_StringEnumItems pygpu_vertcomptype_items[] = {
{0, nullptr},
};
static struct PyC_StringEnumItems pygpu_vertfetchmode_items[] = {
static PyC_StringEnumItems pygpu_vertfetchmode_items[] = {
{GPU_FETCH_FLOAT, "FLOAT"},
{GPU_FETCH_INT, "INT"},
{GPU_FETCH_INT_TO_FLOAT_UNIT, "INT_TO_FLOAT_UNIT"},
@@ -81,8 +81,8 @@ static PyObject *pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *arg
{
const char *id;
uint len;
struct PyC_StringEnum comp_type = {pygpu_vertcomptype_items, GPU_COMP_I8};
struct PyC_StringEnum fetch_mode = {pygpu_vertfetchmode_items, GPU_FETCH_FLOAT};
PyC_StringEnum comp_type = {pygpu_vertcomptype_items, GPU_COMP_I8};
PyC_StringEnum fetch_mode = {pygpu_vertfetchmode_items, GPU_FETCH_FLOAT};
if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) {
PyErr_SetString(PyExc_ValueError, "Maximum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN));