Author: ArcRiley
Date: 2008-03-10 18:19:28 -0400 (Mon, 10 Mar 2008)
New Revision: 1128

Modified:
   trunk/pysoy/src/_datatypes/BodyPosition.pxi
   trunk/pysoy/src/_datatypes/soy._datatypes.pxd
Log:
Ticket #946 :
  * added a quick shortcut to trim down __add__ code
  * now clearly shows that the Pyrex processor is unaware of type(self)


Modified: trunk/pysoy/src/_datatypes/BodyPosition.pxi
===================================================================
--- trunk/pysoy/src/_datatypes/BodyPosition.pxi 2008-03-10 22:05:57 UTC (rev 
1127)
+++ trunk/pysoy/src/_datatypes/BodyPosition.pxi 2008-03-10 22:19:28 UTC (rev 
1128)
@@ -36,35 +36,27 @@
     else :
       raise TypeError("parent must be a soy.bodies.Body, list, or tuple")
 
+
   def __add__(self, value) :
+    cdef float* _position
+    #
     if self._body == NULL :
-      if type(value) == int or type(value) == float :
-        return soy._datatypes.BodyPosition(((<soy.bodies.Body> 
self._body)._position[0] + value,
-                                           (<soy.bodies.Body> 
self._body)._position[1] + value,
-                                           (<soy.bodies.Body> 
self._body)._position[2] + value))
-      if isinstance(value, soy._datatypes.BodyPosition) :
-        return soy._datatypes.BodyPosition(((<soy.bodies.Body> 
self._body)._position[0] + value.x,
-                                           (<soy.bodies.Body> 
self._body)._position[1] + value.y,
-                                           (<soy.bodies.Body> 
self._body)._position[2] + value.z))
-      if type(value) == tuple or type(value) == list and len(value) == 3 :
-        return soy._datatypes.BodyPosition(((<soy.bodies.Body> 
self._body)._position[0] + value[0],
-                                           (<soy.bodies.Body> 
self._body)._position[1] + value[1],
-                                           (<soy.bodies.Body> 
self._body)._position[2] + value[2]))
-      return NotImplemented
+      _position = self._position
     else :
-      if type(value) == int or type(value) == float :
-        return soy._datatypes.BodyPosition((self._position[0] + value,
-                                           self._position[1] + value,
-                                           self._position[2] + value))
-      if isinstance(value, soy._datatypes.BodyPosition) :
-        return soy._datatypes.BodyPosition((self._position[0] + value.x,
-                                           self._position[1] + value.y,
-                                           self._position[2] + value.z))
-      if type(value) == tuple or type(value) == list and len(value) == 3 :
-        return soy._datatypes.BodyPosition((self._position[0] + value[0],
-                                           self._position[1] + value[1],
-                                           self._position[2] + value[2]))
-      return NotImplemented
+      _position = (<soy.bodies.Body> self._body)._position
+    if type(value) == int or type(value) == float :
+      return soy._datatypes.BodyPosition((_position[0] + value,
+                                          _position[1] + value,
+                                          _position[2] + value))
+    if isinstance(value, soy._datatypes.BodyPosition) :
+      return soy._datatypes.BodyPosition((_position[0] + value.x,
+                                          _position[1] + value.y,
+                                          _position[2] + value.z))
+    if type(value) == tuple or type(value) == list and len(value) == 3 :
+      return soy._datatypes.BodyPosition((_position[0] + value[0],
+                                          _position[1] + value[1],
+                                          _position[2] + value[2]))
+    return NotImplemented
     
 
   def __getitem__(self, index) :

Modified: trunk/pysoy/src/_datatypes/soy._datatypes.pxd
===================================================================
--- trunk/pysoy/src/_datatypes/soy._datatypes.pxd       2008-03-10 22:05:57 UTC 
(rev 1127)
+++ trunk/pysoy/src/_datatypes/soy._datatypes.pxd       2008-03-10 22:19:28 UTC 
(rev 1128)
@@ -58,7 +58,15 @@
   cdef object            _addSlice                      ( self, object, 
                                                           object, object )
 
+cdef class BodyPosition :
+  cdef void*                      _body
+  cdef float                      _position[3]
 
+
+cdef class Datatype :
+  cdef void*                      _alloc                ( self, int, int*, 
+                                                          void*, int )
+
 cdef class HashTable :
   cdef glib.GHashTable*           _hashtable
   cdef void                       _insert               ( self, char*, float )
@@ -67,11 +75,6 @@
   cdef int                        _remove               ( self, char* ) 
 
 
-cdef class Datatype :
-  cdef void*                      _alloc                ( self, int, int*, 
-                                                          void*, int )
-
-
 cdef class MaterialList (Datatype) :
   cdef void                      *_mesh
   cdef soy._internals.Children    _children
@@ -126,8 +129,3 @@
   cdef void                       _flagUpdated          ( self, int )
   cdef void                       _uploadFogCoord       ( self, float )
   cdef void                       _calculateTSLV        ( self, void* body )
-
-
-cdef class BodyPosition :
-  cdef void*                      _body
-  cdef float                      _position[3]

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to