示例#1
0
void PokeModel::addPoke(int bank, int address, int value)
{
    if (bank < 0 || bank > 64) {
        // Pentagon 1024 has 65 memory pages
        g_fuseEmulator->showMessage(tr("Invalid bank: use an integer from 0 to 64"), FuseEmulator::Error);
        return;
    }

    if (address < 0 || address > 0xffff) {
        emit g_fuseEmulator->showMessage(tr("Invalid address: use an integer from 0 to 65535"), FuseEmulator::Error);
        return;
    }

    if (bank == 8 && address < 0x4000) {
        g_fuseEmulator->showMessage(tr("Invalid address: use an integer from 16384 to 65535"), FuseEmulator::Error);
        return;
    }

    pokeEvent([this, bank, address, value]{
        auto trainer = pokemem_trainer_list_add(bank, address, value);
        if (!trainer->disabled)
            pokemem_trainer_activate(trainer);
        callFunction([this] {
            beginResetModel();
            endResetModel();
        });
    });
}
示例#2
0
void __cdecl CToJavaCallHandler_Sub(CallTempStruct* call, NativeToJavaCallbackCallInfo* info, DCArgs* args, DCValue* result)
{
	dcMode(call->vm, JNI_CALL_MODE);
	//dcReset(call->vm);
	
	if (!info->fCallbackInstance)
	{
		throwException(call->env, "Trying to call a null callback instance !");
		return;
	}

	dcArgPointer(call->vm, (DCpointer)call->env);
	dcArgPointer(call->vm, info->fCallbackInstance);
	dcArgPointer(call->vm, info->fInfo.fMethodID);
	
	if (info->fIsObjCBlock)
		dcbArgPointer(args); // consume the pointer to the block instance ; TODO use it to reuse native callbacks !!!
	
	if (info->fIsGenericCallback) {
		callGenericFunction(call, &info->fInfo, args, result, (void*)(*call->env)->CallObjectMethod);
	} else {
		callFunction(call, &info->fInfo, args, result, info->fJNICallFunction, CALLING_JAVA | IS_VAR_ARGS);
	}
	
}
示例#3
0
void PokeModel::update()
{
    callFunction([this]{
        beginResetModel();
        endResetModel();
    });
}
bool PHPBackend::initialize (const QString &filename, RKComponentPropertyCode *code_property, bool add_headings) {
	RK_TRACE (PHP);

	if (php_process && php_process->isRunning ()) {
		RK_DO (qDebug ("another template is already openend in this backend"), PHP, DL_ERROR);
		return false;
	}

	php_process = new KProcess ();
	*php_process << RKSettingsModulePHP::phpBin();
//	*php_process << "-a";		// run interactively. Does this have an effect?
	*php_process << (RKSettingsModulePHP::filesPath() + "/common.php");
	
	// we have to be connect at all times! Otherwise the connection will be gone for good.
	//connect (php_process, SIGNAL (receivedStderr (KProcess *, char*, int)), this, SLOT (gotError (KProcess *, char*, int)));
	connect (php_process, SIGNAL (wroteStdin (KProcess *)), this, SLOT (doneWriting (KProcess* )));
	connect (php_process, SIGNAL (receivedStdout (KProcess *, char*, int)), this, SLOT (gotOutput (KProcess *, char*, int)));
	
	if (!php_process->start (KProcess::NotifyOnExit, KProcess::All)) {
		KMessageBox::error (0, i18n ("The PHP backend could not be started. Check whether you have correctly configured the location of the PHP-binary (Settings->Configure Settings->PHP backend)"), i18n ("PHP-Error"));
		emit (haveError ());
		return false;
	}

	busy_writing = doing_command = startup_done = false;
	busy = true;

	// start the real template
	callFunction ("include (\"" + filename + "\");", 0, Ignore);

	PHPBackend::code_property = code_property;
	PHPBackend::add_headings = add_headings;
	return true;
}
示例#5
0
void JSFiber::js_callback()
{
    scope s(this);
    v8::Local<v8::Value> retVal;
    callFunction(retVal);
    Unref();
}
示例#6
0
//__ \subsection{eventAttacked(victim, attacker)}
//__ An event that is run when an object belonging to the script's controlling player is
//__ attacked. The attacker parameter may be either a structure or a droid.
bool triggerEventAttacked(BASE_OBJECT *psVictim, BASE_OBJECT *psAttacker, int lastHit)
{
	if (!psAttacker)
	{
		// do not fire off this event if there is no attacker -- nothing do respond to
		// (FIXME -- consider this carefully)
		return false;
	}
	// throttle the event for performance
	if (gameTime - lastHit < ATTACK_THROTTLE)
	{
		return false;
	}
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		int player = engine->globalObject().property("me").toInt32();
		if (player == psVictim->player)
		{
			QScriptValueList args;
			args += convMax(psVictim, engine);
			args += convMax(psAttacker, engine);
			callFunction(engine, "eventAttacked", args);
		}
	}
	return true;
}
示例#7
0
int main(int argc, char** argv)
{
    auto py = new Interpret::PythonInterpreter();
    //import spam
    auto res = py->loadModule("spam");
    assert (res == 0 );

    //spa.foo2(1,3)
    res = py->callFunction("foo2", {"1","3"});
    assert (res == 0);

    //spa.foo()
    res = py->callFunction("foo", {});

    assert (res == 0);
    return 1;
}
void KvsObject_xmlReader::fatalError(const QString & szError)
{
	m_szLastError = szError;

	KviKvsVariantList vArgs;
	vArgs.append(new KviKvsVariant(m_szLastError));
	callFunction(this, "onError", &vArgs);
}
示例#9
0
/**
    \return A boolean value indicating whether to restart the timer again.
    \sa timerCallBack_t
*/
bool timeElement::clockAlarm ()
{
	callFunction ();
	if (0 != _repeats)		// _repeats == 0 means ad infinitum so don't change.
		if (0 == --_repeats)
			return false;		// timer expired for the last time.
	return true;
}
int main() {
  int i;
  int sum = 0;
  for (i = 0; i < 1000; i++) {
    sum += callFunction();
  }
  return sum == 0;
}
示例#11
0
/// For generic, parameter-less triggers
bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);

		switch (trigger)
		{
		case TRIGGER_GAME_INIT:
			callFunction(engine, "eventGameInit", QScriptValueList());
			break;
		case TRIGGER_START_LEVEL:
			callFunction(engine, "eventStartLevel", QScriptValueList());
			break;
		}
	}
	return true;
}
示例#12
0
void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) {
  if (nrhs != 1)
    mexErrMsgTxt("Bad number of input arguments");
  
  if (nlhs != 3) 
    mexErrMsgTxt("Bad number of output arguments");
  
  callFunction(plhs,prhs,nlhs);
}
示例#13
0
//__ \subsection{eventGroupLoss(object, group id, new size)}
//__ An event that is run whenever a group becomes empty. Input parameter
//__ is the about to be killed object, the group's id, and the new group size.
// Since groups are entities local to one context, we do not iterate over them here.
bool triggerEventGroupLoss(BASE_OBJECT *psObj, int group, int size, QScriptEngine *engine)
{
	QScriptValueList args;
	args += convMax(psObj, engine);
	args += QScriptValue(group);
	args += QScriptValue(size);
	callFunction(engine, "eventGroupLoss", args);
	return true;
}
示例#14
0
void VM::functionHandler(State *state, Object *self, Object *function, Object **arguments, size_t count) {
    (void)self;
    ClosureObject *functionObject = (ClosureObject *)function;
    Object *context = functionObject->m_context;
    GC::disable(state);
    context = setupVaradicArguments(state, context, &functionObject->m_closure, arguments, count);
    callFunction(state, context, &functionObject->m_closure, arguments, count);
    GC::enable(state);
}
示例#15
0
void VM::methodHandler(State *state, Object *self, Object *function, Object **arguments, size_t count) {
    ClosureObject *functionObject = (ClosureObject *)function;
    Object *context = Object::newObject(state, functionObject->m_context);
    Object::setNormal(state, context, "this", self);
    context->m_flags |= kClosed;
    GC::disable(state);
    context = setupVaradicArguments(state, context, &functionObject->m_closure, arguments, count);
    callFunction(state, context, &functionObject->m_closure, arguments, count);
    GC::enable(state);
}
示例#16
0
void PokeModel::clear()
{
    pokeEvent([this]{
        pokemem_clear();
        callFunction([this] {
            beginResetModel();
            endResetModel();
        });
    });
}
示例#17
0
/**
 * ---o
 * [1,2,3].reduce(fn(sum,key,value){return sum+value;},0) => 6
 */
