[Bf-blender-cvs] [91bfea5b052] blender2.8: CPython: py_capi_utils: use more descriptive names for format string utilities.

mano-wii noreply at git.blender.org
Sun Oct 7 17:26:03 CEST 2018


Commit: 91bfea5b052a6276654eb4f71c71707cda3d4305
Author: mano-wii
Date:   Sun Oct 7 12:21:09 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB91bfea5b052a6276654eb4f71c71707cda3d4305

CPython: py_capi_utils: use more descriptive names for format string utilities.

===================================================================

M	source/blender/python/generic/bgl.c
M	source/blender/python/generic/py_capi_utils.h
M	source/blender/python/gpu/gpu_py_element.c

===================================================================

diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index a89525d942f..33ad824bace 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -480,14 +480,16 @@ int BGL_typeSize(int type)
 
 static int gl_buffer_type_from_py_buffer(Py_buffer *pybuffer)
 {
-	const char format = PyC_Formatstr_get(pybuffer->format);
+	const char format = PyC_Formatchar_get(pybuffer->format);
 	Py_ssize_t itemsize = pybuffer->itemsize;
 
-	if (PyC_Formatstr_is_float(format)) {
+	if (PyC_Formatchar_is_floating_type(format)) {
 		if (itemsize == 4) return GL_FLOAT;
 		if (itemsize == 8) return GL_DOUBLE;
 	}
-	if (PyC_Formatstr_is_byte(format) || PyC_Formatstr_is_int(format)) {
+	if (PyC_Formatchar_is_byte_type(format) ||
+	    PyC_Formatchar_is_integer_type(format))
+	{
 		if (itemsize == 1) return GL_BYTE;
 		if (itemsize == 2) return GL_SHORT;
 		if (itemsize == 4) return GL_INT;
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 609f8dc1bed..5ff070d3b75 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -132,7 +132,7 @@ Py_LOCAL_INLINE(int64_t)  PyC_Long_AsI64(PyObject *value) { return (int64_t)PyLo
 Py_LOCAL_INLINE(uint64_t) PyC_Long_AsU64(PyObject *value) { return (uint64_t)PyLong_AsUnsignedLongLong(value); }
 
 /* utils for format string in `struct` module style syntax */
-Py_LOCAL_INLINE(char) PyC_Formatstr_get(const char *typestr)
+Py_LOCAL_INLINE(char) PyC_Formatchar_get(const char *typestr)
 {
 	switch (typestr[0]) {
 		case '!':
@@ -146,7 +146,7 @@ Py_LOCAL_INLINE(char) PyC_Formatstr_get(const char *typestr)
 	}
 }
 
-Py_LOCAL_INLINE(bool) PyC_Formatstr_is_float(char format)
+Py_LOCAL_INLINE(bool) PyC_Formatchar_is_floating_type(char format)
 {
 	switch (format) {
 		case 'f':
@@ -158,7 +158,7 @@ Py_LOCAL_INLINE(bool) PyC_Formatstr_is_float(char format)
 	}
 }
 
-Py_LOCAL_INLINE(bool) PyC_Formatstr_is_int(char format)
+Py_LOCAL_INLINE(bool) PyC_Formatchar_is_integer_type(char format)
 {
 	switch (format) {
 		case 'i':
@@ -180,7 +180,7 @@ Py_LOCAL_INLINE(bool) PyC_Formatstr_is_int(char format)
 	}
 }
 
-Py_LOCAL_INLINE(bool) PyC_Formatstr_is_byte(char format)
+Py_LOCAL_INLINE(bool) PyC_Formatchar_is_byte_type(char format)
 {
 	switch (format) {
 		case 'c':
@@ -192,7 +192,7 @@ Py_LOCAL_INLINE(bool) PyC_Formatstr_is_byte(char format)
 	}
 }
 
-Py_LOCAL_INLINE(bool) PyC_Formatstr_is_bool(char format)
+Py_LOCAL_INLINE(bool) PyC_Formatchar_is_boolean_type(char format)
 {
 	switch (format) {
 		case '?':
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c
index 379cd0836ca..72b593ab432 100644
--- a/source/blender/python/gpu/gpu_py_element.c
+++ b/source/blender/python/gpu/gpu_py_element.c
@@ -92,7 +92,7 @@ static PyObject *bpygpu_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args,
 		}
 
 		if (pybuffer.itemsize != 4 ||
-		    PyC_Formatstr_is_float(PyC_Formatstr_get(pybuffer.format)))
+		    PyC_Formatchar_is_floating_type(PyC_Formatchar_get(pybuffer.format)))
 		{
 			PyErr_Format(PyExc_ValueError,
 			             "Each index must be an 4-bytes integer value");



More information about the Bf-blender-cvs mailing list