mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-01 15:52:41 -06:00
Fixed ugly cluster of problems with Drawing, Painting, RichValue serialization, ValueArray...
git-svn-id: svn://ultimatepp.org/upp/trunk@1118 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
46510f36ff
commit
ea4448d995
6 changed files with 39 additions and 18 deletions
|
|
@ -4,6 +4,10 @@ NAMESPACE_UPP
|
|||
|
||||
//#BLITZ_APPROVE
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<Uuid>::Register();
|
||||
}
|
||||
|
||||
void Uuid::Serialize(Stream& s) {
|
||||
int version = 0;
|
||||
s / version % a % b %c % d;
|
||||
|
|
|
|||
|
|
@ -137,6 +137,8 @@ static void sRegisterStd()
|
|||
RichValue<WString>::Register();
|
||||
RichValue<Date>::Register();
|
||||
RichValue<Time>::Register();
|
||||
RichValue<ValueArray>::Register();
|
||||
RichValue<ValueMap>::Register();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -352,8 +354,10 @@ ValueArray::ValueArray(const Value& src)
|
|||
}
|
||||
|
||||
void ValueArray::Serialize(Stream& s) {
|
||||
if(s.IsStoring())
|
||||
Clone();
|
||||
if(s.IsLoading()) {
|
||||
data->Release();
|
||||
Create();
|
||||
}
|
||||
data->Serialize(s);
|
||||
}
|
||||
|
||||
|
|
@ -406,10 +410,6 @@ String AsString(const ValueArray& v) {
|
|||
return sAsString(v.Get());
|
||||
}
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<ValueArray>::Register();
|
||||
}
|
||||
|
||||
bool ValueMap::Data::IsNull() const {
|
||||
return this == &Single<ValueMap::NullData>();
|
||||
}
|
||||
|
|
@ -546,10 +546,6 @@ Value ValueMap::operator[](const Value& key) const
|
|||
return q >= 0 ? data->value[q] : ErrorValue();
|
||||
}
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<Color>::Register();
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
struct IdList : public Index<String> {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ NAMESPACE_UPP
|
|||
|
||||
static StaticMutex sDrawLock;
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<Painting>::Register();
|
||||
RichValue<Drawing>::Register();
|
||||
}
|
||||
|
||||
Size Draw::GetNativeDpi() const
|
||||
{
|
||||
return nativeDpi;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ enum {
|
|||
|
||||
class Drawing;
|
||||
class Draw;
|
||||
|
||||
class Painting;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
|
@ -475,7 +474,7 @@ void SColorDkShadow_Write(Color c);
|
|||
inline Color InvertColor() { return Color(255, 0); }
|
||||
inline Color DefaultInk() { return Black(); } //TODO!
|
||||
|
||||
class Painting : AssignValueTypeNo<Painting, 48, Moveable<Painting> >{
|
||||
class Painting : AssignValueTypeNo<Painting, 48, Moveable<Painting> > {
|
||||
String cmd;
|
||||
ValueArray data;
|
||||
Sizef size;
|
||||
|
|
@ -488,7 +487,7 @@ public:
|
|||
|
||||
void Clear() { size = Null; data.Clear(); cmd.Clear(); }
|
||||
void Serialize(Stream& s) { s % cmd % data % size; }
|
||||
bool IsNullInstance() const { return data.IsEmpty(); }
|
||||
bool IsNullInstance() const { return cmd.IsEmpty(); }
|
||||
bool operator==(const Painting& b) const { return cmd == b.cmd && data == b.data && size == b.size; }
|
||||
unsigned GetHashValue() const { return CombineHash(cmd, data); }
|
||||
String ToString() const { return "painting " + AsString(size); }
|
||||
|
|
@ -971,7 +970,7 @@ public:
|
|||
class WinMetaFile;
|
||||
#endif
|
||||
|
||||
class Drawing : Moveable<Drawing> {
|
||||
class Drawing : AssignValueTypeNo<Drawing, 49, Moveable<Drawing> > {
|
||||
Size size;
|
||||
String data;
|
||||
ValueArray val;
|
||||
|
|
@ -994,10 +993,13 @@ public:
|
|||
|
||||
void Serialize(Stream& s);
|
||||
|
||||
bool IsNullInstance() const { return data.IsEmpty(); }
|
||||
bool IsNullInstance() const { return data.IsEmpty(); }
|
||||
bool operator==(const Drawing& b) const { return val == b.val && data == b.data && size == b.size; }
|
||||
String ToString() const { return "drawing " + AsString(size); }
|
||||
unsigned GetHashValue() const { return CombineHash(data, val); }
|
||||
|
||||
operator Value() const { return RawValue<Drawing>(*this); }
|
||||
Drawing(const Value& src) { if(!IsNull(src)) *this = RawValue<Drawing>::Extract(src); }
|
||||
operator Value() const { return RichValue<Drawing>(*this); }
|
||||
Drawing(const Value& src);
|
||||
|
||||
Drawing() { size = Null; }
|
||||
Drawing(const Nuller&) { size = Null; }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
#ifdef COMPILER_MSC
|
||||
#pragma warning(disable: 4700)
|
||||
|
|
@ -682,6 +682,16 @@ void Drawing::Append(Drawing& dw)
|
|||
if(IsNull(size))
|
||||
size = dw.size;
|
||||
data << dw.data;
|
||||
for(int i = 0; i < dw.val.GetCount(); i++)
|
||||
val.Add(dw.val[i]);
|
||||
}
|
||||
|
||||
Drawing::Drawing(const Value& src)
|
||||
{
|
||||
if(IsNull(src))
|
||||
size = Null;
|
||||
else
|
||||
*this = RichValue<Drawing>::Extract(src);
|
||||
}
|
||||
|
||||
void Drawing::Serialize(Stream& s)
|
||||
|
|
|
|||
|
|
@ -236,6 +236,10 @@ void Image::Serialize(Stream& s)
|
|||
s.Put(~*this, len * sizeof(RGBA));
|
||||
}
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<Image>::Register();
|
||||
}
|
||||
|
||||
bool Image::operator==(const Image& img) const
|
||||
{
|
||||
if(GetLength() != img.GetLength())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue