[Bf-blender-cvs] [b7e1660d405] master: Cleanup: Use 'pygpu_' prefix in the cpython GPU module

Germano Cavalcante noreply at git.blender.org
Wed Feb 17 14:39:15 CET 2021


Commit: b7e1660d405d9d73f1aff54358a6d2d1461a75d0
Author: Germano Cavalcante
Date:   Wed Feb 17 10:16:41 2021 -0300
Branches: master
https://developer.blender.org/rBb7e1660d405d9d73f1aff54358a6d2d1461a75d0

Cleanup: Use 'pygpu_' prefix in the cpython GPU module

`py_` prefix can be confused with the Python's own API's.

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

M	source/blender/python/gpu/gpu_py_api.c
M	source/blender/python/gpu/gpu_py_batch.c
M	source/blender/python/gpu/gpu_py_element.c
M	source/blender/python/gpu/gpu_py_matrix.c
M	source/blender/python/gpu/gpu_py_offscreen.c
M	source/blender/python/gpu/gpu_py_select.c
M	source/blender/python/gpu/gpu_py_shader.c
M	source/blender/python/gpu/gpu_py_types.c
M	source/blender/python/gpu/gpu_py_vertex_buffer.c
M	source/blender/python/gpu/gpu_py_vertex_format.c

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

diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index eb2fd1f7304..dcc8484319e 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -105,13 +105,13 @@ success:
 /** \name GPU Module
  * \{ */
 
