static int cc_token(parser_ctx_t *ctx, void *lval) { unsigned id_len = 0; cc_var_t *var; static const WCHAR cc_onW[] = {'c','c','_','o','n',0}; static const WCHAR setW[] = {'s','e','t',0}; static const WCHAR elifW[] = {'e','l','i','f',0}; static const WCHAR endW[] = {'e','n','d',0}; ctx->ptr++; if(!check_keyword(ctx, cc_onW, NULL)) return init_cc(ctx); if(!check_keyword(ctx, setW, NULL)) { FIXME("@set not implemented\n"); return lex_error(ctx, E_NOTIMPL); } if(!check_keyword(ctx, ifW, NULL)) { FIXME("@if not implemented\n"); return lex_error(ctx, E_NOTIMPL); } if(!check_keyword(ctx, elifW, NULL)) { FIXME("@elif not implemented\n"); return lex_error(ctx, E_NOTIMPL); } if(!check_keyword(ctx, elseW, NULL)) { FIXME("@else not implemented\n"); return lex_error(ctx, E_NOTIMPL); } if(!check_keyword(ctx, endW, NULL)) { FIXME("@end not implemented\n"); return lex_error(ctx, E_NOTIMPL); } if(!ctx->script->cc) return lex_error(ctx, JS_E_DISABLED_CC); while(ctx->ptr+id_len < ctx->end && is_identifier_char(ctx->ptr[id_len])) id_len++; if(!id_len) return '@'; TRACE("var %s\n", debugstr_wn(ctx->ptr, id_len)); var = find_cc_var(ctx->script->cc, ctx->ptr, id_len); ctx->ptr += id_len; if(!var || var->is_num) { *(literal_t**)lval = new_double_literal(ctx, var ? var->u.n : ret_nan()); return tNumericLiteral; } *(literal_t**)lval = new_boolean_literal(ctx, var->u.b); return tBooleanLiteral; }
void main (void) { init_cc(); BSP_Init(); /* If an on-the-fly device address is generated it must be done before the * call to SMPL_Init(). If the address is set here the ROM value will not * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call * will not take effect. One shot only. The IOCTL call below is conformal. */ #ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE { addr_t lAddr; createRandomAddress(&lAddr); SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr); } #endif /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */ /* This call will fail because the join will fail since there is no Access Point * in this scenario. But we don't care -- just use the default link token later. * We supply a callback pointer to handle the message returned by the peer. */ SMPL_Init(sRxCallback); /* turn on LEDs. */ if (!BSP_LED2_IS_ON()) { toggleLED(2); } if (!BSP_LED1_IS_ON()) { toggleLED(1); } /* wait for a button press... */ do { if (BSP_BUTTON1() || BSP_BUTTON2()) { break; } } while (1); /* never coming back... */ linkTo(); /* but in case we do... */ while (1) ; }
static int cc_token(parser_ctx_t *ctx, void *lval) { unsigned id_len = 0; cc_var_t *var; static const WCHAR cc_onW[] = {'c','c','_','o','n',0}; static const WCHAR setW[] = {'s','e','t',0}; ctx->ptr++; if(!check_keyword(ctx, cc_onW, NULL)) return init_cc(ctx) ? 0 : -1; if(!check_keyword(ctx, setW, NULL)) { const WCHAR *ident; unsigned ident_len; cc_var_t *var; if(!init_cc(ctx)) return -1; if(!skip_spaces(ctx)) return lex_error(ctx, JS_E_EXPECTED_AT); if(!parse_cc_identifier(ctx, &ident, &ident_len)) return -1; if(!skip_spaces(ctx) || *ctx->ptr != '=') return lex_error(ctx, JS_E_EXPECTED_ASSIGN); ctx->ptr++; if(!parse_cc_expr(ctx)) { WARN("parsing CC expression failed\n"); return -1; } var = find_cc_var(ctx->script->cc, ident, ident_len); if(var) { var->val = ctx->ccval; }else { if(!new_cc_var(ctx->script->cc, ident, ident_len, ctx->ccval)) return lex_error(ctx, E_OUTOFMEMORY); } return 0; } if(!check_keyword(ctx, ifW, NULL)) { if(!init_cc(ctx)) return -1; if(!skip_spaces(ctx) || *ctx->ptr != '(') return lex_error(ctx, JS_E_MISSING_LBRACKET); if(!parse_cc_expr(ctx)) return -1; if(get_ccbool(ctx->ccval)) { /* continue parsing block inside if */ ctx->cc_if_depth++; return 0; } return skip_code(ctx, TRUE); } if(!check_keyword(ctx, elifW, NULL) || !check_keyword(ctx, elseW, NULL)) { if(!ctx->cc_if_depth) return lex_error(ctx, JS_E_SYNTAX); return skip_code(ctx, FALSE); } if(!check_keyword(ctx, endW, NULL)) { if(!ctx->cc_if_depth) return lex_error(ctx, JS_E_SYNTAX); ctx->cc_if_depth--; return 0; } if(!ctx->script->cc) return lex_error(ctx, JS_E_DISABLED_CC); while(ctx->ptr+id_len < ctx->end && is_identifier_char(ctx->ptr[id_len])) id_len++; if(!id_len) return '@'; TRACE("var %s\n", debugstr_wn(ctx->ptr, id_len)); var = find_cc_var(ctx->script->cc, ctx->ptr, id_len); ctx->ptr += id_len; if(!var || var->val.is_num) { *(literal_t**)lval = new_double_literal(ctx, var ? var->val.u.n : NAN); return tNumericLiteral; } *(literal_t**)lval = new_boolean_literal(ctx, var->val.u.b); return tBooleanLiteral; }
void Init_wii4r() { wii_mod = rb_define_module("Wii"); rb_define_const(wii_mod, "MAX_WIIMOTES", INT2NUM(4)); rb_define_const(wii_mod, "TIMEOUT", INT2NUM(5)); //Wiimote led consts rb_define_const(wii_mod, "LED_NONE", INT2NUM(WIIMOTE_LED_NONE)); rb_define_const(wii_mod, "LED_1", INT2NUM(WIIMOTE_LED_1)); rb_define_const(wii_mod, "LED_2", INT2NUM(WIIMOTE_LED_2)); rb_define_const(wii_mod, "LED_3", INT2NUM(WIIMOTE_LED_3)); rb_define_const(wii_mod, "LED_4", INT2NUM(WIIMOTE_LED_4)); //Wiimote button consts rb_define_const(wii_mod, "BUTTON_A", INT2NUM(WIIMOTE_BUTTON_A)); rb_define_const(wii_mod, "BUTTON_B", INT2NUM(WIIMOTE_BUTTON_B)); rb_define_const(wii_mod, "BUTTON_ONE", INT2NUM(WIIMOTE_BUTTON_ONE)); rb_define_const(wii_mod, "BUTTON_TWO", INT2NUM(WIIMOTE_BUTTON_TWO)); rb_define_const(wii_mod, "BUTTON_PLUS", INT2NUM(WIIMOTE_BUTTON_PLUS)); rb_define_const(wii_mod, "BUTTON_MINUS", INT2NUM(WIIMOTE_BUTTON_MINUS)); rb_define_const(wii_mod, "BUTTON_HOME", INT2NUM(WIIMOTE_BUTTON_HOME)); rb_define_const(wii_mod, "BUTTON_LEFT", INT2NUM(WIIMOTE_BUTTON_LEFT)); rb_define_const(wii_mod, "BUTTON_RIGHT", INT2NUM(WIIMOTE_BUTTON_RIGHT)); rb_define_const(wii_mod, "BUTTON_DOWN", INT2NUM(WIIMOTE_BUTTON_DOWN)); rb_define_const(wii_mod, "BUTTON_UP", INT2NUM(WIIMOTE_BUTTON_UP)); rb_define_const(wii_mod, "BUTTON_ALL", INT2NUM(WIIMOTE_BUTTON_ALL)); //Wiimote nunchuk button consts rb_define_const(wii_mod, "N_BUTTON_Z", INT2NUM(NUNCHUK_BUTTON_Z)); rb_define_const(wii_mod, "N_BUTTON_C", INT2NUM(NUNCHUK_BUTTON_C)); rb_define_const(wii_mod, "N_BUTTON_ALL", INT2NUM(NUNCHUK_BUTTON_ALL)); //Wiimote classic controller button codes rb_define_const(wii_mod, "C_BUTTON_UP", INT2NUM(CLASSIC_CTRL_BUTTON_UP)); rb_define_const(wii_mod, "C_BUTTON_LEFT", INT2NUM(CLASSIC_CTRL_BUTTON_LEFT)); rb_define_const(wii_mod, "C_BUTTON_ZR", INT2NUM(CLASSIC_CTRL_BUTTON_ZR)); rb_define_const(wii_mod, "C_BUTTON_X", INT2NUM(CLASSIC_CTRL_BUTTON_X)); rb_define_const(wii_mod, "C_BUTTON_A", INT2NUM(CLASSIC_CTRL_BUTTON_A)); rb_define_const(wii_mod, "C_BUTTON_Y", INT2NUM(CLASSIC_CTRL_BUTTON_Y)); rb_define_const(wii_mod, "C_BUTTON_B", INT2NUM(CLASSIC_CTRL_BUTTON_B)); rb_define_const(wii_mod, "C_BUTTON_ZL", INT2NUM(CLASSIC_CTRL_BUTTON_ZL)); rb_define_const(wii_mod, "C_BUTTON_FULL_R", INT2NUM(CLASSIC_CTRL_BUTTON_FULL_R)); rb_define_const(wii_mod, "C_BUTTON_PLUS", INT2NUM(CLASSIC_CTRL_BUTTON_PLUS)); rb_define_const(wii_mod, "C_BUTTON_HOME", INT2NUM(CLASSIC_CTRL_BUTTON_HOME)); rb_define_const(wii_mod, "C_BUTTON_MINUS", INT2NUM(CLASSIC_CTRL_BUTTON_MINUS)); rb_define_const(wii_mod, "C_BUTTON_FULL_L", INT2NUM(CLASSIC_CTRL_BUTTON_FULL_L)); rb_define_const(wii_mod, "C_BUTTON_DOWN", INT2NUM(CLASSIC_CTRL_BUTTON_DOWN)); rb_define_const(wii_mod, "C_BUTTON_RIGHT", INT2NUM(CLASSIC_CTRL_BUTTON_RIGHT)); rb_define_const(wii_mod, "C_BUTTON_ALL", INT2NUM(CLASSIC_CTRL_BUTTON_ALL)); //Wiimote hero button codes rb_define_const(wii_mod, "GUITAR_BUTTON_UP", INT2NUM(GUITAR_HERO_3_BUTTON_STRUM_UP)); rb_define_const(wii_mod, "GUITAR_BUTTON_YELLOW", INT2NUM(GUITAR_HERO_3_BUTTON_YELLOW)); rb_define_const(wii_mod, "GUITAR_BUTTON_GREEN", INT2NUM(GUITAR_HERO_3_BUTTON_GREEN)); rb_define_const(wii_mod, "GUITAR_BUTTON_BLUE", INT2NUM(GUITAR_HERO_3_BUTTON_BLUE)); rb_define_const(wii_mod, "GUITAR_BUTTON_RED", INT2NUM(GUITAR_HERO_3_BUTTON_RED)); rb_define_const(wii_mod, "GUITAR_BUTTON_ORANGE", INT2NUM(GUITAR_HERO_3_BUTTON_ORANGE)); rb_define_const(wii_mod, "GUITAR_BUTTON_PLUS", INT2NUM(GUITAR_HERO_3_BUTTON_PLUS)); rb_define_const(wii_mod, "GUITAR_BUTTON_MINUS", INT2NUM(GUITAR_HERO_3_BUTTON_MINUS)); rb_define_const(wii_mod, "GUITAR_BUTTON_DOWN", INT2NUM(GUITAR_HERO_3_BUTTON_STRUM_DOWN)); rb_define_const(wii_mod, "GUITAR_BUTTON_ALL", INT2NUM(GUITAR_HERO_3_BUTTON_ALL)); //Wiimote expansion codes rb_define_const(wii_mod, "EXP_NONE", INT2NUM(EXP_NONE)); rb_define_const(wii_mod, "EXP_NUNCHUK", INT2NUM(EXP_NUNCHUK)); rb_define_const(wii_mod, "EXP_CLASSIC", INT2NUM(EXP_CLASSIC)); rb_define_const(wii_mod, "EXP_GUITAR", INT2NUM(EXP_GUITAR_HERO_3)); //Aspect ratio and sensor bar position constants rb_define_const(wii_mod, "ASPECT_4_3", INT2NUM(WIIUSE_ASPECT_4_3)); rb_define_const(wii_mod, "ASPECT_16_9", INT2NUM(WIIUSE_ASPECT_16_9)); rb_define_const(wii_mod, "ABOVE", INT2NUM(WIIUSE_IR_ABOVE)); rb_define_const(wii_mod, "BELOW", INT2NUM(WIIUSE_IR_BELOW)); init_wiimotemanager(); init_wiimote(); init_nunchuk(); init_gh3(); init_cc(); init_exceptions(); }