[Bf-blender-cvs] [fdbc962] framebuffer: Rename PyGPUOffScreen -> BPy_GPUOffScreen

Campbell Barton noreply at git.blender.org
Mon Oct 19 18:42:13 CEST 2015


Commit: fdbc962fc61819a73253b7388ce727d2f82e3d73
Author: Campbell Barton
Date:   Tue Oct 20 03:33:55 2015 +1100
Branches: framebuffer
https://developer.blender.org/rBfdbc962fc61819a73253b7388ce727d2f82e3d73

Rename PyGPUOffScreen -> BPy_GPUOffScreen

Generally Py prefix is kept for CPython API

Also added the GPUOffScreen class to the module so it can be accessed for documentation.

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

M	doc/python_api/rst_from_bmesh_opdefines.py
M	doc/python_api/sphinx_doc_gen.py
M	source/blender/python/intern/gpu_offscreen.c

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

diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py
index fcfe0c2..c93be66 100644
--- a/doc/python_api/rst_from_bmesh_opdefines.py
+++ b/doc/python_api/rst_from_bmesh_opdefines.py
@@ -163,6 +163,9 @@ def main():
 
         for i, l in enumerate(b):
             l = l.strip()
+            # casts
+            l = l.replace("(int)", "")
+
             l = l.replace("{", "(")
             l = l.replace("}", ")")
 
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index f68d6bf..62276b0 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1799,6 +1799,7 @@ def write_rst_importable_modules(basepath):
         # C_modules
         "aud"                  : "Audio System",
         "blf"                  : "Font Drawing",
+        "gpu.offscreen"                  : "GPU OffScreen",
         "bmesh"                : "BMesh Module",
         "bmesh.types"          : "BMesh Types",
         "bmesh.utils"          : "BMesh Utilities",
diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index 1468faa..30b6c49 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -62,9 +62,9 @@
 typedef struct {
 	PyObject_HEAD
 	GPUOffScreen *ofs;
-} PyGPUOffScreen;
+} BPy_GPUOffScreen;
 
