Ignore:
Timestamp:
04/09/15 23:51:28 (9 years ago)
Author:
Maciej Komosinski
Message:
  • explicit c_str() in SString instead of (const char*) cast
  • genetic converters and GenMan? are now thread-local which enables multi-threaded simulator separation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/extvalue.cpp

    r337 r348  
    269269                        if (tmp.len() > 30) tmp = tmp.substr(0, 30) + "...";
    270270                        if (type == TString) tmp = SString("\"") + tmp + SString("\"");
    271                         FMprintf("ExtValue", "getObjectTarget", FMLV_WARN, "%s object expected, %s found", classname, (const char*)tmp);
     271                        FMprintf("ExtValue", "getObjectTarget", FMLV_WARN, "%s object expected, %s found", classname, tmp.c_str());
    272272                }
    273273                return NULL;
     
    329329static ExtValue::CompareResult compareString(const SString &a, const SString &b)
    330330{
    331         const char* s1 = (const char*)a;
    332         const char* s2 = (const char*)b;
     331        const char* s1 = a.c_str();
     332        const char* s2 = b.c_str();
    333333        return longsign(strcmp(s1, s2));
    334334}
     
    415415                        if (context->v1 && context->v2)
    416416                                msg += SString::sprintf(": %s %s %s",
    417                                 (const char*)context->v1->typeAndValue(),
     417                                context->v1->typeAndValue().c_str(),
    418418                                cmp_op_names[op - CmpFIRST],
    419                                 (const char*)context->v2->typeAndValue());
    420                 }
    421                 FMprintf("ExtValue", "interpretCompare", FMLV_ERROR, "%s", (const char*)msg);
     419                                context->v2->typeAndValue().c_str());
     420                }
     421                FMprintf("ExtValue", "interpretCompare", FMLV_ERROR, "%s", msg.c_str());
    422422                ret = -1;
    423423        }
     
    448448                {
    449449                case TDouble:
    450                         FMprintf("ExtValue", "add", FMLV_WARN, "Adding %s to %s", (const char*)src.typeAndValue(), (const char*)typeAndValue());
     450                        FMprintf("ExtValue", "add", FMLV_WARN, "Adding %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str());
    451451                        setDouble(double(getInt()) + src.getDouble());
    452452                        return;
     
    487487        default:;
    488488        }
    489         FMprintf("ExtValue", "add", FMLV_ERROR, "Can't add %s to %s", (const char*)src.typeAndValue(), (const char*)typeAndValue());
     489        FMprintf("ExtValue", "add", FMLV_ERROR, "Can't add %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str());
    490490}
    491491
     
    502502                        return;
    503503                case TDouble:
    504                         FMprintf("ExtValue", "subtract", FMLV_WARN, "Subtracting %s from %s", (const char*)src.typeAndValue(), (const char*)typeAndValue());
     504                        FMprintf("ExtValue", "subtract", FMLV_WARN, "Subtracting %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str());
    505505                        setDouble(double(getInt()) - src.getDouble());
    506506                        return;
     
    520520        default:;
    521521        }
    522         FMprintf("ExtValue", "subtract", FMLV_ERROR, "Can't subtract %s from %s", (const char*)src.typeAndValue(), (const char*)typeAndValue());
     522        FMprintf("ExtValue", "subtract", FMLV_ERROR, "Can't subtract %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str());
    523523}
    524524
     
    535535                        return;
    536536                case TDouble:
    537                         FMprintf("ExtValue", "multiply", FMLV_WARN, "Multiplying %s by %s", (const char*)typeAndValue(), (const char*)src.typeAndValue());
     537                        FMprintf("ExtValue", "multiply", FMLV_WARN, "Multiplying %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    538538                        setDouble(double(getInt())*src.getDouble());
    539539                        return;
     
    591591        default:;
    592592        }
    593         FMprintf("ExtValue", "multiply", FMLV_WARN, "Can't multiply %s by %s", (const char*)typeAndValue(), (const char*)src.typeAndValue());
     593        FMprintf("ExtValue", "multiply", FMLV_WARN, "Can't multiply %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    594594}
    595595
     
    621621        if (a == 0.0)
    622622        {
    623                 FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Division by zero: %s/0.0", (const char*)getString());
     623                FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Division by zero: %s/0.0", getString().c_str());
    624624                setInvalid();
    625625        }
     
    630630                if (!finite(tmp))
    631631                {
    632                         FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Overflow %s/%g", (const char*)getString(), a); setInvalid();
     632                        FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Overflow %s/%g", getString().c_str(), a); setInvalid();
    633633                }
    634634                else
     
    652652                        return;
    653653                case TDouble:
    654                         FMprintf("ExtValue", "divide", FMLV_WARN, "Dividing %s by %s", (const char*)typeAndValue(), (const char*)src.typeAndValue());
     654                        FMprintf("ExtValue", "divide", FMLV_WARN, "Dividing %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    655655                        divDouble(src.ddata());
    656656                        return;
     
    674674        default:;
    675675        }
    676         FMprintf("ExtValue", "divide", FMLV_ERROR, "Can't divide %s by %s", (const char*)typeAndValue(), (const char*)src.typeAndValue());
     676        FMprintf("ExtValue", "divide", FMLV_ERROR, "Can't divide %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    677677}
    678678
     
    687687        //            ^-cur     ^-next
    688688        //            ^^^^^^^^^^___sub
    689         const char* begin = (const char*)fmt, *end = begin + fmt.len(), *curr = begin;
     689        const char* begin = fmt.c_str(), *end = begin + fmt.len(), *curr = begin;
    690690        int type = 0;
    691691
     
    733733                switch (type)
    734734                {
    735                 case 'd': a = args.getNext(); ret += SString::sprintf((const char*)sub, a ? a->getInt() : 0); break;
    736                 case 'f': a = args.getNext(); ret += SString::sprintf((const char*)sub, a ? a->getDouble() : 0); break;
    737                 case 's': {a = args.getNext(); SString tmp; if (a) tmp = a->getString(); ret += SString::sprintf((const char*)sub, (const char*)tmp); } break;
     735                case 'd': a = args.getNext(); ret += SString::sprintf(sub.c_str(), a ? a->getInt() : 0); break;
     736                case 'f': a = args.getNext(); ret += SString::sprintf(sub.c_str(), a ? a->getDouble() : 0); break;
     737                case 's': {a = args.getNext(); SString tmp; if (a) tmp = a->getString(); ret += SString::sprintf(sub.c_str(), tmp.c_str()); } break;
    738738                case 't': case 'T':
    739739                {
     
    779779
    780780        case TObj: case TUnknown: case TInvalid:
    781                 FMprintf("ExtValue", "modulo", FMLV_WARN, "Can't apply modulo to %s", (const char*)typeDescription());
     781                FMprintf("ExtValue", "modulo", FMLV_WARN, "Can't apply modulo to %s", typeDescription().c_str());
    782782
    783783        default:;
     
    835835        case TInt: return idata();
    836836        case TDouble: return (int)ddata();
    837         case TString: return getInt((const char*)sdata());
     837        case TString: return getInt(sdata().c_str());
    838838        case TObj:
    839                 FMprintf("ExtValue", "getInt", FMLV_WARN, "Getting integer value from object reference (%s)", (const char*)getString());
     839                FMprintf("ExtValue", "getInt", FMLV_WARN, "Getting integer value from object reference (%s)", getString().c_str());
    840840                return (paInt)(intptr_t)odata().param;
    841841        default:;
     
    850850        case TDouble: return ddata();
    851851        case TInt: return (double)idata();
    852         case TString: return getDouble((const char*)sdata());
     852        case TString: return getDouble(sdata().c_str());
    853853        case TObj:
    854                 FMprintf("ExtValue", "getDouble", FMLV_WARN, "Getting floating point value from object reference (%s)", (const char*)getString());
     854                FMprintf("ExtValue", "getDouble", FMLV_WARN, "Getting floating point value from object reference (%s)", getString().c_str());
    855855                return (double)(intptr_t)odata().param;
    856856        default:;
     
    10951095                ExtValue tmp;
    10961096                ret = tmp.deserialize(ret);
    1097                 ParamInterface *cls = findDeserializableClass(clsname);
     1097                ParamInterface *cls = findDeserializableClass(clsname.c_str());
    10981098                if (cls && (tmp.getType() != TUnknown) && (tmp.getType() != TInvalid))
    10991099                {
     
    11341134                }
    11351135                setEmpty();
    1136                 FMprintf("ExtValue", "deserialize", FMLV_WARN, "object of class \"%s\" could not be deserialized", (const char*)clsname);
     1136                FMprintf("ExtValue", "deserialize", FMLV_WARN, "object of class \"%s\" could not be deserialized", clsname.c_str());
    11371137                return ret;
    11381138        }
Note: See TracChangeset for help on using the changeset viewer.