Ignore:
Timestamp:
02/02/19 20:50:07 (5 years ago)
Author:
Maciej Komosinski
Message:

Getting int or float value casted from null or invalid is an ERROR (but still returns 0)

File:
1 edited

Legend:

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

    r793 r851  
    5656        };
    5757
    58         void copyFrom(const ExtObject& src)  { subtype = src.subtype; object = src.object; param = src.param; }
    59 
    60         void* operator new(size_t s, void* mem){ return mem; }
     58        void copyFrom(const ExtObject& src) { subtype = src.subtype; object = src.object; param = src.param; }
     59
     60        void* operator new(size_t s, void* mem) { return mem; }
    6161#ifdef _MSC_VER
    62                 void operator delete(void* mem, void* t) {}
    63 #endif
    64         void* operator new(size_t s){ return malloc(sizeof(ExtObject)); }
     62        void operator delete(void* mem, void* t) {}
     63#endif
     64        void* operator new(size_t s) { return malloc(sizeof(ExtObject)); }
    6565        void operator delete(void* mem) { free(mem); }
    6666        ///@param tmp_param can be used for temporary storage, the result ParamInterface* is only valid for as long as tmp_param is valid
    67         ParamInterface *getParamInterface(Param &tmp_param) const  { if (subtype & 2){ tmp_param.setParamTab(param->getParamTab()); tmp_param.select(object); return &tmp_param; } return paraminterface; }
     67        ParamInterface *getParamInterface(Param &tmp_param) const { if (subtype & 2) { tmp_param.setParamTab(param->getParamTab()); tmp_param.select(object); return &tmp_param; } return paraminterface; }
    6868        const char* interfaceName() const { if (isEmpty()) return "Empty"; return (subtype & 2) ? param->getName() : paraminterface->getName(); }
    6969        bool matchesInterfaceName(ParamInterface* pi) const { return !strcmp(interfaceName(), pi->getName()); }
     
    7474        int isEmpty() const { return !param; }
    7575        static const ExtObject& empty() { static const ExtObject e((ParamInterface*)NULL); return e; }
    76         ExtObject(const ExtObject& src)      { DEBUG_EXTOBJECT("(const&)"); src.incref(); copyFrom(src); }
     76        ExtObject(const ExtObject& src) { DEBUG_EXTOBJECT("(const&)"); src.incref(); copyFrom(src); }
    7777        void operator=(const ExtObject& src) { src.incref(); decref(); copyFrom(src); }
    7878        bool makeUnique();//< @return false if nothing has changed
     
    8686        ExtObject(Param *p, void *o) :subtype(2), object(o), param(p) { DEBUG_EXTOBJECT("(Param,void)"); }
    8787        ExtObject(ParamInterface *p = 0) :subtype(0), object(0), paraminterface(p) { DEBUG_EXTOBJECT("(ParamInterface)"); }
    88         ExtObject(Param *p, DestrBase *o) :subtype(1 + 2), dbobject(o), param(p){ DEBUG_EXTOBJECT("(Param,DestrBase)"); incref(); }
    89         ExtObject(ParamInterface *p, DestrBase *o) :subtype(1), dbobject(o), paraminterface(p){ DEBUG_EXTOBJECT("(ParamInterface,DestrBase)"); incref(); }
    90 
    91         ~ExtObject(){ DEBUG_EXTOBJECT("~"); decref(); }
     88        ExtObject(Param *p, DestrBase *o) :subtype(1 + 2), dbobject(o), param(p) { DEBUG_EXTOBJECT("(Param,DestrBase)"); incref(); }
     89        ExtObject(ParamInterface *p, DestrBase *o) :subtype(1), dbobject(o), paraminterface(p) { DEBUG_EXTOBJECT("(ParamInterface,DestrBase)"); incref(); }
     90
     91        ~ExtObject() { DEBUG_EXTOBJECT("~"); decref(); }
    9292
    9393        class Serialization
     
    132132#endif
    133133
    134         void* operator new(size_t s, void* mem){ return mem; }
    135         void* operator new(size_t s){ return ::operator new(s); }
    136 
    137                 ExtValue() :type(TUnknown){}
     134        void* operator new(size_t s, void* mem) { return mem; }
     135        void* operator new(size_t s) { return ::operator new(s); }
     136
     137        ExtValue() :type(TUnknown) {}
    138138        ~ExtValue() { setEmpty(); }
    139139        ExtValue(paInt v) { seti(v); }
     
    225225
    226226private: // setrx - release and set, setx - assume released
    227         void setr(const ExtValue& src){ setEmpty(); set(src); }
     227        void setr(const ExtValue& src) { setEmpty(); set(src); }
    228228        void set(const ExtValue& src);
    229229        void setri(paInt v) { setEmpty(); seti(v); }
Note: See TracChangeset for help on using the changeset viewer.