Merge pull request #3076 from samuele3hu/execDev

issue #2244:Modify CallFunc event bug and modify a function name to createCCBreader
This commit is contained in:
minggo 2013-07-05 01:32:06 -07:00
commit 7e56bb57c8
8 changed files with 37 additions and 29 deletions

View File

@ -502,18 +502,23 @@ CallFunc::~CallFunc(void)
}
CallFunc * CallFunc::clone() const
{
// no copy constructor
auto a = new CallFunc();
if( _selectorTarget) {
a->initWithTarget(_selectorTarget);
a->_callFunc = _callFunc;
}
else if( _function )
a->initWithFunction(_function);
{
// no copy constructor
auto a = new CallFunc();
if( _selectorTarget) {
a->initWithTarget(_selectorTarget);
a->_callFunc = _callFunc;
}
else if( _function ){
a->initWithFunction(_function);
}
else if (_scriptHandler > 0 ) {
a->_scriptHandler = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(_scriptHandler);
}
a->autorelease();
return a;
a->autorelease();
return a;
}
CallFunc * CallFunc::reverse() const
@ -561,7 +566,7 @@ void CallFunc::execute() {
} else if( _function )
_function();
if (0 != _scriptHandler) {
BasicScriptData data((void*)&_scriptHandler);
BasicScriptData data((void*)this);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
@ -621,9 +626,12 @@ void CallFuncN::execute() {
else if (_functionN) {
_functionN(_target);
}
if (_scriptHandler) {
ScriptEngineManager::sharedManager()->getScriptEngine()->executeCallFuncActionEvent(this, _target);
}
if (0 != _scriptHandler)
{
BasicScriptData data((void*)this,(void*)_target);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
bool CallFuncN::initWithFunction(const std::function<void (Node *)> &func)

View File

@ -549,7 +549,7 @@ void Node::cleanup()
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&scriptEvent);
}
else if(_scriptType != kScriptTypeJavascript)
else if(_scriptType == kScriptTypeJavascript)
{
ScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kNodeOnCleanup);
}

View File

@ -601,7 +601,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
if(jsControlled) {
String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str());
CallFunc *callback = (CallFunc*)(mKeyframeCallFuncs->objectForKey(callbackName->getCString()))->copy()->autorelease();
CallFunc *callback = ((CallFunc*)(mKeyframeCallFuncs->objectForKey(callbackName->getCString())))->clone();
if(callback != NULL) {
actions->addObject(callback);

View File

@ -151,7 +151,7 @@
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
cocos2d::ScriptEvent event(kCommonEvent,(void*)&data);
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
return YES;
@ -171,7 +171,7 @@
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
cocos2d::ScriptEvent event(kCommonEvent,(void*)&data);
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
memset(data.eventName,0,64*sizeof(char));
strncpy(data.eventName,"return",64);
@ -219,7 +219,7 @@
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
cocos2d::ScriptEvent event(kCommonEvent,(void*)&data);
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}

View File

@ -24,7 +24,7 @@
#include "CCBProxy.h"
CCBReader* CCBProxy::createBreader()
CCBReader* CCBProxy::createCCBReader()
{
NodeLoaderLibrary *ccNodeLoaderLibrary = NodeLoaderLibrary::sharedNodeLoaderLibrary();

View File

@ -14,7 +14,7 @@ public:
CCBProxy() { }
virtual ~ CCBProxy(){ }
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBProxy, create);
CCBReader* createBreader();
CCBReader* createCCBReader();
Node* readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner = false);
const char* getNodeTypeName(Node* pNode);
void setCallback(Node* pNode,int nHandle);

View File

@ -485,7 +485,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data)
return 0;
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
if (NULL == basicScriptData->nativeObject ||NULL == basicScriptData->value)
if (NULL == basicScriptData->nativeObject)
return 0;
CallFunc* callFunc = (CallFunc*)(basicScriptData->nativeObject);

View File

@ -1902,8 +1902,8 @@ tolua_lerror:
#endif //#ifndef TOLUA_DISABLE
/* method: getOwnerCallbackNodes of class CCBReader */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_CCBProxy_createBreader00
static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_Cocos2d_CCBProxy_createCCBReader00
static int tolua_Cocos2d_CCBProxy_createCCBReader00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@ -1917,10 +1917,10 @@ static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
{
CCBProxy* self = (CCBProxy*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'CreateBreader'", NULL);
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'createCCBReader'", NULL);
#endif
{
CCBReader* tolua_ret = (CCBReader*) self->createBreader();
CCBReader* tolua_ret = (CCBReader*) self->createCCBReader();
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCBReader");
@ -1929,7 +1929,7 @@ static int tolua_Cocos2d_CCBProxy_createBreader00(lua_State* tolua_S)
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'CreateBreader'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'createCCBReader'.",&tolua_err);
return 0;
#endif
}
@ -2133,7 +2133,7 @@ TOLUA_API int tolua_extensions_ccb_open(lua_State* tolua_S){
tolua_function(tolua_S,".call",tolua_Cocos2d_CCBProxy_new00_local);
tolua_function(tolua_S,"delete",tolua_Cocos2d_CCBProxy_delete00);
tolua_function(tolua_S, "create", tolua_Cocos2d_CCBProxy_create00);
tolua_function(tolua_S, "createCCBReader", tolua_Cocos2d_CCBProxy_createBreader00);
tolua_function(tolua_S, "createCCBReader", tolua_Cocos2d_CCBProxy_createCCBReader00);
tolua_function(tolua_S, "readCCBFromFile", tolua_Cocos2d_CCBProxy_readCCBFromFile00);
tolua_function(tolua_S, "getNodeTypeName", tolua_Cocos2d_CCBProxy_getNodeTypeName00);
tolua_function(tolua_S, "setCallback", tolua_Cocos2d_CCBProxy_setCallback00);