void CEgIStream::fillBuf() { long bytes = mReadBufSize; Dim( bytes ); mNextPtr = getCStr(); mBufPos = mPos; if ( long(length()) < bytes ) // Verify that we dimmed ok bytes = length(); fillBlock( mPos, getCStr(), bytes ); if ( bytes <= 0 ) throwErr( cEOSErr ); mStrLen = bytes; // Our str len could have only gotten shorter }
void CEgIStream::ResetBuf() { throwErr( cNoErr ); mIsTied = false; mNextPtr = getCStr(); mBufPos = 0; mPos = 0; }
bool LuaInterface::doCall(int nparams, int nrets /* = 0 */) { if(lua_pcall(_lua, nparams, nrets, 0) != LUA_OK) { printCallstack(_lua, getCStr(_lua, -1)); lua_pop(_lua, 1); return false; } return true; }
void CEgIStream::Assign( CEgIStream* inSource, long inBytes ) { if ( inSource ) { Dim( inBytes ); if ( long(length()) < inBytes ) inBytes = length(); inSource -> GetBlock( getCStr(), inBytes ); } ResetBuf(); }
bool LuaInterface::Init() { if(!_lua) { _lua = lua_newstate(the_alloc, this); if(!_lua) return false; lua_atpanic(_lua, the_panic); // Lua internal functions luaL_openlibs(_lua); // Own functions. lua_register_enginefuncs(_lua); /* call open functions from 'customLibs' and set results to global table */ for (const luaL_Reg *lib = customLibs; lib->func; lib++) { luaL_requiref(_lua, lib->name, lib->func, 1); lua_pop(_lua, 1); /* remove lib */ } lua_register_constants(_lua); } // Execute scripts/init.lua lua_getglobal(_lua, "dofile"); lua_pushstring(_lua, "init.lua"); if(lua_pcall(_lua, 1, 0, 0) != LUA_OK) { logerror("Could not run init script 'scripts/init.lua'"); logerror("-> %s", getCStr(_lua, -1)); lua_pop(_lua, 1); return false; } return true; }
void BigInt::println() { char out[BIG_INT_MAX_SIZE]; getCStr(out, BIG_INT_MAX_SIZE); printf("%s\n", out); }