void ExecuteDMLData::Notify(int iErrCode) { TSTRACEAUTO(); lua_State* pLuaState = m_callInfo.GetLuaState(); lua_rawgeti(pLuaState, LUA_REGISTRYINDEX, m_callInfo.GetRefFn()); int iRetCount = 0; lua_pushinteger(pLuaState, iErrCode); ++iRetCount; if (SQLITE_OK == iErrCode) { lua_newtable(pLuaState); int i = 1; std::vector<std::map<std::string,std::string>>::const_iterator c_iter = m_vQuery.begin(); TSDEBUG(_T("count is %d."),m_vQuery.size()); for (;c_iter != m_vQuery.end();++c_iter) { std::map<std::string,std::string> map_Row = *c_iter; std::map<std::string,std::string>::const_iterator c_mapRow = map_Row.begin(); lua_newtable(pLuaState); for (;c_mapRow != map_Row.end();++c_mapRow) { std::string utf8key = c_mapRow->first; std::string utf8Value = c_mapRow->second; lua_pushstring(pLuaState, utf8key.c_str()); if (!utf8Value.empty()) lua_pushstring(pLuaState, utf8Value.c_str()); else lua_pushnil(pLuaState); lua_settable(pLuaState, -3); } lua_rawseti(m_callInfo.GetLuaState(), -2, i); i++; } TSDEBUG(_T("table pusher ok"),m_vQuery.size()); ++iRetCount; free(); } else { lua_pushnil(pLuaState); ++iRetCount; } XLLRT_LuaCall(pLuaState, iRetCount, 0, L"ExecuteDMLData Callback"); }
void LuaListenPre::LuaListener(DWORD userdata1,DWORD userdata2, const char* pszType, DISPPARAMS* pParams ) { //TSAUTO(); USES_CONVERSION; lua_State* pLuaState = (lua_State*)(ULONG_PTR)userdata1; LONG lnStackTop = lua_gettop(pLuaState); lua_rawgeti(pLuaState,LUA_REGISTRYINDEX,userdata2 ); lua_pushstring(pLuaState, pszType); for (int i = 0; i < (int)pParams->cArgs; i++) { PutVariantToLuaStack(&(pParams->rgvarg[i]), pLuaState); } long lret = XLLRT_LuaCall(pLuaState, pParams->cArgs+1, 0, NULL); ATLASSERT(lret == 0); LONG lnStackTop2 = lua_gettop(pLuaState); ATLASSERT(lnStackTop2 == lnStackTop); return ; }