Changeset 372 for cpp/frams/util


Ignore:
Timestamp:
04/22/15 04:14:59 (9 years ago)
Author:
sz
Message:

Renamed some classes and functions to make their purpose more obvious:

All MessageHandlers? must now be given the explicit "Enable" argument if you want them to automatically become active. This makes side effects clearly visible.

Location:
cpp/frams/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/3d.cpp

    r321 r372  
    44
    55#include <common/nonstd_math.h>
    6 #include <common/framsg.h>
     6#include <common/hmessage.h>
    77#include "3d.h"
    88
     
    1717{
    1818        double q = x*x + y*y + z*z;
    19         if (q < 0) { if (report_errors) FMprintf("Pt3D", "operator()", FMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
     19        if (q < 0) { if (report_errors) Hprintf("Pt3D", "operator()", HMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
    2020        return sqrt(q);
    2121}
     
    2424{
    2525        double len = length();
    26         if (fabs(len) < 1e-50) { if (report_errors) FMprintf("Pt3D", "normalize()", FMLV_WARN, "vector[%g,%g,%g] too small", x, y, z); x = 1; y = 0; z = 0; return false; }
     26        if (fabs(len) < 1e-50) { if (report_errors) Hprintf("Pt3D", "normalize()", HMLV_WARN, "vector[%g,%g,%g] too small", x, y, z); x = 1; y = 0; z = 0; return false; }
    2727        operator/=(len);
    2828        return true;
     
    6464        if (dx == 0 && dy == 0)
    6565        {
    66                 if (report_errors) FMprintf("Pt3D", "getAngle()", FMLV_WARN, "atan2(%g,%g)", dy, dx);
     66                if (report_errors) Hprintf("Pt3D", "getAngle()", HMLV_WARN, "atan2(%g,%g)", dy, dx);
    6767                return 0; // incorrect result, but there is no correct one
    6868        }
     
    147147{
    148148        double q = x*x + y*y;
    149         if (q < 0) { if (Pt3D::report_errors) FMprintf("", "d2()", FMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
     149        if (q < 0) { if (Pt3D::report_errors) Hprintf("", "d2()", HMLV_ERROR, "sqrt(%g): domain error", q); return 0; }
    150150        return sqrt(q);
    151151}
  • cpp/frams/util/extvalue.cpp

    r371 r372  
    9898        if (warn)
    9999        {
    100                 FMprintf("ExtValue", "getObjectTarget", FMLV_WARN, "%s object expected, %s found", classname, interfaceName());
     100                Hprintf("ExtValue", "getObjectTarget", HMLV_WARN, "%s object expected, %s found", classname, interfaceName());
    101101        }
    102102
     
    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, tmp.c_str());
     271                        Hprintf("ExtValue", "getObjectTarget", HMLV_WARN, "%s object expected, %s found", classname, tmp.c_str());
    272272                }
    273273                return NULL;
     
    419419                                context->v2->typeAndValue().c_str());
    420420                }
    421                 FMprintf("ExtValue", "interpretCompare", FMLV_ERROR, "%s", msg.c_str());
     421                Hprintf("ExtValue", "interpretCompare", HMLV_ERROR, "%s", msg.c_str());
    422422                ret = -1;
    423423        }
     
    448448                {
    449449                case TDouble:
    450                         FMprintf("ExtValue", "add", FMLV_WARN, "Adding %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str());
     450                        Hprintf("ExtValue", "add", HMLV_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", src.typeAndValue().c_str(), typeAndValue().c_str());
     489        Hprintf("ExtValue", "add", HMLV_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", src.typeAndValue().c_str(), typeAndValue().c_str());
     504                        Hprintf("ExtValue", "subtract", HMLV_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", src.typeAndValue().c_str(), typeAndValue().c_str());
     522        Hprintf("ExtValue", "subtract", HMLV_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", typeAndValue().c_str(), src.typeAndValue().c_str());
     537                        Hprintf("ExtValue", "multiply", HMLV_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", typeAndValue().c_str(), src.typeAndValue().c_str());
    594 }
    595 
    596 #include <common/framsg.h>
     593        Hprintf("ExtValue", "multiply", HMLV_WARN, "Can't multiply %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
     594}
     595
    597596/*#include "fpu_control.h"
    598597#include <signal.h>
     
    612611        else
    613612        {
    614                 FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Division by zero: %d/0", idata());
     613                Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Division by zero: %d/0", idata());
    615614                setInvalid();
    616615        }
     
    621620        if (a == 0.0)
    622621        {
    623                 FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Division by zero: %s/0.0", getString().c_str());
     622                Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Division by zero: %s/0.0", getString().c_str());
    624623                setInvalid();
    625624        }
     
    630629                if (!finite(tmp))
    631630                {
    632                         FMprintf("ExtValue", "divide", FMLV_CRITICAL, "Overflow %s/%g", getString().c_str(), a); setInvalid();
     631                        Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Overflow %s/%g", getString().c_str(), a); setInvalid();
    633632                }
    634633                else
     
    636635                // niby dobrze ale lepiej byloby to robic bardziej systematycznie a nie tylko w dzieleniu?
    637636                //if (isnan(ddata())) //http://www.digitalmars.com/d/archives/c++/Traping_divide_by_zero_5728.html
    638                 //        { FMprintf("ExtValue","divide",FMLV_ERROR,"not-a-number",(const char*)getString()); setInvalid(); }
     637                //        { Hprintf("ExtValue","divide",HMLV_ERROR,"not-a-number",(const char*)getString()); setInvalid(); }
    639638                fpExceptEnable();
    640639        }
     
    652651                        return;
    653652                case TDouble:
    654                         FMprintf("ExtValue", "divide", FMLV_WARN, "Dividing %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
     653                        Hprintf("ExtValue", "divide", HMLV_WARN, "Dividing %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    655654                        divDouble(src.ddata());
    656655                        return;
     
    674673        default:;
    675674        }
    676         FMprintf("ExtValue", "divide", FMLV_ERROR, "Can't divide %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
     675        Hprintf("ExtValue", "divide", HMLV_ERROR, "Can't divide %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());
    677676}
    678677
     
    779778
    780779        case TObj: case TUnknown: case TInvalid:
    781                 FMprintf("ExtValue", "modulo", FMLV_WARN, "Can't apply modulo to %s", typeDescription().c_str());
     780                Hprintf("ExtValue", "modulo", HMLV_WARN, "Can't apply modulo to %s", typeDescription().c_str());
    782781
    783782        default:;
     
    792791        {
    793792                if (error)
    794                         FMprintf("ExtValue", "parseInt", FMLV_ERROR, "Could not parse '%s'%s", s, strict ? " (strict)" : "");
     793                        Hprintf("ExtValue", "parseInt", HMLV_ERROR, "Could not parse '%s'%s", s, strict ? " (strict)" : "");
    795794                return false;
    796795        }
     
    806805        {
    807806                if (error)
    808                         FMprintf("ExtValue", "parseDouble", FMLV_ERROR, "Could not parse '%s'", s);
     807                        Hprintf("ExtValue", "parseDouble", HMLV_ERROR, "Could not parse '%s'", s);
    809808                return false;
    810809        }
     
    837836        case TString: return getInt(sdata().c_str());
    838837        case TObj:
    839                 FMprintf("ExtValue", "getInt", FMLV_WARN, "Getting integer value from object reference (%s)", getString().c_str());
     838                Hprintf("ExtValue", "getInt", HMLV_WARN, "Getting integer value from object reference (%s)", getString().c_str());
    840839                return (paInt)(intptr_t)odata().param;
    841840        default:;
     
    852851        case TString: return getDouble(sdata().c_str());
    853852        case TObj:
    854                 FMprintf("ExtValue", "getDouble", FMLV_WARN, "Getting floating point value from object reference (%s)", getString().c_str());
     853                Hprintf("ExtValue", "getDouble", HMLV_WARN, "Getting floating point value from object reference (%s)", getString().c_str());
    855854                return (double)(intptr_t)odata().param;
    856855        default:;
     
    990989                else
    991990                {
    992                         FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Missing '\"' in string: '%s'", ret);
     991                        Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing '\"' in string: '%s'", ret);
    993992                        return NULL;
    994993                }
     
    10121011                                else if (*p != ']')
    10131012                                {
    1014                                         FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Missing ',' in Vector: '%s'", p);
     1013                                        Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Vector: '%s'", p);
    10151014                                        return NULL;
    10161015                                }
     
    10381037                        if ((!ret) || (args[1].getType() != TString)) { p = NULL; break; }
    10391038                        p = ret;
    1040                         if (*p != ':') { FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Missing ':' in Dictionary: '%s'", p); p = NULL; break; }
     1039                        if (*p != ':') { Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ':' in Dictionary: '%s'", p); p = NULL; break; }
    10411040                        p++;
    10421041                        ret = args[0].deserialize(p);
     
    10471046                        else if (*p != '}')
    10481047                        {
    1049                                 FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Missing ',' in Dictionary: '%s'", p);
     1048                                Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Dictionary: '%s'", p);
    10501049                                return NULL;
    10511050                        }
     
    10871086                        }
    10881087                }
    1089                 FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Invalid reference: '%s'", in - 1);
     1088                Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Invalid reference: '%s'", in - 1);
    10901089                return NULL;
    10911090        }
     
    11341133                }
    11351134                setEmpty();
    1136                 FMprintf("ExtValue", "deserialize", FMLV_WARN, "object of class \"%s\" could not be deserialized", clsname.c_str());
     1135                Hprintf("ExtValue", "deserialize", HMLV_WARN, "object of class \"%s\" could not be deserialized", clsname.c_str());
    11371136                return ret;
    11381137        }
    1139         FMprintf("ExtValue", "deserialize", FMLV_ERROR, "Bad syntax: '%s'", in);
     1138        Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Bad syntax: '%s'", in);
    11401139        setEmpty();
    11411140        return NULL;
  • cpp/frams/util/sstringutils.cpp

    r348 r372  
    55#include "sstringutils.h"
    66#include <frams/virtfile/virtfile.h>
    7 #include <common/framsg.h>
     7#include <common/hmessage.h>
    88#include <common/nonstd.h>
    99
     
    1919        }
    2020        else if (framsgmodule)
    21                 FMprintf(framsgmodule, "loadSString", FMLV_WARN, error ? error : "can't open file \"%s\"", filename);
     21                Hprintf(framsgmodule, "loadSString", HMLV_WARN, error ? error : "can't open file \"%s\"", filename);
    2222        return ret;
    2323}
Note: See TracChangeset for help on using the changeset viewer.