*** empty log message ***

This commit is contained in:
Joe Shochet 2001-03-20 02:26:45 +00:00
parent 7934280ed6
commit 6fcdf375ed
3 changed files with 34 additions and 1 deletions

View File

@ -4,6 +4,12 @@ import DirectNotifyGlobal
import Datagram
from MsgTypes import *
# These are stored here so that the distributed classes we load on the fly
# can be exec'ed in the module namespace as if we imported them normally.
# This is important for redefine to work, and is a good idea anyways.
moduleGlobals = globals()
moduleLocals = locals()
class ClientDistUpdate:
notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistUpdate")
@ -16,7 +22,7 @@ class ClientDistUpdate:
self.divisors = []
self.deriveTypesFromParticle(dcField)
# Figure out our function pointer
exec("import " + cdc.name)
exec("import " + cdc.name, moduleGlobals, moduleLocals)
try:
self.func = eval(cdc.name + "." + cdc.name + "." + self.name)
# Only catch name and attribute errors

View File

@ -304,3 +304,25 @@ class ClientRepository(DirectObject.DirectObject):
self.cw.send(datagram, self.tcpConn)
return None
def replaceMethod(self, oldMethod, newFunction):
foundIt = 0
import new
# Iterate over the ClientDistClasses
for cdc in self.number2cdc.values():
# Iterate over the ClientDistUpdates
for cdu in cdc.allCDU:
method = cdu.func
# See if this is a match
if (method and (method.im_func == oldMethod)):
# Create a new unbound method out of this new function
newMethod = new.instancemethod(newFunction,
method.im_self,
method.im_class)
# Set the new method on the cdu
cdu.func = newMethod
foundIt = 1
return foundIt

View File

@ -133,6 +133,7 @@ def copyFuncs(fromClass, toClass):
replaceMessengerFunc(oldFunc, newFunc)
replaceTaskMgrFunc(oldFunc, newFunc)
replaceStateFunc(oldFunc, newFunc)
replaceTcrFunc(oldFunc, newFunc)
toClass.__dict__[key] = newFunc
def replaceMessengerFunc(oldFunc, newFunc):
@ -154,3 +155,7 @@ def replaceStateFunc(oldFunc, newFunc):
if res:
print ('replaced state exit function: ' + newFunc.__name__)
def replaceTcrFunc(oldFunc, newFunc):
res = toonbase.tcr.replaceMethod(oldFunc, newFunc)
if res:
print ('replaced DistributedObject function: ' + newFunc.__name__)