From: Christopher N. <cn...@it...> - 2008-11-04 02:45:04
|
I've taken a bit more of a look at this, and it seems that the problem is in attempting to use runtime type information across shared module boundaries. The dynamic_cast works for calls within libpcsim, and also works if called within an extension module, but extension classes derived from libpcsim classes cannot be correctly examined by the libpcsim library. I've worked around the issue for the moment by changing SingleThreadNetwork line 170 from: SpikeSender *ss = dynamic_cast<SpikeSender*>( src_obj ); to: SpikeSender *ss = static_cast<SpikeSender*>( dynamic_cast<void*>( src_obj ) ); and similarly in the MultiThreadNetwork class. I'm not particularly sure of the rules for pointer casting in class hierarchies, but as far as I understand it, the dynamic_cast<void*> may not operate correctly if the start of the derived (extension) class is not the same as the start of the SimObject* class? Cheers, Chris. On Wed, 2008-10-29 at 13:02 +1000, Christopher Nolan wrote: > Hi, > > I've tried to create a new spike source in an external module. When > trying to connect the output of the new SpikeSender to spiking synapses > or spike recorders, I get the exception > > <type 'exceptions.RuntimeError'>: PCSIM::ConstructionException in > function SingleThreadNetwork::addSpikeMessage: Specified simulation > object ((n=0,e= > > occurring in: > > void SingleThreadNetwork::_addSpikeMessage_(const SimObject::ID &sender, > const port_t out, const SimObject::ID &receiver, const port_t in_port, > const Time &delay) > > It appears as though the dynamic_cast on line 170 of > SingleThreadNetwork.cpp is returning null, however I can achieve a naive > cast: > > (SpikeSender*) src_obj > > in a debugger and call the appropriate SpikeSender members (so the > object is the right type). > > I've simplified the class and tested that the problem still occurs; the > simplified version is attached along with a python script that produces > the error. Any thoughts would be most appreciated. > > Cheers, > Chris. > > |