Changeset 482 for cpp/frams


Ignore:
Timestamp:
03/26/16 01:32:18 (8 years ago)
Author:
Maciej Komosinski
Message:

Fixed: we want a reference to a static object, not a static reference to a temporary object

File:
1 edited

Legend:

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

    r478 r482  
    1414template <int A, int B> struct CompileTimeMax { enum { val = A > B ? A : B }; };
    1515#define EXTVALUEUNIONSIZE CompileTimeMax<sizeof(ExtObject),sizeof(SString)>::val
     16
     17//#define DEBUG_EXTOBJECT(txt) printf("%p ExtObj::" txt "\n",this)
     18#define DEBUG_EXTOBJECT(txt)
    1619
    1720enum ExtPType
     
    7073        void setEmpty() { decref(); subtype = 0; param = NULL; object = NULL; }
    7174        int isEmpty() const { return !param; }
    72         static const ExtObject& empty() { static const ExtObject& e((ParamInterface*)NULL); return e; }
    73         ExtObject(const ExtObject& src)      { src.incref(); copyFrom(src); }
     75        static const ExtObject& empty() { static const ExtObject e((ParamInterface*)NULL); return e; }
     76        ExtObject(const ExtObject& src)      { DEBUG_EXTOBJECT("(const&)"); src.incref(); copyFrom(src); }
    7477        void operator=(const ExtObject& src) { src.incref(); decref(); copyFrom(src); }
    7578        bool makeUnique();//< @return false if nothing has changed
     
    8184        SString serialize(SerializationFormat format) const;
    8285
    83         ExtObject(Param *p, void *o) :subtype(2), object(o), param(p){}
    84         ExtObject(ParamInterface *p = 0) :subtype(0), object(0), paraminterface(p){}
    85         ExtObject(Param *p, DestrBase *o) :subtype(1 + 2), dbobject(o), param(p){ incref(); }
    86         ExtObject(ParamInterface *p, DestrBase *o) :subtype(1), dbobject(o), paraminterface(p){ incref(); }
    87 
    88         ~ExtObject(){ decref(); }
     86        ExtObject(Param *p, void *o) :subtype(2), object(o), param(p) { DEBUG_EXTOBJECT("(Param,void)");}
     87        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(); }
    8992
    9093        class Serialization
Note: See TracChangeset for help on using the changeset viewer.