Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <mano-wii>2021-02-22 14:26:45 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-02-22 14:35:52 +0300
commit086d70e910a09185e220169342367a0c95ade0fc (patch)
treeafbb7111ce365bcd61fd6cd307e34c01accb6b19 /source/blender/python/gpu/gpu_py_api.c
parent78c3caf3c1b87f449837b11c903ddeaf00afe7b9 (diff)
GPU Python: Use 'PyC_ParseStringEnum' to parse items
Currently the GPU module for python has different ways to handle enums. - Organizing items in `PyC_StringEnumItems` arrays and parsing them with `PyC_ParseStringEnum`. - Using dedicated functions for each type of enum (`bpygpu_ParsePrimType`, `pygpu_ParseVertCompType` and `pygpu_ParseVertFetchMode`). Although apparently more efficient (especially `pygpu_ParseVertCompType` which transforms strings into integers for simple comparison), these dedicated functions duplicate functionality, increase the complexity of the code and consequently make it less readable. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D10456
Diffstat (limited to 'source/blender/python/gpu/gpu_py_api.c')
-rw-r--r--source/blender/python/gpu/gpu_py_api.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index 38e9b61e147..7213dc59886 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -31,7 +31,6 @@
#include "../generic/python_utildefines.h"
#include "GPU_init_exit.h"
-#include "GPU_primitive.h"
#include "gpu_py_matrix.h"
#include "gpu_py_select.h"
@@ -59,50 +58,6 @@ bool bpygpu_is_init_or_error(void)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Primitive Type Utils
- * \{ */
-
-int bpygpu_ParsePrimType(PyObject *o, void *p)
-{
- Py_ssize_t mode_id_len;
- const char *mode_id = PyUnicode_AsUTF8AndSize(o, &mode_id_len);
- if (mode_id == NULL) {
- PyErr_Format(PyExc_ValueError, "expected a string, got %s", Py_TYPE(o)->tp_name);
- return 0;
- }
-#define MATCH_ID(id) \
- if (mode_id_len == strlen(STRINGIFY(id))) { \
- if (STREQ(mode_id, STRINGIFY(id))) { \
- mode = GPU_PRIM_##id; \
- goto success; \
- } \
- } \
- ((void)0)
-
- GPUPrimType mode;
- MATCH_ID(POINTS);
- MATCH_ID(LINES);
- MATCH_ID(TRIS);
- MATCH_ID(LINE_STRIP);
- MATCH_ID(LINE_LOOP);
- MATCH_ID(TRI_STRIP);
- MATCH_ID(TRI_FAN);
- MATCH_ID(LINES_ADJ);
- MATCH_ID(TRIS_ADJ);
- MATCH_ID(LINE_STRIP_ADJ);
-
-#undef MATCH_ID
- PyErr_Format(PyExc_ValueError, "unknown type literal: '%s'", mode_id);
- return 0;
-
-success:
- (*(GPUPrimType *)p) = mode;
- return 1;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name GPU Module
* \{ */