From db03281dfbe597d4cad58fbfa0a80487cd764267 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 14 Sep 2012 11:43:13 +0000 Subject: [PATCH] uppsrc: OLD_VALUE completely removed, Core/Rpc: Now supports Json parameters and return values git-svn-id: svn://ultimatepp.org/upp/trunk@5356 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Color.cpp | 6 - uppsrc/Core/Color.h | 5 - uppsrc/Core/Core.h | 14 - uppsrc/Core/Core.upp | 2 - uppsrc/Core/Gtypes.h | 27 - uppsrc/Core/JSON.cpp | 18 +- uppsrc/Core/JSON.h | 18 +- uppsrc/Core/OldValue.cpp | 681 ------------------------- uppsrc/Core/OldValue.h | 787 ----------------------------- uppsrc/Core/Rpc/Client.cpp | 19 +- uppsrc/Core/Rpc/Rpc.h | 5 + uppsrc/Core/Rpc/Server.cpp | 40 +- uppsrc/Core/Rpc/Value.cpp | 7 + uppsrc/Core/Uuid.h | 5 - uppsrc/Core/Value.cpp | 4 - uppsrc/Core/Value.h | 4 - uppsrc/Core/Value.hpp | 3 - uppsrc/Core/ValueUtil.cpp | 19 - uppsrc/Core/ValueUtil.h | 4 - uppsrc/Core/Xmlize.cpp | 176 ------- uppsrc/Core/Xmlize.h | 8 - uppsrc/Core/src.tpp/JSON$en-us.tpp | 14 +- uppsrc/Draw/Draw.h | 6 - uppsrc/Draw/DrawTextUtil.cpp | 4 +- uppsrc/Draw/Font.cpp | 2 - uppsrc/Draw/Image.h | 6 +- uppsrc/XmlView/XmlView.upp | 28 +- uppsrc/ide/ide.upp | 3 +- uppsrc/uppconfig.h | 1 - 29 files changed, 98 insertions(+), 1818 deletions(-) delete mode 100644 uppsrc/Core/OldValue.cpp delete mode 100644 uppsrc/Core/OldValue.h diff --git a/uppsrc/Core/Color.cpp b/uppsrc/Core/Color.cpp index 03d17ea84..7c92a0a4b 100644 --- a/uppsrc/Core/Color.cpp +++ b/uppsrc/Core/Color.cpp @@ -165,15 +165,9 @@ Color Blend(Color c1, Color c2, int alpha) min(((a * (c2.GetB() - c1.GetB())) >> 8) + c1.GetB(), 255)); } -#ifdef SVO_VALUE INITBLOCK { Value::SvoRegister("Color"); } -#else -INITBLOCK { - RichValue::Register(); -} -#endif int Grayscale(const Color& c) { diff --git a/uppsrc/Core/Color.h b/uppsrc/Core/Color.h index 6cd14d723..8fa537aa7 100644 --- a/uppsrc/Core/Color.h +++ b/uppsrc/Core/Color.h @@ -57,13 +57,8 @@ public: Color(const Nuller&) { SetNull(); } -#ifdef SVO_VALUE operator Value() const { return SvoToValue(*this); } Color(const Value& q) { color = q.Get().color; } -#else - operator Value() const { return RichValue(*this); } - Color(const Value& q) { color = RichValue::Extract(q).color; } -#endif operator RGBA() const; Color(RGBA rgba); diff --git a/uppsrc/Core/Core.h b/uppsrc/Core/Core.h index fe15ed960..36c8e8685 100644 --- a/uppsrc/Core/Core.h +++ b/uppsrc/Core/Core.h @@ -281,20 +281,6 @@ NAMESPACE_UPP #include "Vcont.hpp" #include "Index.hpp" -#ifdef flagSVO_VALUE -#ifndef SVO_VALUE -#define SVO_VALUE -#endif -#endif - -#ifdef flagOLD_VALUE -#ifdef SVO_VALUE -#undef SVO_VALUE -#endif -#endif - -#include "OldValue.h" - #include "Value.h" #include "ValueUtil.h" diff --git a/uppsrc/Core/Core.upp b/uppsrc/Core/Core.upp index 874be3381..fec111eea 100644 --- a/uppsrc/Core/Core.upp +++ b/uppsrc/Core/Core.upp @@ -98,8 +98,6 @@ file Callback.cpp optimize_speed, TimeDate.h, TimeDate.cpp optimize_speed, - OldValue.h, - OldValue.cpp optimize_speed, Value.h, Value.hpp, Value.cpp optimize_speed, diff --git a/uppsrc/Core/Gtypes.h b/uppsrc/Core/Gtypes.h index 6c8f249f7..28e535e83 100644 --- a/uppsrc/Core/Gtypes.h +++ b/uppsrc/Core/Gtypes.h @@ -72,13 +72,8 @@ struct Size_ : Moveable< Size_ > { Size_(const Nuller&) { cx = cy = Null; } -#ifdef SVO_VALUE operator Value() const { return FitsSvoValue() ? SvoToValue(*this) : RichToValue(*this); } Size_(const Value& src) { *this = src.Get(); } -#else - operator Value() const { return RichValue(*this); } - Size_(const Value& src) { *this = RichValue::Extract(src); } -#endif void Serialize(Stream& s) { s % cx % cy; } void Jsonize(JsonIO& jio) { jio("cx", cx)("cy", cy); } @@ -181,13 +176,8 @@ struct Point_ : Moveable< Point_ > { Point_(const Nuller&) { x = y = Null; } -#ifdef SVO_VALUE operator Value() const { return FitsSvoValue() ? SvoToValue(*this) : RichToValue(*this); } Point_(const Value& src) { *this = src.Get(); } -#else - operator Value() const { return RichValue(*this); } - Point_(const Value& src) { *this = RichValue::Extract(src); } -#endif void Serialize(Stream& s) { s % x % y; } void Jsonize(JsonIO& jio) { jio("x", x)("y", y); } @@ -726,20 +716,3 @@ double Distance(const Pointf& p1, const Pointf& p2); double SquaredDistance(const Pointf& p1, const Pointf& p2); Pointf Polar(double a); Pointf Polar(const Pointf& p, double r, double a); - -#ifndef SVO_VALUE -template<> void Xmlize(XmlIO& xml, Point& p); -template<> void Xmlize(XmlIO& xml, Point16& p); -template<> void Xmlize(XmlIO& xml, Point64& p); -template<> void Xmlize(XmlIO& xml, Pointf& p); - -template<> void Xmlize(XmlIO& xml, Size& sz); -template<> void Xmlize(XmlIO& xml, Size16& sz); -template<> void Xmlize(XmlIO& xml, Size64& sz); -template<> void Xmlize(XmlIO& xml, Sizef& sz); - -template<> void Xmlize(XmlIO& xml, Rect& r); -template<> void Xmlize(XmlIO& xml, Rect16& r); -template<> void Xmlize(XmlIO& xml, Rect64& r); -template<> void Xmlize(XmlIO& xml, Rectf& r); -#endif \ No newline at end of file diff --git a/uppsrc/Core/JSON.cpp b/uppsrc/Core/JSON.cpp index 2d12f2758..b34376d44 100644 --- a/uppsrc/Core/JSON.cpp +++ b/uppsrc/Core/JSON.cpp @@ -51,6 +51,22 @@ Value ParseJSON(const char *s) } } +Json& Json::CatRaw(const char *key, const String& val) +{ + if(text.GetCount()) + text << ','; + text << AsJSON(key) << ":" << val; + return *this; +} + +JsonArray& JsonArray::CatRaw(const String& val) +{ + if(text.GetCount()) + text << ','; + text << val; + return *this; +} + String AsJSON(const Value& v, const String& sep, bool pretty) { String r; @@ -114,9 +130,7 @@ String AsJSON(const Value& v, const String& sep, bool pretty) return AsCString((String)v, INT_MAX, NULL, ASCSTRING_JSON); if(IsNull(v)) return "null"; -#ifdef SVO_VALUE NEVER_("Non-JSON value in AsJSON: " + v.GetTypeName()); -#endif return "null"; } diff --git a/uppsrc/Core/JSON.h b/uppsrc/Core/JSON.h index 68b1b0ca9..253723052 100644 --- a/uppsrc/Core/JSON.h +++ b/uppsrc/Core/JSON.h @@ -16,14 +16,9 @@ class JsonArray; class Json { String text; - Json& CatRaw(const char *key, const String& val) { - if(text.GetCount()) - text << ','; - text << AsJSON(key) << ":" << val; - return *this; - } - public: + Json& CatRaw(const char *key, const String& val); + String ToString() const { return "{" + text + "}"; } String operator~() const { return ToString(); } operator String() const { return ToString(); } @@ -53,14 +48,9 @@ public: class JsonArray { String text; - JsonArray& CatRaw(const String& val) { - if(text.GetCount()) - text << ','; - text << val; - return *this; - } - public: + JsonArray& CatRaw(const String& val); + String ToString() const { return "[" + text + "]"; } String operator~() const { return ToString(); } operator String() const { return ToString(); } diff --git a/uppsrc/Core/OldValue.cpp b/uppsrc/Core/OldValue.cpp deleted file mode 100644 index 110f61c54..000000000 --- a/uppsrc/Core/OldValue.cpp +++ /dev/null @@ -1,681 +0,0 @@ -#include "Core.h" - -#ifndef SVO_VALUE - -NAMESPACE_UPP - -#ifndef flagSO -const Nuller Null; -#endif - -#define LTIMING(x) // RTIMING(x) - -unsigned Value::GetHashValue() const { - return IsNull() ? 0 : ptr->GetHashValue(); -} - -Value& Value::operator=(const Value& v) { - if(this == &v) return *this; - ptr->Release(); - ptr = v.ptr; - ptr->Retain(); - return *this; -} - -Value::Value(const Value& v) { - ptr = v.ptr; - ptr->Retain(); -} - -void Value::SetVoidVal() -{ - ptr = &Single(); - ptr->Retain(); -} - -Value::Value() { - SetVoidVal(); -} - -Value::~Value() { - ptr->Release(); -} - -bool Value::operator==(const Value& v) const { - if(ptr == v.ptr) return true; - bool an = IsNull(); - bool bn = v.IsNull(); - if(an || bn) return an && bn; - if(GetType() == v.GetType()) - return ptr->IsEqual(v.ptr); - return ptr->IsPolyEqual(v) || v.ptr->IsPolyEqual(*this); -} - -Value::Value(const String& s) { ptr = new RichValueRep(s); } -Value::Value(const WString& s) { ptr = new RichValueRep(s); } -Value::Value(const char *s) { ptr = new RichValueRep(s); } -Value::Value(int i) { ptr = new RichValueRep(i); } -Value::Value(int64 i) { ptr = new RichValueRep(i); } -Value::Value(double d) { ptr = new RichValueRep(d); } -Value::Value(bool b) { ptr = new RichValueRep(b); } -Value::Value(Date d) { ptr = new RichValueRep(d); } -Value::Value(Time t) { ptr = new RichValueRep