Syncing uppdev

git-svn-id: svn://ultimatepp.org/upp/trunk@1825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-12-21 10:33:12 +00:00
parent ea7d86aacd
commit 6a809a7a5d
9 changed files with 157 additions and 12 deletions

View file

@ -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?")) {

View file

@ -12,16 +12,17 @@ void Register(const char *name, Callback1<XmlRpcData&> cb)
String XmlRpcExecute(const String& request)
{
XmlParser p(request);
XmlRpcData data;
String methodname;
try {
String r = XmlHeader();
r << "<methodResponse>\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;

View file

@ -41,7 +41,7 @@ CONSOLE_APP_MAIN
DDUMP(XmlRpcExecute(r));
XmlRpcData d;
d << 12 << "-" << 22;
d << "12" << "-" << 22;
DDUMP(XmlRpcCall("compute", d));
int res;

21
uppdev/asmopt/asmopt.cpp Normal file
View file

@ -0,0 +1,21 @@
#include <Core/Core.h>
using namespace Upp;
int Count(const Vector<String>& 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<String> x;
for(int i = 0; i < 1000; i++)
x.Add(AsString(Random(100)));
Cout() << Count(x, "50");
}

11
uppdev/asmopt/asmopt.upp Normal file
View file

@ -0,0 +1,11 @@
optimize_speed;
uses
Core;
file
asmopt.cpp;
mainconfig
"" = "";

4
uppdev/asmopt/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _asmopt_icpp_init_stub
#define _asmopt_icpp_init_stub
#include "Core/init"
#endif

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI MT";

4
uppdev/guimtbug/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _guimtbug_icpp_init_stub
#define _guimtbug_icpp_init_stub
#include "CtrlLib/init"
#endif

90
uppdev/guimtbug/main.cpp Normal file
View file

@ -0,0 +1,90 @@
#include <CtrlLib/CtrlLib.h>
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();
}