diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-02 17:08:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-02 17:08:26 +0300 |
commit | 72e2a0cfb6f8e4d21b33982bbd572f10c20e947c (patch) | |
tree | e850c2de5b3068be3b0822d27348b632c901ca41 /source/blender/python/gpu/gpu_py_shader.c | |
parent | d07bc44a96ce6838cd25edca61127021fbebe4d1 (diff) |
Cleanup: py-gpu error checks
Move gpu initialization checks to the start of each function instead
of mixing with argument parsing.
Diffstat (limited to 'source/blender/python/gpu/gpu_py_shader.c')
-rw-r--r-- | source/blender/python/gpu/gpu_py_shader.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 59a416a0c3a..52fe6f2d912 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -105,6 +105,8 @@ static int bpygpu_uniform_location_get(GPUShader *shader, const char *name, cons static PyObject *bpygpu_shader_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) { + BPYGPU_IS_INIT_OR_ERROR_OBJ; + struct { const char *vertexcode; const char *fragcode; @@ -118,8 +120,7 @@ static PyObject *bpygpu_shader_new(PyTypeObject *UNUSED(type), PyObject *args, P "libcode", "defines", NULL}; static _PyArg_Parser _parser = {"ss|$sss:GPUShader.__new__", _keywords, 0}; - if (!bpygpu_is_initialized() || - !_PyArg_ParseTupleAndKeywordsFast( + if (!_PyArg_ParseTupleAndKeywordsFast( args, kwds, &_parser, ¶ms.vertexcode, ¶ms.fragcode, ¶ms.geocode, ¶ms.libcode, ¶ms.defines)) @@ -717,11 +718,11 @@ PyDoc_STRVAR(bpygpu_shader_from_builtin_doc, ); static PyObject *bpygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg) { + BPYGPU_IS_INIT_OR_ERROR_OBJ; + GPUBuiltinShader shader_id; - if (!bpygpu_is_initialized() || - !bpygpu_ParseBultinShaderEnum(arg, &shader_id)) - { + if (!bpygpu_ParseBultinShaderEnum(arg, &shader_id)) { return NULL; } |