[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34837] trunk/blender/source/blender/ python: python api renaming and added headers for some files which didnt have one, no functionality change.
Campbell Barton
ideasman42 at gmail.com
Mon Feb 14 05:15:28 CET 2011
Revision: 34837
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34837
Author: campbellbarton
Date: 2011-02-14 04:15:25 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
python api renaming and added headers for some files which didnt have one, no functionality change.
Modified Paths:
--------------
trunk/blender/source/blender/python/generic/CMakeLists.txt
trunk/blender/source/blender/python/generic/IDProp.c
trunk/blender/source/blender/python/generic/IDProp.h
trunk/blender/source/blender/python/generic/bgl.c
trunk/blender/source/blender/python/generic/bgl.h
trunk/blender/source/blender/python/generic/mathutils.c
trunk/blender/source/blender/python/generic/mathutils.h
trunk/blender/source/blender/python/generic/mathutils_geometry.c
trunk/blender/source/blender/python/generic/mathutils_geometry.h
trunk/blender/source/blender/python/generic/py_capi_utils.c
trunk/blender/source/blender/python/intern/CMakeLists.txt
trunk/blender/source/blender/python/intern/bpy.c
trunk/blender/source/blender/python/intern/bpy_app.c
trunk/blender/source/blender/python/intern/bpy_app.h
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/python/intern/bpy_operator.c
trunk/blender/source/blender/python/intern/bpy_operator.h
trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
trunk/blender/source/blender/python/intern/bpy_operator_wrap.h
trunk/blender/source/blender/python/intern/bpy_props.c
trunk/blender/source/blender/python/intern/bpy_props.h
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/intern/bpy_rna.h
trunk/blender/source/blender/python/intern/bpy_rna_array.c
trunk/blender/source/blender/python/intern/bpy_rna_callback.c
trunk/blender/source/blender/python/intern/bpy_util.c
trunk/blender/source/blender/python/intern/bpy_util.h
Added Paths:
-----------
trunk/blender/source/blender/python/generic/mathutils_Color.c
trunk/blender/source/blender/python/generic/mathutils_Color.h
trunk/blender/source/blender/python/generic/mathutils_Euler.c
trunk/blender/source/blender/python/generic/mathutils_Euler.h
trunk/blender/source/blender/python/generic/mathutils_Matrix.c
trunk/blender/source/blender/python/generic/mathutils_Matrix.h
trunk/blender/source/blender/python/generic/mathutils_Quaternion.c
trunk/blender/source/blender/python/generic/mathutils_Quaternion.h
trunk/blender/source/blender/python/generic/mathutils_Vector.c
trunk/blender/source/blender/python/generic/mathutils_Vector.h
trunk/blender/source/blender/python/generic/noise_py_api.c
trunk/blender/source/blender/python/generic/noise_py_api.h
trunk/blender/source/blender/python/intern/bpy_driver.h
Removed Paths:
-------------
trunk/blender/source/blender/python/generic/mathutils_color.c
trunk/blender/source/blender/python/generic/mathutils_color.h
trunk/blender/source/blender/python/generic/mathutils_euler.c
trunk/blender/source/blender/python/generic/mathutils_euler.h
trunk/blender/source/blender/python/generic/mathutils_matrix.c
trunk/blender/source/blender/python/generic/mathutils_matrix.h
trunk/blender/source/blender/python/generic/mathutils_quat.c
trunk/blender/source/blender/python/generic/mathutils_quat.h
trunk/blender/source/blender/python/generic/mathutils_vector.c
trunk/blender/source/blender/python/generic/mathutils_vector.h
trunk/blender/source/blender/python/generic/noise.c
Modified: trunk/blender/source/blender/python/generic/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/generic/CMakeLists.txt 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/CMakeLists.txt 2011-02-14 04:15:25 UTC (rev 34837)
@@ -34,13 +34,13 @@
blf_py_api.c
bpy_internal_import.c
mathutils.c
- mathutils_color.c
- mathutils_euler.c
+ mathutils_Color.c
+ mathutils_Euler.c
+ mathutils_Matrix.c
+ mathutils_Quaternion.c
+ mathutils_Vector.c
mathutils_geometry.c
- mathutils_matrix.c
- mathutils_quat.c
- mathutils_vector.c
- noise.c
+ noise_py_api.c
py_capi_utils.c
IDProp.h
@@ -48,13 +48,15 @@
blf_py_api.h
bpy_internal_import.h
mathutils.h
- mathutils_color.h
- mathutils_euler.h
+ mathutils_Color.h
+ mathutils_Euler.h
+ mathutils_Matrix.h
+ mathutils_Quaternion.h
+ mathutils_Vector.h
mathutils_geometry.h
- mathutils_matrix.h
- mathutils_quat.h
- mathutils_vector.h
+ noise_py_api.h
py_capi_utils.h
)
+
blender_add_lib(bf_python_ext "${SRC}" "${INC}")
Modified: trunk/blender/source/blender/python/generic/IDProp.c
===================================================================
--- trunk/blender/source/blender/python/generic/IDProp.c 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/IDProp.c 2011-02-14 04:15:25 UTC (rev 34837)
@@ -23,6 +23,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <Python.h>
+
#include "IDProp.h"
#include "MEM_guardedalloc.h"
Modified: trunk/blender/source/blender/python/generic/IDProp.h
===================================================================
--- trunk/blender/source/blender/python/generic/IDProp.h 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/IDProp.h 2011-02-14 04:15:25 UTC (rev 34837)
@@ -22,7 +22,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include <Python.h>
+#ifndef IDPROP_H
+#define IDPROP_H
struct ID;
struct IDProperty;
@@ -62,3 +63,5 @@
#define IDPROP_ITER_KEYS 0
#define IDPROP_ITER_ITEMS 1
+
+#endif /* IDPROP_H */
Modified: trunk/blender/source/blender/python/generic/bgl.c
===================================================================
--- trunk/blender/source/blender/python/generic/bgl.c 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/bgl.c 2011-02-14 04:15:25 UTC (rev 34837)
@@ -31,6 +31,8 @@
* The BGL submodule "wraps" OpenGL functions and constants,
* allowing script writers to make OpenGL calls in their Python scripts. */
+#include <Python.h>
+
#include "bgl.h" /*This must come first */
#include <GL/glew.h>
#include "MEM_guardedalloc.h"
@@ -38,7 +40,6 @@
#include "BLI_utildefines.h"
-
static char Method_Buffer_doc[] =
"(type, dimensions, [template]) - Create a new Buffer object\n\n\
(type) - The format to store data in\n\
Modified: trunk/blender/source/blender/python/generic/bgl.h
===================================================================
--- trunk/blender/source/blender/python/generic/bgl.h 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/bgl.h 2011-02-14 04:15:25 UTC (rev 34837)
@@ -36,8 +36,6 @@
#ifndef BGL_H
#define BGL_H
-#include <Python.h>
-
PyObject *BPyInit_bgl(void);
/*@ Create a buffer object */
Modified: trunk/blender/source/blender/python/generic/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils.c 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/mathutils.c 2011-02-14 04:15:25 UTC (rev 34837)
@@ -87,6 +87,8 @@
* - geometry.BarycentricTransform -> barycentric_transform
*/
+#include <Python.h>
+
#include "mathutils.h"
#include "BLI_math.h"
Modified: trunk/blender/source/blender/python/generic/mathutils.h
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils.h 2011-02-14 03:43:28 UTC (rev 34836)
+++ trunk/blender/source/blender/python/generic/mathutils.h 2011-02-14 04:15:25 UTC (rev 34837)
@@ -31,8 +31,6 @@
#ifndef MATHUTILS_H
#define MATHUTILS_H
-#include <Python.h>
-
/* Can cast different mathutils types to this, use for generic funcs */
extern char BaseMathObject_Wrapped_doc[];
@@ -50,11 +48,11 @@
BASE_MATH_MEMBERS(data)
} BaseMathObject;
-#include "mathutils_vector.h"
-#include "mathutils_matrix.h"
-#include "mathutils_quat.h"
-#include "mathutils_euler.h"
-#include "mathutils_color.h"
+#include "mathutils_Vector.h"
+#include "mathutils_Matrix.h"
+#include "mathutils_Quaternion.h"
+#include "mathutils_Euler.h"
+#include "mathutils_Color.h"
#include "mathutils_geometry.h"
PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * );
Copied: trunk/blender/source/blender/python/generic/mathutils_Color.c (from rev 34824, trunk/blender/source/blender/python/generic/mathutils_color.c)
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils_Color.c (rev 0)
+++ trunk/blender/source/blender/python/generic/mathutils_Color.c 2011-02-14 04:15:25 UTC (rev 34837)
@@ -0,0 +1,554 @@
+/*
+ * $Id$
+ *
+ * ***** 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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Python.h>
+
+#include "mathutils.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#define COLOR_SIZE 3
+
+//----------------------------------mathutils.Color() -------------------
+//makes a new color for you to play with
+static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ float col[3]= {0.0f, 0.0f, 0.0f};
+
+ if(kwds && PyDict_Size(kwds)) {
+ PyErr_SetString(PyExc_TypeError, "mathutils.Color(): takes no keyword args");
+ return NULL;
+ }
+
+ switch(PyTuple_GET_SIZE(args)) {
+ case 0:
+ break;
+ case 1:
+ if((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
+ return NULL;
+ break;
+ default:
+ PyErr_SetString(PyExc_TypeError, "mathutils.Color(): more then a single arg given");
+ return NULL;
+ }
+ return newColorObject(col, Py_NEW, type);
+}
+
+//-----------------------------METHODS----------------------------
+
+/* note: BaseMath_ReadCallback must be called beforehand */
+static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits)
+{
+ PyObject *ret;
+ int i;
+
+ ret= PyTuple_New(COLOR_SIZE);
+
+ if(ndigits >= 0) {
+ for(i= 0; i < COLOR_SIZE; i++) {
+ PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits)));
+ }
+ }
+ else {
+ for(i= 0; i < COLOR_SIZE; i++) {
+ PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->col[i]));
+ }
+ }
+
+ return ret;
+}
+
+static char Color_copy_doc[] =
+".. function:: copy()\n"
+"\n"
+" Returns a copy of this color.\n"
+"\n"
+" :return: A copy of the color.\n"
+" :rtype: :class:`Color`\n"
+"\n"
+" .. note:: use this to get a copy of a wrapped color with no reference to the original data.\n"
+;
+static PyObject *Color_copy(ColorObject *self)
+{
+ if(!BaseMath_ReadCallback(self))
+ return NULL;
+
+ return newColorObject(self->col, Py_NEW, Py_TYPE(self));
+}
+
+//----------------------------print object (internal)--------------
+//print the object to screen
+
+static PyObject *Color_repr(ColorObject * self)
+{
+ PyObject *ret, *tuple;
+
+ if(!BaseMath_ReadCallback(self))
+ return NULL;
+
+ tuple= Color_ToTupleExt(self, -1);
+
+ ret= PyUnicode_FromFormat("Color(%R)", tuple);
+
+ Py_DECREF(tuple);
+ return ret;
+}
+
+//------------------------tp_richcmpr
+//returns -1 execption, 0 false, 1 true
+static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op)
+{
+ PyObject *res;
+ int ok= -1; /* zero is true */
+
+ if (ColorObject_Check(a) && ColorObject_Check(b)) {
+ ColorObject *colA= (ColorObject*)a;
+ ColorObject *colB= (ColorObject*)b;
+
+ if(!BaseMath_ReadCallback(colA) || !BaseMath_ReadCallback(colB))
+ return NULL;
+
+ ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
+ }
+
+ switch (op) {
+ case Py_NE:
+ ok = !ok; /* pass through */
+ case Py_EQ:
+ res = ok ? Py_False : Py_True;
+ break;
+
+ case Py_LT:
+ case Py_LE:
+ case Py_GT:
+ case Py_GE:
+ res = Py_NotImplemented;
+ break;
+ default:
+ PyErr_BadArgument();
+ return NULL;
+ }
+
+ return Py_INCREF(res), res;
+}
+
+//---------------------SEQUENCE PROTOCOLS------------------------
+//----------------------------len(object)------------------------
+//sequence length
+static int Color_len(ColorObject *UNUSED(self))
+{
+ return COLOR_SIZE;
+}
+//----------------------------object[]---------------------------
+//sequence accessor (get)
+static PyObject *Color_item(ColorObject * self, int i)
+{
+ if(i<0) i= COLOR_SIZE-i;
+
+ if(i < 0 || i >= COLOR_SIZE) {
+ PyErr_SetString(PyExc_IndexError, "color[attribute]: array index out of range");
+ return NULL;
+ }
+
+ if(!BaseMath_ReadIndexCallback(self, i))
+ return NULL;
+
+ return PyFloat_FromDouble(self->col[i]);
+
+}
+//----------------------------object[]-------------------------
+//sequence accessor (set)
+static int Color_ass_item(ColorObject * self, int i, PyObject * value)
+{
+ float f = PyFloat_AsDouble(value);
+
+ if(f == -1 && PyErr_Occurred()) { // parsed item not a number
+ PyErr_SetString(PyExc_TypeError, "color[attribute] = x: argument not a number");
+ return -1;
+ }
+
+ if(i<0) i= COLOR_SIZE-i;
+
+ if(i < 0 || i >= COLOR_SIZE){
+ PyErr_SetString(PyExc_IndexError, "color[attribute] = x: array assignment index out of range");
+ return -1;
+ }
+
+ self->col[i] = f;
+
+ if(!BaseMath_WriteIndexCallback(self, i))
+ return -1;
+
+ return 0;
+}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list