|
@@ -194,10 +194,12 @@ struct SQObjectPtr;
|
|
|
_unVal.sym = x; \
|
|
_unVal.sym = x; \
|
|
|
} \
|
|
} \
|
|
|
inline SQObjectPtr& operator=(_class x) \
|
|
inline SQObjectPtr& operator=(_class x) \
|
|
|
- { \
|
|
|
|
|
- __Release(_type,_unVal); \
|
|
|
|
|
- _type = type; \
|
|
|
|
|
- SQ_OBJECT_RAWINIT() \
|
|
|
|
|
|
|
+ { \
|
|
|
|
|
+ if(_type != type){\
|
|
|
|
|
+ __Release(_type,_unVal); \
|
|
|
|
|
+ _type = type; \
|
|
|
|
|
+ SQ_OBJECT_RAWINIT() \
|
|
|
|
|
+ }\
|
|
|
_unVal.sym = x; \
|
|
_unVal.sym = x; \
|
|
|
return *this; \
|
|
return *this; \
|
|
|
}
|
|
}
|
|
@@ -246,10 +248,12 @@ struct SQObjectPtr : public SQObject
|
|
|
_unVal.nInteger = bBool?1:0;
|
|
_unVal.nInteger = bBool?1:0;
|
|
|
}
|
|
}
|
|
|
inline SQObjectPtr& operator=(bool b)
|
|
inline SQObjectPtr& operator=(bool b)
|
|
|
- {
|
|
|
|
|
- __Release(_type,_unVal);
|
|
|
|
|
- SQ_OBJECT_RAWINIT()
|
|
|
|
|
- _type = OT_BOOL;
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ if(_type != OT_BOOL){
|
|
|
|
|
+ __Release(_type,_unVal);
|
|
|
|
|
+ SQ_OBJECT_RAWINIT()
|
|
|
|
|
+ _type = OT_BOOL;
|
|
|
|
|
+ }
|
|
|
_unVal.nInteger = b?1:0;
|
|
_unVal.nInteger = b?1:0;
|
|
|
return *this;
|
|
return *this;
|
|
|
}
|
|
}
|
|
@@ -260,33 +264,34 @@ struct SQObjectPtr : public SQObject
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline SQObjectPtr& operator=(const SQObjectPtr& obj)
|
|
inline SQObjectPtr& operator=(const SQObjectPtr& obj)
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ //saving temporarily the old value for cases
|
|
|
|
|
+ //where we are assigning a inner value to the old value
|
|
|
|
|
+ //local tbl = {a=2, b=4}; tbl = tbl.a;
|
|
|
SQObjectType tOldType =_type;
|
|
SQObjectType tOldType =_type;
|
|
|
SQObjectValue unOldVal =_unVal;
|
|
SQObjectValue unOldVal =_unVal;
|
|
|
_unVal = obj._unVal;
|
|
_unVal = obj._unVal;
|
|
|
_type = obj._type;
|
|
_type = obj._type;
|
|
|
__AddRef(_type,_unVal);
|
|
__AddRef(_type,_unVal);
|
|
|
- __Release(tOldType,unOldVal);
|
|
|
|
|
|
|
+ __Release(tOldType,unOldVal);
|
|
|
return *this;
|
|
return *this;
|
|
|
}
|
|
}
|
|
|
inline SQObjectPtr& operator=(const SQObject& obj)
|
|
inline SQObjectPtr& operator=(const SQObject& obj)
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
SQObjectType tOldType =_type;
|
|
SQObjectType tOldType =_type;
|
|
|
SQObjectValue unOldVal =_unVal;
|
|
SQObjectValue unOldVal =_unVal;
|
|
|
_unVal = obj._unVal;
|
|
_unVal = obj._unVal;
|
|
|
_type = obj._type;
|
|
_type = obj._type;
|
|
|
__AddRef(_type,_unVal);
|
|
__AddRef(_type,_unVal);
|
|
|
- __Release(tOldType,unOldVal);
|
|
|
|
|
|
|
+ __Release(tOldType,unOldVal);
|
|
|
return *this;
|
|
return *this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void Null()
|
|
inline void Null()
|
|
|
{
|
|
{
|
|
|
- SQObjectType tOldType = _type;
|
|
|
|
|
- SQObjectValue unOldVal = _unVal;
|
|
|
|
|
|
|
+ __Release(_type,_unVal);
|
|
|
_type = OT_NULL;
|
|
_type = OT_NULL;
|
|
|
_unVal.raw = (SQRawObjectVal)NULL;
|
|
_unVal.raw = (SQRawObjectVal)NULL;
|
|
|
- __Release(tOldType ,unOldVal);
|
|
|
|
|
}
|
|
}
|
|
|
private:
|
|
private:
|
|
|
SQObjectPtr(const SQChar *){} //safety
|
|
SQObjectPtr(const SQChar *){} //safety
|