- Timestamp:
- 11/14/18 03:49:59 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r805 r822 11 11 #include <frams/util/sstringutils.h> 12 12 #include <common/virtfile/stringfile.h> 13 14 #ifdef _DEBUG 15 //for sanityCheck - mutable param detection 16 #include "mutparamiface.h" 17 #endif 13 18 14 19 //#define SAVE_ALL_NAMES … … 54 59 && (*type(i) != 'p')) 55 60 { 56 j = src->findId(id(i));57 if (j < 0) continue;58 src->get(j, v);59 set(i, v);61 j = src->findId(id(i)); 62 if (j < 0) continue; 63 src->get(j, v); 64 set(i, v); 60 65 } 61 66 } … … 69 74 && (*type(i) != 'p')) 70 75 { 71 src->get(i, v);72 set(i, v);76 src->get(i, v); 77 set(i, v); 73 78 } 74 79 } … … 157 162 setDouble(i, def); 158 163 } 159 164 break; 160 165 case 'd': 161 166 { … … 164 169 setInt(i, def); 165 170 } 166 171 break; 167 172 case 's': case 'x': 168 173 { … … 176 181 } 177 182 } 178 183 break; 179 184 case 'o': 180 185 setObject(i, ExtObject::empty()); … … 194 199 setDouble(i, mn); 195 200 } 196 201 break; 197 202 case 'd': 198 203 { … … 201 206 setInt(i, mn); 202 207 } 203 208 break; 204 209 default: setFromString(i, "", false); 205 210 } … … 217 222 setDouble(i, mx); 218 223 } 219 224 break; 220 225 case 'd': 221 226 { … … 224 229 setInt(i, mx); 225 230 } 226 231 break; 227 232 default: setFromString(i, "", false); 228 233 } … … 370 375 if (!((fl = flags(i))&PARAM_DONTSAVE)) 371 376 { 372 if (defdata && isequal(i, defdata))373 needlabel = 1;374 else375 {376 if (!first) t += ", ";377 if (defdata && isequal(i, defdata)) 378 needlabel = 1; 379 else 380 { 381 if (!first) t += ", "; 377 382 #ifndef SAVE_ALL_NAMES 378 383 #ifdef SAVE_SELECTED_NAMES 379 if (needlabel || all_names || !(fl & PARAM_CANOMITNAME))384 if (needlabel || all_names || !(fl & PARAM_CANOMITNAME)) 380 385 #else 381 if (needlabel)386 if (needlabel) 382 387 #endif 383 388 #endif 384 {385 t += p; t += "="; needlabel = 0;386 }387 if (type(i)[0] == 's')388 { // string - special case389 SString str = getString(i);390 if (strContainsOneOf(str.c_str(), ", \\\n\r\t\""))391 389 { 392 t += "\""; 393 sstringQuote(str); 394 t += str; 395 t += "\""; 390 t += p; t += "="; needlabel = 0; 391 } 392 if (type(i)[0] == 's') 393 { // string - special case 394 SString str = getString(i); 395 if (strContainsOneOf(str.c_str(), ", \\\n\r\t\"")) 396 { 397 t += "\""; 398 sstringQuote(str); 399 t += str; 400 t += "\""; 401 } 402 else 403 t += str; 396 404 } 397 405 else 398 t += str; 406 t += get(i); 407 first = 0; 399 408 } 400 else401 t += get(i);402 first = 0;403 }404 409 } 405 410 if (addcr) … … 445 450 (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", 446 451 ::sstringDelimitAndShorten(actual, 30, show_length, quote, quote).c_str() 447 452 ); 448 453 } 449 454 } … … 569 574 if ((tmp = strchr(tmp, '\n'))) 570 575 { 571 lfcount++; tmp++;576 lfcount++; tmp++; 572 577 } 573 578 removeCR(s); … … 606 611 if ((tmp = strchr(tmp, '\n'))) 607 612 { 608 lfcount++; tmp++;613 lfcount++; tmp++; 609 614 } 610 615 (*options.linenum) += lfcount; … … 834 839 if ((have >= 2) && (b < a) && (a != 0) && (b != -1)) return false; // max<min meaning 'undefined' is only allowed as "d 0 -1" 835 840 } 836 841 break; 837 842 case 'f': 838 843 { … … 842 847 if ((have >= 2) && (b < a) && (a != 0) && (b != -1)) return false; // max<min meaning 'undefined' is only allowed as "f 0 -1" 843 848 } 844 849 break; 845 850 case 's': 846 851 { … … 851 856 if ((have >= 2) && (b < 0)) return false; // max=0 means unlimited, max<0 is not allowed 852 857 } 853 858 break; 854 859 } 855 860 return true; … … 863 868 case 'd': t += "integer"; 864 869 {paInt a, b, c; int n = getMinMaxIntFromTypeDef(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %d..%d", a, b); if (n >= 3) t += SString::sprintf(" (default %d)", c); } 865 870 break; 866 871 case 'f': t += "float"; 867 872 {double a, b, c; int n = getMinMaxDoubleFromTypeDef(type, a, b, c); if ((n >= 2) && (b >= a)) t += SString::sprintf(" %g..%g", a, b); if (n >= 3) t += SString::sprintf(" (default %g)", c); } 868 873 break; 869 874 case 's': t += "string"; 870 875 {int a, b; SString c; int n = getMinMaxStringFromTypeDef(type, a, b, c); if ((n >= 2) && (b > 0)) t += SString::sprintf(", max %d chars", b); if (n >= 3) t += SString::sprintf(" (default \"%s\")", c.c_str()); } 871 876 break; 872 877 case 'x': t += "untyped value"; break; 873 878 case 'p': t += "function"; break; … … 893 898 { 894 899 if (pe->fun1 == NULL) 895 err = "no procedure defined"; 900 { 901 MutableParamInterface *mpi = dynamic_cast<MutableParamInterface*>(this); 902 if (mpi == NULL) // Avoid false positives for script-driven mutable params, like expdefs. This can't be reliably verified. Function pointer checking is meant for static param tables anyway so it's probably not a big deal. 903 err = "no procedure defined"; 904 } 896 905 if (pe->flags & PARAM_READONLY) 897 906 err = "function can't be PARAM_READONLY"; … … 911 920 if (err != NULL) 912 921 logPrintf("SimpleAbstractParam", "sanityCheck", LOG_ERROR, 913 "Invalid ParamEntry for %s.%s (%s)", getName(), pe->id, err);922 "Invalid ParamEntry for %s.%s (%s)", getName(), pe->id, err); 914 923 } 915 924 #endif … … 1029 1038 if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking 1030 1039 { 1031 if (x < mn) { x = mn; result = PSET_HITMIN; }1032 else if (x > mx) { x = mx; result = PSET_HITMAX; }1040 if (x < mn) { x = mn; result = PSET_HITMIN; } 1041 else if (x > mx) { x = mx; result = PSET_HITMAX; } 1033 1042 } 1034 1043 … … 1063 1072 if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking 1064 1073 { 1065 if (x < mn) { x = mn; result = PSET_HITMIN; }1066 else if (x > mx) { x = mx; result = PSET_HITMAX; }1074 if (x < mn) { x = mn; result = PSET_HITMIN; } 1075 else if (x > mx) { x = mx; result = PSET_HITMAX; } 1067 1076 } 1068 1077 … … 1145 1154 else 1146 1155 logPrintf("SimpleAbstractParam", "setObject", LOG_ERROR, 1147 "'%s.%s' is PARAM_OBJECTSET but no 'assign()' in %s", getName(), pe->id, o.interfaceName());1156 "'%s.%s' is PARAM_OBJECTSET but no 'assign()' in %s", getName(), pe->id, o.interfaceName()); 1148 1157 return PSET_CHANGED; 1149 1158 } … … 1263 1272 field_end = strchrlimit(t, ',', end); if (!field_end) field_end = end; 1264 1273 next_field = field_end; 1265 while ((field_end >t) && isblank(field_end[-1])) field_end--;1274 while ((field_end > t) && isblank(field_end[-1])) field_end--; 1266 1275 quote = strchrlimit(t, '\"', field_end); 1267 1276 if (quote) … … 1304 1313 #endif 1305 1314 { 1306 if (id(i))1307 logPrintf("Param", "loadSingleLine", LOG_WARN, "Missing property name in '%s' (assuming '%s')", getName(), id(i));1308 else1309 logPrintf("Param", "loadSingleLine", LOG_WARN, "Value after the last property of '%s'", getName());1315 if (id(i)) 1316 logPrintf("Param", "loadSingleLine", LOG_WARN, "Missing property name in '%s' (assuming '%s')", getName(), id(i)); 1317 else 1318 logPrintf("Param", "loadSingleLine", LOG_WARN, "Value after the last property of '%s'", getName()); 1310 1319 } 1311 1320 #endif
Note: See TracChangeset
for help on using the changeset viewer.