maybe a bug in lua.

CCLuaEngine.cpp

at line 159:

CCLuaEngine::executeLayerTouchEvent(CCLayer* pLayer, int eventType, CCTouch *pTouch)
{
    CCTouchScriptHandlerEntry* pScriptHandlerEntry = pLayer->getScriptTouchHandlerEntry();
    int nHandler = pScriptHandlerEntry->getHandler();
    if (!nHandler) return 0;
    CCLOG("layer touch event");
    lua_State *L = m_stack->getLuaState();
    CCLOG("stack = %d", lua_gettop(L));
    // I tried to log the stack here
    switch (eventType)
    {
        case CCTOUCHBEGAN:
            m_stack->pushString("began");
            break;
        case CCTOUCHMOVED:
            m_stack->pushString("moved");
            break;
        case CCTOUCHENDED:
            m_stack->pushString("ended");
            break;
        case CCTOUCHCANCELLED:
            m_stack->pushString("cancelled");
            break;
        default:
            return 0;
    }    const CCPoint pt = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView());
    m_stack->pushFloat(pt.x);
    m_stack->pushFloat(pt.y);
    int nret = m_stack->executeFunctionByHandler(nHandler, 3);
    CCLOG("function called, stack = %d", lua_gettop(L));
    // and Log here,
    return nret;
}

the top of the stack increased 1 when I called it everytime.
and I modified the executeFunctionByHandler, and lua_pop(L, 2) to fix it. but I’m not sure….