[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11934] branches/pyapi_devel/source/ blender/python: module rearrange as discussed in bpython meeting.
Campbell Barton
cbarton at metavr.com
Mon Sep 3 22:57:12 CEST 2007
Revision: 11934
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11934
Author: campbellbarton
Date: 2007-09-03 22:57:12 +0200 (Mon, 03 Sep 2007)
Log Message:
-----------
module rearrange as discussed in bpython meeting.
removed the Blender module and Blender.c/h
so now we have...
Blender.BGL -> bpy.gl
Blender.Mathutils -> bpy.math.utils
Blender.Geometry -> bpy.math.geometry
Blender.Noise -> bpy.math.noise
bpy.app.version, datadir. homedir etc. - static vars
bpy.state.event, mode, link - non static blender runtime vars
for details see..
http://wiki.blender.org/index.php/Rewriting_the_2.4x_BPython_API/Meetings#IRC_PyAPI_Meeting_19_August_2007
Modified Paths:
--------------
branches/pyapi_devel/source/blender/python/BPY_interface.c
branches/pyapi_devel/source/blender/python/api2_2x/Draw.c
branches/pyapi_devel/source/blender/python/api2_2x/EXPP_interface.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_config.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_data.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_data.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.h
branches/pyapi_devel/source/blender/python/api2_2x/modules.h
branches/pyapi_devel/source/blender/python/api2_2x/sceneRender.c
Added Paths:
-----------
branches/pyapi_devel/source/blender/python/api2_2x/bpy_app.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_app.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_gl.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_gl.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_state.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_state.h
branches/pyapi_devel/source/blender/python/api2_2x/bpy_utils.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_utils.h
Removed Paths:
-------------
branches/pyapi_devel/source/blender/python/api2_2x/BGL.c
branches/pyapi_devel/source/blender/python/api2_2x/BGL.h
branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
branches/pyapi_devel/source/blender/python/api2_2x/Blender.h
branches/pyapi_devel/source/blender/python/api2_2x/Sys.c
branches/pyapi_devel/source/blender/python/api2_2x/Sys.h
Modified: branches/pyapi_devel/source/blender/python/BPY_interface.c
===================================================================
--- branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-09-03 19:12:36 UTC (rev 11933)
+++ branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-09-03 20:57:12 UTC (rev 11934)
@@ -31,8 +31,6 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-/* TODO - replace g_blenderdict - its null now! */
-
#include <Python.h>
#include "compile.h" /* for the PyCodeObject */
@@ -65,9 +63,9 @@
#include "api2_2x/EXPP_interface.h"
#include "api2_2x/gen_utils.h"
#include "api2_2x/gen_library.h" /* GetPyObjectFromID */
-#include "api2_2x/BGL.h"
-#include "api2_2x/Blender.h"
+#include "api2_2x/bpy_gl.h"
#include "api2_2x/bpy.h"
+#include "api2_2x/bpy_state.h"
#include "api2_2x/Camera.h"
#include "api2_2x/Draw.h"
#include "api2_2x/Object.h"
@@ -310,8 +308,6 @@
init_ourReload( );
//init a global dictionary
- g_blenderdict = NULL;
- g_bpydict = NULL;
g_bpystatedict = NULL;
/* Init the module here! */
Deleted: branches/pyapi_devel/source/blender/python/api2_2x/BGL.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/BGL.c 2007-09-03 19:12:36 UTC (rev 11933)
+++ branches/pyapi_devel/source/blender/python/api2_2x/BGL.c 2007-09-03 20:57:12 UTC (rev 11934)
@@ -1,1582 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * This is a new part of Blender.
- *
- * Contributor(s): Willian P. Germano
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/* This file is the Blender.BGL part of opy_draw.c, from the old
- * bpython/intern dir, with minor changes to adapt it to the new Python
- * implementation. The BGL submodule "wraps" OpenGL functions and constants,
- * allowing script writers to make OpenGL calls in their Python scripts. */
-
-#include "BGL.h" /*This must come first */
-
-#include "MEM_guardedalloc.h"
-#include "gen_utils.h"
-
-static int type_size( int type );
-static BPyGLBufferObject *make_buffer( int type, int ndimensions, int *dimensions );
-
-static char Method_GLBuffer_doc[] =
- "(type, dimensions, [template]) - Create a new GLBuffer object\n\n\
-(type) - The format to store data in\n\
-(dimensions) - An int or sequence specifying the dimensions of the buffer\n\
-[template] - A sequence of matching dimensions to the buffer to be created\n\
- which will be used to initialize the GLBuffer.\n\n\
-If a template is not passed in all fields will be initialized to 0.\n\n\
-The type should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE.\n\
-If the dimensions are specified as an int a linear buffer will be\n\
-created. If a sequence is passed for the dimensions the buffer\n\
-will have len(sequence) dimensions, where the size for each dimension\n\
-is determined by the value in the sequence at that index.\n\n\
-For example, passing [100, 100] will create a 2 dimensional\n\
-square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\
-buffer which is twice as deep as it is wide or high.";
-
-static PyObject *Method_GLBuffer( PyObject * self, PyObject * args );
-
-/* Buffer sequence methods */
-
-static int GLBuffer_len( BPyGLBufferObject * self );
-static PyObject *GLBuffer_item( BPyGLBufferObject * self, int i );
-static PyObject *GLBuffer_slice( BPyGLBufferObject * self, int begin, int end );
-static int GLBuffer_ass_item( BPyGLBufferObject * self, int i, PyObject * v );
-static int GLBuffer_ass_slice( BPyGLBufferObject * self, int begin, int end,
- PyObject * seq );
-
-static PySequenceMethods GLBuffer_SeqMethods = {
- ( inquiry ) GLBuffer_len, /*sq_length */
- ( binaryfunc ) 0, /*sq_concat */
- ( intargfunc ) 0, /*sq_repeat */
- ( intargfunc ) GLBuffer_item, /*sq_item */
- ( intintargfunc ) GLBuffer_slice, /*sq_slice */
- ( intobjargproc ) GLBuffer_ass_item, /*sq_ass_item */
- ( intintobjargproc ) GLBuffer_ass_slice, /*sq_ass_slice */
-};
-
-static void GLBuffer_dealloc( BPyGLBufferObject * self );
-static PyObject *GLBuffer_tolist( BPyGLBufferObject * self );
-static PyObject *GLBuffer_dimensions( BPyGLBufferObject * self );
-static PyObject *GLBuffer_getattr( BPyGLBufferObject * self, char *name );
-static PyObject *GLBuffer_repr( BPyGLBufferObject * self );
-
-PyTypeObject BPyGLBuffer_Type = {
- PyObject_HEAD_INIT( NULL ) /* required python macro */
- 0, /*ob_size */
- "buffer", /*tp_name */
- sizeof( BPyGLBufferObject ), /*tp_basicsize */
- 0, /*tp_itemsize */
- ( destructor ) GLBuffer_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) GLBuffer_getattr, /*tp_getattr */
- ( setattrfunc ) 0, /*tp_setattr */
- ( cmpfunc ) 0, /*tp_compare */
- ( reprfunc ) GLBuffer_repr, /*tp_repr */
- 0, /*tp_as_number */
- &GLBuffer_SeqMethods, /*tp_as_sequence */
-};
-
-/* #ifndef __APPLE__ */
-
-#define BGL_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
- arg_def##nargs arg_list; \
- ret_def_##ret; \
- if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
- ret_set_##ret gl##funcname (arg_var##nargs arg_list);\
- ret_ret_##ret; \
-}
-
-#define BGLU_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
- arg_def##nargs arg_list; \
- ret_def_##ret; \
- if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
- ret_set_##ret glu##funcname (arg_var##nargs arg_list);\
- ret_ret_##ret; \
-}
-
-/* #endif */
-
-PyObject *BGL_Init( void );
-
-/********/
-static int type_size(int type)
-{
- switch (type) {
- case GL_BYTE:
- return sizeof(char);
- case GL_SHORT:
- return sizeof(short);
- case GL_INT:
- return sizeof(int);
- case GL_FLOAT:
- return sizeof(float);
- case GL_DOUBLE:
- return sizeof(double);
- }
- return -1;
-}
-
-static BPyGLBufferObject *make_buffer(int type, int ndimensions, int *dimensions)
-{
- BPyGLBufferObject *buffer;
- void *buf= NULL;
- int i, size, length;
-
- length= 1;
- for (i=0; i<ndimensions; i++)
- length*= dimensions[i];
-
- size= type_size(type);
-
- buf= MEM_mallocN(length*size, "GLBuffer buffer");
-
- buffer= (BPyGLBufferObject *) PyObject_NEW(BPyGLBufferObject, &BPyGLBuffer_Type);
- buffer->parent= NULL;
- buffer->ndimensions= ndimensions;
- buffer->dimensions= dimensions;
- buffer->type= type;
- buffer->buf.asvoid= buf;
-
- for (i= 0; i<length; i++) {
- if (type==GL_BYTE)
- buffer->buf.asbyte[i]= 0;
- else if (type==GL_SHORT)
- buffer->buf.asshort[i]= 0;
- else if (type==GL_INT)
- buffer->buf.asint[i]= 0;
- else if (type==GL_FLOAT)
- buffer->buf.asfloat[i]= 0.0f;
- else if (type==GL_DOUBLE)
- buffer->buf.asdouble[i]= 0.0;
- }
- return buffer;
-}
-
-static PyObject *Method_GLBuffer (PyObject *self, PyObject *args)
-{
- PyObject *length_ob= NULL, *template= NULL;
- BPyGLBufferObject *buffer;
-
- int i, type;
- int *dimensions = 0, ndimensions = 0;
-
- if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "expected an int and one or two PyObjects");
-
- if (type!=GL_BYTE && type!=GL_SHORT && type!=GL_INT && type!=GL_FLOAT && type!=GL_DOUBLE) {
- PyErr_SetString(PyExc_AttributeError, "type");
- return NULL;
- }
-
- if (PyNumber_Check(length_ob)) {
- ndimensions= 1;
- dimensions= MEM_mallocN(ndimensions*sizeof(int), "GLBuffer dimensions");
- dimensions[0]= PyInt_AsLong(length_ob);
- } else if (PySequence_Check(length_ob)) {
- ndimensions= PySequence_Length(length_ob);
- dimensions= MEM_mallocN(ndimensions*sizeof(int), "GLBuffer dimensions");
- for (i=0; i<ndimensions; i++) {
- PyObject *ob= PySequence_GetItem(length_ob, i);
-
- if (!PyNumber_Check(ob)) dimensions[i]= 1;
- else dimensions[i]= PyInt_AsLong(ob);
- Py_DECREF(ob);
- }
- }
-
- buffer= make_buffer(type, ndimensions, dimensions);
- if (template && ndimensions) {
- if (GLBuffer_ass_slice(buffer, 0, dimensions[0], template)) {
- Py_DECREF(buffer);
- return NULL;
- }
- }
-
- return (PyObject *) buffer;
-}
-
-/*@ GLBuffer sequence methods */
-
-static int GLBuffer_len(BPyGLBufferObject *self)
-{
- return self->dimensions[0];
-}
-
-static PyObject *GLBuffer_item(BPyGLBufferObject *self, int i)
-{
- if (i >= self->dimensions[0]) {
- PyErr_SetString(PyExc_IndexError, "array index out of range");
- return NULL;
- }
-
- if (self->ndimensions==1) {
- switch (self->type) {
- case GL_BYTE: return Py_BuildValue("b", self->buf.asbyte[i]);
- case GL_SHORT: return Py_BuildValue("h", self->buf.asshort[i]);
- case GL_INT: return Py_BuildValue("i", self->buf.asint[i]);
- case GL_FLOAT: return PyFloat_FromDouble(self->buf.asfloat[i]);
- case GL_DOUBLE: return Py_BuildValue("d", self->buf.asdouble[i]);
- }
- } else {
- BPyGLBufferObject *newbuf;
- int j, length, size;
-
- length= 1;
- for (j=1; j < self->ndimensions; j++) {
- length*= self->dimensions[j];
- }
- size= type_size(self->type);
-
- newbuf= (BPyGLBufferObject *) PyObject_NEW(BPyGLBufferObject, &BPyGLBuffer_Type);
-
- Py_INCREF(self);
- newbuf->parent= (PyObject *)self;
-
- newbuf->ndimensions= self->ndimensions-1;
- newbuf->type= self->type;
- newbuf->buf.asvoid= self->buf.asbyte + i*length*size;
- newbuf->dimensions= MEM_mallocN(newbuf->ndimensions*sizeof(int),
- "GLBuffer dimensions");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list