EXPR *UnitMult( int U1, int U2 ) { EXPR *expr ; expr = UnitOP3( "*", "+", UN(U1), UN(U2) ) ; return ExprFindCommensurate( expr ) ; }
EXPR *UnitDivide( int U1, int U2 ) { EXPR *expr ; expr = UnitOP3( "/", "-", UN(U1), UN(U2) ) ; return ExprFindCommensurate( expr ) ; }
int UnitAdd( EXPR *name, EXPR *def ) { unsigned int i ; EXPR *expr ; for( i = 0 ; i < U(UnitList)->used ; i++ ) { if( UN(i) == name ) { if( Compare( def, U(UN(i))->Eeval ) ) return 0 ; else { IOerror( IO_WARN, "UnitAdd", "unit %s already refined", LabelValue(name) ) ; return 1 ; } } } expr = FindBasic( def ) ; delete U(expr)->Ehead ; U(expr)->Ehead = name ; U(expr)->Eeval = def->Copy() ; ListAppend( UnitList, expr ) ; return 0 ; }
static void e_entry_up_cb(void *_data, Evas * _e, Evas_Object * _o, void *event) { E_Entry *entry; Evas_Event_Mouse_Up *ev = event; entry = _data; if (ev->button == entry->mouse_down) entry->mouse_down = 0; e_entry_configure(entry); UN(_e); UN(_o); }
EXPR *ExprFindCommensurate( EXPR *expr ) { unsigned int i, j ; EXPR *tmp, *tmp2 ; for( i = 0 ; i < U(UnitList)->used ; i++ ) { if( U(UN(i))->used != U(expr)->used ) continue ; for( j = 1 ; j < U(expr)->used ; j++ ) { if( !BooleanValue( (BOOL*) OP3( "?=", U(UN(i))->list[j], U(expr)->list[j] ) ) ) break ; } if( j == U(expr)->used ) /* found one */ { tmp = OP3( "/", U(expr)->list[0], U(UN(i))->list[0] ) ; tmp2 = Real( MAGNITUDE( tmp ), i ) ; delete tmp ; delete expr ; return tmp2 ; } } for( i = 1 ; i < U(expr)->used ; i++ ) { if( IS_ZERO( U(expr)->list[i] ) ) continue ; if( MAGNITUDE( U(expr)->list[i] ) == 1.0 ) tmp = U(UN(i))->Ehead->Copy() ; else { tmp = Operator( OPER_POW ) ; D(tmp)->Eleft = U(UN(i))->Ehead->Copy() ; D(tmp)->Eright = U(expr)->list[i]->Copy() ; } if( U(expr)->Eeval ) { tmp2 = Operator( OPER_MULTIPLY ) ; D(tmp2)->Eleft = U(expr)->Eeval ; D(tmp2)->Eright = tmp ; U(expr)->Eeval = tmp2 ; } else U(expr)->Eeval = tmp ; } tmp = Real( MAGNITUDE( U(expr)->list[0] ), U(UnitList)->used ) ; delete U(expr)->list[0] ; U(expr)->list[0] = Real(1,0) ; ListAppend( UnitList, expr ) ; return tmp ; }
/*----------------------------------------------------- player4() -----------------------------------------------------*/ int UN(player4)(int local_area[9], int ball_direction, int x, int y) { /* * Just do the same thing as homogeneousplayer */ return(UN(homogeneousplayer)(local_area, ball_direction, x, y)); }
/*----------------------------------------------------- player3() -----------------------------------------------------*/ int UN(player3)(int local_area[9], int ball_direction, int x, int y) { /* * Just do the same thing as player1 */ return(UN(player1)(local_area, ball_direction, x, y)); }
double ExprCommensurate( int U1, int U2 ) { unsigned int i ; double scale ; EXPR *tmp ; return 1.0 ; // EVIL HACK if( U1 == U2 ) return 1.0 ; if( U(UN(U1))->used != U(UN(U2))->used ) return 0.0 ; for( i = 1 ; i < U(UN(U1))->used ; i++ ) { if( !BooleanValue( (BOOL*) OP3( "?=", U(UN(U1))->list[i], U(UN(U2))->list[i] ) ) ) return 0.0 ; } tmp = OP3( "/", U(UN(U2))->list[0], U(UN(U1))->list[0] ) ; scale = MAGNITUDE( tmp ) ; delete tmp ; return scale ; }
EXPR *UnitPower( int U1, double power ) { EXPR *expr, *Epow ; Epow = Real( power, 0 ) ; expr = UnitOP3( "^", "*", UN(U1), Epow ) ; delete Epow ; return ExprFindCommensurate( expr ) ; }
/*----------------------------------------------------- player1() If the ball is nearby, either get to the east side of it, or if already on the east, kick it. -----------------------------------------------------*/ int UN(player1)(int local_area[9], int ball_direction, int x, int y) /* UN(player1)(int local_area[9] . . .) becomes EASTplayer(int local_area[9] . . .) or WESTplayer(int local_area[9] . . .) depending on whether this team is compiled to play on the east or west. */ { /* * Just do the same thing as homogeneousplayer */ return(UN(homogeneousplayer)(local_area, ball_direction, x, y)); }
int UnitFind( EXPR *def ) { unsigned int i ; EXPR *expr ; for( i = 0 ; i < U(UnitList)->used ; i++ ) { if( Compare( U(UN(i))->Eeval, def ) ) return i ; } expr = FindBasic( def ) ; U(expr)->Eeval = def->Copy() ; ListAppend( UnitList, expr ) ; return U(UnitList)->used - 1 ; }
void e_entry_set_size(E_Entry *entry, int w, int h) { int p1l, p1r, p1t, p1b; int p2l, p2r, p2t, p2b; p1l = p1r = p1t = p1b = 0; if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); if (p1l + p1r + p2l + p2r + w > entry->w) { entry->min_size = w; e_entry_configure(entry); } UN(h); }
static void e_entry_down_cb(void *_data, Evas * _e, Evas_Object * _o, void *event) { E_Entry *entry; int pos; Evas_Event_Mouse_Down *ev = event; entry = _data; if ((ev->button == 2) && (!entry->mouse_down)) { if (entry->paste_win) ecore_window_destroy(entry->paste_win); entry->paste_win = ecore_selection_request(); } else if (!entry->mouse_down) { /* key = 0 (not a tab) */ med_e_entry_down_internal(_e, entry, ev->button, ev->canvas.x, ev->canvas.y, 0); /* kjb - moved code to med_e_entry_down_internal() */ } UN(_o); }
EXPR *FindBasic( EXPR *def ) { unsigned int i ; EXPR *expr, *E1, *E2 ; if( IsReal(def) ) { expr = new UNIT ; U(expr)->Ehead = String( "Ordinate" ) ; ListAppend( expr, def->Copy() ) ; return expr ; } if( IsLabel( def ) ) { for( i = 0 ; i < U(UnitList)->used ; i++ ) { if( U(UN(i))->Ehead == def ) { expr = UN(i)->Copy() ; delete U(expr)->Eeval ; U(expr)->Eeval = NULL_EXPR ; return expr ; } } IOerror( IO_ERR, "FindBasic", "%s is an undefined unit", LabelValue(def) ) ; return garbageunit() ; } if( !IsOper(def) ) { IOerror( IO_FATAL, "FindBasic", "unexpected in units definition" ) ; return garbageunit() ; } if( D(def)->oper == OPER_MINUS ) { expr = FindBasic( D(def)->Eleft ) ; if( U(expr)->used > 1 ) { IOerror( IO_ERR, "FindBasic", "illegal negation of unit" ) ; return garbageunit() ; } E1 = OP3( "u-", U(expr)->list[0], NULL_EXPR ) ; delete U(expr)->list[0] ; U(expr)->list[0] = E1 ; return expr ; } E1 = FindBasic( D(def)->Eleft ) ; E2 = FindBasic( D(def)->Eright ) ; switch( D(def)->oper ) { case OPER_MULTIPLY: expr = UnitOP3( "*", "+", E1, E2 ) ; break ; case OPER_DIVIDE: expr = UnitOP3( "/", "-", E1, E2 ) ; break ; case OPER_POW: expr = UnitOP3( "^", "*", E1, E2 ) ; break ; default: IOerror( IO_ERR, "FindBasic", "unexpected operator in unit" ) ; expr = garbageunit() ; break ; } delete E1 ; delete E2 ; return expr ; }
static void e_entry_move_cb(void *_data, Evas * _e, Evas_Object * _o, void *event) { E_Entry *entry; Evas_Event_Mouse_Move *ev = event; entry = _data; if (entry->mouse_down > 0) { int pos, ppos; double ty, tw; ppos = entry->cursor_pos; evas_object_geometry_get(entry->text, NULL, &ty, &tw, NULL); pos = evas_object_text_char_coords_get(entry->text, ev->cur.canvas.x, ty, NULL, NULL, NULL, NULL); if (pos < 0) { if (ev->cur.canvas.x > entry->x + tw) { entry->cursor_pos = strlen(entry->buffer); } else if (ev->cur.canvas.x < entry->x) { entry->cursor_pos = 0; } } else { entry->cursor_pos = pos; } if ((entry->select.start < 0) && (ppos != entry->cursor_pos)) { if (ppos < entry->cursor_pos) { entry->select.down = ppos; entry->select.start = ppos; entry->select.length = entry->cursor_pos - ppos +1; } else { entry->select.down = ppos; entry->select.start = entry->cursor_pos; entry->select.length = ppos - entry->cursor_pos +1; } } else if (entry->select.start >= 0) { if (entry->cursor_pos < entry->select.down) { entry->select.start = entry->cursor_pos; entry->select.length = entry->select.down - entry->cursor_pos + 1; } else { entry->select.start = entry->select.down; entry->select.length = entry->cursor_pos - entry->select.down + 1; } } if (entry->select.start >= 0) { char *str2; str2 = e_entry_get_selection(entry); if (str2) { if (entry->selection_win) ecore_window_destroy(entry->selection_win); entry->selection_win = ecore_selection_set(str2); free(str2); } } e_entry_configure(entry); } UN(_o); }