Update of /cvsroot/pyode/pyode/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17308/src
Modified Files:
joints.pyx
Log Message:
Modified the joint base so that joints can store arbitrary attributes
Index: joints.pyx
===================================================================
RCS file: /cvsroot/pyode/pyode/src/joints.pyx,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** joints.pyx 6 Jun 2005 12:55:52 -0000 1.7
--- joints.pyx 24 Jun 2005 16:21:42 -0000 1.8
***************
*** 103,106 ****
--- 103,110 ----
cdef object body2
+ # A dictionary with user attributes
+ # (set via __getattr__ and __setattr__)
+ cdef object userattribs
+
def __new__(self, *a, **kw):
self.jid = NULL
***************
*** 109,112 ****
--- 113,117 ----
self.body1 = None
self.body2 = None
+ self.userattribs = {}
def __init__(self, *a, **kw):
***************
*** 118,121 ****
--- 123,141 ----
dJointDestroy(self.jid)
+ def __getattr__(self, name):
+ try:
+ return self.userattribs[name]
+ except:
+ raise AttributeError, "Joint object has no attribute '%s'"%name
+
+ def __setattr__(self, name, value):
+ self.userattribs[name] = value
+
+ def __delattr__(self, name):
+ try:
+ del self.userattribs[name]
+ except:
+ raise AttributeError, "Joint object has no attribute '%s'"%name
+
# _destroyed
def _destroyed(self):
|