Exemplo n.º 1
0
void ScriptApiBase::setOriginFromTableRaw(int index, const char *fxn)
{
#ifdef SCRIPTAPI_DEBUG
	lua_State *L = getStack();

	m_last_run_mod = lua_istable(L, index) ?
		getstringfield_default(L, index, "mod_origin", "") : "";
	//printf(">>>> running %s for mod: %s\n", fxn, m_last_run_mod.c_str());
#endif
}
Exemplo n.º 2
0
void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
	Common::String cardName = getStack()->getName(kCardNames, cardNameId);
	if (cardName.empty())
		return;
	ZipMode zip;
	zip.name = cardName;
	zip.id = cardId;
	if (Common::find(_zipModeData.begin(), _zipModeData.end(), zip) == _zipModeData.end())
		_zipModeData.push_back(zip);
}
void errCatchEnd(struct errCatch *errCatch)
/* Restore error handlers and pop self off of catching stack. */
{
popWarnHandler();
popAbortHandler();
struct errCatch **pErrCatchStack = getStack(), *errCatchStack = *pErrCatchStack;
if (errCatch != errCatchStack)
   errAbort("Mismatch betweene errCatch and errCatchStack");
*pErrCatchStack = errCatch->next;
}
Exemplo n.º 4
0
// Creates a new anonymous reference if cobj=NULL or id=0
void ScriptApiBase::objectrefGetOrCreate(
		ServerActiveObject *cobj)
{
	lua_State *L = getStack();

	if(cobj == NULL || cobj->getId() == 0){
		ObjectRef::create(L, cobj);
	} else {
		objectrefGet(cobj->getId());
	}
}
Exemplo n.º 5
0
int32_t ZendExecutionStack::numArgs() {
  auto& stack = getStack();
  auto& entry = stack.m_stack.back();
  switch (entry.mode) {
    case ZendStackMode::HHVM_STACK:
      return ((HPHP::ActRec*)entry.value)->numArgs();
    case ZendStackMode::SIDE_STACK:
      // Zend puts the number of args as the last thing on the stack
      return uintptr_t(entry.value);
  }
  not_reached();
  return 0;
}
Exemplo n.º 6
0
void ScriptApiBase::objectrefGet(u16 id)
{
	lua_State *L = getStack();

	// Get minetest.object_refs[i]
	lua_getglobal(L, "minetest");
	lua_getfield(L, -1, "object_refs");
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_pushnumber(L, id);
	lua_gettable(L, -2);
	lua_remove(L, -2); // object_refs
	lua_remove(L, -2); // minetest
}
Exemplo n.º 7
0
void PluginHost::processStack(float *buffer, int stackType, Channel *ch) {

	gVector <Plugin *> *pStack = getStack(stackType, ch);

	/* empty stack, stack not found or mixer not ready: do nothing */
	/// TODO - join evaluation

	if (!G_Mixer.ready)
		return;
	if (pStack == NULL)
		return;
	if (pStack->size == 0)
		return;

	/* converting buffer from Giada to VST */

	for (unsigned i=0; i<kernelAudio::realBufsize; i++) {
		bufferI[0][i] = buffer[i*2];
		bufferI[1][i] = buffer[(i*2)+1];
	}

	/* hardcore processing. At the end we swap input and output, so that
	 * the N-th plugin will process the result of the plugin N-1. */

	for (unsigned i=0; i<pStack->size; i++) {
		/// TODO - join evaluation

		if (pStack->at(i)->status != 1)
			continue;
		if (pStack->at(i)->suspended)
			continue;
		if (pStack->at(i)->bypass)
			continue;
		if (ch) {   // process events if it's a channel stack
			if (ch->type == CHANNEL_MIDI) {
				///gLog("events: %d\n", (((MidiChannel*)ch)->getVstEvents())->numEvents);
				pStack->at(i)->processEvents(((MidiChannel*)ch)->getVstEvents());
			}
		}
		pStack->at(i)->processAudio(bufferI, bufferO, kernelAudio::realBufsize);
		bufferI = bufferO;
	}

	/* converting buffer from VST to Giada. A note for the future: if we
	 * overwrite (=) (as we do now) it's SEND, if we add (+) it's INSERT. */

	for (unsigned i=0; i<kernelAudio::realBufsize; i++) {
		buffer[i*2]     = bufferO[0][i];
		buffer[(i*2)+1] = bufferO[1][i];
	}
}
Exemplo n.º 8
0
void pkCU::updateState_move()
{
	assert(getStackStage() == STAGE_SEEDED);
	advanceStackStage();

	// the floor of the stack: everything below this stack value has been evaluated
	size_t baseFloor = iBase, baseCeil = getStack().size(), iNBase;

	// evaluate first pokemon's moves, and their probabilities (iBase provided by updateState)
	evaluateMove();

	// POSSIBLE THAT POKEMON MIGHT HAVE DIED IN PREVIOUS STEP

	iBase = baseFloor;
	swapTeamIndexes();

	// TODO: STAGE_POSTROUND should automatically be set after the second go-around as stage keeps incrementing
	// increment with iNBase, as evaluateMove will manipulate stack
	for (iNBase = baseFloor, baseCeil = getStack().size(); iNBase != baseCeil; ++iNBase, iBase = iNBase)
	{
		// do not evaluate a move that has not been evaluated by first pokemon yet:
		if (getStackStage() != STAGE_POSTTURN) { continue; }

		// if the pokemon died, no reason for it to take its turn
		//if (!getPKV().isAlive()) { continue; }

		// evaluate second pokemon's moves and their probabilities
		stackStage[iBase] = STAGE_PRETURN;
		evaluateMove();
	}

	// assert ALL moves have completed both turns:
	for (iBase = baseFloor, baseCeil = getStack().size(); iBase != baseCeil; ++iBase)
	{
		if (getStackStage() != STAGE_POSTTURN) { continue; }
		advanceStackStage();
	}
}
Exemplo n.º 9
0
int recu(int num){
	
	printf("Stack: %d, ESP: %d, Iteration: %d\n", getStack((int)(getp()->stack)), getp()->esp, num);
	int a[200];
	a[2] = 1;
	if(num == 0){
		return 1;
	}
	else if( num%5 ){
		softyield();
	}
	recu(num-1);
	return 1;
}
Exemplo n.º 10
0
double Info::getMRatio(int index) const
{
  /*
  From Wikipedia (Herrington Zones):

  M-ratio        Zone name    "Optimal" strategy
  M >= 20        Green zone   Most desirable situation, freedom to play conservatively or aggressively as you choose
  10 <= M < 20   Yellow zone  Must take on more risk, hands containing small pairs and small suited connectors lose value
  6 <= M < 10    Orange zone  Main focus is to be first-in whatever you decide to play, important to preserve chips
  1 <= M < 6     Red zone     Your only move is to move all-in or fold
  M < 1          Dead zone    You are completely dependent on luck to survive, the only strategy is to push all-in into an empty pot
  */
  return ((double)getStack(index)) / (rules.smallBlind + rules.bigBlind + rules.ante * players.size());
}
Exemplo n.º 11
0
bool ScriptApiBase::loadMod(const std::string &scriptpath,
		const std::string &modname)
{
	ModNameStorer modnamestorer(getStack(), modname);

	if (!string_allowed(modname, MODNAME_ALLOWED_CHARS)) {
		errorstream<<"Error loading mod \""<<modname
				<<"\": modname does not follow naming conventions: "
				<<"Only chararacters [a-z0-9_] are allowed."<<std::endl;
		return false;
	}

	return loadScript(scriptpath);
}
Exemplo n.º 12
0
void GenericMapCreature::grow()
{
	uint value, percent;
	
	switch( _growth ) {
	case Stable:
		break;
	case FixedPercentage:
		for( uint i = 0; i < MAX_UNIT; i++ ) {
			value = getStack( i );
			value = (int)( ( value * (100 + _growthParam0) ) / 100 );
			setStack( i, value );
		}
		break;
	case VariablePercentage:
		for( uint i = 0; i < MAX_UNIT; i++ ) {
			percent = _growthParam0 + ( rand() % (_growthParam1 + 1 - _growthParam0) );
			value = getStack( i );
			value = (int)( ( value * (100 + percent) ) / 100 );
			setStack( i, value );
		}
		break;
	}
}
Exemplo n.º 13
0
CardStack* GameState::findById(int cardId, int* idx)
{
    for (int i=0; i<STACK_COUNT; i++)
    {
        CardStack* cs = getStack(i);
        for (int j=0; j<cs->size(); j++) {
            if ((*cs)[j].id == cardId) 
            {
                *idx = j;
                return cs;
            }
        }
    }

    return NULL_PTR;
}
Exemplo n.º 14
0
//=============================================================================
// METHOD: SPELLserverCif::completeMessage
//=============================================================================
void SPELLserverCif::completeMessage( SPELLipcMessage* msg )
{
    msg->set(MessageField::FIELD_TIME, timestamp() );
    msg->set(MessageField::FIELD_MSG_SEQUENCE, ISTR(m_sequence));
    m_sequence++;

    msg->set(MessageField::FIELD_CSP, getStack() + "/" + ISTR(getNumExecutions()) );

    if (isManual())
    {
        msg->set(MessageField::FIELD_EXECUTION_MODE, MessageValue::DATA_EXEC_MODE_MANUAL);
    }
    else
    {
        msg->set(MessageField::FIELD_EXECUTION_MODE, MessageValue::DATA_EXEC_MODE_PROCEDURE);
    }
}
Exemplo n.º 15
0
void PluginHost::swapPlugin(unsigned indexA, unsigned indexB, int stackType, Channel *ch) {

	gVector <Plugin *> *pStack = getStack(stackType, ch);

	int lockStatus;
	while (true) {
		lockStatus = pthread_mutex_trylock(&G_Mixer.mutex_plugins);
		if (lockStatus == 0) {
			pStack->swap(indexA, indexB);
			pthread_mutex_unlock(&G_Mixer.mutex_plugins);
			gLog("[pluginHost] plugin at index %d and %d swapped\n", indexA, indexB);
			return;
		}
		//else
			//gLog("[pluginHost] waiting for mutex...\n");
	}
}
Exemplo n.º 16
0
void ScriptApiServer::getAuthHandler()
{
	lua_State *L = getStack();

	lua_getglobal(L, "core");
	lua_getfield(L, -1, "registered_auth_handler");
	if (lua_isnil(L, -1)){
		lua_pop(L, 1);
		lua_getfield(L, -1, "builtin_auth_handler");
	}

	setOriginFromTable(-1);

	lua_remove(L, -2); // Remove core
	if (lua_type(L, -1) != LUA_TTABLE)
		throw LuaError("Authentication handler table not valid");
}
Exemplo n.º 17
0
//=============================================================================
// METHOD    : SPELLcallstack::event_call
//=============================================================================
void SPELLcallstack::event_call( const std::string& file, const int& line, const std::string& name )
{
	// Call to a function, increase the stack
	DEBUG("[CSTACK] Event call: " + file + ":" + ISTR(line) + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));

	// Consider first the first call in the execution: create the roots
	if (m_rootNode == NULL)
	{
		DEBUG("[CSTACK] First call" );
		m_rootNode = new SPELLcodeTreeNode(0,file,line,NULL);
		m_currentNode = m_rootNode;
		m_viewNode = m_rootNode;

	    // Visit the line
		SPELLexecutor::instance().getFrame().getTraceModel(file).setCurrentLine(line);
	}
	else // If we are in this case, there is a subprocedure being called
	{
		assert(m_currentNode != NULL);

		DEBUG("[CSTACK] Function call" );
		// ...and ensure the next line will be marked by default
		m_markExecuted = true;
		// Will add the child code corresponding to the call

		DEBUG("[CSTACK] Doing call on node " + m_currentNode->getCodeIdentifier() + ", depth " + ISTR(m_currentNode->getDepth()) );
		m_currentNode->eventCall(file,line);
		// Now update which the current node is
		m_currentNode = m_currentNode->getCurrentLine()->getChildCode();
		// If we are stepping over, do not change the view node position
		// otherwise move the view node together with the leaf
		if ( m_soMode >= SO_ONCE_INTO )
		{
			DEBUG("[CSTACK] Increasing level: " + ISTR(m_soMode) );
			m_viewNode = m_currentNode;
		}
	}
    // Update the stack string
    m_stack = std::string(file + ":" + ISTR(line));
    // Update the code name string
    m_codeName = name;

	DEBUG("[CSTACK] Event call notify: " + getStack() + ", mode=" + ISTR(m_soMode) + ", so=" + BSTR(isSteppingOver()));
	SPELLexecutor::instance().getCIF().notifyCall();
}
Exemplo n.º 18
0
AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobDispatcher,
		unsigned int threadNum) :
	ScriptApiBase(),
	jobDispatcher(jobDispatcher),
	threadnum(threadNum)
{
	lua_State *L = getStack();

	// Prepare job lua environment
	lua_getglobal(L, "core");
	int top = lua_gettop(L);

	// Push builtin initialization type
	lua_pushstring(L, "async");
	lua_setglobal(L, "INIT");

	jobDispatcher->prepareEnvironment(L, top);
}
Exemplo n.º 19
0
void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result)
{
	lua_State *L = getStack();

	result.clear();
	lua_pushnil(L);
	if (index < 0)
		index -= 1;
	while (lua_next(L, index) != 0) {
		// key at index -2 and value at index -1
		std::string key = luaL_checkstring(L, -2);
		bool value = lua_toboolean(L, -1);
		if (value)
			result.insert(key);
		// removes value, keeps key for next iteration
		lua_pop(L, 1);
	}
}
Exemplo n.º 20
0
AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobDispatcher,
		const std::string &name) :
	Thread(name),
	ScriptApiBase(ScriptingType::Async),
	jobDispatcher(jobDispatcher)
{
	lua_State *L = getStack();

	// Prepare job lua environment
	lua_getglobal(L, "core");
	int top = lua_gettop(L);

	// Push builtin initialization type
	lua_pushstring(L, "async");
	lua_setglobal(L, "INIT");

	jobDispatcher->prepareEnvironment(L, top);
}
Exemplo n.º 21
0
//=============================================================================
// METHOD: SPELLserverCif::notifyCall
//=============================================================================
void SPELLserverCif::notifyCall()
{
    std::string stack = getStack();

    DEBUG("[CIF] Procedure call: " + stack );

    m_lnMessage.set( MessageField::FIELD_DATA_TYPE, MessageValue::DATA_TYPE_CALL );
    m_lnMessage.setType(MSG_TYPE_NOTIFY);

    completeMessage( &m_lnMessage );
    m_lnMessage.set(MessageField::FIELD_MSG_SEQUENCE, ISTR(m_sequenceStack));
    m_sequenceStack++;
    m_lnMessage.set(MessageField::FIELD_CODE_NAME, getCodeName() );

    m_asRun->writeCall( stack, (m_sequence-1) );

    SPELLipcMessage* response = sendGUIRequest(&m_lnMessage, SPELL_CIF_NOTIFICATION_TIMEOUT_SEC);
    if (response) delete response;
}
Exemplo n.º 22
0
//=============================================================================
// METHOD: SPELLserverCif::notifyLine
//=============================================================================
void SPELLserverCif::notifyLine()
{
    std::string stack = getStack();

    if (m_lastStack == stack) return;
    m_lastStack = stack;

    std::string stage = getStage();

    DEBUG("[CIF] Procedure line: " + stack + "(" + stage + ")");

    m_lnMessage.set( MessageField::FIELD_DATA_TYPE, MessageValue::DATA_TYPE_LINE );
    m_lnMessage.setType(MSG_TYPE_NOTIFY_ASYNC);

    completeMessage( &m_lnMessage );
    m_lnMessage.set(MessageField::FIELD_MSG_SEQUENCE, ISTR(m_sequenceStack));
    m_sequenceStack++;
    m_lnMessage.set(MessageField::FIELD_CODE_NAME, getCodeName() );

    if (stage.find(":") != std::string::npos)
    {
        std::vector<std::string> stage_title = tokenize(stage,":");
        if (stage_title.size()==2)
        {
            m_lnMessage.set(MessageField::FIELD_STAGE_ID,stage_title[0]);
            m_lnMessage.set(MessageField::FIELD_STAGE_TL,stage_title[1]);
        }
        else
        {
            m_lnMessage.set(MessageField::FIELD_STAGE_ID,"(none)");
            m_lnMessage.set(MessageField::FIELD_STAGE_TL,"(none)");
        }
    }
    else
    {
        m_lnMessage.set(MessageField::FIELD_STAGE_ID,stage);
        m_lnMessage.set(MessageField::FIELD_STAGE_TL,stage);
    }

    m_asRun->writeLine( stack, (m_sequence-1) );

    sendGUIMessage(&m_lnMessage);
}
Exemplo n.º 23
0
/** Push a shader onto the top of the stack */
void ShaderManager::push(Shader* shdr){
	//std::cout << "Pushing " << shdr->filepath()<< " ID:" << shdr->shaderID() << std::endl;
	bool newProc = false;
	std::stack<Shader*>* curStack = getStack(shdr->type());
	if (!curStack->empty()){
		if (curStack->top()->priority() > shdr->priority()){
			curStack->push(curStack->top());
		} else {
			newProc = true;
		}
	} else {
		newProc = true;
	}
	if (newProc){
		curStack->push(shdr);
		invalid = true;
	}
	//curStack = NULL;
}
Exemplo n.º 24
0
bool ScriptApiBase::loadScript(const std::string &scriptpath)
{
	verbosestream<<"Loading and running script from "<<scriptpath<<std::endl;

	lua_State *L = getStack();

	int ret = luaL_loadfile(L, scriptpath.c_str()) || lua_pcall(L, 0, 0, m_errorhandler);
	if (ret) {
		errorstream << "========== ERROR FROM LUA ===========" << std::endl;
		errorstream << "Failed to load and run script from " << std::endl;
		errorstream << scriptpath << ":" << std::endl;
		errorstream << std::endl;
		errorstream << lua_tostring(L, -1) << std::endl;
		errorstream << std::endl;
		errorstream << "======= END OF ERROR FROM LUA ========" << std::endl;
		lua_pop(L, 1); // Pop error message from stack
		return false;
	}
	return true;
}
Exemplo n.º 25
0
// Retrieves core.detached_inventories[name][callbackname]
// If that is nil or on error, return false and stack is unchanged
// If that is a function, returns true and pushes the
// function onto the stack
bool ScriptApiDetached::getDetachedInventoryCallback(
		const std::string &name, const char *callbackname)
{
	lua_State *L = getStack();

	lua_getglobal(L, "core");
	lua_getfield(L, -1, "detached_inventories");
	lua_remove(L, -2);
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_getfield(L, -1, name.c_str());
	lua_remove(L, -2);
	// Should be a table
	if(lua_type(L, -1) != LUA_TTABLE)
	{
		errorstream<<"Detached inventory \""<<name<<"\" not defined"<<std::endl;
		lua_pop(L, 1);
		return false;
	}

	setOriginFromTable(-1);

	lua_getfield(L, -1, callbackname);
	lua_remove(L, -2);
	// Should be a function or nil
	if(lua_type(L, -1) == LUA_TFUNCTION)
	{
		return true;
	}
	else if(lua_isnil(L, -1))
	{
		lua_pop(L, 1);
		return false;
	}
	else
	{
		errorstream<<"Detached inventory \""<<name<<"\" callback \""
			<<callbackname<<"\" is not a function"<<std::endl;
		lua_pop(L, 1);
		return false;
	}
}
Exemplo n.º 26
0
// Retrieves core.registered_items[name][callbackname]
// If that is nil or on error, return false and stack is unchanged
// If that is a function, returns true and pushes the
// function onto the stack
// If core.registered_items[name] doesn't exist, core.nodedef_default
// is tried instead so unknown items can still be manipulated to some degree
bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname)
{
	lua_State* L = getStack();

	lua_getglobal(L, "core");
	lua_getfield(L, -1, "registered_items");
	lua_remove(L, -2); // Remove core
	luaL_checktype(L, -1, LUA_TTABLE);
	lua_getfield(L, -1, name);
	lua_remove(L, -2); // Remove registered_items
	// Should be a table
	if(lua_type(L, -1) != LUA_TTABLE)
	{
		// Report error and clean up
		errorstream << "Item \"" << name << "\" not defined" << std::endl;
		lua_pop(L, 1);

		// Try core.nodedef_default instead
		lua_getglobal(L, "core");
		lua_getfield(L, -1, "nodedef_default");
		lua_remove(L, -2);
		luaL_checktype(L, -1, LUA_TTABLE);
	}

	setOriginFromTable(-1);

	lua_getfield(L, -1, callbackname);
	lua_remove(L, -2); // Remove item def
	// Should be a function or nil
	if (lua_type(L, -1) == LUA_TFUNCTION) {
		return true;
	} else if (!lua_isnil(L, -1)) {
		errorstream << "Item \"" << name << "\" callback \""
			<< callbackname << "\" is not a function" << std::endl;
	}
	lua_pop(L, 1);
	return false;
}
Exemplo n.º 27
0
zval* ZendExecutionStack::getArg(int i) {
  auto& stack = getStack();
  auto& entry = stack.m_stack.back();
  switch (entry.mode) {
    case ZendStackMode::HHVM_STACK: {
      HPHP::ActRec* ar = (HPHP::ActRec*)entry.value;
      const int numNonVaradic = ar->m_func->numNonVariadicParams();
      HPHP::TypedValue* arg;
      if (i < numNonVaradic) {
        arg = (HPHP::TypedValue*)ar - i - 1;
      } else if (i < ar->numArgs()) {
        arg = ar->getExtraArg(i - numNonVaradic);
      } else {
        if (!stack.m_nullArg) {
          stack.m_nullArg =
            HPHP::RefData::Make(HPHP::make_tv<HPHP::KindOfNull>());
        }
        return stack.m_nullArg;
      }

      HPHP::zBoxAndProxy(arg);
      return arg->m_data.pref;
    }

    case ZendStackMode::SIDE_STACK: {
      // Zend puts the number of args as the last thing on the stack
      int numargs = uintptr_t(entry.value);
      assert(numargs < 4096);
      assert(i < numargs);
      zval* zv =
        (zval*) stack.m_stack[stack.m_stack.size() - 1 - numargs + i].value;
      zv->assertValid();
      return zv;
    }
  }
  not_reached();
  return nullptr;
}
Exemplo n.º 28
0
/** Pop the top shader from the stack */
void ShaderManager::pop(ShaderType type){
	if(type!=ShaderType::ALL){
		std::stack<Shader*>* curStack = getStack(type);
		if(!curStack->empty()){
			Shader* prevTop = curStack->top();
			curStack->pop();
			if(!curStack->empty()){
				if (prevTop->shaderID() != curStack->top()->shaderID()){
					invalid = true;
				}
			} else {
				invalid = true;
			}
			//delete[] prevTop;
			//prevTop = NULL;
		}
		//curStack = NULL;
	} else {
		vtShaders.pop();
		pxShaders.pop();
		geoShaders.pop();
		updateCurrentShaderProc();
	}
}
Exemplo n.º 29
0
unsigned PluginHost::countPlugins(int stackType, Channel *ch) {
	gVector <Plugin *> *pStack = getStack(stackType, ch);
	return pStack->size;
}
Exemplo n.º 30
0
void* AsyncWorkerThread::run()
{
	lua_State *L = getStack();

	std::string script = getServer()->getBuiltinLuaPath() + DIR_DELIM + "init.lua";
	try {
		loadScript(script);
	} catch (const ModError &e) {
		errorstream << "Execution of async base environment failed: "
			<< e.what() << std::endl;
		FATAL_ERROR("Execution of async base environment failed");
	}

	int error_handler = PUSH_ERROR_HANDLER(L);

	lua_getglobal(L, "core");
	if (lua_isnil(L, -1)) {
		FATAL_ERROR("Unable to find core within async environment!");
	}

	// Main loop
	while (!stopRequested()) {
		// Wait for job
		LuaJobInfo toProcess = jobDispatcher->getJob();

		if (!toProcess.valid || stopRequested()) {
			continue;
		}

		lua_getfield(L, -1, "job_processor");
		if (lua_isnil(L, -1)) {
			FATAL_ERROR("Unable to get async job processor!");
		}

		luaL_checktype(L, -1, LUA_TFUNCTION);

		// Call it
		lua_pushlstring(L,
				toProcess.serializedFunction.data(),
				toProcess.serializedFunction.size());
		lua_pushlstring(L,
				toProcess.serializedParams.data(),
				toProcess.serializedParams.size());

		int result = lua_pcall(L, 2, 1, error_handler);
		if (result) {
			PCALL_RES(result);
			toProcess.serializedResult = "";
		} else {
			// Fetch result
			size_t length;
			const char *retval = lua_tolstring(L, -1, &length);
			toProcess.serializedResult = std::string(retval, length);
		}

		lua_pop(L, 1);  // Pop retval

		// Put job result
		jobDispatcher->putJobResult(toProcess);
	}

	lua_pop(L, 2);  // Pop core and error handler

	return 0;
}