diff --git a/uppdev/Gen2/main.cpp b/uppdev/Gen2/main.cpp index 976b23ac5..258159b88 100644 --- a/uppdev/Gen2/main.cpp +++ b/uppdev/Gen2/main.cpp @@ -235,7 +235,6 @@ void World::Step() for(int i = 0; i < 8192; i++) nc.gen[i] = (rand() & 1) ? c.gen[i] : pc.gen[i]; while((rand() & 5) == 0) { - LOG("...and mutating"); nc.color = Color(127 + (((rand() & 15) + c.color.GetR() - 7) & 127), 127 + (((rand() & 15) + c.color.GetG() - 7) & 127), 127 + (((rand() & 15) + c.color.GetB() - 7) & 127)); @@ -252,12 +251,12 @@ void World::Step() born++; } } - for(int i = 0; i < 1024; i++) { +/* for(int i = 0; i < 1024; i++) { spot[i][0].kind = TRAP; spot[i][PMSK].kind = TRAP; spot[0][i].kind = TRAP; spot[PMSK][i].kind = TRAP; - } + }*/ Title(String().Cat() << "Step: " << step << " Gen: " << gen << ", pop: " << creature.GetCount() << ", born: " << born << ", died: " << died << " best: " << best); Refresh(); @@ -278,10 +277,10 @@ World::World() p.kind = GRASS; p.energy = rand(); } - if(x == 0 || y == 0 || x == PMSK || y == PMSK) { - p.kind = TRAP; - p.energy = 0; - } +// if(x == 0 || y == 0 || x == PMSK || y == PMSK) { +// p.kind = TRAP; +// p.energy = 0; +// } p.creature = NULL; } if(PromptYesNo("Restore creatures from the previous run?")) { diff --git a/uppdev/NewXmlRpc/XmlRpcBroker.cpp b/uppdev/NewXmlRpc/XmlRpcBroker.cpp index 2b6a99676..1f781635b 100644 --- a/uppdev/NewXmlRpc/XmlRpcBroker.cpp +++ b/uppdev/NewXmlRpc/XmlRpcBroker.cpp @@ -12,16 +12,17 @@ void Register(const char *name, Callback1 cb) String XmlRpcExecute(const String& request) { XmlParser p(request); + XmlRpcData data; + String methodname; try { String r = XmlHeader(); r << "\r\n"; p.ReadPI(); p.PassTag("methodCall"); p.PassTag("methodName"); - String methodname = p.ReadText(); + methodname = p.ReadText(); LLOG("method name: " << methodname); p.PassEnd(); - XmlRpcData data; data.in = ParseXmlRpcParams(p); int q = xmlrpcmap.Find(methodname); if(q >= 0) { @@ -33,8 +34,13 @@ String XmlRpcExecute(const String& request) p.PassEnd(); return r; } - catch(XmlError e) { // Add error handling! - LOG("XmlError " << e << ": " << p.GetPtr()); + catch(XmlError e) { + LLOG("XmlError " << e << ": " << p.GetPtr()); + return FormatXmlRpcError(1, methodname + " XML Error: " + e); + } + catch(ValueTypeMismatch) { + LLOG("ValueTypeMismatch at parameter " << data.ii); + return FormatXmlRpcError(2, methodname + " Value type mismatch at parameter " + AsString(data.ii)); } return Null; } @@ -60,6 +66,7 @@ Value XmlRpcCall(const char *name, XmlRpcData& param) } catch(XmlError e) { LOG("XmlError " << e << ": " << p.GetPtr()); + return ErrorValue(); } return param.in.GetCount() ? param.in[0] : Null; diff --git a/uppdev/NewXmlRpc/main.cpp b/uppdev/NewXmlRpc/main.cpp index 010bc70a9..fbadcddc5 100644 --- a/uppdev/NewXmlRpc/main.cpp +++ b/uppdev/NewXmlRpc/main.cpp @@ -41,7 +41,7 @@ CONSOLE_APP_MAIN DDUMP(XmlRpcExecute(r)); XmlRpcData d; - d << 12 << "-" << 22; + d << "12" << "-" << 22; DDUMP(XmlRpcCall("compute", d)); int res; diff --git a/uppdev/asmopt/asmopt.cpp b/uppdev/asmopt/asmopt.cpp new file mode 100644 index 000000000..9a98881e0 --- /dev/null +++ b/uppdev/asmopt/asmopt.cpp @@ -0,0 +1,21 @@ +#include + +using namespace Upp; + +int Count(const Vector& v, const String& x) +{ + int count = 0; + for(int i = 0; i < v.GetCount(); i++) + if(v[i] == x) + count++; + return count; +} + + +CONSOLE_APP_MAIN +{ + Vector x; + for(int i = 0; i < 1000; i++) + x.Add(AsString(Random(100))); + Cout() << Count(x, "50"); +} diff --git a/uppdev/asmopt/asmopt.upp b/uppdev/asmopt/asmopt.upp new file mode 100644 index 000000000..71bcae841 --- /dev/null +++ b/uppdev/asmopt/asmopt.upp @@ -0,0 +1,11 @@ +optimize_speed; + +uses + Core; + +file + asmopt.cpp; + +mainconfig + "" = ""; + diff --git a/uppdev/asmopt/init b/uppdev/asmopt/init new file mode 100644 index 000000000..50a4dc316 --- /dev/null +++ b/uppdev/asmopt/init @@ -0,0 +1,4 @@ +#ifndef _asmopt_icpp_init_stub +#define _asmopt_icpp_init_stub +#include "Core/init" +#endif diff --git a/uppdev/guimtbug/guimtbug.upp b/uppdev/guimtbug/guimtbug.upp new file mode 100644 index 000000000..a456850d0 --- /dev/null +++ b/uppdev/guimtbug/guimtbug.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI MT"; + diff --git a/uppdev/guimtbug/init b/uppdev/guimtbug/init new file mode 100644 index 000000000..682401cfc --- /dev/null +++ b/uppdev/guimtbug/init @@ -0,0 +1,4 @@ +#ifndef _guimtbug_icpp_init_stub +#define _guimtbug_icpp_init_stub +#include "CtrlLib/init" +#endif diff --git a/uppdev/guimtbug/main.cpp b/uppdev/guimtbug/main.cpp new file mode 100644 index 000000000..248273dd3 --- /dev/null +++ b/uppdev/guimtbug/main.cpp @@ -0,0 +1,90 @@ +#include + +using namespace Upp; + +class TestThread : public TopWindow +{ + protected: + bool stop; + void buttonCb(void); + Thread thr; + virtual void thrCb(void); + + void Stop(); + + ProgressIndicator progress; + Button button; + StatusBar status; + + public: + typedef TestThread CLASSNAME; + + TestThread(); + +}; + +void TestThread::thrCb(void) +{ + { + GuiLock __; + status.Set("Running, " + FormatInt(thr.GetCount()) + " threads"); + } + for(;;) + { + { + GuiLock __; + if(progress < 100) + progress++; + else + progress = 0; + if(stop) + break; + } + Sleep(1000); + } + { + GuiLock __; + status.Set("Idle...."); + } + PostCallback(THISBACK(Stop)); +} + +void TestThread::Stop() +{ + button.SetLabel("START"); +} + + +void TestThread::buttonCb(void) +{ + if(stop) + { + stop = false; + button.SetLabel("STOP"); + thr.Run(THISBACK(thrCb)); + } + else + stop = true; +} + +TestThread::TestThread() +{ + SetRect(0, 0, 300, 150); + Add(button); + button.TopPos(90, 30).HCenterPos(100); + button.SetLabel("START"); + Add(progress); + progress.TopPos(30, 40).HCenterPos(250); + progress.Set(0, 100); + AddFrame(status); + status.Set(" "); + + stop = true; + button <<= THISBACK(buttonCb); + +} + +GUI_APP_MAIN +{ + TestThread().Run(); +}