-static int bpy_gpu_offscreen_valid_check(PyGPUOffScreen *py_gpu_ofs, const char *error_prefix)
+static int bpy_gpu_offscreen_valid_check(BPy_GPUOffScreen *py_gpu_ofs, const char *error_prefix)
 {
 	if (UNLIKELY(py_gpu_ofs->ofs == NULL)) {
 		PyErr_Format(PyExc_ReferenceError,
@@ -85,28 +85,28 @@ static int bpy_gpu_offscreen_valid_check(PyGPUOffScreen *py_gpu_ofs, const char
 #define UINT_IS_NEG(n) ((n) > INT_MAX)
 
 PyDoc_STRVAR(pygpu_offscreen_width_doc, "Texture width.\n\n:type: i");
-static PyObject *pygpu_offscreen_width_get(PyGPUOffScreen *self, void *UNUSED(type))
+static PyObject *pygpu_offscreen_width_get(BPy_GPUOffScreen *self, void *UNUSED(type))
 {
 	BPY_GPU_OFFSCREEN_CHECK_OBJ(self, "width");
 	return PyLong_FromLong(GPU_offscreen_width(self->ofs));
 }
 
 PyDoc_STRVAR(pygpu_offscreen_height_doc, "Texture height.\n\n:type: int");
-static PyObject *pygpu_offscreen_height_get(PyGPUOffScreen *self, void *UNUSED(type))
+static PyObject *pygpu_offscreen_height_get(BPy_GPUOffScreen *self, void *UNUSED(type))
 {
 	BPY_GPU_OFFSCREEN_CHECK_OBJ(self, "height");
 	return PyLong_FromLong(GPU_offscreen_height(self->ofs));
 }
 
 PyDoc_STRVAR(pygpu_offscreen_framebuffer_object_doc, "Framebuffer object.\n\n:type: int");
-static PyObject *pygpu_offscreen_framebuffer_object_get(PyGPUOffScreen *self, void *UNUSED(type))
+static PyObject *pygpu_offscreen_framebuffer_object_get(BPy_GPUOffScreen *self, void *UNUSED(type))
 {
 	BPY_GPU_OFFSCREEN_CHECK_OBJ(self, "framebuffer object");
 	return PyLong_FromLong(GPU_offscreen_fb_object(self->ofs));
 }
 
 PyDoc_STRVAR(pygpu_offscreen_color_object_doc, "Color object.\n\n:type: int");
-static PyObject *pygpu_offscreen_color_object_get(PyGPUOffScreen *self, void *UNUSED(type))
+static PyObject *pygpu_offscreen_color_object_get(BPy_GPUOffScreen *self, void *UNUSED(type))
 {
 	BPY_GPU_OFFSCREEN_CHECK_OBJ(self, "color object");
 	return PyLong_FromLong(GPU_offscreen_color_object(self->ofs));
@@ -120,7 +120,7 @@ PyDoc_STRVAR(pygpu_offscreen_bind_doc,
 "   :param save: save OpenGL current states\n"
 "   :type save: bool\n"
 );
-static PyObject *pygpu_offscreen_bind(PyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_bind(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
 {
 	static const char *kwlist[] = {"save", NULL};
 	bool save = true;
@@ -146,7 +146,7 @@ PyDoc_STRVAR(pygpu_offscreen_unbind_doc,
 "   :param restore: restore OpenGL previous states\n"
 "   :type restore: bool\n"
 );
-static PyObject *pygpu_offscreen_unbind(PyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_unbind(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
 {
 	static const char *kwlist[] = {"restore", NULL};
 	bool restore = true;
@@ -210,7 +210,7 @@ PyDoc_STRVAR(pygpu_offscreen_draw_view3d_doc,
 "   :param projection_matrix: Projection Matrix\n"
 "   :type projection_matrix: :class:`mathutils.Matrix`\n"
 );
-static PyObject *pygpu_offscreen_draw_view3d(PyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
 {
 	static const char *kwlist[] = {"scene", "view3d", "region", "projection_matrix", "modelview_matrix", NULL};
 
@@ -264,7 +264,7 @@ PyDoc_STRVAR(pygpu_offscreen_free_doc,
 "   Free the offscreen object\n"
 "   The framebuffer, texture and render objects will no longer be accessible.\n"
 );
-static PyObject *pygpu_offscreen_free(PyGPUOffScreen *self)
+static PyObject *pygpu_offscreen_free(BPy_GPUOffScreen *self)
 {
 	BPY_GPU_OFFSCREEN_CHECK_OBJ(self, "free");
 
@@ -273,7 +273,7 @@ static PyObject *pygpu_offscreen_free(PyGPUOffScreen *self)
 	Py_RETURN_NONE;
 }
 
-static void PyGPUOffScreen__tp_dealloc(PyGPUOffScreen *self)
+static void BPy_GPUOffScreen__tp_dealloc(BPy_GPUOffScreen *self)
 {
 	if (self->ofs)
 		GPU_offscreen_free(self->ofs);
@@ -301,13 +301,13 @@ PyDoc_STRVAR(py_gpu_offscreen_doc,
 "\n"
 "   This object gives access to off screen buffers.\n"
 );
-static PyTypeObject PyGPUOffScreen_Type = {
+static PyTypeObject BPy_GPUOffScreen_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"GPUOffScreen",                              /* tp_name */
-	sizeof(PyGPUOffScreen),                      /* tp_basicsize */
+	sizeof(BPy_GPUOffScreen),                      /* tp_basicsize */
 	0,                                           /* tp_itemsize */
 	/* methods */
-	(destructor)PyGPUOffScreen__tp_dealloc,      /* tp_dealloc */
+	(destructor)BPy_GPUOffScreen__tp_dealloc,      /* tp_dealloc */
 	NULL,                                        /* tp_print */
 	NULL,                                        /* tp_getattr */
 	NULL,                                        /* tp_setattr */
@@ -356,8 +356,8 @@ static PyTypeObject PyGPUOffScreen_Type = {
 
 static PyObject *BPy_GPU_OffScreen_CreatePyObject(GPUOffScreen *ofs)
 {
-	PyGPUOffScreen *self;
-	self = PyObject_New(PyGPUOffScreen, &PyGPUOffScreen_Type);
+	BPy_GPUOffScreen *self;
+	self = PyObject_New(BPy_GPUOffScreen, &BPy_GPUOffScreen_Type);
 	self->ofs = ofs;
 	return (PyObject *)self;
 }
@@ -443,12 +443,19 @@ PyObject *BPyInit_gpu_offscreen(void)
 	PyObject *submodule;
 
 	/* Register the 'GPUOffscreen' class */
-	if (PyType_Ready(&PyGPUOffScreen_Type)) {
+	if (PyType_Ready(&BPy_GPUOffScreen_Type)) {
 		return NULL;
 	}
 
 	submodule = PyModule_Create(&BPy_GPU_offscreen_module_def);
 
+#define MODULE_TYPE_ADD(s, t) \
+	PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
+
+	MODULE_TYPE_ADD(submodule, BPy_GPUOffScreen_Type);
+
+#undef MODULE_TYPE_ADD
+
 	return submodule;
 }




More information about the Bf-blender-cvs mailing list