[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20044] trunk/blender/source: on second thought its less trouble to make a python script that makes all the getset 's in the array, apologies to Alex for suggesting this be dynamic :/
Campbell Barton
ideasman42 at gmail.com
Sun May 3 21:47:15 CEST 2009
Revision: 20044
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20044
Author: campbellbarton
Date: 2009-05-03 21:47:13 +0200 (Sun, 03 May 2009)
Log Message:
-----------
on second thought its less trouble to make a python script that makes all the getset's in the array, apologies to Alex for suggesting this be dynamic :/
included python script to print out getsets as a comment
Modified Paths:
--------------
trunk/blender/source/blender/python/BPY_interface.c
trunk/blender/source/blender/python/api2_2x/Mathutils.c
trunk/blender/source/blender/python/api2_2x/Mathutils.h
trunk/blender/source/blender/python/api2_2x/vector.c
trunk/blender/source/blender/python/api2_2x/vector.h
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
Modified: trunk/blender/source/blender/python/BPY_interface.c
===================================================================
--- trunk/blender/source/blender/python/BPY_interface.c 2009-05-03 17:52:03 UTC (rev 20043)
+++ trunk/blender/source/blender/python/BPY_interface.c 2009-05-03 19:47:13 UTC (rev 20044)
@@ -285,8 +285,6 @@
next_script = script->id.next;
free_libblock( &G.main->script, script );
}
-
- Mathutils_Free(NULL);
Py_Finalize( );
Modified: trunk/blender/source/blender/python/api2_2x/Mathutils.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Mathutils.c 2009-05-03 17:52:03 UTC (rev 20043)
+++ trunk/blender/source/blender/python/api2_2x/Mathutils.c 2009-05-03 19:47:13 UTC (rev 20044)
@@ -107,11 +107,6 @@
/*----------------------------MODULE INIT-------------------------*/
/* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */
-void Mathutils_Free(void * closure)
-{
- Vector_Free();
-}
-
#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef M_Mathutils_module_def = {
{}, /* m_base */
@@ -122,7 +117,7 @@
0, /* m_reload */
0, /* m_traverse */
0, /* m_clear */
- Mathutils_Free, /* m_free */
+ 0, /* m_free */
};
#endif
@@ -133,11 +128,6 @@
//seed the generator for the rand function
BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF));
- /* needed for getseters */
- if(!(vector_Type.tp_flags & Py_TPFLAGS_READY))
- if (Vector_Init() != 0) /* setup dynamic getset array */
- return NULL;
-
if( PyType_Ready( &vector_Type ) < 0 )
return NULL;
if( PyType_Ready( &matrix_Type ) < 0 )
Modified: trunk/blender/source/blender/python/api2_2x/Mathutils.h
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Mathutils.h 2009-05-03 17:52:03 UTC (rev 20043)
+++ trunk/blender/source/blender/python/api2_2x/Mathutils.h 2009-05-03 19:47:13 UTC (rev 20044)
@@ -38,7 +38,6 @@
#include "euler.h"
PyObject *Mathutils_Init( const char * from );
-void Mathutils_Free(void *);
PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat);
PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec);
Modified: trunk/blender/source/blender/python/api2_2x/vector.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/vector.c 2009-05-03 17:52:03 UTC (rev 20043)
+++ trunk/blender/source/blender/python/api2_2x/vector.c 2009-05-03 19:47:13 UTC (rev 20044)
@@ -39,17 +39,6 @@
#define SWIZZLE_VALID_AXIS 0x4
#define SWIZZLE_AXIS 0x3
-
-/* An array of getseters, some of which have members on the stack and some on
- the heap.
-
- Vector_dyn_getseters: The getseter structures. Terminated with a NULL sentinel.
- Vector_dyn_names: All the names of the getseters that were allocated on the heap.
- Each name is terminated with a null character, but there is
- currently no way to find the length of this array. */
-PyGetSetDef* Vector_dyn_getseters = NULL;
-char* Vector_dyn_names = NULL;
-
/*-------------------------DOC STRINGS ---------------------------*/
char Vector_Zero_doc[] = "() - set all values in the vector to 0";
char Vector_Normalize_doc[] = "() - normalize the vector";
@@ -1105,41 +1094,6 @@
}
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef Vector_getseters[] = {
- {"x",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector X axis",
- (void *)'X'},
- {"y",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Y axis",
- (void *)'Y'},
- {"z",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Z axis",
- (void *)'Z'},
- {"w",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Z axis",
- (void *)'W'},
- {"length",
- (getter)Vector_getLength, (setter)Vector_setLength,
- "Vector Length",
- NULL},
- {"magnitude",
- (getter)Vector_getLength, (setter)Vector_setLength,
- "Vector Length",
- NULL},
- {"wrapped",
- (getter)Vector_getWrapped, (setter)NULL,
- "True when this wraps blenders internal data",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
/* Get a new Vector according to the provided swizzle. This function has little
error checking, as we are in control of the inputs: the closure is set by us
in Vector_createSwizzleGetSeter. */
@@ -1264,164 +1218,423 @@
}
}
-/* Create a getseter that operates on the axes defined in swizzle.
- Parameters:
- gsd: An empty PyGetSetDef object. This will be modified.
- swizzle: An array of axis indices.
- dimensions: The number of axes to swizzle. Must be >= 2 and <=
- MAX_DIMENSIONS.
- name: A pointer to string that the name will be stored in. This is
- purely to reduce the number of allocations. Before this function
- returns, name will be advanced to the point immediately after
- the name of the new getseter. Therefore, do not attempt to read
- its contents. */
-static void Vector_createSwizzleGetSeter
-(
- PyGetSetDef *gsd,
- unsigned short *swizzle,
- size_t dimensions,
- char **name
-)
-{
- const char axes[] = {'x', 'y', 'z', 'w'};
- unsigned int closure;
- int i;
+/*****************************************************************************/
+/* Python attributes get/set structure: */
+/*****************************************************************************/
+static PyGetSetDef Vector_getseters[] = {
+ {"x",
+ (getter)Vector_getAxis, (setter)Vector_setAxis,
+ "Vector X axis",
+ (void *)'X'},
+ {"y",
+ (getter)Vector_getAxis, (setter)Vector_setAxis,
+ "Vector Y axis",
+ (void *)'Y'},
+ {"z",
+ (getter)Vector_getAxis, (setter)Vector_setAxis,
+ "Vector Z axis",
+ (void *)'Z'},
+ {"w",
+ (getter)Vector_getAxis, (setter)Vector_setAxis,
+ "Vector Z axis",
+ (void *)'W'},
+ {"length",
+ (getter)Vector_getLength, (setter)Vector_setLength,
+ "Vector Length",
+ NULL},
+ {"magnitude",
+ (getter)Vector_getLength, (setter)Vector_setLength,
+ "Vector Length",
+ NULL},
+ {"wrapped",
+ (getter)Vector_getWrapped, (setter)NULL,
+ "True when this wraps blenders internal data",
+ NULL},
- /* Convert the index array into named axes. Store the name in the string
- that was passed in, and make the getseter structure point to the same
- address. */
- gsd->name = *name;
- for (i = 0; i < dimensions; i++)
- gsd->name[i] = axes[swizzle[i]];
- gsd->name[i] = '\0';
- /* Advance the name pointer to the next available address. */
- (*name) = (*name) + dimensions + 1;
-
- gsd->get = (getter)Vector_getSwizzle;
- gsd->set = (setter)Vector_setSwizzle;
-
- gsd->doc = Vector_swizzle_doc;
-
- /* Pack the axes into a single value to use as the closure. Pack these in
- in reverse so they come out in the right order when unpacked. */
- closure = 0;
- for (i = MAX_DIMENSIONS - 1; i >= 0; i--)
- {
- closure = closure << SWIZZLE_BITS_PER_AXIS;
- if (i < dimensions)
- closure = closure | swizzle[i] | SWIZZLE_VALID_AXIS;
- }
- gsd->closure = (void*) closure;
-}
+ /* autogenerated swizzle attrs, see python script below */
+ {"xx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 36 */
+ {"xxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 292 */
+ {"xxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2340 */
+ {"xxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2852 */
+ {"xxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3364 */
+ {"xxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3876 */
+ {"xxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 356 */
+ {"xxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2404 */
+ {"xxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2916 */
+ {"xxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3428 */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list