Skip to content

Commit

Permalink
[events] Rework the logic of dispatchEvent since clone is always defined
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed Jan 27, 2012
1 parent 4f6b6ae commit faa8357
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/scripting/flash/events/flashevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,27 +524,20 @@ ASFUNCTIONBODY(EventDispatcher,dispatchEvent)
cloneName.ns.push_back(nsNameAndKind("",PACKAGE_NAMESPACE));

_NR<ASObject> clone=e->getVariableByMultiname(cloneName);
if(!clone.isNull() && clone->getObjectType()==T_FUNCTION)
{
IFunction* f = static_cast<IFunction*>(clone.getPtr());
e->incRef();
ASObject* funcRet=f->call(e.getPtr(),NULL,0);
//Verify that the returned object is actually an event
Event* newEvent=dynamic_cast<Event*>(funcRet);
if(newEvent==NULL)
{
if(funcRet)
funcRet->decRef();
return abstract_b(false);
}
e=_MR(newEvent);
}
else
//Clone always exists since it's implemented in Event itself
assert(!clone.isNull());
IFunction* f = static_cast<IFunction*>(clone.getPtr());
e->incRef();
ASObject* funcRet=f->call(e.getPtr(),NULL,0);
//Verify that the returned object is actually an event
Event* newEvent=dynamic_cast<Event*>(funcRet);
if(newEvent==NULL)
{
//TODO: support cloning of actual type
LOG(LOG_NOT_IMPLEMENTED,"Event cloning not supported!");
e=_MR(Class<Event>::getInstanceS(e->type,e->bubbles, e->cancelable));
if(funcRet)
funcRet->decRef();
return abstract_b(false);
}
e=_MR(newEvent);
}
th->incRef();
ABCVm::publicHandleEvent(_MR(th), e);
Expand Down

0 comments on commit faa8357

Please sign in to comment.