-PyDoc_STRVAR(GPU_doc,
+PyDoc_STRVAR(pygpu_doc,
              "This module provides Python wrappers for the GPU implementation in Blender.\n"
              "Some higher level functions can be found in the `gpu_extras` module.");
-static struct PyModuleDef GPU_module_def = {
+static struct PyModuleDef pygpu_module_def = {
     PyModuleDef_HEAD_INIT,
     .m_name = "gpu",
-    .m_doc = GPU_doc,
+    .m_doc = pygpu_doc,
 };
 
 PyObject *BPyInit_gpu(void)
@@ -120,7 +120,7 @@ PyObject *BPyInit_gpu(void)
   PyObject *submodule;
   PyObject *mod;
 
-  mod = PyModule_Create(&GPU_module_def);
+  mod = PyModule_Create(&pygpu_module_def);
 
   PyModule_AddObject(mod, "types", (submodule = bpygpu_types_init()));
   PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 9fb7aea162a..0e4cc4d2219 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -48,7 +48,7 @@
 /** \name Utility Functions
  * \{ */
 
-static bool py_batch_is_program_or_error(BPyGPUBatch *self)
+static bool pygpu_batch_is_program_or_error(BPyGPUBatch *self)
 {
   if (!self->batch->shader) {
     PyErr_SetString(PyExc_RuntimeError, "batch does not have any program assigned to it");
@@ -63,7 +63,7 @@ static bool py_batch_is_program_or_error(BPyGPUBatch *self)
 /** \name GPUBatch Type
  * \{ */
 
-static PyObject *py_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
 {
   BPYGPU_IS_INIT_OR_ERROR_OBJ;
 
@@ -121,7 +121,7 @@ static PyObject *py_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObje
   return (PyObject *)ret;
 }
 
-PyDoc_STRVAR(py_Batch_vertbuf_add_doc,
+PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc,
 ".. method:: vertbuf_add(buf)\n"
 "\n"
 "   Add another vertex buffer to the Batch.\n"
@@ -134,7 +134,7 @@ PyDoc_STRVAR(py_Batch_vertbuf_add_doc,
 "   :param buf: The vertex buffer that will be added to the batch.\n"
 "   :type buf: :class:`gpu.types.GPUVertBuf`\n"
 );
-static PyObject *py_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
+static PyObject *pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
 {
   if (!BPyGPUVertBuf_Check(py_buf)) {
     PyErr_Format(PyExc_TypeError, "Expected a GPUVertBuf, got %s", Py_TYPE(py_buf)->tp_name);
@@ -167,7 +167,7 @@ static PyObject *py_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
 }
 
 PyDoc_STRVAR(
-    py_Batch_program_set_doc,
+    pygpu_batch_program_set_doc,
     ".. method:: program_set(program)\n"
     "\n"
     "   Assign a shader to this batch that will be used for drawing when not overwritten later.\n"
@@ -177,7 +177,7 @@ PyDoc_STRVAR(
     "\n"
     "   :param program: The program/shader the batch will use in future draw calls.\n"
     "   :type program: :class:`gpu.types.GPUShader`\n");
-static PyObject *py_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
+static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
 {
   if (!BPyGPUShader_Check(py_shader)) {
     PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
@@ -208,7 +208,7 @@ static PyObject *py_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader
   Py_RETURN_NONE;
 }
 
-PyDoc_STRVAR(py_Batch_draw_doc,
+PyDoc_STRVAR(pygpu_batch_draw_doc,
              ".. method:: draw(program=None)\n"
              "\n"
              "   Run the drawing program with the parameters assigned to the batch.\n"
@@ -216,7 +216,7 @@ PyDoc_STRVAR(py_Batch_draw_doc,
              "   :param program: Program that performs the drawing operations.\n"
              "      If ``None`` is passed, the last program set to this batch will run.\n"
              "   :type program: :class:`gpu.types.GPUShader`\n");
-static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
+static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
 {
   BPyGPUShader *py_program = NULL;
 
@@ -224,7 +224,7 @@ static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
     return NULL;
   }
   if (py_program == NULL) {
-    if (!py_batch_is_program_or_error(self)) {
+    if (!pygpu_batch_is_program_or_error(self)) {
       return NULL;
     }
   }
@@ -236,42 +236,42 @@ static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
   Py_RETURN_NONE;
 }
 
-static PyObject *py_Batch_program_use_begin(BPyGPUBatch *self)
+static PyObject *pygpu_batch_program_use_begin(BPyGPUBatch *self)
 {
-  if (!py_batch_is_program_or_error(self)) {
+  if (!pygpu_batch_is_program_or_error(self)) {
     return NULL;
   }
   GPU_shader_bind(self->batch->shader);
   Py_RETURN_NONE;
 }
 
-static PyObject *py_Batch_program_use_end(BPyGPUBatch *self)
+static PyObject *pygpu_batch_program_use_end(BPyGPUBatch *self)
 {
-  if (!py_batch_is_program_or_error(self)) {
+  if (!pygpu_batch_is_program_or_error(self)) {
     return NULL;
   }
   GPU_shader_unbind();
   Py_RETURN_NONE;
 }
 
-static struct PyMethodDef py_Batch_methods[] = {
-    {"vertbuf_add", (PyCFunction)py_Batch_vertbuf_add, METH_O, py_Batch_vertbuf_add_doc},
-    {"program_set", (PyCFunction)py_Batch_program_set, METH_O, py_Batch_program_set_doc},
-    {"draw", (PyCFunction)py_Batch_draw, METH_VARARGS, py_Batch_draw_doc},
-    {"_program_use_begin", (PyCFunction)py_Batch_program_use_begin, METH_NOARGS, ""},
-    {"_program_use_end", (PyCFunction)py_Batch_program_use_end, METH_NOARGS, ""},
+static struct PyMethodDef pygpu_batch__tp_methods[] = {
+    {"vertbuf_add", (PyCFunction)pygpu_batch_vertbuf_add, METH_O, pygpu_batch_vertbuf_add_doc},
+    {"program_set", (PyCFunction)pygpu_batch_program_set, METH_O, pygpu_batch_program_set_doc},
+    {"draw", (PyCFunction)pygpu_batch_draw, METH_VARARGS, pygpu_batch_draw_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},
 };
 
 #ifdef USE_GPU_PY_REFERENCES
 
-static int py_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
+static int pygpu_batch__tp_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
 {
   Py_VISIT(self->references);
   return 0;
 }
 
-static int py_Batch_clear(BPyGPUBatch *self)
+static int pygpu_batch__tp_clear(BPyGPUBatch *self)
 {
   Py_CLEAR(self->references);
   return 0;
@@ -279,14 +279,14 @@ static int py_Batch_clear(BPyGPUBatch *self)
 
 #endif
 
-static void py_Batch_dealloc(BPyGPUBatch *self)
+static void pygpu_batch__tp_dealloc(BPyGPUBatch *self)
 {
   GPU_batch_discard(self->batch);
 
 #ifdef USE_GPU_PY_REFERENCES
   if (self->references) {
     PyObject_GC_UnTrack(self);
-    py_Batch_clear(self);
+    pygpu_batch__tp_clear(self);
     Py_XDECREF(self->references);
   }
 #endif
@@ -295,7 +295,7 @@ static void py_Batch_dealloc(BPyGPUBatch *self)
 }
 
 PyDoc_STRVAR(
-    py_gpu_batch_doc,
+    pygpu_batch__tp_doc,
     ".. class:: GPUBatch(type, buf, elem=None)\n"
     "\n"
     "   Reusable container for drawable geometry.\n"
@@ -319,17 +319,17 @@ PyDoc_STRVAR(
 PyTypeObject BPyGPUBatch_Type = {
     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch",
     .tp_basicsize = sizeof(BPyGPUBatch),
-    .tp_dealloc = (destructor)py_Batch_dealloc,
+    .tp_dealloc = (destructor)pygpu_batch__tp_dealloc,
 #ifdef USE_GPU_PY_REFERENCES
     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
-    .tp_doc = py_gpu_batch_doc,
-    .tp_traverse = (traverseproc)py_Batch_traverse,
-    .tp_clear = (inquiry)py_Batch_clear,
+    .tp_doc = pygpu_batch__tp_doc,
+    .tp_traverse = (traverseproc)pygpu_batch__tp_traverse,
+    .tp_clear = (inquiry)pygpu_batch__tp_clear,
 #else
     .tp_flags = Py_TPFLAGS_DEFAULT,
 #endif
-    .tp_methods = py_Batch_methods,
-    .tp_new = py_Batch_new,
+    .tp_methods = pygpu_batch__tp_methods,
+    .tp_new = pygpu_batch__tp_new,
 };
 
 /** \} */
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c
index 0a1aecde986..f43338c42d2 100644
--- a/source/blender/python/gpu/gpu_py_element.c
+++ b/source/blender/python/gpu/gpu_py_element.c
@@ -39,7 +39,7 @@
 /** \name IndexBuf Type
  * \{ */
 
-static PyObject *py_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
 {
   BPYGPU_IS_INIT_OR_ERROR_OBJ;
 
@@ -175,13 +175,13 @@ static PyObject *py_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyO
   return BPyGPUIndexBuf_CreatePyObject(GPU_indexbuf_build(&builder));
 }
 
-static void py_IndexBuf_dealloc(BPyGPUIndexBuf *self)
+static void pygpu_IndexBuf__tp_dealloc(BPyGPUIndexBuf *self)
 {
   GPU_indexbuf_discard(self->elem);
   Py_TYPE(self)->tp_free(self);
 }
 
-PyDoc_STRVAR(py_gpu_element_doc,
+PyDoc_STRVAR(pygpu_IndexBuf__tp_doc,
              ".. class:: GPUIndexBuf(type, seq)\n"
              "\n"
              "   Contains an index buffer.\n"
@@ -199,10 +199,10 @@ PyDoc_STRVAR(py_gpu_element_doc,
 PyTypeObject BPyGPUIndexBuf_Type = {
     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUIndexBuf",
     .tp_basicsize = sizeof(BPyGPUIndexBuf),
-    .tp_dealloc = (destructor)py_IndexBuf_dealloc,
+    .tp_dealloc = (destructor)pygpu_IndexBuf__tp_dealloc,
     .tp_flags = Py_TPFLAGS_DEFAULT,
-    .tp_doc = py_gpu_element_doc,
-    .tp_new = py_IndexBuf_new,
+    .tp_doc = pygpu_IndexBuf__tp_doc,
+    .tp_new = pygpu_IndexBuf__tp_new,
 };
 
 /** \} */
diff --git a/source/blender/python/gpu/gpu_py_matrix.c b/source/blender/python/gpu/gpu_py_matrix.c
index 05e0a416b94..df7c82379b3 100644
--- a/source/blender/python/gpu/gpu_py_matrix.c
+++ b/source/blender/python/gpu/gpu_py_matrix.c
@@ -44,7 +44,7 @@
 /** \name Helper Functions
  * \{ */
 
-static bool py_st

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list