Exemplo n.º 1
0
UIElement * UserInterface::Activate(){
	UIElement * stackTop = GetStackTop();
	if (!stackTop)
		return NULL;
	UIElement * result = NULL;
	result = stackTop->Activate();
	if (result)
	{
		if (result->activationMessage.Length() == 0){
		//	assert(false && "Activatable UI element has no valid activation message string!");
			return NULL;
		}
		if (result->activationMessage.Length() != 0){
			if (result->activationMessage.Type() == String::WIDE_CHAR)
				result->activationMessage.ConvertToChar();
			List<String> msgs = result->activationMessage.Tokenize("&");
			for (int i = 0; i < msgs.Size(); ++i){
				Message * message = new Message(msgs[i]);
				message->element = result;
				MesMan.QueueMessage(message);
			}
			return result;
		}
		else {
			std::cout<<"\nonActivate and activationMessage both NULL in element: "<<result->name;
			return NULL;
		}
	}
	return result;
}
Exemplo n.º 2
0
/// If allUi is specified, the action will try, similar to hover, and go through the entire stack from the top down until it processes an element.
UIElement * UserInterface::Click(int x, int y, bool allUi){
	UIElement * elementClicked = NULL;
	if (allUi){
		for (int i = stack.Size()-1; i >= 0; --i)
		{
			UIElement * stackElement = stack[i];
			elementClicked = stackElement->Click(x,y);
			if (elementClicked)
				break;
		}
		/// If still no result, try the root.
		if (!elementClicked)
		{
			elementClicked = root->Click(x,y);
		}
		/// Demand hover will have to be investigated how it could work in this mode, if at all.
	}
	/// Old code for just the stack-top
	else {
		UIElement * stackTop = GetStackTop();
		if (!stackTop)
			return NULL;
		/// Clear the active-flag?
		elementClicked = stackTop->Click(x,y);
	}
	return elementClicked;
}
	String LuaState::DumpStack() const
	{
		StringStream stream;
		unsigned int stackTop = GetStackTop();
		stream << stackTop << " entries\n";

		for (unsigned int i = 1; i <= stackTop; ++i)
		{
			stream << i << ": ";
			switch (GetType(i))
			{
				case LuaType_Boolean:
					stream << "Boolean(" << ToBoolean(i) << ')';
					break;

				case LuaType_Function:
					stream << "Function(" << ToPointer(i) << ')';
					break;

				case LuaType_LightUserdata:
				case LuaType_Userdata:
					stream << "Userdata(" << ToUserdata(i) << ')';
					break;

				case LuaType_Nil:
					stream << "Nil";
					break;

				case LuaType_None:
					stream << "None";
					break;

				case LuaType_Number:
					stream << "Number(" << ToNumber(i) << ')';
					break;

				case LuaType_String:
					stream << "String(" << ToString(i) << ')';
					break;

				case LuaType_Table:
					stream << "Table(" << ToPointer(i) << ')';
					break;

				case LuaType_Thread:
					stream << "Thread(" << ToPointer(i) << ')';
					break;

				default:
					stream << "Unknown(" << ToPointer(i) << ')';
					break;
			}

			stream << '\n';
		}

		return stream.ToString();
	}
