Ignore:
Timestamp:
11/07/14 17:51:01 (9 years ago)
Author:
Maciej Komosinski
Message:

Sources support both 32-bit and 64-bit, and more compilers

File:
1 edited

Legend:

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

    r230 r247  
    3737static const char *strchrlimit(const char *t, int ch, const char *limit)
    3838{
    39         int n = limit - t;
     39        int n = (int)(limit - t);
    4040        for (; (n > 0) && *t; t++, n--)
    4141                if (*t == ch) return t;
     
    7272}
    7373
    74 int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long &def)
     74int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def)
    7575{
    7676        const char* t = type(prop) + 1;
    7777        while (*t) if (*t == ' ') break; else t++;
    78         return sscanf(t, "%ld %ld %ld", &minumum, &maximum, &def);
     78        return sscanf(t, PA_INT_SCANF " " PA_INT_SCANF " " PA_INT_SCANF, &minumum, &maximum, &def);
    7979}
    8080
     
    121121        case 'd':
    122122        {
    123                 long a = 0, b = 0, c = 0;
     123                paInt a = 0, b = 0, c = 0;
    124124                if (getMinMax(i, a, b, c) < 3) c = a;
    125125                setInt(i, c);
     
    144144        case 'd':
    145145        {
    146                 long a = 0, b = 0, c = 0;
     146                paInt a = 0, b = 0, c = 0;
    147147                getMinMax(i, a, b, c);
    148148                setInt(i, a);
     
    167167        case 'd':
    168168        {
    169                 long a = 0, b = 0, c = 0;
     169                paInt a = 0, b = 0, c = 0;
    170170                getMinMax(i, a, b, c);
    171171                setInt(i, b);
     
    178178SString ParamInterface::getStringById(const char*prop)
    179179{int i=findId(prop); if (i>=0) return getString(i); else return SString();}
    180 long ParamInterface::getIntById(const char*prop)
     180paInt ParamInterface::getIntById(const char*prop)
    181181{int i=findId(prop); if (i>=0) return getInt(i); else return 0;}
    182182double ParamInterface::getDoubleById(const char*prop)
     
    187187{int i=findId(prop); if (i>=0) return getExtValue(i); else return ExtValue();}
    188188
    189 int ParamInterface::setIntById(const char* prop,long v)
     189int ParamInterface::setIntById(const char* prop,paInt v)
    190190{int i=findId(prop); if (i>=0) return setInt(i,v); else return PSET_NOPROPERTY;}
    191191int ParamInterface::setDoubleById(const char* prop,double v)
     
    260260        {
    261261                select(defdata);
    262                 long x = getInt(i);
     262                paInt x = getInt(i);
    263263                select(backup);
    264264                return x == getInt(i);
     
    347347                if (!*p0) break;
    348348                p = strchr(p0, ':'); if (!p) continue;
    349                 p_len = p - p0;
     349                p_len = (int)(p - p0);
    350350                loaded = false;
    351351                if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD)))
     
    442442        if (!stringIsNumeric(str))
    443443        {
    444                 long a, b, c;
     444                paInt a, b, c;
    445445                if (getMinMax(i, a, b, c) >= 3)
    446446                        return setInt(i, c);
    447447                else
    448                         return setInt(i, (long)0);
     448                        return setInt(i, (paInt)0);
    449449        }
    450450        else
     
    536536                        const char *t2 = strchr(t, '~');
    537537                        if (!t2) t2 = t + strlen(t);
    538                         return SString(t, t2 - t);
     538                        return SString(t, (int)(t2 - t));
    539539                }
    540540        }
     
    599599#endif
    600600
    601 long SimpleAbstractParam::getInt(int i)
     601paInt SimpleAbstractParam::getInt(int i)
    602602{
    603603        SANITY_CHECK(i);
     
    612612        {
    613613                void *target = getTarget(i);
    614                 return *((long*)target);
     614                return *((paInt*)target);
    615615        }
    616616}
     
    687687//////// set
    688688
    689 int SimpleAbstractParam::setInt(int i, long x)
     689int SimpleAbstractParam::setInt(int i, paInt x)
    690690{
    691691        SANITY_CHECK(i);
     
    693693        ParamEntry *pe = entry(i);
    694694        if (pe->flags&PARAM_READONLY) return PSET_RONLY;
    695         long xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
    696         long a = 0, b = 0;
     695        paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
     696        paInt a = 0, b = 0;
    697697        int result = 0;
    698698        const char* t = pe->type + 1;
    699699        while (*t) if (*t == ' ') break; else t++;
    700         if (sscanf(t, "%ld %ld", &a, &b) == 2)
     700        if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)
    701701                if (a <= b) // if max<min then the min/max constraint check is not supported
    702702                {
     
    713713        {
    714714                void *target = getTarget(i);
    715                 if (dontcheckchanges || (*((long*)target) != x))
     715                if (dontcheckchanges || (*((paInt*)target) != x))
    716716                {
    717717                        result |= PSET_CHANGED;
    718                         *((long*)target) = x;
     718                        *((paInt*)target) = x;
    719719                }
    720720        }
     
    770770        const char* t = pe->type + 1;
    771771        while (*t) if (*t == ' ') break; else t++;
    772         long a = 0, b = 0;
     772        paInt a = 0, b = 0;
    773773        int result = 0;
    774         if (sscanf(t, "%ld %ld", &a, &b) == 2)
     774        if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)
    775775        {
    776776                if ((x.len() > b) && (b > 0))
     
    883883        const char *lf = strchr(beg, '\n');
    884884        if (!lf) { lf = (const char*)s + s.len() - 1; poz = s.len(); }
    885         else { poz = (lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }
     885        else { poz = (int)(lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }
    886886        while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break;
    887         len = lf - beg + 1;
     887        len = (int)(lf - beg) + 1;
    888888        return beg;
    889889}
     
    939939                if (equals_sign) // have parameter name
    940940                {
    941                         tmpi = findIdn(t, equals_sign - t);
     941                        tmpi = findIdn(t, (int)(equals_sign - t));
    942942                        i = tmpi;
    943943                        if (tmpi < 0)
     
    960960                        if (quote)
    961961                        {
    962                                 tmpvalue.copyFrom(quote + 1, quote2 - quote - 1);
     962                                tmpvalue.copyFrom(quote + 1, (int)(quote2 - quote) - 1);
    963963                                sstringUnquote(tmpvalue);
    964964                                value = tmpvalue;
Note: See TracChangeset for help on using the changeset viewer.