예제 #1
0
PRT_VALUE *P_FUN_StartTimer_IMPL(PRT_MACHINEINST *context)
{
	PRT_MACHINEINST_PRIV *p_tmp_mach_priv = (PRT_MACHINEINST_PRIV *)context;
	PRT_VALUE *p_tmp_ret = NULL;
	PRT_FUNSTACK_INFO p_tmp_frame;

	// pop frame
	PrtPopFrame(p_tmp_mach_priv, &p_tmp_frame);

	PRT_VALUE* timerMachineId = p_tmp_frame.locals[0];
	PRT_MACHINEINST* timerMachine = PrtGetMachine(context->process, timerMachineId);
	TimerContext *timerContext = (TimerContext *)timerMachine->extContext;

	int timeout_value = p_tmp_frame.locals[1]->valueUnion.nt;
	
	SleepMs(timeout_value);

	PRT_VALUE *ev = PrtMkEventValue(P_EVENT_TIMEOUT);
	PRT_MACHINEINST* clientMachine = PrtGetMachine(context->process, timerContext->client);
	PrtSend(context, clientMachine, ev, context->id, PRT_FALSE);
	PrtFreeValue(ev);

	// free the frame
	PrtFreeLocals(p_tmp_mach_priv, &p_tmp_frame);
	return NULL;
}
예제 #2
0
	PRT_VALUE *P_FUN_GetSystemTime_IMPL(PRT_MACHINEINST *context)
	{
		PRT_MACHINEINST_PRIV *p_tmp_mach_priv = (PRT_MACHINEINST_PRIV *)context;
		PRT_FUNSTACK_INFO p_tmp_frame;
		PrtPopFrame(p_tmp_mach_priv, &p_tmp_frame);

		int ms = GetTickCount();

		PrtFreeLocals(p_tmp_mach_priv, &p_tmp_frame);
		return PrtMkIntValue(ms);
	}
예제 #3
0
파일: ForeignTypes.c 프로젝트: annakoppad/P
PRT_VALUE *P_FUN_TestMachine_GetPassword_IMPL(PRT_MACHINEINST *context)
{
	PRT_MACHINEINST_PRIV *p_tmp_mach_priv = (PRT_MACHINEINST_PRIV *)context;
	PRT_VALUE *p_tmp_ret = NULL;
	PRT_FUNSTACK_INFO p_tmp_frame;
	//remm to pop frame
	PrtPopFrame(p_tmp_mach_priv, &p_tmp_frame);
	//remm to free the frame
	PrtFreeLocals(p_tmp_mach_priv, &p_tmp_frame);

	return PrtMkDefaultValue(P_GEND_TYPE_StringType);
}
예제 #4
0
	PRT_VALUE *P_FUN_CommanderMachine_SendCommandToPx4_IMPL(PRT_MACHINEINST *context)
	{
		PRT_MACHINEINST_PRIV *p_tmp_mach_priv = (PRT_MACHINEINST_PRIV *)context;
		PRT_FUNSTACK_INFO p_tmp_frame;
		PrtPopFrame(p_tmp_mach_priv, &p_tmp_frame);

		PRT_VALUE* caller = p_tmp_frame.locals[0];

		PRT_VALUE* cmdId = p_tmp_frame.locals[2];
		int cmd = 0;
		if (cmdId->discriminator == PRT_VALUE_KIND_INT)
		{
			cmd = PrtPrimGetInt(cmdId);
		}

		PRT_VALUE* confirmValue = p_tmp_frame.locals[1];
		bool confirm = false;
		if (confirmValue->discriminator == PRT_VALUE_KIND_BOOL)
		{
			confirm = (PrtPrimGetBool(confirmValue) == PRT_TRUE);
		}

		float floats[7] = { 0,0,0,0,0,0,0 };

		// gray the remaining 7 arguments and convert them to float values.
		for (int i = 3; i < 3 + 7; i++)
		{
			PRT_VALUE* arg = p_tmp_frame.locals[i];
			float value = PrtGetFloat32(arg);
			floats[i - 3] = value;
		}

		EventTrace(PProgram, 0, "Sending command: %d, with args (%f,%f,%f,%f,%f,%f,%f)\n", cmd, floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6]);

		SendCommand(cmd, confirm, floats[0], floats[1], floats[2], floats[3], floats[4], floats[5], floats[6]);

		PrtFreeLocals(p_tmp_mach_priv, &p_tmp_frame);
		return NULL;
	}