Exemplo n.º 4
0
/// If false, will use current stack top to get hover element. If using mouse you should pass true as argument.
UIElement * UserInterface::GetHoverElement(bool fromRoot /* = false */)
{
	if (fromRoot)
		return root->GetElementByState(UIState::HOVER);
	UIElement * stackTop = GetStackTop();
	if (stackTop)
		return stackTop->GetElementByState(UIState::HOVER);
	return NULL;
}
Exemplo n.º 5
0
void State::Resume() {
  AssertCritical();
  Cpu::GetCurrent().SetAsyncKernelTop((void *)GetStackTop());
  if (iretInfo.cs & 3) {
    __asm__ __volatile__("swapgs");
  }

  __asm__ __volatile__(
    "sub $0x28, %%rsp\n"
    "mov $5, %%rcx\n"
    "mov %%rsp, %%rdi\n"
    "rep movsq\n"
    "mov %%rdx, %%rdi\n"
    "iretq"
    : : "S" (&iretInfo), "d" (rdi)
  );
  
  __builtin_unreachable();
}
Exemplo n.º 6
0
bool mozilla_sampler_register_thread(const char* aName, void* aGuessStackTop)
{
  if (sInitCount == 0) {
    return false;
  }

#if defined(MOZ_WIDGET_GONK) && !defined(MOZ_PROFILING)
  // The only way to profile secondary threads on b2g
  // is to build with profiling OR have the profiler
  // running on startup.
  if (!profiler_is_active()) {
    return false;
  }
#endif

  MOZ_ASSERT(tlsPseudoStack.get() == nullptr);
  PseudoStack* stack = PseudoStack::create();
  tlsPseudoStack.set(stack);
  bool isMainThread = is_main_thread_name(aName);
  void* stackTop = GetStackTop(aGuessStackTop);
  return Sampler::RegisterCurrentThread(aName, stack, isMainThread, stackTop);
}
Exemplo n.º 7
0
Arquivo: exp.c Projeto: Jungzhang/-C-
//输入表达式并计算结果
double CalculateExp(void)
{
	double result, tempNum1, tempNum2;
	double data = 0, expn;
	char ch, topSign, point = 'n', num = 'n';
	OPTR *sign;
	OPRD *number;

	InitStack(OPTR, &sign);
	InitStack(OPRD, &number);
	PushStack(sign, '#');
	printf("请输入表达式:");
	ch = getchar();
	GetStackTop(sign, &topSign);

	while(ch != '#' || topSign != '#'){
		if ('0' <= ch && ch <= '9' || ch == '.'){
			if (ch == '.' && point == 'y'){
				printf("表达式输入有误!\n");
				exit(-1);
			}
			else if (ch == '.' && point == 'n'){
				point = 'y';
				expn = 0.1;
			}
			else{
				if (point == 'y'){
					data = data + expn * (ch - '0');
					expn *= 0.1;
				}
				else{
					data = data * 10 + (ch - '0');
				}
				num = 'y';
			}
			ch = getchar();
		}
		else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '(' || ch == ')' || ch == '#'){
			if (num == 'y'){
				PushStack(number, data);
				num = 'n';	point = 'n';
				data = 0;
			}
			GetStackTop(sign, &topSign);
			switch(compare(ch, topSign)){
				case '<':		//扫描运算符优先级小于栈顶元素
					PopStack(sign, &topSign);
					PopStack(number, &tempNum1);
					PopStack(number, &tempNum2);
					switch(topSign){
						case '+':	result = tempNum1 + tempNum2;	break;
						case '-':	result = tempNum1 - tempNum2;	break;
						case '*':	result = tempNum1 * tempNum2;	break;
						case '/':	result = tempNum2 / tempNum1;	break;
					}
					PushStack(number, result);
					break;
				case '>':		//扫描运算符优先级大于栈顶元素
					PushStack(sign, ch);
					ch = getchar();
					break;
				case '=':		//扫描运算符为右括号,匹配到了左括号
					PopStack(sign, &topSign);
					ch = getchar();
					break;
			}
		}
		else if (ch == '\n'){
			ch = '#';
		}
		else{
			printf("输入的表达式有误!\n");
			exit(-1);
		}
		GetStackTop(sign, &topSign);
	}
	PopStack(number, &result);	//将结果从栈中取出来
	if (!EmptyStack(number)){   //如果取出后栈不为空则表示输入的表达式不正确
		printf("表达式有误!\n");
		exit(-1);
	}
	
	return result;
}
Exemplo n.º 8
0
/// Removes target state flags from all elements in the active stack-level.
void UserInterface::RemoveState(int state){
	UIElement * currentElement = GetStackTop();
	if (!currentElement)
		return;
	currentElement->RemoveState(state, true);
}
Exemplo n.º 9
0
/** Mouse interactions with the UI, in x and y from 0.0 to 1.0, with 0.0 being in the Upper Left corner. Returns the element currently hovered over.
	If allUi is specified the current stack order will be ignored to a certain extent, meaning that ui below the current stack top will be made available too.
	Search is conducted starting at the highest stack element and going down until an element is found that we can hover over.
*/
UIElement * UserInterface::Hover(int x, int y, bool allUi)
{
	UIElement * stackTop = GetStackTop();
	if (!stackTop)
		return NULL;
	UIElement * previousHoverElement = NULL;
	if (!previousHoverElement)
	{			
		previousHoverElement = stackTop->GetElementByState(UIState::HOVER);
//		std::cout<<"\nPrevious hover element: "<<previousHoverElement;
//		if (previousHoverElement)
//			std::cout<<previousHoverElement->name;
	}
	UIElement * result = NULL;
	/// Search taking into consideration the stack but searching until an element is found.
	if(allUi)
	{
		for (int i = stack.Size()-1; i >= 0; --i)
		{
			UIElement * stackElement = stack[i];
			/// Remove the hover flag before re-hovering.
			stackElement->RemoveFlags(UIState::HOVER);
			result = stackElement->Hover(x,y);
			if (result)
				break;
		}
		/// If still no result, try the root.
		if (!result)
		{
			root->RemoveFlags(UIState::HOVER);
			result = root->Hover(x,y);
		}
		/// Demand hover will have to be investigated how it could work in this mode, if at all.
		hoverElement = result;	
	}
	/// Old search using only the stack-top.
	else {
		UIElement * previous = stackTop->GetElementByState(UIState::HOVER);
		/// Remove the hover flag before re-hovering.
		stackTop->RemoveFlags(UIState::HOVER);
		result = stackTop->Hover(x,y);
		hoverElement = result;
		/// If we always want a hovered element (for whatever reason).
		if (!hoverElement && demandHovered && previous){
			hoverElement = stackTop->Hover(previous->posX, previous->posY);
		}
	}

	if (inputState->demandHoverElement && result == NULL)
	{
		/// Try reverting to previous element?
		if (previousHoverElement)
		{
			result = previousHoverElement;
			result->state |= UIState::HOVER;
		}
		if (result == NULL)
		{
//			std::cout<<"\nProblema.";
		}
	}
	return result;
}
Exemplo n.º 10
0
int main()
{
    UART_CFG_Type uart_config;
    UART_FIFO_CFG_Type uart_fifo_config;
    TIM_TIMERCFG_Type timer_config;
    TIM_MATCHCFG_Type timer_match;
    OS_TID uart_task_id = 0;
    OS_TID activity_task_id = 0;
    uint32_t reset_flags = 0;

    reset_flags = LPC_SYSCON->SYSRSTSTAT;

    SEQ_Initialize();
    PROTO_Reset();
    PROTO_SetHandlers(g_protocol_handlers);

    SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);

    // Reset pin
    IOCON_SetPinFunc(IOCON_PIO0_0, PIO0_0_FUN_RESET);

    // Status LED pin
    ACTIVITY_SET_PIN();
    GPIO_SetDir(ACTIVITY_PORT, ACTIVITY_PIN, 1);
    GPIO_ResetBits(ACTIVITY_PORT, ACTIVITY_PIN);

    // Timer activity LED pin
    TIMER_ACTIVITY_SET_PIN();
    GPIO_SetDir(TIMER_ACTIVITY_PORT, TIMER_ACTIVITY_PIN, 1);
    GPIO_ResetBits(TIMER_ACTIVITY_PORT, TIMER_ACTIVITY_PIN);

    // RGB control
    RED_SET_PIN();
    GREEN_SET_PIN();
    BLUE_SET_PIN();
    GPIO_SetDir(RED_PORT, RED_PIN, 1);
    GPIO_SetDir(GREEN_PORT, GREEN_PIN, 1);
    GPIO_SetDir(BLUE_PORT, BLUE_PIN, 1);
    GPIO_ResetBits(RED_PORT, RED_PIN);
    GPIO_ResetBits(GREEN_PORT, GREEN_PIN);
    GPIO_ResetBits(BLUE_PORT, BLUE_PIN);

    timer_config.PrescaleOption = TIM_PRESCALE_TICKVAL;
    timer_config.PrescaleValue = 1;
    TIM_Init(LPC_TMR32B0, TIM_TIMER_MODE, &timer_config);

    timer_match.MatchChannel = 0;
    timer_match.IntOnMatch = ENABLE;
    timer_match.StopOnMatch = DISABLE;
    timer_match.ResetOnMatch = ENABLE;
    timer_match.ExtMatchOutputType = 0;
    timer_match.MatchValue = SystemCoreClock / (TICKS_PER_SECOND * 256);
    TIM_ConfigMatch(LPC_TMR32B0, &timer_match);

    TIM_Cmd(LPC_TMR32B0, ENABLE);
    NVIC_EnableIRQ(TIMER_32_0_IRQn);

    // UART
    IOCON_SetPinFunc(IOCON_PIO1_6, PIO1_6_FUN_RXD);   /* UART RXD - PIO1_6 */
    IOCON_SetPinFunc(IOCON_PIO1_7, PIO1_7_FUN_TXD);   /* UART RXD - PIO1_7 */

    uart_config.Baud_rate = 115200;
    uart_config.Databits = UART_DATABIT_8;
    uart_config.Parity = UART_PARITY_NONE;
    uart_config.Stopbits = UART_STOPBIT_1;

    UART_Init(LPC_UART, &uart_config);

    uart_fifo_config.FIFO_Level = UART_FIFO_TRGLEV0;
    uart_fifo_config.FIFO_ResetRxBuf = ENABLE;
    uart_fifo_config.FIFO_ResetTxBuf = ENABLE;
    UART_FIFOConfig(LPC_UART, &uart_fifo_config);

    UART_TxCmd(LPC_UART, ENABLE);

    // SPI
    CL632_Init();
    // Select page 0 and no paging access
    CL632_SpiWriteByte(0x00, 0x00);
    CL632_SpiWriteByte(0x00, 0x00);

    // LCD
    // LCD backlite control
    LCD_BACKLITE_SET_PIN();
    GPIO_SetDir(LCD_BACKLITE_PORT, LCD_BACKLITE_PIN, 1);
    GPIO_ResetBits(LCD_BACKLITE_PORT, LCD_BACKLITE_PIN);

    // LCD Data bus
    LCD_DATA_SET_PINS();
    GPIO_SetDir(LCD_DATA_PORT, LCD_DATA_BUS, 1);
    GPIO_ResetBits(LCD_DATA_PORT, LCD_DATA_BUS);

    LCD_RS_SET_PIN();
    GPIO_SetDir(LCD_RS_PORT, LCD_RS_PIN, 1);
    GPIO_ResetBits(LCD_RS_PORT, LCD_RS_PIN);

    LCD_RW_SET_PIN();
    GPIO_SetDir(LCD_RW_PORT, LCD_RW_PIN, 1);
    GPIO_ResetBits(LCD_RW_PORT, LCD_RW_PIN);

    LCD_E_SET_PIN();
    GPIO_SetDir(LCD_E_PORT, LCD_E_PIN, 1);
    GPIO_ResetBits(LCD_E_PORT, LCD_E_PIN);

    KS0066_PowerUpDelay();
    KS0066_FunctionSet();
    KS0066_WaitForIdle();
    KS0066_DisplayOnOffControl(KS0066_DISPCTL_DISPLAY_ON);
    KS0066_WaitForIdle();
    KS0066_ClearDisplay();
    KS0066_WaitForIdle();

    CoInitOS();
    GPIO_SetBits(ACTIVITY_PORT, ACTIVITY_PIN);

    uart_task_id = CoCreateTask(uartTask, NULL, UART_TASK_PRIORITY,
            GetStackTop(uartTaskStack), GetStackSize(uartTaskStack));

    activity_task_id = CoCreateTask(activityTask, NULL, ACTIVITY_TASK_PRIORITY,
            GetStackTop(activityTaskStack), GetStackSize(activityTaskStack));

    if (uart_task_id == E_CREATE_FAIL || activity_task_id == E_CREATE_FAIL) {
        UART_PrintString("INIT ERROR");
        UART_PrintString(kNewLine);
    }

    if (reset_flags & 0x01)
        UART_PrintString("RST:PU");
    else if (reset_flags & 0x02)
        UART_PrintString("RST:RST");
    else if (reset_flags & 0x04)
        UART_PrintString("RST:WDT");
    else if (reset_flags & 0x08)
        UART_PrintString("RST:BOD");
    else if (reset_flags & 0x10)
        UART_PrintString("RST:SOFT");
    else
        UART_PrintString("RST");

    UART_PrintString(kNewLine);

    PrintVersionString(UART_WriteChar);
    UART_PrintString(kNewLine);
    func_printf_nofloat(UART_WriteChar, "COOS:%d\r\n", CoGetOSVersion());

    KS0066_WriteString("V:" __DATE__ " " __TIME__, KS0066_WRAP_FLAG);

    CoStartOS();

    //while (1) {
    //}

    return 0;
}