Changeset 247 for cpp/frams/param
- Timestamp:
- 11/07/14 17:51:01 (11 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/mutableparam.cpp
r240 r247 108 108 switch(pe->type[0]) 109 109 { 110 case 'd': d=new int(); *((int*)d)=0; break;110 case 'd': d=new paInt(); *((paInt*)d)=0; break; 111 111 case 'f': d=new double(); *((double*)d)=0; break; 112 112 case 's': d=new SString(); break; … … 114 114 case 'o': d=new ExtObject(); break; 115 115 } 116 pe->offset=(int )d;116 pe->offset=(intptr_t)d; 117 117 } 118 118 onadd.action(position); … … 134 134 switch(pe->type[0]) 135 135 { 136 case 'd': delete ( int*)d; break;136 case 'd': delete (paInt*)d; break; 137 137 case 'f': delete (double*)d; break; 138 138 case 's': delete (SString*)d; break; … … 173 173 pe->group=(short)group; 174 174 pe->flags=(short)(flags | MUTPARAM_ALLOCENTRY); 175 pe->offset=( long)data;175 pe->offset=(intptr_t)data; 176 176 pe->id=strdup(id); 177 177 pe->type=strdup(type); … … 209 209 } 210 210 211 int MutableParam::setInt(int i, longv)211 int MutableParam::setInt(int i,paInt v) 212 212 { 213 213 int ret=SimpleAbstractParam::setInt(i,v); -
cpp/frams/param/mutableparam.h
r197 r247 23 23 SList entries; 24 24 SList groups; 25 longchanged;25 int changed; 26 26 ParamEntry *entry(int i) {return (i<staticprops)? pe_tab+i : ((ParamEntry*)entries(i-staticprops));} 27 27 void *getTarget(int i) {return (i<staticprops)? SimpleAbstractParam::getTarget(i) : (void*)entry(i)->offset;} … … 54 54 void notify(int id); 55 55 56 int setInt(int, long);56 int setInt(int,paInt); 57 57 int setDouble(int,double); 58 58 int setString(int,const SString &); -
cpp/frams/param/mutparamlist.cpp
r197 r247 126 126 } 127 127 128 void MutableParamList::onPropAdd(void* data, longi)128 void MutableParamList::onPropAdd(void* data,intptr_t i) 129 129 { 130 130 ParamInfo *pi=(ParamInfo*)data; … … 136 136 } 137 137 138 void MutableParamList::onPropDelete(void* data, longi)138 void MutableParamList::onPropDelete(void* data,intptr_t i) 139 139 { 140 140 ParamInfo *pi=(ParamInfo*)data; … … 146 146 } 147 147 148 void MutableParamList::onPropChange(void* data, longi)148 void MutableParamList::onPropChange(void* data,intptr_t i) 149 149 { 150 150 ParamInfo *pi=(ParamInfo*)data; … … 152 152 } 153 153 154 void MutableParamList::onPropActivate(void* data, longi)154 void MutableParamList::onPropActivate(void* data,intptr_t i) 155 155 { 156 156 ParamInfo *pi=(ParamInfo*)data; … … 158 158 } 159 159 160 void MutableParamList::onGroupAdd(void* data, longi)160 void MutableParamList::onGroupAdd(void* data,intptr_t i) 161 161 { 162 162 ParamInfo *pi=(ParamInfo*)data; … … 168 168 } 169 169 170 void MutableParamList::onGroupDelete(void* data, longi)170 void MutableParamList::onGroupDelete(void* data,intptr_t i) 171 171 { 172 172 ParamInfo *pi=(ParamInfo*)data; … … 178 178 } 179 179 180 void MutableParamList::onGroupChange(void* data, longi)180 void MutableParamList::onGroupChange(void* data,intptr_t i) 181 181 { 182 182 ParamInfo *pi=(ParamInfo*)data; … … 295 295 FUN(int,flags,0) 296 296 FUN(SString,getString,SString()) 297 FUN( long,getInt,0)297 FUN(paInt,getInt,0) 298 298 FUN(double,getDouble,0) 299 FUN(ExtValue,getExtValue,ExtValue(( long)0))299 FUN(ExtValue,getExtValue,ExtValue((paInt)0)) 300 300 FUN(ExtObject,getObject,ExtObject()) 301 301 … … 322 322 } 323 323 324 FUN2(int,setInt, long)324 FUN2(int,setInt,paInt) 325 325 FUN2(int,setDouble,double) 326 326 FUN2(int,setString,const SString &) -
cpp/frams/param/mutparamlist.h
r197 r247 75 75 76 76 SString getString(int); 77 longgetInt(int);77 paInt getInt(int); 78 78 double getDouble(int); 79 79 ExtValue getExtValue(int); 80 80 ExtObject getObject(int); 81 81 82 int setInt(int, long);82 int setInt(int,paInt); 83 83 int setDouble(int,double); 84 84 int setString(int,const SString &); -
cpp/frams/param/param.cpp
r230 r247 37 37 static const char *strchrlimit(const char *t, int ch, const char *limit) 38 38 { 39 int n = limit - t;39 int n = (int)(limit - t); 40 40 for (; (n > 0) && *t; t++, n--) 41 41 if (*t == ch) return t; … … 72 72 } 73 73 74 int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long&def)74 int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def) 75 75 { 76 76 const char* t = type(prop) + 1; 77 77 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); 79 79 } 80 80 … … 121 121 case 'd': 122 122 { 123 longa = 0, b = 0, c = 0;123 paInt a = 0, b = 0, c = 0; 124 124 if (getMinMax(i, a, b, c) < 3) c = a; 125 125 setInt(i, c); … … 144 144 case 'd': 145 145 { 146 longa = 0, b = 0, c = 0;146 paInt a = 0, b = 0, c = 0; 147 147 getMinMax(i, a, b, c); 148 148 setInt(i, a); … … 167 167 case 'd': 168 168 { 169 longa = 0, b = 0, c = 0;169 paInt a = 0, b = 0, c = 0; 170 170 getMinMax(i, a, b, c); 171 171 setInt(i, b); … … 178 178 SString ParamInterface::getStringById(const char*prop) 179 179 {int i=findId(prop); if (i>=0) return getString(i); else return SString();} 180 longParamInterface::getIntById(const char*prop)180 paInt ParamInterface::getIntById(const char*prop) 181 181 {int i=findId(prop); if (i>=0) return getInt(i); else return 0;} 182 182 double ParamInterface::getDoubleById(const char*prop) … … 187 187 {int i=findId(prop); if (i>=0) return getExtValue(i); else return ExtValue();} 188 188 189 int ParamInterface::setIntById(const char* prop, longv)189 int ParamInterface::setIntById(const char* prop,paInt v) 190 190 {int i=findId(prop); if (i>=0) return setInt(i,v); else return PSET_NOPROPERTY;} 191 191 int ParamInterface::setDoubleById(const char* prop,double v) … … 260 260 { 261 261 select(defdata); 262 longx = getInt(i);262 paInt x = getInt(i); 263 263 select(backup); 264 264 return x == getInt(i); … … 347 347 if (!*p0) break; 348 348 p = strchr(p0, ':'); if (!p) continue; 349 p_len = p - p0;349 p_len = (int)(p - p0); 350 350 loaded = false; 351 351 if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD))) … … 442 442 if (!stringIsNumeric(str)) 443 443 { 444 longa, b, c;444 paInt a, b, c; 445 445 if (getMinMax(i, a, b, c) >= 3) 446 446 return setInt(i, c); 447 447 else 448 return setInt(i, ( long)0);448 return setInt(i, (paInt)0); 449 449 } 450 450 else … … 536 536 const char *t2 = strchr(t, '~'); 537 537 if (!t2) t2 = t + strlen(t); 538 return SString(t, t2 - t);538 return SString(t, (int)(t2 - t)); 539 539 } 540 540 } … … 599 599 #endif 600 600 601 longSimpleAbstractParam::getInt(int i)601 paInt SimpleAbstractParam::getInt(int i) 602 602 { 603 603 SANITY_CHECK(i); … … 612 612 { 613 613 void *target = getTarget(i); 614 return *(( long*)target);614 return *((paInt*)target); 615 615 } 616 616 } … … 687 687 //////// set 688 688 689 int SimpleAbstractParam::setInt(int i, longx)689 int SimpleAbstractParam::setInt(int i, paInt x) 690 690 { 691 691 SANITY_CHECK(i); … … 693 693 ParamEntry *pe = entry(i); 694 694 if (pe->flags&PARAM_READONLY) return PSET_RONLY; 695 longxcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below696 longa = 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; 697 697 int result = 0; 698 698 const char* t = pe->type + 1; 699 699 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) 701 701 if (a <= b) // if max<min then the min/max constraint check is not supported 702 702 { … … 713 713 { 714 714 void *target = getTarget(i); 715 if (dontcheckchanges || (*(( long*)target) != x))715 if (dontcheckchanges || (*((paInt*)target) != x)) 716 716 { 717 717 result |= PSET_CHANGED; 718 *(( long*)target) = x;718 *((paInt*)target) = x; 719 719 } 720 720 } … … 770 770 const char* t = pe->type + 1; 771 771 while (*t) if (*t == ' ') break; else t++; 772 longa = 0, b = 0;772 paInt a = 0, b = 0; 773 773 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) 775 775 { 776 776 if ((x.len() > b) && (b > 0)) … … 883 883 const char *lf = strchr(beg, '\n'); 884 884 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(); } 886 886 while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break; 887 len = lf - beg+ 1;887 len = (int)(lf - beg) + 1; 888 888 return beg; 889 889 } … … 939 939 if (equals_sign) // have parameter name 940 940 { 941 tmpi = findIdn(t, equals_sign - t);941 tmpi = findIdn(t, (int)(equals_sign - t)); 942 942 i = tmpi; 943 943 if (tmpi < 0) … … 960 960 if (quote) 961 961 { 962 tmpvalue.copyFrom(quote + 1, quote2 - quote- 1);962 tmpvalue.copyFrom(quote + 1, (int)(quote2 - quote) - 1); 963 963 sstringUnquote(tmpvalue); 964 964 value = tmpvalue; -
cpp/frams/param/param.h
r230 r247 7 7 8 8 #include <stdio.h> 9 #include <stdint.h> 9 10 #include <frams/util/sstring.h> 10 11 #include <frams/util/list.h> … … 33 34 #define PARAM_DEPRECATED 8192 34 35 36 typedef int32_t paInt; 37 #define PA_INT_SCANF "%d" 38 35 39 // the result of param::set() is a combination of bits: 36 40 … … 92 96 93 97 virtual SString getString(int) = 0; ///< get string value, you can only use this for "s" type property 94 virtual longgetInt(int) = 0; ///< get long value, you can only use this for "d" type property98 virtual paInt getInt(int) = 0; ///< get long value, you can only use this for "d" type property 95 99 virtual double getDouble(int) = 0; ///< get double value, you can only use this for "f" type property 96 100 virtual ExtObject getObject(int) = 0; ///< get object reference, you can only use this for "o" type property … … 101 105 102 106 SString getStringById(const char*prop); ///< get string value, you can only use this for "s" type property 103 longgetIntById(const char* prop); ///< get long value, you can only use this for "d" type property107 paInt getIntById(const char* prop); ///< get long value, you can only use this for "d" type property 104 108 double getDoubleById(const char* prop);///< get double value, you can only use this for "f" type property 105 109 ExtObject getObjectById(const char* prop);///< get object reference, you can only use this for "o" type property … … 109 113 int setInt(int i, const char* str); 110 114 int setDouble(int i, const char* str); 111 virtual int setInt(int, long) = 0; ///< set long value, you can only use this for "d" type prop115 virtual int setInt(int, paInt) = 0; ///< set long value, you can only use this for "d" type prop 112 116 virtual int setDouble(int, double) = 0; ///< set double value, you can only use this for "f" type prop 113 117 virtual int setString(int, const SString &) = 0; ///< set string value, you can only use this for "s" type prop … … 119 123 int set(int, const char*); ///< oldstyle set, can convert string to long or double 120 124 121 int setIntById(const char* prop, long);///< set long value, you can only use this for "d" type prop125 int setIntById(const char* prop, paInt);///< set long value, you can only use this for "d" type prop 122 126 int setDoubleById(const char* prop, double);///< set double value, you can only use this for "f" type prop 123 127 int setStringById(const char* prop, const SString &);///< set string value, you can only use this for "s" type prop … … 128 132 /** get valid minimum, maximum and default value for property 'prop' 129 133 @return 0 if min/max/def information is not available */ 130 int getMinMax(int prop, long& minumum, long& maximum, long& def);134 int getMinMax(int prop, paInt& minumum, paInt& maximum, paInt& def); 131 135 /** get valid minimum, maximum and default value for property 'prop' 132 136 @return 0 if min/max/def information is not available */ … … 172 176 #define SETOFFSET(_proc_) ( (int (*)(void*,const ExtValue*)) &(FIELDSTRUCT :: _proc_ ## _statrick)) 173 177 174 #define FIELDOFFSET(_fld_) (( long)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy))))178 #define FIELDOFFSET(_fld_) ((intptr_t)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy)))) 175 179 176 180 #ifdef DEBUG 177 #define PARAM_ILLEGAL_OFFSET (( long)0xdeadbeef)181 #define PARAM_ILLEGAL_OFFSET ((intptr_t)0xdeadbeef) 178 182 #else 179 183 #define PARAM_ILLEGAL_OFFSET 0 … … 205 209 short group, flags; 206 210 const char *name, *type; 207 longoffset;211 intptr_t offset; 208 212 void *fun1; ///< procedure or get 209 213 void *fun2; ///< set … … 214 218 { 215 219 public: 216 ParamEntryConstructor(const char *_id, short _group = 0, short _flags = 0, const char *_name = 0, const char *_type = 0, long_offset = 0, void *_fun1 = 0, void *_fun2 = 0, const char *_help = 0)220 ParamEntryConstructor(const char *_id, short _group = 0, short _flags = 0, const char *_name = 0, const char *_type = 0, intptr_t _offset = 0, void *_fun1 = 0, void *_fun2 = 0, const char *_help = 0) 217 221 { 218 222 id = _id; group = _group; flags = _flags; name = _name; type = _type; offset = _offset; fun1 = _fun1; fun2 = _fun2; help = _help; … … 254 258 255 259 SString getString(int); 256 longgetInt(int);260 paInt getInt(int); 257 261 double getDouble(int); 258 262 ExtObject getObject(int); … … 270 274 } 271 275 272 int setInt(int, long);276 int setInt(int, paInt); 273 277 int setDouble(int, double); 274 278 int setString(int, const SString &);
Note: See TracChangeset
for help on using the changeset viewer.