From c15439bcdc52f90570dd22fc0f61b94bdf56145d Mon Sep 17 00:00:00 2001 From: mano-wii Date: Thu, 4 Oct 2018 23:52:49 -0300 Subject: Cleanup: use PyModule_AddIntConstant --- source/blender/python/gpu/gpu_py_shader.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index c8193e00f6a..64b208ed49f 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -45,21 +45,18 @@ static void bpygpu_shader_add_enum_objects(PyObject *submodule) { - PyObject *dict = PyModule_GetDict(submodule); - PyObject *item; - -#define PY_DICT_ADD_INT(x) PyDict_SetItemString(dict, #x, item = PyLong_FromLong(x)); Py_DECREF(item) +#define ADDCONST(x) PyModule_AddIntConstant(submodule, #x, x) /* Shaders */ - PY_DICT_ADD_INT(GPU_SHADER_2D_UNIFORM_COLOR); - PY_DICT_ADD_INT(GPU_SHADER_2D_FLAT_COLOR); - PY_DICT_ADD_INT(GPU_SHADER_2D_SMOOTH_COLOR); - PY_DICT_ADD_INT(GPU_SHADER_2D_IMAGE); - PY_DICT_ADD_INT(GPU_SHADER_3D_UNIFORM_COLOR); - PY_DICT_ADD_INT(GPU_SHADER_3D_FLAT_COLOR); - PY_DICT_ADD_INT(GPU_SHADER_3D_SMOOTH_COLOR); - -#undef PY_DICT_ADD_INT + ADDCONST(GPU_SHADER_2D_UNIFORM_COLOR); + ADDCONST(GPU_SHADER_2D_FLAT_COLOR); + ADDCONST(GPU_SHADER_2D_SMOOTH_COLOR); + ADDCONST(GPU_SHADER_2D_IMAGE); + ADDCONST(GPU_SHADER_3D_UNIFORM_COLOR); + ADDCONST(GPU_SHADER_3D_FLAT_COLOR); + ADDCONST(GPU_SHADER_3D_SMOOTH_COLOR); + +#undef ADDCONST } static int bpygpu_pyLong_as_shader_enum(PyObject *o) -- cgit v1.2.3