Changeset 314


Ignore:
Timestamp:
01/26/15 13:03:22 (9 years ago)
Author:
Maciej Komosinski
Message:

Less cryptic variable names: a,b,c -> mn,mx,def

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r312 r314  
    139139        case 'f':
    140140        {
    141                 double a = 0, b = 0, c = 0;
    142                 if (getMinMax(i, a, b, c) < 3) c = a;
    143                 setDouble(i, c);
     141                double mn = 0, mx = 0, def = 0;
     142                if (getMinMax(i, mn, mx, def) < 3) def = mn;
     143                setDouble(i, def);
    144144        }
    145145                break;
    146146        case 'd':
    147147        {
    148                 paInt a = 0, b = 0, c = 0;
    149                 if (getMinMax(i, a, b, c) < 3) c = a;
    150                 setInt(i, c);
     148                paInt mn = 0, mx = 0, def = 0;
     149                if (getMinMax(i, mn, mx, def) < 3) def = mn;
     150                setInt(i, def);
    151151        }
    152152                break;
    153153        case 's': case 'x':
    154154        {
    155                 int a, b; SString c;
    156                 getMinMax(i, a, b, c);
     155                int mn, mx; SString def;
     156                getMinMax(i, mn, mx, def);
    157157                if (*t == 's')
    158                         setString(i, c);
     158                        setString(i, def);
    159159                else
    160160                {
    161                         if (c.len() > 0) setExtValue(i, ExtValue(c)); else setExtValue(i, ExtValue::empty());
     161                        if (def.len() > 0) setExtValue(i, ExtValue(def)); else setExtValue(i, ExtValue::empty());
    162162                }
    163163        }
     
    176176        case 'f':
    177177        {
    178                 double a = 0, b = 0, c = 0;
    179                 getMinMax(i, a, b, c);
    180                 setDouble(i, a);
     178                double mn = 0, mx = 0, def = 0;
     179                getMinMax(i, mn, mx, def);
     180                setDouble(i, mn);
    181181        }
    182182                break;
    183183        case 'd':
    184184        {
    185                 paInt a = 0, b = 0, c = 0;
    186                 getMinMax(i, a, b, c);
    187                 setInt(i, a);
     185                paInt mn = 0, mx = 0, def = 0;
     186                getMinMax(i, mn, mx, def);
     187                setInt(i, mn);
    188188        }
    189189                break;
     
    199199        case 'f':
    200200        {
    201                 double a = 0, b = 0, c = 0;
    202                 getMinMax(i, a, b, c);
    203                 setDouble(i, b);
     201                double mn = 0, mx = 0, def = 0;
     202                getMinMax(i, mn, mx, def);
     203                setDouble(i, mx);
    204204        }
    205205                break;
    206206        case 'd':
    207207        {
    208                 paInt a = 0, b = 0, c = 0;
    209                 getMinMax(i, a, b, c);
    210                 setInt(i, b);
     208                paInt mn = 0, mx = 0, def = 0;
     209                getMinMax(i, mn, mx, def);
     210                setInt(i, mx);
    211211        }
    212212                break;
     
    497497        case 'o':       ret.setObject(getObject(i)); break;
    498498        case 'x':       ret = getExtValue(i); break;
    499         default: FMprintf("ParamInterface", "get", FMLV_ERROR, "'%s.%s' is not a field", getName(), id(i));
     499        default: FMprintf("ParamInterface", "get", FMLV_ERROR, "'%s.%s' is not mn field", getName(), id(i));
    500500        }
    501501}
     
    513513        if (!stringIsNumeric(str))
    514514        {
    515                 paInt a, b, c;
    516                 if (getMinMax(i, a, b, c) >= 3)
    517                         return setInt(i, c);
     515                paInt mn, mx, def;
     516                if (getMinMax(i, mn, mx, def) >= 3)
     517                        return setInt(i, def);
    518518                else
    519519                        return setInt(i, (paInt)0);
     
    527527        if (!stringIsNumeric(str))
    528528        {
    529                 double a, b, c;
    530                 if (getMinMax(i, a, b, c) >= 3)
    531                         return setDouble(i, c);
     529                double mn, mx, def;
     530                if (getMinMax(i, mn, mx, def) >= 3)
     531                        return setDouble(i, def);
    532532                else
    533533                        return setDouble(i, (double)0);
     
    605605        if ((*(t = type(i))) == 'd')
    606606        {
    607                 paInt a, b, c;
     607                paInt mn, mx, def;
    608608                int value = getInt(i);
    609                 if (getMinMax(i, a, b, c) >= 2)
    610                 {
    611                         if (value > b)
     609                if (getMinMax(i, mn, mx, def) >= 2)
     610                {
     611                        if (value > mx)
    612612                                return get(i);
    613                         value -= a;
     613                        value -= mn;
    614614                }
    615615                if (value < 0) return get(i);
     
    778778        if (pe->flags&PARAM_READONLY) return PSET_RONLY;
    779779        paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
    780         paInt a = 0, b = 0;
     780        paInt mn = 0, mx = 0;
    781781        int result = 0;
    782782        const char* t = pe->type + 1;
    783783        while (*t) if (*t == ' ') break; else t++;
    784         if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)
    785                 if (a <= b) // if max<min then the min/max constraint check is not supported
    786                 {
    787                 if (x < a) { x = a; result = PSET_HITMIN; }
    788                 else if (x > b) { x = b; result = PSET_HITMAX; }
     784        if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &mn, &mx) == 2)
     785                if (mn <= mx) // if max<min then the min/max constraint check is not supported
     786                {
     787                if (x < mn) { x = mn; result = PSET_HITMIN; }
     788                else if (x > mx) { x = mx; result = PSET_HITMAX; }
    789789                }
    790790
     
    814814        if (pe->flags&PARAM_READONLY) return PSET_RONLY;
    815815        double xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
    816         double a = 0, b = 0;
     816        double mn = 0, mx = 0;
    817817        int result = 0;
    818818        const char* t = pe->type + 1;
    819819        while (*t) if (*t == ' ') break; else t++;
    820         if (sscanf(t, "%lg %lg", &a, &b) == 2)
    821                 if (a <= b) // if max<min then the min/max constraint check is not supported
    822                 {
    823                 if (x < a) { x = a; result = PSET_HITMIN; }
    824                 else if (x > b) { x = b; result = PSET_HITMAX; }
     820        if (sscanf(t, "%lg %lg", &mn, &mx) == 2)
     821                if (mn <= mx) // if max<min then the min/max constraint check is not supported
     822                {
     823                if (x < mn) { x = mn; result = PSET_HITMIN; }
     824                else if (x > mx) { x = mx; result = PSET_HITMAX; }
    825825                }
    826826
     
    854854        const char* t = pe->type + 1;
    855855        while (*t) if (*t == ' ') break; else t++;
    856         int a = 0, b = 0;
     856        int mn = 0, mx = 0;
    857857        int result = 0;
    858         if (sscanf(t, "%d %d", &a, &b) == 2) //using getMinMax would also get default value, which is not needed here
    859         {
    860                 if ((x.len() > b) && (b > 0))
    861                 {
    862                         vs = x.substr(0, b);
     858        if (sscanf(t, "%d %d", &mn, &mx) == 2) //using getMinMax would also get default value, which is not needed here
     859        {
     860                if ((x.len() > mx) && (mx > 0))
     861                {
     862                        vs = x.substr(0, mx);
    863863                        xx = &vs;
    864864                        result |= PSET_HITMAX;
Note: See TracChangeset for help on using the changeset viewer.