Object * Collection::rt_reduce(Runtime & runtime,ObjPtr function,ObjPtr initialValue){
    ObjRef runningVar= initialValue.isNull() ? Void::get() : initialValue;

    for(ERef<Iterator> it=getIterator(); !it->end() ; it->next()){
        ObjRef key=it->key();
        ObjRef value=it->value();
        runningVar=callFunction(runtime,function.get(),ParameterValues(runningVar,key,value));
    }
    return runningVar.detachAndDecrease();
}
示例#18
0
//__ \subsection{eventCheatMode(entered)} Game entered or left cheat/debug mode.
//__ The entered parameter is true if cheat mode entered, false otherwise.
bool triggerEventCheatMode(bool entered)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		QScriptValueList args;
		args += entered;
		callFunction(engine, "eventCheatMode", args);
	}
	return true;
}
void DOMTransaction::reapply()
{
    if (!m_isAutomatic)
        callFunction("redo");
    else {
        for (size_t i = 0; i < m_transactionSteps.size(); ++i)
            m_transactionSteps[i]->reapply();
    }

    if (m_undoManager)
        m_undoManager->registerUndoStep(this);
}
示例#20
0
static void thenPromise(ExecState& state, JSPromise* deferredPromise, JSValue fullfilFunction, JSValue rejectFunction)
{
    JSValue thenValue = deferredPromise->get(&state, state.vm().propertyNames->then);
    if (state.hadException())
        return;

    MarkedArgumentBuffer arguments;
    arguments.append(fullfilFunction);
    arguments.append(rejectFunction);

    callFunction(state, thenValue, deferredPromise, arguments);
}
示例#21
0
QString ScriptHandler::customToString(const DataInformation* data, const QScriptValue& func)
{
    Q_ASSERT(func.isValid());
    Q_ASSERT(func.isFunction());
    Q_ASSERT(data->wasAbleToRead()); //this should never be called if EOF was reached
    //it is effectively const, since nothing may be modified while mode is CustomToString
    //const_cast is okay in this case
    QScriptValue result = callFunction(func, const_cast<DataInformation*>(data), ScriptHandlerInfo::CustomToString);
    if (result.isError())
        data->logError() << "toStringFunc caused an error:" << result.toString();
    return result.toString();
}
void DOMTransaction::unapply()
{
    if (!m_isAutomatic)
        callFunction("undo");
    else {
        for (size_t i = m_transactionSteps.size(); i > 0; --i)
            m_transactionSteps[i - 1]->unapply();
    }

    if (m_undoManager)
        m_undoManager->registerRedoStep(this);
}
示例#23
0
//__ \subsection{eventPickup(feature, droid)}
//__ An event that is run whenever a feature is picked up. It is called for
//__ all players / scripts.
//__ Careful passing the parameter object around, since it is about to vanish! (3.2+ only)
bool triggerEventPickup(FEATURE *psFeat, DROID *psDroid)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		QScriptValueList args;
		args += convFeature(psFeat, engine);
		args += convDroid(psDroid, engine);
		callFunction(engine, "eventPickup", args);
	}
	return true;
}
示例#24
0
/// For generic, parameter-less triggers
//__ \subsection{eventGameInit()}
//__ An event that is run once as the game is initialized. Not all game may have been 
//__ properly initialized by this time, so use this only to initialize script state.
//__ \subsection{eventStartLevel()}
//__ An event that is run once the game has started and all game data has been loaded.
//__ \subsection{eventLaunchTransporter()}
//__ An event that is run when the transporter has been ordered to fly off in a mission.
//__ \subsection{eventReinforcementsArrived()}
//__ An event that is run when the transporter has arrived with reinforcements in a mission.
//__ \subsection{eventMissionTimeout()}
//__ An event that is run when the mission timer has run out.
//__ \subsection{eventVideoDone()}
//__ An event that is run when a video show stopped playing.
bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);

		switch (trigger)
		{
		case TRIGGER_GAME_INIT:
			callFunction(engine, "eventGameInit", QScriptValueList());
			break;
		case TRIGGER_START_LEVEL:
			processVisibility(); // make sure we initialize visibility first
			callFunction(engine, "eventStartLevel", QScriptValueList());
			break;
		case TRIGGER_LAUNCH_TRANSPORTER:
			callFunction(engine, "eventLaunchTransporter", QScriptValueList());
			break;
		case TRIGGER_REINFORCEMENTS_ARRIVED:
			callFunction(engine, "eventReinforcementsArrived", QScriptValueList());
			break;
		case TRIGGER_MISSION_TIMEOUT:
			callFunction(engine, "eventMissionTimeout", QScriptValueList());
			break;
		case TRIGGER_VIDEO_QUIT:
			callFunction(engine, "eventVideoDone", QScriptValueList());
			break;
		}
	}
	return true;
}
示例#25
0
void __cdecl JavaToCCallHandler_Sub(CallTempStruct* call, JavaToNativeCallbackCallInfo* info, jobject instance, DCArgs* args, DCValue* result)
{
	void* callbackPtr;
	
	dcMode(call->vm, info->fInfo.fDCMode);
	//dcReset(call->vm);
	
	callbackPtr = getNativeObjectPointer(call->env, instance, NULL);
	
	// printf("doJavaToCCallHandler(callback = %d) !!!\n", callback);
	
	callFunction(call, &info->fInfo, args, result, callbackPtr, 0);
}
示例#26
0
bool updateScripts()
{
	// Update gameTime
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);

		engine->globalObject().setProperty("gameTime", gameTime, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	}
	// Weed out dead timers
	for (int i = 0; i < timers.count(); )
	{
		const timerNode node = timers.at(i);
		if (node.type == TIMER_ONESHOT_DONE || (node.baseobj > 0 && !IdToPointer(node.baseobj, node.player)))
		{
			timers.removeAt(i);
		}
		else
		{
			i++;
		}
	}
	// Check for timers, and run them if applicable.
	// TODO - load balancing
	QList<timerNode> runlist; // make a new list here, since we might trample all over the timer list during execution
	QList<timerNode>::iterator iter;
	// Weed out dead timers
	for (iter = timers.begin(); iter != timers.end(); iter++)
	{
		if (iter->frameTime <= gameTime)
		{
			iter->frameTime = iter->ms + gameTime;	// update for next invokation
			if (iter->type == TIMER_ONESHOT_READY)
			{
				iter->type = TIMER_ONESHOT_DONE; // unless there is none
			}
			runlist.append(*iter);
		}
	}
	for (iter = runlist.begin(); iter != runlist.end(); iter++)
	{
		QScriptValueList args;
		if (iter->baseobj > 0)
		{
			args += convObj(IdToPointer(iter->baseobj, iter->player), iter->engine);
		}
		callFunction(iter->engine, iter->function, args, true);
	}
	return true;
}
示例#27
0
void PokeModel::setActive(int row, bool active)
{
    pokeEvent([this, row, active] {
        if (auto trainer = getTrainer(row)) {
            if (active)
                pokemem_trainer_activate(trainer);
            else
                pokemem_trainer_deactivate(trainer);
            callFunction([this, row] {
                emit dataChanged(index(row), index(row));
            });
        }
    });
}
示例#28
0
//__ \subsection{eventDestroyed(object)}
//__ An event that is run whenever an object is destroyed for the owning player.
//__ Careful passing the parameter object around, since it is about to vanish!
bool triggerEventDestroyed(BASE_OBJECT *psVictim)
{
	for (int i = 0; i < scripts.size() && psVictim; ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		int me = engine->globalObject().property("me").toInt32();
		if (me == psVictim->player)
		{
			QScriptValueList args;
			args += convMax(psVictim, engine);
			callFunction(engine, "eventDestroyed", args);
		}
	}
	return true;
}
示例#29
0
//__ \subsection{eventStructureReady(structure)}
//__ An event that is run every time a structure is ready to perform some
//__ special ability. It will only fire once, so if the time is not right,
//__ register your own timer to keep checking.
bool triggerEventStructureReady(STRUCTURE *psStruct)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		int player = engine->globalObject().property("me").toInt32();
		if (player == psStruct->player)
		{
			QScriptValueList args;
			args += convStructure(psStruct, engine);
			callFunction(engine, "eventStructureReady", args);
		}
	}
	return true;
}
示例#30
0
//__ \subsection{eventDroidIdle(droid)} A droid should be given new orders.
bool triggerEventDroidIdle(DROID *psDroid)
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		int player = engine->globalObject().property("me").toInt32();
		if (player == psDroid->player)
		{
			QScriptValueList args;
			args += convDroid(psDroid, engine);
			callFunction(engine, "eventDroidIdle", args);
		}
	}
	return true;
}