From d07bc44a96ce6838cd25edca61127021fbebe4d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Jan 2019 00:55:07 +1100 Subject: Revert file rename from T59773 fix Mixing file rename with other changes should be avoided. Using 'module_py_api' convention here is in keeping with imbuf, idprop, blf & bmesh. No reason for gpu to have a different convention. --- source/blender/python/gpu/CMakeLists.txt | 4 +- source/blender/python/gpu/gpu_py.c | 165 --------------------------- source/blender/python/gpu/gpu_py.h | 34 ------ source/blender/python/gpu/gpu_py_api.c | 165 +++++++++++++++++++++++++++ source/blender/python/gpu/gpu_py_api.h | 34 ++++++ source/blender/python/gpu/gpu_py_batch.c | 2 +- source/blender/python/gpu/gpu_py_element.c | 2 +- source/blender/python/gpu/gpu_py_offscreen.c | 2 +- source/blender/python/gpu/gpu_py_shader.c | 2 +- source/blender/python/intern/bpy_interface.c | 2 +- 10 files changed, 206 insertions(+), 206 deletions(-) delete mode 100644 source/blender/python/gpu/gpu_py.c delete mode 100644 source/blender/python/gpu/gpu_py.h create mode 100644 source/blender/python/gpu/gpu_py_api.c create mode 100644 source/blender/python/gpu/gpu_py_api.h (limited to 'source') diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt index fb5eb07a7d8..fcb0b828ffb 100644 --- a/source/blender/python/gpu/CMakeLists.txt +++ b/source/blender/python/gpu/CMakeLists.txt @@ -34,7 +34,7 @@ set(INC_SYS ) set(SRC - gpu_py.c + gpu_py_api.c gpu_py_batch.c gpu_py_element.c gpu_py_matrix.c @@ -45,7 +45,7 @@ set(SRC gpu_py_vertex_buffer.c gpu_py_vertex_format.c - gpu_py.h + gpu_py_api.h gpu_py_batch.h gpu_py_element.h gpu_py_matrix.h diff --git a/source/blender/python/gpu/gpu_py.c b/source/blender/python/gpu/gpu_py.c deleted file mode 100644 index 5470e791011..00000000000 --- a/source/blender/python/gpu/gpu_py.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gpu/gpu_py_api.c - * \ingroup bpygpu - * - * Experimental Python API, not considered public yet (called '_gpu'), - * we may re-expose as public later. - * - * - Use ``bpygpu_`` for local API. - * - Use ``BPyGPU`` for public API. - */ - -#include - -#include "BLI_utildefines.h" - -#include "../generic/python_utildefines.h" - -#include "GPU_init_exit.h" -#include "GPU_primitive.h" - -#include "gpu_py_matrix.h" -#include "gpu_py_select.h" -#include "gpu_py_types.h" - -#include "gpu_py.h" /* own include */ - - -/* -------------------------------------------------------------------- */ - -/** \name Utils to invalidate functions - * \{ */ - -bool bpygpu_is_initialized(void) -{ - if (!GPU_is_initialized()) { - PyErr_SetString( - PyExc_SystemError, - "GPU functions for drawing are not available in background mode"); - - return false; - } - - return true; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Primitive Type Utils - * \{ */ - -int bpygpu_ParsePrimType(PyObject *o, void *p) -{ - Py_ssize_t mode_id_len; - const char *mode_id = _PyUnicode_AsStringAndSize(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(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 - * \{ */ - - -PyDoc_STRVAR(GPU_doc, -"This module provides Python wrappers for the GPU implementation in Blender. " -"Some higher level functions can be found in the `gpu_extras` module. " -"\n\n" -"Submodules:\n" -"\n" -".. toctree::\n" -" :maxdepth: 1\n" -"\n" -" gpu.types.rst\n" -" gpu.shader.rst\n" -" gpu.matrix.rst\n" -" gpu.select.rst\n" -"\n" -); -static struct PyModuleDef GPU_module_def = { - PyModuleDef_HEAD_INIT, - .m_name = "gpu", - .m_doc = GPU_doc, -}; - -PyObject *BPyInit_gpu(void) -{ - PyObject *sys_modules = PyImport_GetModuleDict(); - PyObject *submodule; - PyObject *mod; - - mod = PyModule_Create(&GPU_module_def); - - PyModule_AddObject(mod, "types", (submodule = BPyInit_gpu_types())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - - PyModule_AddObject(mod, "matrix", (submodule = BPyInit_gpu_matrix())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - - PyModule_AddObject(mod, "select", (submodule = BPyInit_gpu_select())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - - PyModule_AddObject(mod, "shader", (submodule = BPyInit_gpu_shader())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - - return mod; -} - -/** \} */ diff --git a/source/blender/python/gpu/gpu_py.h b/source/blender/python/gpu/gpu_py.h deleted file mode 100644 index d3ee7b56def..00000000000 --- a/source/blender/python/gpu/gpu_py.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gpu/gpu_py_api.h - * \ingroup bpygpu - */ - -#ifndef __GPU_PY_H__ -#define __GPU_PY_H__ - -bool bpygpu_is_initialized(void); - -int bpygpu_ParsePrimType(PyObject *o, void *p); - -PyObject *BPyInit_gpu(void); - -#endif /* __GPU_PY_H__ */ diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c new file mode 100644 index 00000000000..f237561246a --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.c @@ -0,0 +1,165 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_api.c + * \ingroup bpygpu + * + * Experimental Python API, not considered public yet (called '_gpu'), + * we may re-expose as public later. + * + * - Use ``bpygpu_`` for local API. + * - Use ``BPyGPU`` for public API. + */ + +#include + +#include "BLI_utildefines.h" + +#include "../generic/python_utildefines.h" + +#include "GPU_init_exit.h" +#include "GPU_primitive.h" + +#include "gpu_py_matrix.h" +#include "gpu_py_select.h" +#include "gpu_py_types.h" + +#include "gpu_py_api.h" /* own include */ + + +/* -------------------------------------------------------------------- */ + +/** \name Utils to invalidate functions + * \{ */ + +bool bpygpu_is_initialized(void) +{ + if (!GPU_is_initialized()) { + PyErr_SetString( + PyExc_SystemError, + "GPU functions for drawing are not available in background mode"); + + return false; + } + + return true; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Primitive Type Utils + * \{ */ + +int bpygpu_ParsePrimType(PyObject *o, void *p) +{ + Py_ssize_t mode_id_len; + const char *mode_id = _PyUnicode_AsStringAndSize(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(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 + * \{ */ + + +PyDoc_STRVAR(GPU_doc, +"This module provides Python wrappers for the GPU implementation in Blender. " +"Some higher level functions can be found in the `gpu_extras` module. " +"\n\n" +"Submodules:\n" +"\n" +".. toctree::\n" +" :maxdepth: 1\n" +"\n" +" gpu.types.rst\n" +" gpu.shader.rst\n" +" gpu.matrix.rst\n" +" gpu.select.rst\n" +"\n" +); +static struct PyModuleDef GPU_module_def = { + PyModuleDef_HEAD_INIT, + .m_name = "gpu", + .m_doc = GPU_doc, +}; + +PyObject *BPyInit_gpu(void) +{ + PyObject *sys_modules = PyImport_GetModuleDict(); + PyObject *submodule; + PyObject *mod; + + mod = PyModule_Create(&GPU_module_def); + + PyModule_AddObject(mod, "types", (submodule = BPyInit_gpu_types())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + + PyModule_AddObject(mod, "matrix", (submodule = BPyInit_gpu_matrix())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + + PyModule_AddObject(mod, "select", (submodule = BPyInit_gpu_select())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + + PyModule_AddObject(mod, "shader", (submodule = BPyInit_gpu_shader())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + + return mod; +} + +/** \} */ diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h new file mode 100644 index 00000000000..2b4d8fa515c --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.h @@ -0,0 +1,34 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_api.h + * \ingroup bpygpu + */ + +#ifndef __GPU_PY_API_H__ +#define __GPU_PY_API_H__ + +bool bpygpu_is_initialized(void); + +int bpygpu_ParsePrimType(PyObject *o, void *p); + +PyObject *BPyInit_gpu(void); + +#endif /* __GPU_PY_API_H__ */ diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index aa687ecaff5..93274e33cc4 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -44,7 +44,7 @@ #include "../generic/py_capi_utils.h" -#include "gpu_py.h" +#include "gpu_py_api.h" #include "gpu_py_shader.h" #include "gpu_py_vertex_buffer.h" #include "gpu_py_element.h" diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c index b996e859bc7..592c761ffbc 100644 --- a/source/blender/python/gpu/gpu_py_element.c +++ b/source/blender/python/gpu/gpu_py_element.c @@ -36,7 +36,7 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_utildefines.h" -#include "gpu_py.h" +#include "gpu_py_api.h" #include "gpu_py_element.h" /* own include */ diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 2725b55a5da..3ce90c5d648 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -53,7 +53,7 @@ #include "../generic/py_capi_utils.h" -#include "gpu_py.h" +#include "gpu_py_api.h" #include "gpu_py_offscreen.h" /* own include */ diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 3c50900c688..59a416a0c3a 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -36,7 +36,7 @@ #include "../generic/python_utildefines.h" #include "../mathutils/mathutils.h" -#include "gpu_py.h" +#include "gpu_py_api.h" #include "gpu_py_shader.h" /* own include */ #include "gpu_py_vertex_format.h" diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 3b4e8c0904c..e17e7562f2a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -74,7 +74,7 @@ #include "../generic/blf_py_api.h" #include "../generic/idprop_py_api.h" #include "../generic/imbuf_py_api.h" -#include "../gpu/gpu_py.h" +#include "../gpu/gpu_py_api.h" #include "../bmesh/bmesh_py_api.h" #include "../mathutils/mathutils.h" -- cgit v1.2.3