wheat-cvs Mailing List for Wheat (Page 2)
Status: Pre-Alpha
Brought to you by:
mark_lentczner
You can subscribe to this list here.
2005 |
Jan
(152) |
Feb
(248) |
Mar
(69) |
Apr
(27) |
May
(3) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Kragen S. <kr...@us...> - 2005-04-09 03:19:13
|
Update of /cvsroot/wheat/r1/web-dev/source/graffiti In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3763/graffiti Log Message: Directory /cvsroot/wheat/r1/web-dev/source/graffiti added to the repository |
From: Mark L. <mar...@us...> - 2005-04-08 18:25:20
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10045/wheat Modified Files: renderlibrary.cpp Log Message: support for nested expansion in expansion trace in Wheat changed the format of the raw trace array handed to Wheat Index: renderlibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/renderlibrary.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- renderlibrary.cpp 7 Apr 2005 18:15:13 -0000 1.8 +++ renderlibrary.cpp 8 Apr 2005 18:25:12 -0000 1.9 @@ -225,29 +225,52 @@ } void - buildRawTrace(tt::Trace& trace, Local& rawTrace) + addRawTrace(tt::Trace& trace, Local& rawTrace) { - rawTrace = Array(); - for (int i = 0; i < trace.count(); i += 1) { pt::string name = trace.index(i); - pt::string action; - switch (trace.action(name)) { + pt::string actionStr; + tt::Trace::Action action = trace.action(name); + switch (action) { default: - case tt::Trace::Unknown: action = "unknown"; break; - case tt::Trace::Unexpanded: action = "unexpanded"; break; - case tt::Trace::Kept: action = "kept"; break; - case tt::Trace::Skipped: action = "skipped"; break; - case tt::Trace::Replaced: action = "replaced"; break; - case tt::Trace::Repeated: action = "repeated"; break; - case tt::Trace::Ambiguous: action = "ambiguous"; break; + case tt::Trace::Unknown: actionStr = "unknown"; break; + case tt::Trace::Unexpanded: actionStr = "unexpanded"; break; + case tt::Trace::Kept: actionStr = "kept"; break; + case tt::Trace::Skipped: actionStr = "skipped"; break; + case tt::Trace::Replaced: actionStr = "replaced"; break; + case tt::Trace::Repeated: actionStr = "repeated"; break; + case tt::Trace::Ambiguous: actionStr = "ambiguous"; break; } - pt::string replacement = trace.replacementText(name); rawTrace.send("add", String(name)); - rawTrace.send("add", String(action)); - rawTrace.send("add", String(replacement)); + rawTrace.send("add", String(actionStr)); + + switch (action) { + case tt::Trace::Replaced: + rawTrace.send("add", String(trace.replacementText(name))); + break; + + case tt::Trace::Repeated: { + int n = trace.repeatCount(name); + rawTrace.send("add", Int(n)); + for (int i = 0; i < n; ++i) { + addRawTrace(trace.repeatIndex(name, i), rawTrace); + } + break; + } + + default: ; + } } + + rawTrace.send("add", False()); + } + + void + buildRawTrace(tt::Trace& trace, Local& rawTrace) + { + rawTrace = Array(); + addRawTrace(trace, rawTrace); } Return |
From: Mark L. <mar...@us...> - 2005-04-08 18:25:20
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10045/root/library Modified Files: render.ws Log Message: support for nested expansion in expansion trace in Wheat changed the format of the raw trace array handed to Wheat Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- render.ws 7 Apr 2005 18:15:13 -0000 1.34 +++ render.ws 8 Apr 2005 18:25:12 -0000 1.35 @@ -178,7 +178,7 @@ action-type: { :'/library/base/enum': values: ["unknown", "unexpanded", "kept", "skipped", "replaced", - "repeated" + "repeated", "ambiguous" ] } @@ -192,24 +192,54 @@ } replacement(name): { return #map[name].replacement } + + repeat-count(name): { return #map[name].count } + repeat-index(name, index): { return \#map[name].repeats[index] } + array-stream: { + -- instance -- + array: [ ] + index: 0 + -- public -- + new(array): { return {:self: array: \\array; index: 0 } } + next(): { v := #array[#index]; #index += 1; return v } + more(): { return #index < #array.size } + done(): { return ~#done } + } + from-raw(raw-trace): { + raw-stream := #array-stream.new(\\raw-trace) + return #build-from-raw(\raw-stream) + } + + build-from-raw(raw-stream): { t := #new() t.map := $/library/base/table.new() - i := 0; - while (i < raw-trace.size) { - name := raw-trace[i] - action := #action-type.new(raw-trace[i+1]) - replacement := raw-trace[i+2] - - if (action.matches("repeat")) { - replacement := #from-raw(replacement) - } + while (raw-stream.more()) { + name := raw-stream.next() + if (false == name) { return t } - t.map[name] := { action: action; replacement: replacement } + action := #action-type.new(raw-stream.next()); - i += 3 + if (action.matches("replaced")) { + replacement := raw-stream.next() + t.map[name] := { action: action; replacement: replacement } + } + else if (action.matches("repeated")) { + count := raw-stream.next() + repeats := [ ] + j := 0 + while (j < count) { + repeats.add(#build-from-raw(\\raw-stream)) + j += 1 + } + t.map[name] := + ... { action: action; count: count; repeats: repeats } + } + else { + t.map[name] := { action: action } + } } return t @@ -910,6 +940,9 @@ <p tt:name="do-keep">a secret</p> <p tt:name="do-skip">a beat</p> <p tt:name="do-replace-text">one two three</p> + <ul> + <li tt:name="do-repeat"><tt:span name="count">some</tt:span></li> + </ul> </body> "") @@ -918,6 +951,25 @@ tt-do-keep(): { #keep } tt-do-skip(): { #skip } tt-do-replace-text(): { #replace-text("123") } + tt-do-repeat(): { + #start-repeat() + i := 0 + while (i < 4) { + #expand(expander: \#count-expander, subject: i) + i += 1 + } + } + + count-expander: {:'/library/render/expander': + numbers: [ "nil", "uno", "due", "tre" ] + + tt-count(): { + if (#subject >= 0 && #subject < #numbers.size) { + return #numbers[#subject] + } + return #subject.as-string + } + } } test-expander-trace(): { @@ -933,7 +985,21 @@ #assert-equals("skipped", trace.action("do-skip").value) #assert-equals("replaced", trace.action("do-replace-text").value) - #assert-equals("123", trace.replacement("do-replace-text")) + #assert-equals("123", trace.replacement("do-replace-text")) + + #assert-equals("repeated", trace.action("do-repeat").value) + #assert-equals(4, trace.repeat-count("do-repeat")) + + numbers := [ "nil", "uno", "due", "tre" ] + i := 0 + while (i < numbers.size) { + sub-trace := \trace.repeat-index("do-repeat", i); + #assert-equals("replaced", sub-trace.action("count").value) + #assert-equals(numbers[i], sub-trace.replacement("count")) + i += 1 + } + + #assert-equals("unknown", trace.action("count").value) } } |
From: Mark L. <mar...@us...> - 2005-04-07 18:15:22
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23808/wheat Modified Files: renderlibrary.cpp Log Message: first stab at getting trace into Wheat code - doesn't do repeats or nested expansions yet - someone hokey implementation on the C++ side - doesn't handle errors at all Index: renderlibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/renderlibrary.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- renderlibrary.cpp 1 Apr 2005 06:11:34 -0000 1.7 +++ renderlibrary.cpp 7 Apr 2005 18:15:13 -0000 1.8 @@ -224,6 +224,31 @@ return tt::Instruction::none(); } + void + buildRawTrace(tt::Trace& trace, Local& rawTrace) + { + rawTrace = Array(); + + for (int i = 0; i < trace.count(); i += 1) { + pt::string name = trace.index(i); + pt::string action; + switch (trace.action(name)) { + default: + case tt::Trace::Unknown: action = "unknown"; break; + case tt::Trace::Unexpanded: action = "unexpanded"; break; + case tt::Trace::Kept: action = "kept"; break; + case tt::Trace::Skipped: action = "skipped"; break; + case tt::Trace::Replaced: action = "replaced"; break; + case tt::Trace::Repeated: action = "repeated"; break; + case tt::Trace::Ambiguous: action = "ambiguous"; break; + } + pt::string replacement = trace.replacementText(name); + + rawTrace.send("add", String(name)); + rawTrace.send("add", String(action)); + rawTrace.send("add", String(replacement)); + } + } Return expandPrim(Frame& f, int code) @@ -231,6 +256,7 @@ Argument contextArg (f, "context"); Argument templateArg (f, "template"); Argument partArg (f, "part"); + Argument traceArg (f, "trace"); if (contextArg.error()) return contextArg; @@ -256,13 +282,14 @@ sourceStream->open(); resultStream.open(); - + bool doTrace = traceArg.isBool() && traceArg.asBool(); pt::string errors; try { tt::Template t(*sourceStream, resultStream); t.declareNamespace("tt", true); + if (doTrace) t.enableTrace(); Local contexts(f); contexts = Array(); @@ -275,6 +302,12 @@ else t.expand(ctx); } + + if (doTrace) { + Local rawTrace(f); + buildRawTrace(t.trace(), rawTrace); + return rawTrace; + } } catch (const char* s) { errors += s; } catch (const pt::string& s) { errors += s; } |
From: Mark L. <mar...@us...> - 2005-04-07 18:15:22
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23808/root/library Modified Files: render.ws Log Message: first stab at getting trace into Wheat code - doesn't do repeats or nested expansions yet - someone hokey implementation on the C++ side - doesn't handle errors at all Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- render.ws 1 Apr 2005 06:11:35 -0000 1.33 +++ render.ws 7 Apr 2005 18:15:13 -0000 1.34 @@ -4,12 +4,14 @@ Render Library ``) -expand(subject: s, expander: e, request: r, template: t, part: p): { +expand(subject: s, expander: e, request: r, template: t, part: p, trace: tr): { c := #expander.context-for(subject: \\s, expander: \\e, request: \\r) if (~t?) { t := s.template(part: p, request: \\r) } - return #expand-prim(context: c, template: \\t, part: p) + r := #expand-prim(context: c, template: \\t, part: p, trace: tr) + if (tr) { return #expand-trace.from-raw(r) } + return r } expand-prim: {:'/library/base/primitive':} @@ -169,6 +171,51 @@ } } +expand-trace: { + -- instance -- + map: ??? + -- public -- + action-type: { :'/library/base/enum': + values: ["unknown", "unexpanded", + "kept", "skipped", "replaced", + "repeated" + ] + } + + action(name): { + if (#map.has(name)) { + return #map[name].action + } + else { + return #action-type.new("unknown") + } + } + + replacement(name): { return #map[name].replacement } + + from-raw(raw-trace): { + t := #new() + t.map := $/library/base/table.new() + + i := 0; + while (i < raw-trace.size) { + name := raw-trace[i] + action := #action-type.new(raw-trace[i+1]) + replacement := raw-trace[i+2] + + if (action.matches("repeat")) { + replacement := #from-raw(replacement) + } + + t.map[name] := { action: action; replacement: replacement } + + i += 3 + } + + return t + } +} + request: { -- instance -- in-cookies: ??? @@ -850,4 +897,43 @@ #assert-equals("text/css", v.contents().'simple.css'.render().mime-type); } + +``( + Expander Trace Tests +``) + + -- private -- + trace-template: +""( +<body> + <p tt:name="not-expanded">quark</p> + <p tt:name="do-keep">a secret</p> + <p tt:name="do-skip">a beat</p> + <p tt:name="do-replace-text">one two three</p> +</body> +"") + + trace-expander: {:'/library/render/expander': + tt-not-in-template(): { #replace-text("ha ha") } + tt-do-keep(): { #keep } + tt-do-skip(): { #skip } + tt-do-replace-text(): { #replace-text("123") } + } + + test-expander-trace(): { + trace := $/library/render.expand( + template: \#trace-template, + expander: \#trace-expander, + trace: true) + + #assert-equals("unexpanded",trace.action("not-expanded").value) + #assert-equals("unknown", trace.action("not-in-template").value) + + #assert-equals("kept", trace.action("do-keep").value) + #assert-equals("skipped", trace.action("do-skip").value) + + #assert-equals("replaced", trace.action("do-replace-text").value) + #assert-equals("123", trace.replacement("do-replace-text")) + } + } |
From: Mark L. <mar...@us...> - 2005-04-07 18:13:53
|
Update of /cvsroot/wheat/r1/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23567/util Modified Files: tinytemplate.cpp tinytemplate.h Log Message: added ability to enumerate the trace entries Index: tinytemplate.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/tinytemplate.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- tinytemplate.cpp 6 Apr 2005 06:45:36 -0000 1.17 +++ tinytemplate.cpp 7 Apr 2005 18:13:40 -0000 1.18 @@ -359,6 +359,9 @@ virtual int repeatCount(XMLName tag); virtual Trace& repeatIndex(XMLName tag, int index); + virtual int count(); + virtual pt::string index(int); + void note(const string& tag, Action action); void note(const string& tag, Action action, const string& replacement); @@ -462,6 +465,13 @@ return *r->repeats[i]; } +int +TraceInfo::count() + { return mMap.get_count(); } + +pt::string +TraceInfo::index(int i) + { return mMap.getkey(i); } class Template::impl Index: tinytemplate.h =================================================================== RCS file: /cvsroot/wheat/r1/util/tinytemplate.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- tinytemplate.h 6 Apr 2005 06:45:36 -0000 1.12 +++ tinytemplate.h 7 Apr 2005 18:13:40 -0000 1.13 @@ -180,6 +180,10 @@ virtual Trace& repeatIndex(XMLName tag, int index) = 0; virtual Trace& expansion(XMLName tag) { return repeatIndex(tag, 0); } + + virtual int count() = 0; // number of names in trace + virtual pt::string index(int) = 0; // name at index i (zero based) + protected: Trace(); virtual ~Trace(); |
From: Mark L. <mar...@us...> - 2005-04-06 06:45:46
|
Update of /cvsroot/wheat/r1/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27795/util Modified Files: tinytemplate.cpp tinytemplate.h tinytemplatetest.cpp Log Message: added tracing facility to tinytemplate doesn't support tracing of attribute modifications as these are going to change in the near future and the tracing facility as presented here will suffice once that change occurs Index: tinytemplatetest.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/tinytemplatetest.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- tinytemplatetest.cpp 5 Mar 2005 05:56:46 -0000 1.15 +++ tinytemplatetest.cpp 6 Apr 2005 06:45:36 -0000 1.16 @@ -62,49 +62,78 @@ } } + class SampleTransform { + public: + SampleTransform(const string& source, bool predecltt = true); + + string expand(); + Trace& trace(); + + private: + inmemory mSourceStream; + outmemory mResultStream; + SimpleContext mContext; + Template mTemplate; + }; - static string - transform(const string& source, bool predecltt = true) + SampleTransform::SampleTransform(const string& source, bool predecltt) + : mSourceStream(source), mTemplate(mSourceStream, mResultStream) { - inmemory sourceStream(source); - outmemory resultStream; - sourceStream.open(); - resultStream.open(); - - SimpleContext ctx; - ctx.keep("keep"); - ctx.skip("skip"); + mSourceStream.open(); + mResultStream.open(); + + mContext.keep("keep"); + mContext.skip("skip"); - ctx.replaceText("replace", "Yes, we have no bananas..."); - ctx.replaceText("htmlize", "if x < y & x > y the \"equal\""); - ctx.replaceText("empty", ""); + mContext.replaceText("replace", "Yes, we have no bananas..."); + mContext.replaceText("htmlize", "if x < y & x > y the \"equal\""); + mContext.replaceText("empty", ""); + mContext.replaceText("neverused", "moo"); - ctx.attribute("anchor", "href", "boat.html"); - ctx.replaceText("anchor", "Boat"); + mContext.attribute("anchor", "href", "boat.html"); + mContext.replaceText("anchor", "Boat"); - ctx.attribute("acid", "href", "rain.html"); + mContext.attribute("acid", "href", "rain.html"); - ctx.attribute("whereami", "href", "/down/by/the/bay/", AttrPrefix); + mContext.attribute("whereami", "href", "/down/by/the/bay/", AttrPrefix); - ctx.attribute("image", "src", "smile.png"); - ctx.attribute("image", "lowsrc", "", AttrSkip); - ctx.attribute("image", "width", "40"); - ctx.attribute("image", "height", "30"); - ctx.attribute("image", "alt", "Smile!"); + mContext.attribute("image", "src", "smile.png"); + mContext.attribute("image", "lowsrc", "", AttrSkip); + mContext.attribute("image", "width", "40"); + mContext.attribute("image", "height", "30"); + mContext.attribute("image", "alt", "Smile!"); - expandNTimes(ctx, "multi-0", 0); - expandNTimes(ctx, "multi-1", 1); - expandNTimes(ctx, "multi-3", 3); - expandNTimes(ctx, "multi-20", 20); + expandNTimes(mContext, "multi-0", 0); + expandNTimes(mContext, "multi-1", 1); + expandNTimes(mContext, "multi-3", 3); + expandNTimes(mContext, "multi-20", 20); - expandNTimes(ctx, "ttt-x", 3); - expandNTimes(ctx, "ttt-y", 3); + expandNTimes(mContext, "ttt-x", 3); + expandNTimes(mContext, "ttt-y", 3); + + if (predecltt) mTemplate.declareNamespace("tt", true); + } - Template t(sourceStream, resultStream); - if (predecltt) t.declareNamespace("tt", true); - t.expand(ctx); + string + SampleTransform::expand() + { + mTemplate.expand(mContext); + return mResultStream.get_strdata(); + } - return resultStream.get_strdata(); + Trace& + SampleTransform::trace() + { + mTemplate.enableTrace(); + mTemplate.expand(mContext); + return mTemplate.trace(); + } + + string + transform(const string& source, bool predecltt = true) + { + SampleTransform s(source, predecltt); + return s.expand(); } }; @@ -731,4 +760,47 @@ ); } +TEST(template, traceSimple) +{ + SampleTransform s( + "<body>" + "<p tt:name='keep'>yes</p>" + "<p tt:name='skip'>no</p>" + "<p tt:name='whatever'>yo</p>" + "<p tt:name='replace'>stuff</p>" + "<p tt:name='htmlize'>garage</p>" + "<p tt:name='empty'>full</p>" + "<p tt:name='multi-3'>number <tt:span name='count'>x</tt:span></p>" + "</body>" + ); + + Trace& t = s.trace(); + + CHECK_SAME(Trace::Unknown, t.action("neverused")); + CHECK_SAME(Trace::Unexpanded, t.action("whatever")); + CHECK_SAME(Trace::Skipped, t.action("skip")); + CHECK_SAME(Trace::Kept, t.action("keep")); + + CHECK_SAME(Trace::Replaced, t.action("replace")); + CHECK_SAME("Yes, we have no bananas...", t.replacementText("replace")); + + CHECK_SAME(Trace::Replaced, t.action("htmlize")); + CHECK_SAME("if x < y & x > y the "equal"", + t.replacementText("htmlize")); + + CHECK_SAME(Trace::Replaced, t.action("empty")); + CHECK_SAME("", t.replacementText("empty")); + + CHECK_SAME(Trace::Repeated, t.action("multi-3")); + CHECK_SAME(3, t.repeatCount("multi-3")); + + static const char *const names[] = { "one", "two", "three" }; + for (int i = 0; i < 3; ++i) { + Trace& sub = t.repeatIndex("multi-3", i); + CHECK_SAME(Trace::Replaced, sub.action("count")); + CHECK_SAME(names[i], sub.replacementText("count")); + } + + CHECK_SAME(Trace::Unknown, t.action("count")); +} Index: tinytemplate.h =================================================================== RCS file: /cvsroot/wheat/r1/util/tinytemplate.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- tinytemplate.h 5 Mar 2005 05:56:46 -0000 1.11 +++ tinytemplate.h 6 Apr 2005 06:45:36 -0000 1.12 @@ -47,6 +47,7 @@ class Context; + class Trace; class Template { public: @@ -57,6 +58,9 @@ void expand(Context& ctx, XMLName partName = 0); + void enableTrace(); // call before expand() + Trace& trace(); // call after expand() + public: class impl; private: @@ -157,5 +161,28 @@ pt::tstrlist<Instruction> imap; }; -} + class Trace { + // a trace of what happened during expansion + public: + enum Action { + Unknown, // name never used in template + Unexpanded, // name not expanded by contexts + Kept, // expanded with keep(true) or skip(false) + Skipped, // expanded with keep(false) or skip(true) + Replaced, // expanded with replaceText() or replaceContent() + Repeated, // expanded with repeat() and repeatAddContext() + Ambiguous // name expanded more than once, with different results + }; + + virtual Action action(XMLName tag) = 0; + virtual pt::string replacementText(XMLName tag) = 0; //for Prefixed too + virtual int repeatCount(XMLName tag) = 0; + virtual Trace& repeatIndex(XMLName tag, int index) = 0; + virtual Trace& expansion(XMLName tag) + { return repeatIndex(tag, 0); } + protected: + Trace(); + virtual ~Trace(); + }; +} Index: tinytemplate.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/tinytemplate.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- tinytemplate.cpp 5 Mar 2005 05:56:45 -0000 1.16 +++ tinytemplate.cpp 6 Apr 2005 06:45:36 -0000 1.17 @@ -344,6 +344,124 @@ }; +Trace::Trace() { } +Trace::~Trace() { } + + +class TraceInfo : public Trace +{ +public: + TraceInfo(); + ~TraceInfo(); + + virtual Action action(XMLName tag); + virtual pt::string replacementText(XMLName tag); + virtual int repeatCount(XMLName tag); + virtual Trace& repeatIndex(XMLName tag, int index); + + void note(const string& tag, Action action); + void note(const string& tag, Action action, const string& replacement); + + TraceInfo* addRepeat(const string& tag); + +private: + void note(const string& tag, Action action, const string* replacement); + + class TraceList : public tobjlist<TraceInfo> { + public: + TraceList() : tobjlist<TraceInfo>(true) { } + }; + + struct Record { + Action action; + pt::string replacement; + TraceList repeats; + }; + + class RecordMap : public tstrlist<Record> { + public: + RecordMap() + : tstrlist<Record>(SL_SORTED | SL_CASESENS | SL_OWNOBJECTS) + { } + }; + + RecordMap mMap; +}; + +TraceInfo::TraceInfo() { } +TraceInfo::~TraceInfo() { } + +void +TraceInfo::note(const string& tag, Action action) + { note(tag, action, ""); } + +void +TraceInfo::note(const string& tag, Action action, const string& replacement) + { note(tag, action, &replacement); } + +void +TraceInfo::note(const string& tag, Action action, const string* replacement) +{ + Record* r = mMap[tag]; + if (r) { + if (r->action != action + || r->replacement != *replacement) + { + r->action = Ambiguous; + } + } + else { + r = new Record; + r->action = action; + r->replacement = *replacement; + mMap.add(tag, r); + } +} + +TraceInfo* +TraceInfo::addRepeat(const string& tag) +{ + Record* r = mMap[tag]; + if (!r) throw "illegal call to addRepeat called"; + + TraceInfo* t = new TraceInfo; + r->repeats.add(t); + return t; +} + + + +Trace::Action +TraceInfo::action(XMLName tag) +{ + Record* r = mMap[tag]; + return r ? r->action : Unknown; +} + +pt::string +TraceInfo::replacementText(XMLName tag) +{ + Record* r = mMap[tag]; + return r ? r->replacement : ""; +} + +int +TraceInfo::repeatCount(XMLName tag) +{ + Record* r = mMap[tag]; + return r ? r->repeats.get_count() : 0; +} + +Trace& +TraceInfo::repeatIndex(XMLName tag, int i) +{ + Record* r = mMap[tag]; + if (!r) throw "not repeated"; + if (i < 0 || i >= r->repeats.get_count()) throw "bad index"; + + return *r->repeats[i]; +} + class Template::impl @@ -370,6 +488,10 @@ tobjlist<Context> contextStack; int blockStart; // index of fragment that is at start of current block // -1 = not in a block + // tracing + bool tracing; + TraceInfo traceInfo; + TraceInfo* currentTraceInfo; public: impl(Template& own, instm& in, outstm& out); @@ -389,8 +511,29 @@ void parse(); void declareNamespace(const XML_Char* prefix, bool isTinyTemplate); -}; + + void enableTrace() { tracing = true; } + Trace& trace() { return traceInfo; } +protected: + void noteTrace(const string& tag, Trace::Action action) + { if (tracing) currentTraceInfo->note(tag, action); } + + void noteTrace(const string& tag, Trace::Action action, + const string& replacement) + { if (tracing) currentTraceInfo->note(tag, action, replacement); } + + class TraceRepeat { + public: + TraceRepeat(impl&, const string& tag); + ~TraceRepeat(); + private: + impl& mImpl; + TraceInfo* mOriginalInfo; + }; + + friend class TraceRepeat; +}; @@ -423,26 +566,35 @@ ins = lookupInContext(f.name); if (ins.m->none) { // no instruction, so just keep fragment + noteTrace(f.name, Trace::Unexpanded); } else if (!ins.m->keep) { + noteTrace(f.name, Trace::Skipped); fragmentSkipping = true; fragmentSkipUntil = fragmentNest; } else if (ins.m->repeat) { + noteTrace(f.name, Trace::Repeated); int oldBlockStart = blockStart; blockStart = pos; int rlen = ins.m->repeatContexts.get_count(); - for (int i = 0; i < rlen; ++i) + for (int i = 0; i < rlen; ++i) { + TraceRepeat tracer(*this, f.name); owner.expand(*ins.m->repeatContexts[i]); + } blockStart = oldBlockStart; fragmentSkipping = true; fragmentSkipUntil = fragmentNest; } else if (ins.m->replace) { + noteTrace(f.name, Trace::Replaced, ins.m->replacement); addedContent = true; } + else { + noteTrace(f.name, Trace::Kept); + } } fragmentNest += 1; if (!fragmentSkipping) { @@ -803,7 +955,9 @@ Template::impl::impl(Template& own, instm& in, outstm& out) - : owner(own), input(in), output(out), namespaceStack(true), fragments(true), contextStack(false) + : owner(own), input(in), output(out), + namespaceStack(true), fragments(true), contextStack(false), + tracing(false) { parser = XML_ParserCreate(NULL); @@ -820,6 +974,8 @@ fragmentSkipping = false; blockStart = -1; + + currentTraceInfo = &traceInfo; } Template::impl::~impl() @@ -828,7 +984,22 @@ } +Template::impl::TraceRepeat::TraceRepeat( + Template::impl& impl, const string& tag) + : mImpl(impl) +{ + if (mImpl.tracing) { + mOriginalInfo = mImpl.currentTraceInfo; + mImpl.currentTraceInfo = mOriginalInfo->addRepeat(tag); + } +} +Template::impl::TraceRepeat::~TraceRepeat() +{ + if (mImpl.tracing) { + mImpl.currentTraceInfo = mOriginalInfo; + } +} @@ -851,6 +1022,8 @@ m.skipToPart(partName); m.expand(ctx); } - + +void Template::enableTrace() { m.enableTrace(); } +Trace& Template::trace() { return m.trace(); } } |
From: Jim K. <ki...@us...> - 2005-04-03 07:48:16
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2387/wheat Modified Files: baselibrary.cpp Log Message: Get rid of the strange reader interface to iterating over characters of a string. Instead, just provide a function which returns the characters as an array of strings. Index: baselibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/baselibrary.cpp,v retrieving revision 1.107 retrieving revision 1.108 diff -u -d -r1.107 -r1.108 --- baselibrary.cpp 2 Apr 2005 17:32:01 -0000 1.107 +++ baselibrary.cpp 3 Apr 2005 07:48:01 -0000 1.108 @@ -533,39 +533,40 @@ } Return - stringReaderRead(Frame& f, int code) + stringCharacters(Frame& f, int code) { Self self(f); - Local string(f); - string = self.send("string"); + Local characters(f); + characters = Array(); - pt::string contents = self.send("string").asString(); - int position = self.send("position").asInt(); + pt::string contents = self.asString(); + int byteCount = pt::length(contents); + int position = 0; - if (position == pt::length(contents)) { - return Return(f, Null()); - } + while (position < byteCount) { + const unsigned char* byte1p = pt::copy(contents, position, 1); + unsigned char ch = *byte1p; - const unsigned char* byte1p = pt::copy(contents, position, 1); - unsigned char ch = *byte1p; + int len; + if (ch <= 0x7f) { + len = 1; + } else if (ch >= 0xc2 && ch <= 0xdf) { + len = 2; + } else if (ch >= 0xe0 && ch <= 0xef) { + len = 3; + } else if (ch >= 0xf0 && ch <= 0xf7) { + len = 4; + } else { + return Return(f, Error("Bad UTF-8 sequence")); + } - int len; - if (ch <= 0x7f) { - len = 1; - } else if (ch >= 0xc2 && ch <= 0xdf) { - len = 2; - } else if (ch >= 0xe0 && ch <= 0xef) { - len = 3; - } else if (ch >= 0xf0 && ch <= 0xf7) { - len = 4; - } else { - return Return(f, Error("Bad UTF-8 sequence")); - } + characters.send("add", String(pt::copy(contents, position, len))); - self.assign("position", Int(position + len)); + position += len; + } - return Return(f, String(pt::copy(contents, position, len))); + return characters; } Return @@ -1186,7 +1187,7 @@ { "string/==", stringEquals, 0 }, { "string/contains", stringContains, 0 }, { "string/match-against", stringMatchAgainst, 0 }, - { "string/reader/read", stringReaderRead, 0 }, + { "string/characters", stringCharacters, 0 }, { "string/starts-with", stringStartsWith, 0 }, { "string/ends-with", stringEndsWith, 0 }, { "string/split", stringSplit, 0 }, |
From: Jim K. <ki...@us...> - 2005-04-03 07:48:13
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2387/root/library Modified Files: base.ws Log Message: Get rid of the strange reader interface to iterating over characters of a string. Instead, just provide a function which returns the characters as an array of strings. Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- base.ws 2 Apr 2005 17:32:00 -0000 1.56 +++ base.ws 3 Apr 2005 07:48:00 -0000 1.57 @@ -206,51 +206,15 @@ as-path: {:'/library/base/primitive':} md5: {:'/library/base/primitive':} - - `` This is the current interface for iterating through each character - `` of a string. The idea behind the stream-like interface is that - `` this operation is like reading a file or streaming an HTTP download - `` (without doing something like constructing an array/string in memory). - `` However, I don't really think I have it right. - `` Right now the string which one calls open on must live until - `` the close call. For example: - - `` reader := "foo".open(); - `` reader.read(); `` WRONG: "foo" no longer exists - - `` string := "foo"; - `` reader := string.open(); - `` reader.read(); `` OK: string is still alive - - `` Furthermore, the VM doesn't detect this kind of bug; it just - `` looks for the string in whatever register it had been in, - `` which by now has been reused. - - reader: { - -- public -- - read: {:'/library/base/primitive':} - close(): { } - -- rw----c- -- - string: ??? - position: 0 - } - + ``( Low level string manipulation - turn a string into an + array of characters. array/join can perform the reverse. ``) + characters: {:'/library/base/primitive':} ``( Return the number of characters in the string (not named size or length to avoid any possible confusion with the number of bytes in the string). ``) - characters(): { - i := 0; - reader := #open(); - while (reader.read() != null) { - i += 1; - } - reader.close(); - return i; - } - - open(): { - return { :'/library/base/string/reader': string: \self }; + character-count(): { + return #characters().size; } } @@ -756,33 +720,34 @@ } } - test-string-characters(): { - #assert-equals(0, "".characters()); - #assert-equals(5, "ASCII".characters()); + test-string-character-count(): { + #assert-equals(0, "".character-count()); + #assert-equals(5, "ASCII".character-count()); `` The middle character is 2 bytes in UTF-8 - #assert-equals(3, "eÄ¥o".characters()); + #assert-equals(3, "eÄ¥o".character-count()); `` U+0905 DEVANAGARI LETTER A (3 bytes in UTF-8) - #assert-equals(1, "ठ".characters()); + #assert-equals(1, "ठ".character-count()); `` U+10463 SHAVIAN LETTER HA-HA (4 bytes in UTF-8) - #assert-equals(1, "ð£".characters()); + #assert-equals(1, "ð£".character-count()); } - test-string-reader(): { + test-string-characters(): { string := "eÄ¥oÅanÄo"; - reader := string.open(); - #assert-equals("e", reader.read()); - #assert-equals("Ä¥", reader.read()); - #assert-equals("o", reader.read()); - #assert-equals("Å", reader.read()); - #assert-equals("a", reader.read()); - #assert-equals("n", reader.read()); - #assert-equals("Ä", reader.read()); - #assert-equals("o", reader.read()); - #assert-equals(null, reader.read()); - reader.close(); + characters := string.characters(); + #assert-equals("/library/base/array", + characters.prototype().as-string); + #assert-equals(8, characters.size()); + #assert-equals("e", characters[0]); + #assert-equals("Ä¥", characters[1]); + #assert-equals("o", characters[2]); + #assert-equals("Å", characters[3]); + #assert-equals("a", characters[4]); + #assert-equals("n", characters[5]); + #assert-equals("Ä", characters[6]); + #assert-equals("o", characters[7]); } test-split(): { |
From: Jim K. <ki...@us...> - 2005-04-03 07:45:55
|
Update of /cvsroot/wheat/r1/root/applications/farm.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2285 Added Files: trace.html Log Message: Very preliminary step towards a trace page. --- NEW FILE: trace.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tt="http://tinytemplate.org/ns/tt" > <head> <title>WheatFarm Trace</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link tt:name="root-based-href" href="r/farm.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="banner"> <h1><span class="suffix">Wheat</span>Farm</h1> <ul class="location" tt:name="object-path"> <li tt:example=""><a href="/"> / </a></li> <li tt:name="segment"><a href="/da-apps" tt:name="url-path-href"><tt:span name="name">da-apps</tt:span> / </a></li> <li tt:example=""><a href="/da-apps/kollective">kollective /</a></li> </ul> </div> <div class="main"> <div class="content"> <p tt:name="reason">library/base/tests/error-traceback(argument)</p> <p tt:name="generated-event">generated by generate-error-feh</p> <p tt:name="returned-event">returned to generate-error-inner</p> <p tt:example="" tt:name="returned-event">returned to generate-error-trace</p> </div> </div> </body> </html> |
From: Jim K. <ki...@us...> - 2005-04-03 07:45:27
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2217 Modified Files: farm.ws Log Message: Fix a few comments and make compilation-states not -- instance --. Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- farm.ws 30 Mar 2005 07:23:03 -0000 1.62 +++ farm.ws 3 Apr 2005 07:45:18 -0000 1.63 @@ -94,18 +94,23 @@ -- public -- project: { - -- instance -- - source: ??? ``path to source file - target: ??? ``path to where the compiled module goes - + -- public -- compilation-states: { :'/library/base/enum': values: ["never", "compile-error-location", "compile-error-nolocation", "test-results"] } - `` How to invoke .new()? Kind of an instantiator question (if that is how people - `` are creating projects). + + -- instance -- + source: ??? ``path to source file + target: ??? ``path to where the compiled module goes + + ``( Need to say raw-value here because the new semantics which + make this a call to value := "never" only apply for dynamic + objects, not static ones (should go away when dynamic/static + are unified). + ``) compilation-state: { :'/applications/farm/project/compilation-states': raw-value: "never" } |
From: Mark L. <mar...@us...> - 2005-04-02 17:32:11
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22777/wheat Modified Files: baselibrary.cpp Log Message: added three math unary operations: absolute, floor and ceiling factored out the code that returned numeric results Index: baselibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/baselibrary.cpp,v retrieving revision 1.106 retrieving revision 1.107 diff -u -d -r1.106 -r1.107 --- baselibrary.cpp 24 Mar 2005 21:54:39 -0000 1.106 +++ baselibrary.cpp 2 Apr 2005 17:32:01 -0000 1.107 @@ -861,12 +861,21 @@ } } + Return + returnNumber(Frame& f, double a) + { + if (a == floor(a) && INT_MIN <= a && a <= INT_MAX) + return Return(f, Int((int)a)); + else + return Return(f, Double(a)); + } + enum { mathAdd, mathSubtract, mathMultiply, mathDivide }; Return - numberMath(Frame& f, int code) + numberMathBinary(Frame& f, int code) { Self self(f); Argument arg(f); @@ -881,10 +890,7 @@ case mathDivide: a /= b; break; } - if (a == floor(a) && INT_MIN <= a && a <= INT_MAX) - return Return(f, Int((int)a)); - else - return Return(f, Double(a)); + return returnNumber(f, a); } enum { @@ -933,6 +939,26 @@ return Return(f, Int(v)); } + enum { + mathAbsolute, mathFloor, mathCeiling + }; + + Return + numberMathUnary(Frame& f, int code) + { + Self self(f); + + double a = self.asDouble(); + + switch (code) { + case mathAbsolute: a = fabs(a); break; + case mathFloor: a = floor(a); break; + case mathCeiling: a = ceil(a); break; + } + + return returnNumber(f, a); + } + Return dateToday(Frame& f, int code) { @@ -1187,10 +1213,10 @@ { "number/is-string", returnTrue, 0 }, { "number/as-string", numberAsString, 0 }, - { "number/+", numberMath, mathAdd }, - { "number/-", numberMath, mathSubtract }, - { "number/*", numberMath, mathMultiply }, - { "number/%2f", numberMath, mathDivide }, + { "number/+", numberMathBinary, mathAdd }, + { "number/-", numberMathBinary, mathSubtract }, + { "number/*", numberMathBinary, mathMultiply }, + { "number/%2f", numberMathBinary, mathDivide }, { "number/<", numberCompare, compareLT }, { "number/<=", numberCompare, compareLE }, { "number/==", numberCompare, compareEQ }, @@ -1198,6 +1224,9 @@ { "number/>=", numberCompare, compareGE }, { "number/>", numberCompare, compareGT }, { "number/<=>", numberCompare2, 0 }, + { "number/absolute", numberMathUnary, mathAbsolute }, + { "number/floor", numberMathUnary, mathFloor }, + { "number/ceiling", numberMathUnary, mathCeiling }, { "date/today", dateToday, 0 }, |
From: Mark L. <mar...@us...> - 2005-04-02 17:32:09
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22777/root/library Modified Files: base.ws Log Message: added three math unary operations: absolute, floor and ceiling factored out the code that returned numeric results Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- base.ws 24 Mar 2005 21:54:39 -0000 1.55 +++ base.ws 2 Apr 2005 17:32:00 -0000 1.56 @@ -175,6 +175,9 @@ '>=': {:'/library/base/primitive':} '>': {:'/library/base/primitive':} '<=>': {:'/library/base/primitive':} + absolute: {:'/library/base/primitive':} + floor: {:'/library/base/primitive':} + ceiling: {:'/library/base/primitive':} } byte-array: { |
From: Mark L. <mar...@us...> - 2005-04-02 06:36:00
|
Update of /cvsroot/wheat/r1/web-dev/source/cardfile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6716/web-dev/source/cardfile Modified Files: card.html cardfile.ws stack.html Log Message: cardfile objects now start off with two stacks beginnings of rendering for cardfile and stack objects cardfile is now instantiable -- thanks Donovan Preston for pairing! Index: cardfile.ws =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/cardfile/cardfile.ws,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cardfile.ws 27 Mar 2005 21:35:29 -0000 1.1 +++ cardfile.ws 2 Apr 2005 06:35:35 -0000 1.2 @@ -6,12 +6,34 @@ stacks: [ ] -- public -- + new(): { + object := { :self: } + object.stacks := [] + object.add-stack("stuff") + object.add-stack("morgue") + object.stacks.first.new-table-card(at:0).title := "change me" + return object + } add-stack(title): { s := $../stack.new(); s.title := title; #stacks.add(s); + return \#stacks.last } stack-count(): { return #stacks.size() } + render(request: r): { + return $/library/render.redirect(\#stacks[0], request: \r); + } + expander: {:'/library/render/expander': + tt-stack(): { + #start-repeat() + i := 0 + while (i < #subject.stacks.size) { + #expand(subject: \#subject.stacks[i]) + i += 1 + } + } + } } stack: { @@ -61,6 +83,8 @@ return c } + containing-file(): { return \#container.container } + table-map(): { `` mostly for testing a := [ ] i := 0 @@ -85,6 +109,57 @@ } return a } + + template: -> '/source/cardfile/stack.html' + expander: {:'/library/render/expander': + tt-root-based-attr(attr): { + #attribute(attr, prefix: "/source/cardfile/") + } + tt-root-based-href(): { #tt-root-based-attr("href") } + tt-root-based-src(): { #tt-root-based-attr("src") } + + tt-url(): { + #attribute("href", + $/library/render.url(\#subject, request:\#request)) + } + tt-title(): { + return #subject.title; + } + tt-stacks(): { + #expand(subject: \#subject.containing-file) + } + + tt-table-row(): { + #start-repeat() + num-rows := #subject.table.size / 3 + i := 0 + while (i < num-rows) { + #expand(expand: {<:'/library/render/expander': + row: i + stack: \#subject + tt-table-card(): { + #start-repeat() + j := 0 + while (j < 3) { + k := #row * 3 + j; + if (#stack.table[k]?) { + #expand(subject: \#stack.table[k]) + } + else { + + } + j += 1 + } + } + }) + i += 1; + } + } + + tt-table-card(): { + + } + } } card: { @@ -108,22 +183,27 @@ test-stack-basics(): { cf := $../cardfile.new() - #assert-equals(0, cf.stack-count) - - cf.add-stack("now") - #assert-equals(1, cf.stack-count) - #assert-equals("now", cf.stacks[0].title) - - cf.add-stack("later") #assert-equals(2, cf.stack-count) - #assert-equals("later", cf.stacks[1].title) + #assert-equals("stuff", cf.stacks[0].title) + #assert-equals("morgue", cf.stacks[1].title) + #assert-equals("change me", cf.stacks[0].table[0].title) + + now := \cf.add-stack("now") + #assert-equals(3, cf.stack-count) + #assert-equals("now", now.title) + + later := \cf.add-stack("later") + #assert-equals(4, cf.stack-count) + #assert-equals("later", later.title) + + #assert-equals(cf.absolute-path(), + now.containing-file.absolute-path()) } test-card-basics(): { cf := $../cardfile.new() - cf.add-stack("now") + st := \cf.add-stack("now") - st := \cf.stacks[0] #assert-array([], st.pile-map) #assert-array([], st.table-map) @@ -139,9 +219,8 @@ test-table-movement(): { cf := $../cardfile.new() - cf.add-stack("now") + st := \cf.add-stack("now") - st := \cf.stacks[0] st.new-table-card(at: 2).title := "a" #assert-array([2, "a"], st.table-map) st.move-table-card(from: 2, to: 0) @@ -198,20 +277,69 @@ st.to-table(at: 1, card: st.from-pile(at: 0)) #assert-array([0, "c", 1, "b", 2, "a"], st.table-map) #assert-array([ ], st.pile-map) - } + } + + -- private -- + setup(): { + cf := $../cardfile.new() + cf.add-stack("now") + cf.add-stack("later") + + st0 := \cf.stacks[0] + st0.new-table-card(at: 0).title := "a" + st0.new-table-card(at: 1).title := "b" + st0.new-table-card(at: 2).title := "c" + + l := [ "d", "e", "f", "g" ] + i := 0 + while (i < l.size) { + st0.new-table-card(at: 3).title := l[i] + st0.to-pile(card: st0.from-table(at: 3)) + i += 1 + } + + st1 := \cf.stacks[1] + st1.new-table-card(at: 1).title := "z" + st1.new-table-card(at: 4).title := "y" + st1.new-table-card(at: 6).title := "x" + + return cf; + } + + sample-request(): { + return $/library/render.tests.sample-request; + } + + render(node): { + return node.render(request: #sample-request); + } + -- public -- + test-stack-render(): { + cf := #setup() + #assert-equals(4, cf.stacks.size) + + html := #render(\cf.stacks[0]) + #assert-contains(">stuff</a>", html) + #assert-contains("/stacks/0", html) + #assert-contains(">morgue</a>", html) + #assert-contains("/stacks/1", html) + #assert-contains(">now</a>", html) + #assert-contains("/stacks/2", html) + #assert-contains(">later</a>", html) + #assert-contains("/stacks/3", html) + } + ``( things that are rendered cardfile tt-title (trivial) cardfile tt-stack (in proper order) cardfile tt-stack-id - cardfile tt-stack-title - cardfile tt-stack-url + stack tt-stacks (list of stacks) stack tt-title (trivial) stack tt-url (trivial) - stack tt-list-card (in proper order) stack tt-table-row (in proper order, proper number) stack tt-table-card (proper card or place) stack tt-table-card-id @@ -219,6 +347,8 @@ stack tt-table-card-delete-url stack tt-table-place-add-url stack tt-table-place-name + + stack tt-list-card (in proper order) stack tt-list-row stack tt-list-row-even stack tt-list-row-odd @@ -260,3 +390,6 @@ ``) } +instantiables: [ + -> '/applications/cardfile/cardfile' +] Index: card.html =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/cardfile/card.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- card.html 27 Mar 2005 21:35:29 -0000 1.1 +++ card.html 2 Apr 2005 06:35:35 -0000 1.2 @@ -6,7 +6,7 @@ <meta http-equiv="content-type" content="text/html;charset=utf8" /> <title>Card File</title> <link tt:name="root-based-href" rel="stylesheet" type="text/css" href="card.css" /> -<script type="text/javascript" src="card.js"> +<script tt:name="root-based-src" type="text/javascript" src="card.js"> </script> </head> <body id="cardPage"> Index: stack.html =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/cardfile/stack.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- stack.html 27 Mar 2005 21:35:29 -0000 1.1 +++ stack.html 2 Apr 2005 06:35:35 -0000 1.2 @@ -6,7 +6,7 @@ <meta http-equiv="content-type" content="text/html;charset=utf8" /> <title>Card File</title> <link tt:name="root-based-href" rel="stylesheet" type="text/css" href="card.css" /> -<script type="text/javascript" src="card.js"> +<script tt:name="root-based-src" type="text/javascript" src="card.js"> </script> </head> <body id="stackPage"> @@ -16,8 +16,8 @@ <div id="main"> <div id="content"> <table id="table"> - <tr> - <td><div class="place" id="placeA"> + <tr tt:name="table-row"> + <td td:name="table-card"><div class="place" id="placeA"> <p>ⓐ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeA" title="add new card">+</a></li> @@ -158,13 +158,13 @@ </div> <div id="panel"> <p><b>Stacks</b></p> - <ul id="stacks"> - <li id="stackA"><a href="stackA">do now</a></li> - <li id="stackB"><a href="stackB">later</a></li> - <li id="stackC"><a href="stackC">much later</a></li> - <li id="stackD"><a href="stackD">never</a></li> - <li id="stackE" class="selected"><a href="stackE">frank's</a></li> - <li id="stackF"><a href="stackF">morgue</a></li> + <ul tt:name="stacks" id="stacks"> + <li tt:name="stack" id="stackA"><a href="stackA" tt:name="url"><tt:span name="title">do now</tt:span></a></li> + <li tt:example="stack" id="stackB"><a href="stackB">later</a></li> + <li tt:example="stack" id="stackC"><a href="stackC">much later</a></li> + <li tt:example="stack" id="stackD"><a href="stackD">never</a></li> + <li tt:example="stack" id="stackE" class="selected"><a href="stackE">frank's</a></li> + <li tt:example="stack" id="stackF"><a href="stackF">morgue</a></li> </ul> <p>❖</p> <form tt:name="blog-action" action="login" method="post"> @@ -186,7 +186,7 @@ </div> </div> <div id="smallcard"> -<img src="card-image.png" alt="card" /> +<img tt:name="root-based-src" src="card-image.png" alt="card" /> </div> </body> </html> |
From: Jim K. <ki...@us...> - 2005-04-01 06:41:12
|
Update of /cvsroot/wheat/r1/root/applications/farm.d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29223/root/applications/farm.d Modified Files: view.html Log Message: Add breadcrumb to view page too. Index: view.html =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.d/view.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- view.html 19 Mar 2005 08:58:55 -0000 1.4 +++ view.html 1 Apr 2005 06:41:04 -0000 1.5 @@ -10,6 +10,11 @@ <body> <div class="banner"> <h1><span class="suffix">Wheat</span>Farm</h1> +<ul class="location" tt:name="object-path"> + <li tt:example=""><a href="/"> / </a></li> + <li tt:name="segment"><a href="/da-apps" tt:name="url-path-href"><tt:span name="name">da-apps</tt:span> / </a></li> + <li tt:example=""><a href="/da-apps/kollective">kollective /</a></li> +</ul> </div> <pre> <tt:span name="listing"><tt:span name="plain-text">five: 5; |
From: Mark L. <mar...@us...> - 2005-04-01 06:11:46
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14535/root/library Modified Files: render.ws Log Message: factored out context-for for the crazy subject/expander dance that was in both Wheat code and in C++ -- and because this is the thing that is going to change in the near future! moved some of the expand() code into Wheat, simplifying the C++ primitive fixed a long standing inefficiency with the expand primitive that never cleared out old contexts or reused slots in the context array Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- render.ws 18 Mar 2005 07:18:50 -0000 1.32 +++ render.ws 1 Apr 2005 06:11:35 -0000 1.33 @@ -3,8 +3,16 @@ ``( Render Library ``) - -expand: {:'/library/base/primitive':} + +expand(subject: s, expander: e, request: r, template: t, part: p): { + c := #expander.context-for(subject: \\s, expander: \\e, request: \\r) + if (~t?) { + t := s.template(part: p, request: \\r) + } + return #expand-prim(context: c, template: \\t, part: p) +} + +expand-prim: {:'/library/base/primitive':} instructions: { @@ -63,6 +71,21 @@ new(subject: s, request: r): { return {:self: subject: \\s; request: \\r; }; } + context-for(subject: s, expander: e, request: r): { + if (~e?) { + if (~s.expander!) { + e := \\s.expander.new(subject: \\s, request: \\r) + } + else { + e := ($.).new(subject: \\s, request: \\r) + } + } + else { + e := e.new(subject: \\s, request: \\r); + } + return e + } + keep(bool): { #instruction := {:'/library/render/instructions/keep': value: bool ?? true; }; @@ -110,10 +133,7 @@ }; } - if (??? != s && ??? == e) { - e := \s.expander; - } - e := e.new(subject: \\s, request: \\#request); + e := #context-for(subject: \\s, expander: \\e, request: \\#request); #instruction.contexts.add(e); } |
From: Mark L. <mar...@us...> - 2005-04-01 06:11:45
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14535/wheat Modified Files: renderlibrary.cpp Log Message: factored out context-for for the crazy subject/expander dance that was in both Wheat code and in C++ -- and because this is the thing that is going to change in the near future! moved some of the expand() code into Wheat, simplifying the C++ primitive fixed a long standing inefficiency with the expand primitive that never cleared out old contexts or reused slots in the context array Index: renderlibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/renderlibrary.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- renderlibrary.cpp 5 Mar 2005 05:56:46 -0000 1.6 +++ renderlibrary.cpp 1 Apr 2005 06:11:34 -0000 1.7 @@ -84,8 +84,19 @@ WheatContext::~WheatContext() { - if (mIndex >= 0) - mCtxArray.send("set", Int(mIndex), Unknown()); + if (mIndex >= 0) { + Int indexArg(mIndex); + pt::string assignKey("assign"); + True trueArg; + pt::string valueKey("value"); + Unknown unknownArg; + + mCtxArray.send("[]", + SendArgPos, &indexArg, + SendArgKey, &assignKey, &trueArg, + SendArgKey, &valueKey, &unknownArg, + SendArgEnd); + } } void @@ -94,7 +105,17 @@ int n = mCtxArray.send("size").asInt(); for (int i = 0; i < n; ++i) { if (mCtxArray.send("[]", Int(i)).isUnknown()) { - mCtxArray.send("set", Int(i), ctx); + Int indexArg(i); + pt::string assignKey("assign"); + True trueArg; + pt::string valueKey("value"); + + mCtxArray.send("[]", + SendArgPos, &indexArg, + SendArgKey, &assignKey, &trueArg, + SendArgKey, &valueKey, &ctx, + SendArgEnd); + mIndex = i; return; } @@ -207,27 +228,13 @@ Return expandPrim(Frame& f, int code) { - Argument subjectArg (f, "subject"); - Argument expanderArg (f, "expander"); + Argument contextArg (f, "context"); Argument templateArg (f, "template"); Argument partArg (f, "part"); - Argument requestArg (f, "request"); - if (!subjectArg.isUnknown() && expanderArg.isUnknown()) { - expanderArg = subjectArg.send("expander").asis(); - } - expanderArg = expanderArg.send("new", - "subject", subjectArg.link(), - "request", requestArg.link()); - if (expanderArg.error()) - return expanderArg; + if (contextArg.error()) + return contextArg; - - if (templateArg.isUnknown()) { - templateArg = subjectArg.send("template", - "part", partArg, - "request", requestArg.link()); - } if (templateArg.error()) return templateArg; @@ -260,7 +267,7 @@ Local contexts(f); contexts = Array(); { - WheatContext ctx(f, contexts, errors, expanderArg); + WheatContext ctx(f, contexts, errors, contextArg); // ctx must NOT outlive contexts, so this is in a block if (partArg.isString()) @@ -291,7 +298,7 @@ const PrimitiveDescriptor renderPrims[] = { - { "expand", expandPrim, 0 }, + { "expand-prim", expandPrim, 0 }, { 0, 0, 0 } }; }; |
From: Jim K. <ki...@us...> - 2005-03-30 07:23:13
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7244/root/library Modified Files: buffer.ws wheatunit.ws Log Message: Move rendering code from wheatunit to farm. Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- wheatunit.ws 29 Mar 2005 06:59:32 -0000 1.42 +++ wheatunit.ws 30 Mar 2005 07:23:04 -0000 1.43 @@ -86,24 +86,6 @@ } return message; } - - -- private -- - failure-info-template: "<pre tt:name=\"failure-message\">failed</pre>" - - expander: { :'/library/render/expander': - tt-failure-message(): { return #subject.failure-message; } - } - - -- public -- - failure-info(): { - if (#failure-message?) { - return $/library/render.expand(template: #failure-info-template, - subject: self); - } - else { - return ???; - } - } } test-case: { @@ -256,96 +238,6 @@ return package.tests.run-all(); } -results-template: -""( -<div> -<table> - <tt:span name="results"> - <tr tt:name="passed"> - <td class="pass" - ><tt:span tt:name="name">test-sample-function</tt:span></td> - <td>passed</td> - </tr> - <tr tt:name="failed"> - <td class="failure" - ><tt:span tt:name="name">test-sample-function</tt:span></td> - <td>failed</td> - </tr> - </tt:span> -</table> -<hr /> -<tt:span name="all-passed"> - <span class="pass">Total: <tt:span tt:name="total">-1</tt:span></span> - <span class="pass">Failed: <tt:span tt:name="fails">-1</tt:span></span> -</tt:span> -<tt:span name="some-failed"> - <span class="failure">Total: <tt:span tt:name="total">-1</tt:span></span> - <span class="failure">Failed: <tt:span tt:name="fails">-1</tt:span></span> -</tt:span> -<table> - <tr tt:name="failures"> - <td class="failure" tt:name="name">test-sample-failure</td> - <td tt:name="failure-info"> - <pre>expected something got nothing</pre> - </td> - </tr> -</table> -</div> -"") - -results-expander: {:'/library/render/expander': - -- private -- - result-expander: {:'/library/render/expander': - -- public -- - tt-passed(): { return #subject.passed; } - tt-failed(): { return ~#subject.passed; } - tt-name(): { return #subject.name; } - tt-failure-info(): { #replace-content(#subject.failure-info); } - } - -- public -- - tt-results(): { - #start-repeat(); - i := 0; - while (i < #subject.size) { - #expand(subject: #subject[i], expander: \#result-expander); - i += 1; - } - } - tt-failures(): { - #start-repeat(); - i := 0; - while (i < #subject.size) { - if (~#subject[i].passed) { - #expand(subject: #subject[i], expander: \#result-expander); - } - i += 1; - } - } - tt-all-passed(): { #keep(#tt-fails == 0); } - tt-some-failed(): { #keep(#tt-fails > 0); } - tt-total(): { return #subject.size; } - tt-fails(): { - i := 0; - f := 0; - while (i < #subject.size) { - if (~#subject[i].passed) { - f += 1; - } - i += 1; - } - return f; - } -} - -format-results(results): { - return $/library/render.expand( - subject: results, - template: \#results-template, - expander: \#results-expander - ); -} - - tests: { :test-case: wheatunit: ->'/library/wheatunit' @@ -360,19 +252,19 @@ #assert-equals("test-pass", result.name); #assert-equals(true, result.passed); #assert-equals(false, result.skipped); - #assert-equals(???, result.failure-info); + #assert-equals(???, result.failure-message); result := basics.run-one("test-fail"); #assert-equals("test-fail", result.name); #assert-equals(false, result.passed); #assert-equals(false, result.skipped); - #assert-equals("<pre>expected 7 was 5</pre>", result.failure-info); + #assert-equals("expected 7 was 5", result.failure-message); result := basics.run-one("test-skip"); #assert-equals("test-skip", result.name); #assert-equals(false, result.passed); #assert-equals(true, result.skipped); - #assert-equals("<pre>#skip called</pre>", result.failure-info); + #assert-equals("#skip called", result.failure-message); } -- private -- @@ -448,7 +340,7 @@ #assert-equals("test-pass", results[1].name); #assert-equals(true, results[1].passed); - #assert-equals(???, results[1].failure-info); + #assert-equals(???, results[1].failure-message); } -- private -- @@ -484,7 +376,7 @@ assert-pass(testcase): { result := #one-result(\\testcase); - #assert-equals(???, result.failure-info); + #assert-equals(???, result.failure-message); return #assert-equals(true, result.passed); } @@ -510,12 +402,11 @@ l := result.failure-error.trace-event(2).start-line; #assert-equals(false, result.passed); #assert-equals( - "<pre>warp-drive-failed\n" + + "warp-drive-failed\n" + ... file + ":" + (l + 6) + ": generated by bar()\n" + ... file + ":" + (l + 3) + ": returned to foo()\n" + - ... file + ":" + l + ": returned to test-error()\n" + - ... "</pre>" - ... , result.failure-info()); + ... file + ":" + l + ": returned to test-error()\n" + ... , result.failure-message()); } Index: buffer.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/buffer.ws,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- buffer.ws 28 Feb 2005 07:05:08 -0000 1.3 +++ buffer.ws 30 Mar 2005 07:23:03 -0000 1.4 @@ -1,5 +1,7 @@ wheat(version: 1) +``( String processing class, loosely inspired by an emacs buffer ``) + buffer: { mark: {:'/library/base/primitive':} mark-line-end: {:'/library/base/primitive':} @@ -12,9 +14,6 @@ new(astring): { return { :self: buffer-contents : astring }; } - - `` mark(): primitive; - `` split(): primitive; } tests: { :'/library/wheatunit/test-case': |
From: Jim K. <ki...@us...> - 2005-03-30 07:23:12
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7244/root/applications Modified Files: farm.ws Log Message: Move rendering code from wheatunit to farm. Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- farm.ws 29 Mar 2005 06:59:31 -0000 1.61 +++ farm.ws 30 Mar 2005 07:23:03 -0000 1.62 @@ -323,10 +323,129 @@ run-unit-tests(): { package := \#via-path(#target); results := $/library/wheatunit.run-all-for(\package); - return $/library/wheatunit.format-results(results); + return $/library/render.expand( + subject: results, + template: \#results-template, + expander: \#results-expander + ); } + + -- private -- + results-template: +""( +<div> +<table> + <tt:span name="results"> + <tr tt:name="passed"> + <td class="pass" + ><tt:span tt:name="name">test-sample-function</tt:span></td> + <td>passed</td> + </tr> + <tr tt:name="failed"> + <td class="failure" + ><tt:span tt:name="name">test-sample-function</tt:span></td> + <td>failed</td> + </tr> + </tt:span> +</table> +<hr /> +<tt:span name="all-passed"> + <span class="pass">Total: <tt:span tt:name="total">-1</tt:span></span> + <span class="pass">Failed: <tt:span tt:name="fails">-1</tt:span></span> +</tt:span> +<tt:span name="some-failed"> + <span class="failure">Total: <tt:span tt:name="total">-1</tt:span></span> + <span class="failure">Failed: <tt:span tt:name="fails">-1</tt:span></span> +</tt:span> +<table> + <tr tt:name="failures"> + <td class="failure" tt:name="name">test-sample-failure</td> + <td> + <pre tt:name="nonerror-message">expected 27 got 3</pre> + <pre tt:name="reason-string">not-found(a)</pre> + <pre tt:name="trace-string">at line blah</pre> + </td> + </tr> +</table> +</div> +"") + + results-expander: {:'/library/render/expander': + -- private -- + result-expander: {:'/library/render/expander': + -- public -- + tt-passed(): { return #subject.passed; } + tt-failed(): { return ~#subject.passed; } + tt-name(): { return #subject.name; } + tt-nonerror-message(): { + if (#subject.failure-error?) { + #skip(); + } + else { + #replace-text(#subject.nonerror-message); + } + } + tt-reason-string(): { + if (#subject.failure-error?) { + #replace-text(#subject.failure-error.reason-string()); + } + else { + #skip(); + } + } + tt-trace-string(): { + if (#subject.failure-error?) { + trace := #subject.failure-error.trace-string(); + if (trace.is-empty()) { + #skip(); + } + else { + #replace-text(trace); + } + } + else { + #skip(); + } + } + } + -- public -- + tt-results(): { + #start-repeat(); + i := 0; + while (i < #subject.size) { + #expand(subject: #subject[i], expander: \#result-expander); + i += 1; + } + } + tt-failures(): { + #start-repeat(); + i := 0; + while (i < #subject.size) { + if (~#subject[i].passed) { + #expand(subject: #subject[i], expander: \#result-expander); + } + i += 1; + } + } + tt-all-passed(): { #keep(#tt-fails == 0); } + tt-some-failed(): { #keep(#tt-fails > 0); } + tt-total(): { return #subject.size; } + tt-fails(): { + i := 0; + f := 0; + while (i < #subject.size) { + if (~#subject[i].passed) { + f += 1; + } + i += 1; + } + return f; + } + } + } +-- public -- instantiator: { -- public -- get-protos(): { @@ -557,7 +676,7 @@ ``( trying to test both occurrences of this string, but they are spelled the same, so it doesn't work ``) true "<td class=\"failure\">test-a-number</td>" - true "<td><pre>expected bob was a walnut</pre></td>" + true "<pre>expected bob was a walnut</pre>" false "<td>passed</td>" false "class=\"pass\"" ] |
From: Jim K. <ki...@us...> - 2005-03-29 06:59:45
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22298/root/library Modified Files: wheatunit.ws Log Message: Move test result rendering tests from wheatunit to farm. Rendering code to move there next (in preparation for rendering traces as links to elsewhere in the farm). Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- wheatunit.ws 18 Mar 2005 07:18:50 -0000 1.41 +++ wheatunit.ws 29 Mar 2005 06:59:32 -0000 1.42 @@ -808,80 +808,28 @@ -- public -- test-run-all-for-package(): { results := #wheatunit.run-all-for(\#package-with-passing-test); + #assert-equals(1, results.size); #assert-equals(true, results[0].passed); - #assert-has-all-substrings( - #result-substrings-for-passing-test, - #wheatunit.format-results(results)); results := #wheatunit.run-all-for(\#package-with-no-tests); #assert-equals(0, results.size); - #assert-has-all-substrings( - #result-substrings-for-no-tests, - #wheatunit.format-results(results)); results := #wheatunit.run-all-for(\#package-with-failing-test); + #assert-equals(1, results.size); #assert-equals(false, results[0].passed); - #assert-has-all-substrings( - #result-substrings-for-failing-test, - #wheatunit.format-results(results)); } - - -- private -- - assert-has-all-substrings(substrings, result): { - $/library/render/tests.assert-rendered-cleanly(\self, result); - i := 0; - while (i < substrings.size) { - should-be-there := substrings[i]; - substring := substrings[i+1]; - - if (should-be-there) { - #assert-contains(substring, result); - } - else { - #assert-not-contains(substring, result); - } - i += 2; - } - } - + -- private -- package-with-passing-test: { tests: {:'/library/wheatunit/test-case': test-should-pass(): { #assert-equals(7, 3+4); } } } - result-substrings-for-passing-test: [ - true "<td class=\"pass\">test-should-pass</td>" - true "<td>passed</td>" - true "<span class=\"pass\">Total: 1</span>" - true "<span class=\"pass\">Failed: 0</span>" - false "<td>failed</td>" - false "class=\"failure\"" - ] - package-with-no-tests: { } - result-substrings-for-no-tests: [ - true "<span class=\"pass\">Total: 0</span>" - true "<span class=\"pass\">Failed: 0</span>" - false "<td>passed</td>" - false "<td>failed</td>" - false "class=\"failure\"" - ] - package-with-failing-test: { tests: {:'/library/wheatunit/test-case': test-should-fail(): { #assert-equals(5, 2+2); } } } - result-substrings-for-failing-test: [ - true "<td class=\"failure\">test-should-fail</td>" - true "<td>failed</td>" - true "<span class=\"failure\">Total: 1</span>" - true "<span class=\"failure\">Failed: 1</span>" - true "<td class=\"failure\">test-should-fail</td>" - true "<td><pre>expected 5 was 4</pre></td>" - false "<td>passed</td>" - false "class=\"pass\"" - ] } |
From: Jim K. <ki...@us...> - 2005-03-29 06:59:45
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22298/root/applications Modified Files: farm.ws Log Message: Move test result rendering tests from wheatunit to farm. Rendering code to move there next (in preparation for rendering traces as links to elsewhere in the farm). Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- farm.ws 20 Mar 2005 06:50:41 -0000 1.60 +++ farm.ws 29 Mar 2005 06:59:31 -0000 1.61 @@ -519,16 +519,87 @@ `` assert there's a view button next to that message } - test-show-test-results(): { + test-show-passing-test-results(): { #sample.init(\#sample.source-text-good); #sample.do-compile(); - result := #sample.submit( + page := #sample.submit( post-args: { }, request: #sample-request ); - #assert-contains("<span class=\"pass\">Total: 1</span>", result); + #assert-has-all-substrings( + #result-substrings-for-passing-test, page); + } + + result-substrings-for-passing-test: [ + true "<td class=\"pass\">test-a-number</td>" + true "<td>passed</td>" + true "<span class=\"pass\">Total: 1</span>" + true "<span class=\"pass\">Failed: 0</span>" + false "<td>failed</td>" + false "class=\"failure\"" + ] + + test-show-failing-test-results(): { + #sample.init(\#sample.source-text-bad-test); + #sample.do-compile(); + page := #sample.submit( + post-args: { }, + request: #sample-request + ); + #assert-has-all-substrings(#result-substrings-for-failing-test, page); } + result-substrings-for-failing-test: [ + true "<td class=\"failure\">test-a-number</td>" + true "<td>failed</td>" + true "<span class=\"failure\">Total: 1</span>" + true "<span class=\"failure\">Failed: 1</span>" + ``( trying to test both occurrences of this string, but + they are spelled the same, so it doesn't work ``) + true "<td class=\"failure\">test-a-number</td>" + true "<td><pre>expected bob was a walnut</pre></td>" + false "<td>passed</td>" + false "class=\"pass\"" + ] + + test-show-empty-test-results(): { + #sample.init(\#sample.source-text-empty-tests); + #sample.do-compile(); + page := #sample.submit( + post-args: { }, + request: #sample-request + ); + #assert-has-all-substrings(#result-substrings-for-no-tests, page); + } + + result-substrings-for-no-tests: [ + true "<span class=\"pass\">Total: 0</span>" + true "<span class=\"pass\">Failed: 0</span>" + false "<td>passed</td>" + false "<td>failed</td>" + false "class=\"failure\"" + ] + + -- private -- + assert-has-all-substrings(substrings, result): { + $/library/render/tests.assert-rendered-cleanly(\self, result); + + i := 0; + while (i < substrings.size) { + should-be-there := substrings[i]; + substring := substrings[i+1]; + + if (should-be-there) { + #assert-contains(substring, result); + } + else { + #assert-not-contains(substring, result); + } + i += 2; + } + } + + -- public -- test-view-never-compiled(): { #sample.init(\#sample.source-text-good); expander := #sample.expander.new( @@ -926,6 +997,12 @@ } "") + source-text-empty-tests: +""( +tests: {:'/library/wheatunit/test-case': +} +"") + source-text-odd-characters: ""( parses: "x<y || &foo > 5 || ãã¥ã¼ã¹" |
From: Mark L. <mar...@us...> - 2005-03-27 21:35:41
|
Update of /cvsroot/wheat/r1/web-dev/source/cardfile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5485 Added Files: card-image.png card.css card.html card.js cardfile.ws stack.html Log Message: some sketching out of a task-card style system... ...open up stack.html in a browser and check it out! --- NEW FILE: card-image.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: card.css --- /*<group=structure>*/ body { margin: 0px; padding: 0px; background: white; color: black; } div#header { margin: 0; padding: 0; width: 50em; } div#main { position: absolute; margin: 0; padding: 0; width: 52em; } div#content { padding: 1em; width: auto; } #stackPage div#content { margin-left: 7em; } #cardPage div#content { margin-left: 10.5em; } div#panel { position: absolute; top: 0px; left: 0px; margin: 0; padding: 0; } #stackPage div#panel { width: 7em; } #cardPage div#panel { width: 10.5em; } /*</group>*/ /*<group=basics>*/ body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; } h1, h2, h3 { font-family: Trebuchet, Trebuchet MS, Times, sans; } table, tr, td { margin: 0; padding: 0; border: none; border-spacing: 0; } /*</group>*/ /*<group=header>*/ #header h1 { border-bottom: 1px solid #ccc; color: #be0000; font-size: 28px; margin: 0; padding: 6px 8px; } #header h1 .alt { color: #999; } /*</group>*/ /*<group=content>*/ div#content { border-left: 1px solid #ccc; } /*</group>*/ /*<group=panel>*/ div#panel { text-align: center; color: #be0000; } #panel ul, #panel p { font-size: 70%; line-height: 120%; margin: 1em 0; padding: 0 4px; } #panel hr { height: 0; border-top: 2px solid #fff; border-left: none; border-right: none; border-bottom: none; } #panel ul { list-style: none; } #panel a { color: #be0000; text-decoration: none; } #panel a:hover { background: #ffbebf; color: #000; } #panel li a { display: block; margin: 0; padding: 0.25em 0; } #panel li.selected a { background: #bd5d5f; color: #fff; } #panel .target { background-color: #9bcb98; } #panel input { font-size: 80%; } /*</group>*/ /*<group=cards & places>*/ #table td { width: 14.5em; height: 9.5em; } #table .place { text-align: center; background-color: #f2f2f2; position: relative; width: 13em; height: 8em; border-width: 2px 4px 4px 2px; border-color: #f2f2f2; border-style: solid; } #table .place p { margin: 0; padding: 1.25em 0 0 0; font-size: 2em; color: #ddd; } #table .target { background-color: #749872; border-color: #749872; } #table .placeControls { position: absolute; right: 0px; top: 0px; margin: 0; padding: 0; text-align: right; font-size: 0.75em; list-style: none; } #table .card, #view .card { width: 13em; border-width: 1px 2px 2px 1px; border-color: #999; border-style: solid; background: white; color: black; text-align: left; } #table .card { position: absolute; left: 0px; top: 0px; overflow: hidden; height: 8em; } #view .card { margin: 0 1em 0 0; } #table .card h2, #view .card h2 { margin: 0; padding: 2px 8px 1px; font-size: 110%; background-color: #ffefef; border-bottom: 1px solid #ee4649; } #table .card h2 { cursor: move; } #table .card p, #view .card p { margin: 0.75em 0; font-size: 70%; color: black; padding: 0 16px 0 8px; } #table .cardControls { position: absolute; right: 0px; bottom: 0px; margin: 0; padding: 0; text-align: right; font-size: 0.75em; color: #0080ff; list-style: none; } /*<group=view>*/ #view td { font-size: 120%; vertical-align: top; } #formTitle { width: 95%; font-family: Trebuchet, Trebuchet MS, Times, sans; font-size: 85%; } #formBody { width: 95%; height: 20em; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 90%; } /*</group>*/ /*</group>*/ /*<group=list>*/ #list { margin: 1em 0 0 0; } #list tr.header { background: #bd5d5f; color: #fff; } #list td, #list th { margin: 0; font-size: 70%; text-align: left; vertical-align: top; padding: 4px; } #list .odd { background: #ddd; } #list .even { background: #eee; } #list .lc { width: 4em; } #list .lt { width: 13em; font-weight: bold; } #list td.lt { cursor: move; } #list .ld { width: 40em; } #list .listControls { font-size: 0.75em; } /*</group>*/ /*<group=misc>*/ #smallcard { visibility: hidden; position: fixed; left: 0px; top: 0px; } .listControls a, .cardControls a, .placeControls a { color: #b7cbcb; padding: 0 4px; text-decoration: none; } .listControls a:hover, .cardControls a:hover, .placeControls a:hover { background: #197f7f; color: #fff; } /*</group>*/ /*<group=tinyTable>*/ #tinyTable { font-size: 65%; border-spacing: .5em; width: 100%; } #tinyTable td { width: 4.25em; height: 2.75em; } #tinyTable .place, #tinyTable .card a { width: 4em; height: 2.5em; margin: 0; padding: 2px; border-width: 1px; border-style: solid; } #tinyTable .place { text-align: center; background-color: #f2f2f2; border-color: #f2f2f2; } #tinyTable .card a { display: block; overflow: hidden; text-align: left; background-color: #ffefef; color: #000; border-color: #999; } #tinyTable .card a:hover { background: #ffbebf; color: #000; } /*</group>*/ /*<group=tinyList>*/ #tinyList { margin: 0; padding: 0; } #tinyList .header { background: #bd5d5f; color: #fff; } #tinyList li { } #tinyList li a { font-size: 85%; display: block; overflow: hidden; text-align: left; margin: 0; padding: 2px 2px; color: #000; } #tinyList .odd { background: #ddd; } #tinyList .even { background: #eee; } /*</group>*/ --- NEW FILE: cardfile.ws --- wheat(version: 1) cardfile: { -- instance -- title: ??? stacks: [ ] -- public -- add-stack(title): { s := $../stack.new(); s.title := title; #stacks.add(s); } stack-count(): { return #stacks.size() } } stack: { -- instance -- title: ??? table: [ ] `` an array, laid out rows of 3 pile: [ ] `` a simple list -- public -- new-table-card(at: i): { c := $../card.new() #table[i] := c return \#table[i] } to-table(at: i, card: c): { if (c!) { return c } if (#table[i]) { #move-table-card(from: i, to: i + 3) } #table[i] := c } from-table(at: j): { c := #table[j] #table[j] := ??? return c } move-table-card(from: i, to: j): { #to-table(at: j, card: #from-table(at: i)) } to-pile(card: c): { if (c!) { return c } #pile.push(c) } from-pile(at: i): { c := #pile[i] n := #pile.size - 1 while (i < n) { #pile[i] := #pile[i + 1] i += 1 } #pile.delete(n) return c } table-map(): { `` mostly for testing a := [ ] i := 0 while (i < #table.size) { if (#table[i]) { a.add(i) a.add(#table[i].title) } i += 1 } return a } pile-map(): { a := [ ] i := 0 while (i < #pile.size) { if (#pile[i]) { a.add(#pile[i].title) } i += 1 } return a } } card: { -- instance -- title: ??? body: ??? } tests: {:'/library/wheatunit/test-case': assert-array(expected, actual): { #assert-equals(expected.size, actual.size) i := 0 while (i < expected.size) { #assert-equals(expected[i], actual[i]) i += 1 } } `` testing basics test-stack-basics(): { cf := $../cardfile.new() #assert-equals(0, cf.stack-count) cf.add-stack("now") #assert-equals(1, cf.stack-count) #assert-equals("now", cf.stacks[0].title) cf.add-stack("later") #assert-equals(2, cf.stack-count) #assert-equals("later", cf.stacks[1].title) } test-card-basics(): { cf := $../cardfile.new() cf.add-stack("now") st := \cf.stacks[0] #assert-array([], st.pile-map) #assert-array([], st.table-map) st.new-table-card(at: 0).title := "a" #assert-array([0, "a"], st.table-map) st.new-table-card(at: 2).title := "b" #assert-array([0, "a", 2, "b"], st.table-map) st.new-table-card(at: 1).title := "c" #assert-array([0, "a", 1, "c", 2, "b"], st.table-map) } test-table-movement(): { cf := $../cardfile.new() cf.add-stack("now") st := \cf.stacks[0] st.new-table-card(at: 2).title := "a" #assert-array([2, "a"], st.table-map) st.move-table-card(from: 2, to: 0) #assert-array([0, "a"], st.table-map) st.new-table-card(at: 1).title := "b" st.new-table-card(at: 2).title := "c" #assert-array([0, "a", 1, "b", 2, "c"], st.table-map) st.move-table-card(from: 1, to: 5) #assert-array([0, "a", 2, "c", 5, "b"], st.table-map) st.move-table-card(from: 2, to: 1) #assert-array([0, "a", 1, "c", 5, "b"], st.table-map) st.move-table-card(from: 0, to: 1) #assert-array([1, "a", 4, "c", 5, "b"], st.table-map) st.move-table-card(from: 5, to: 4) #assert-array([1, "a", 4, "b", 7, "c"], st.table-map) } test-pile-movement(): { cf := $../cardfile.new() cf.add-stack("now") st := \cf.stacks[0] st.new-table-card(at: 0).title := "a" st.new-table-card(at: 1).title := "b" st.new-table-card(at: 2).title := "c" #assert-array([0, "a", 1, "b", 2, "c"], st.table-map) #assert-array([ ], st.pile-map) st.to-pile(card: st.from-table(at: 1)) #assert-array([0, "a", 2, "c"], st.table-map) #assert-array([ "b" ], st.pile-map) st.to-pile(card: st.from-table(at: 2)) #assert-array([0, "a"], st.table-map) #assert-array([ "b", "c" ], st.pile-map) st.to-pile(card: st.from-table(at: 0)) #assert-array([], st.table-map) #assert-array([ "b", "c", "a" ], st.pile-map) st.to-table(at: 0, card: st.from-pile(at: 1)) #assert-array([0, "c"], st.table-map) #assert-array([ "b", "a" ], st.pile-map) st.to-table(at: 2, card: st.from-pile(at: 1)) #assert-array([0, "c", 2, "a"], st.table-map) #assert-array([ "b" ], st.pile-map) st.to-table(at: 1, card: st.from-pile(at: 0)) #assert-array([0, "c", 1, "b", 2, "a"], st.table-map) #assert-array([ ], st.pile-map) } ``( things that are rendered cardfile tt-title (trivial) cardfile tt-stack (in proper order) cardfile tt-stack-id cardfile tt-stack-title cardfile tt-stack-url stack tt-title (trivial) stack tt-url (trivial) stack tt-list-card (in proper order) stack tt-table-row (in proper order, proper number) stack tt-table-card (proper card or place) stack tt-table-card-id stack tt-table-card-url stack tt-table-card-delete-url stack tt-table-place-add-url stack tt-table-place-name stack tt-list-row stack tt-list-row-even stack tt-list-row-odd stack tt-list-card-id stack tt-list-card-url stack tt-list-card-delete-url card tt-title (trivial) card tt-body (writeup formatted, trivial) card tt-body-raw (trivial) ``) ``( operations when viewing a stack or a card come back as GETs and POSTs: view card: GET /path/to/card view stack: GET /path/to/stack add card: GET /path/to/stack/add?d=table3 -- redirect to new card delete table: GET /path/to/stack/delete?s=table3 delete list: GET /path/to/stack/delete?s=list5 -- redirect back to stack moves POST /path/to/file op=move;c=stack1 from table s=table3 from list s=list3 to table d=table5 to list d=list to stack d=stack5 -- redirect back to stack add stack POST /path/to/file op=add;c=stack1;n=newname rename stack POST /path/to/file op=rename;c=stack1;n=newname -- redirect back to stack save edit POST /path/to/card op=save;t=title;b=body -- redirect back to stack ``) } --- NEW FILE: card.js --- function note(s) { window.status = s; } function elementBox(elem) { var top = elem.offsetTop; var bottom = elem.offsetHeight + top; var left = elem.offsetLeft; var right = elem.offsetWidth + left; while (elem = elem.offsetParent) { top += elem.offsetTop; bottom += elem.offsetTop; left += elem.offsetLeft; right += elem.offsetLeft; } return { top: top, bottom: bottom, left: left, right: right }; } function ClassList(elem) { this.elem = elem; this.list = (elem.className || "").split(" "); } ClassList.prototype.set = function() { this.elem.className = this.list.join(" "); } ClassList.prototype.classIndex = function(c) { for (var i = 0; i < this.list.length; ++i) { if (this.list[i] == c) return i; } return -1; } ClassList.prototype.hasClass = function(c) { return this.classIndex(c) >= 0; } ClassList.prototype.addClass = function(c) { if (!this.hasClass(c)) { this.list.push(c); this.set(); } } ClassList.prototype.removeClass = function(c) { var i = this.classIndex(c); if (i >= 0) { this.list.splice(i, 1); this.set(); } } function Target(elem) { this.elem = elem; this.id = elem.id; this.recomputeBox(); this.classes = new ClassList(elem); } Target.prototype.recomputeBox = function() { this.box = elementBox(this.elem); } Target.prototype.hitTest = function(e) { var x = e.clientX + window.pageXOffset; var y = e.clientY + window.pageYOffset; return (this.box.left <= x) && (x <= this.box.right) && (this.box.top <= y) && (y <= this.box.bottom); } Target.prototype.toString = function() { return this.id + " @ " + this.box.left + "," + this.box.top + "::" + this.box.right + "," + this.box.bottom; } Target.prototype.hilight = function() { //this.origBackgroundColor = this.elem.style.backgroundColor; //this.elem.style.backgroundColor = "green"; this.classes.addClass("target"); } Target.prototype.unhilight = function() { //this.elem.style.backgroundColor = this.origBackgroundColor; this.classes.removeClass("target"); } Target.all = new Array; Target.build = function() { var table = document.getElementById("table"); var divs = table.getElementsByTagName("div"); for (var i = 0; i < divs.length; ++i) { var div = divs[i]; if (div.className == "place" && div.id) { this.all.push(new Target(div)); } } var stacks = document.getElementById("stacks"); var lis = stacks.getElementsByTagName("li"); for (var i = 0; i < lis.length; ++i) { var li = lis[i]; if (li.id) { this.all.push(new Target(li)); } } var list = document.getElementById("list"); if (list) { this.all.push(new Target(list)); } } Target.find = function(e) { for (var i = 0; i < this.all.length; ++i) { if (this.all[i].hitTest(e)) { return this.all[i]; } } return null; } Target.recomputeBoxes = function() { for (var i = 0; i < this.all.length; ++i) { this.all[i].recomputeBox(); } } function Source(elem, handle, dragElem) { this.elem = elem; this.handle = handle; this.dragElem = dragElem; if (!Source.smallDiv) { Source.smallDiv = document.getElementById("smallcard"); } var me = this; handle.onmousedown = function(e) { return me.onmousedown(e); } } Source.prototype.onmousedown = function(e) { var dragger = new Dragger(this); return dragger.dragStart(e); } Source.prototype.dragStart = function(e) { this.startX = e.clientX; this.startY = e.clientY; if (this.dragElem) { this.origZIndex = this.elem.style.zIndex; this.elem.style.zIndex = 1000; } } Source.prototype.dragMove = function(e, dragSmall) { if (this.dragElem && !dragSmall) { var dx = e.clientX - this.startX; var dy = e.clientY - this.startY; this.elem.style.left = dx + "px"; this.elem.style.top = dy + "px"; Source.smallDiv.style.visibility = "hidden"; this.elem.style.visibility = "visible"; } else { if (this.dragElem) { this.elem.style.visibility = "hidden"; } Source.smallDiv.style.top = (e.clientY - Source.smallDiv.offsetHeight / 2) + "px"; Source.smallDiv.style.left = (e.clientX - Source.smallDiv.offsetWidth / 2) + "px"; Source.smallDiv.style.visibility = "visible"; } } Source.prototype.dragEnd = function(e) { Source.smallDiv.style.visibility = "hidden"; if (this.dragElem) { this.elem.style.visibility = "visible"; this.elem.style.left = 0; this.elem.style.top = 0; this.elem.style.zIndex = this.origZIndex; } } Source.all = new Array; Source.build = function() { var table = document.getElementById("table"); var divs = table.getElementsByTagName("div"); for (var i = 0; i < divs.length; ++i) { var div = divs[i]; if (div.className == "card" && div.id) { var handle = div.getElementsByTagName("h2")[0]; this.all.push(new Source(div, handle, true)); } } var list = document.getElementById("list"); var trs = list.getElementsByTagName("tr"); for (var i = 0; i < trs.length; ++i) { var tr = trs[i]; if (tr.id) { var handle = tr.getElementsByTagName("td")[1]; this.all.push(new Source(tr, handle, false)); } } } function Dragger(source) { this.source = source; this.target = null; var me = this; document.onmousemove = function(e) { return me.dragMove(e); }; document.onmouseup = function(e) { return me.dragEnd(e); }; if (!Dragger.panel) { Dragger.panel = document.getElementById("panel"); } Dragger.panelBox = elementBox(Dragger.panel); Target.recomputeBoxes(); } Dragger.prototype.dragStart = function(e) { e = e || event; this.source.dragStart(e); return this.dragMove(e); } Dragger.prototype.dragMove = function(e) { e = e || event; if (this.target && this.target.hitTest(e)) { // nothing, still here... } else { if (this.target) { this.target.unhilight(); } this.target = Target.find(e); if (this.target) { this.target.hilight(); note("drag over " + this.target); } else { note(""); } } this.source.dragMove(e, e.clientX <= Dragger.panelBox.right); return false; } Dragger.prototype.dragEnd = function(e) { e = e || event; document.onmousemove = null; document.onmouseup = null; if (this.target) { this.target.unhilight(); this.target = null; } this.source.dragEnd(e); note(""); return false; } function setup() { Target.build(); Source.build(); } window.onload = setup; --- NEW FILE: card.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:tt="http://tinytemplate.org/ns/tt" > <head> <meta http-equiv="content-type" content="text/html;charset=utf8" /> <title>Card File</title> <link tt:name="root-based-href" rel="stylesheet" type="text/css" href="card.css" /> <script type="text/javascript" src="card.js"> </script> </head> <body id="cardPage"> <div id="header"> <h1><span class="alt">CardFile:</span> Boating Project</h1> </div> <div id="main"> <div id="content"> <table id="view"> <tr> <td> <div class="card"> <h2>Sew Sails</h2> <p>The sails should be rectangles that are approx. 30' by 8'. </p> <p>Traditionally they are made out of canvas, but in this day and age we want them made out of a tyvek and organic hemp blend.</p> <p>We'd like them to be a sort of Robin's egg blue, though with a tinge of red. And maybe a cool white stripe.</p> </div> </td> <td> <form action="post"> <div class="card"> <h2><input id="formTitle" type="text" name="title" value="Sew Sails" /></h2> <p><textarea id="formBody" name="body" rows="15" cols="30"> The sails should be rectangles that are approx. 30' by 8'. Traditionally they are made out of canvas, but in this day and age we want them made out of a tyvek and organic hemp blend. We'd like them to be a sort of Robin's egg blue, though with a tinge of red. And maybe a cool white stripe. </textarea> </p> </div> <p> <input id="formSubmit" type="submit" name="edit" value="Save Changes" /> </p> </form> </td> </tr> </table> </div> <div id="panel"> <ul id="stacks"> <li id="stackE" class="selected"><a href="stackE">frank's</a></li> </ul> <table id="tinyTable"> <tr> <td><div class="card selected"> <a href="cardA">Sew Sails</a> </div></td> <td><div class="card"> <a href="cardB">Anchor</a> </div></td> <td><div class="place"> </div></td> </tr> <tr> <td><div class="card"> <a href="cardD">Generate Interest</a> </div></td> <td><div class="place"> </div></td> <td><div class="card"> <a href="cardF">Anchor</a> </div></td> </tr> <tr> <td><div class="place"> </div></td> <td><div class="place"> </div></td> <td><div class="place"> </div></td> </tr> </table> <ul id="tinyList"> <li class="header"> </li> <li class="odd"> <a href="listA">Rig Sails</a> </li> <li class="even"> <a href="listB">Erect Mast</a> </li> <li class="odd"> <a href="listC">Sing Sea Chantys</a> </li> </ul> <p>❖</p> <ul> <li><a href="help">Help</a></li> <li> </li> <li><a href="cardfile">About CardFile</a></li> <li> </li> <li><a href="http://wheatfarm.org/">Powered by Wheat</a></li> </ul> </div> </div> </body> </html> --- NEW FILE: stack.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:tt="http://tinytemplate.org/ns/tt" > <head> <meta http-equiv="content-type" content="text/html;charset=utf8" /> <title>Card File</title> <link tt:name="root-based-href" rel="stylesheet" type="text/css" href="card.css" /> <script type="text/javascript" src="card.js"> </script> </head> <body id="stackPage"> <div id="header"> <h1><span class="alt">CardFile:</span> Boating Project</h1> </div> <div id="main"> <div id="content"> <table id="table"> <tr> <td><div class="place" id="placeA"> <p>ⓐ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeA" title="add new card">+</a></li> </ul> <div class="card" id="cardA"> <h2 title="drag to rearrange">Sew Sails</h2> <p>The sails should be rectangles that are approx. 30' by 8'. </p> <p>Traditionally they are made out of canvas, but in this day and age we want them made out of a tyvek and organic hemp blend.</p> <p>We'd like them to be a sort of Robin's egg blue, though with a tinge of red. And maybe a cool white stripe.</p> <ul class="cardControls"> <li><a href="cardA" title="view and edit card">✎</a></li> <li><a href="?op=delete;item=cardA" title="delete card">×</a></li> </ul> </div> </div></td> <td><div class="place" id="placeB"> <p>ⓑ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeB" title="add new card">+</a></li> </ul> <div class="card" id="cardB"> <h2 title="drag to rearrange">Anchor</h2> <p>We need an anchor. Preferably iron.</p> <ul class="cardControls"> <li><a href="cardB" title="view and edit card">✎</a></li> <li><a href="?op=delete;item=cardB" title="delete card">×</a></li> </ul> </div> </div> </td> <td><div class="place" id="placeC"> <p>ⓒ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeC" title="add new card">+</a></li> </ul> </div> </td> </tr> <tr> <td><div class="place" id="placeD"> <p>ⓓ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeD" title="add new card">+</a></li> </ul> <div class="card" id="cardD"> <h2 title="drag to rearrange">Generate Interest</h2> <p>The very first thing we need to do is get the media alerted. Perhaps with a really snazzy event, or a happening. Or we could stage some outrageous behavior that would capture some notice. No matter how we do it we need to get people talking about it and getting them to sit up and take notice. </p> <ul class="cardControls"> <li><a href="cardD" title="view and edit card">✎</a></li> <li><a href="?op=delete;item=cardD" title="delete card">×</a></li> </ul> </div> </div></td> <td><div class="place" id="placeE"> <p>ⓔ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeE" title="add new card">+</a></li> </ul> </div> </td> <td><div class="place" id="placeF"> <p>ⓕ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeF" title="add new card">+</a></li> </ul> <div class="card" id="cardF"> <h2 title="drag to rearrange">Anchor</h2> <p>We need an anchor. Preferably iron.</p> <ul class="cardControls"> <li><a href="cardF" title="view and edit card">✎</a></li> <li><a href="?op=delete;item=cardF" title="delete card">×</a></li> </ul> </div> </div></td> </tr> <tr> <td><div class="place" id="placeG"> <p>ⓖ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeG" title="add new card">+</a></li> </ul> </div> </td> <td><div class="place" id="placeH"> <p>ⓗ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeH" title="add new card">+</a></li> </ul> </div> </td> <td><div class="place" id="placeI"> <p>ⓘ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeI" title="add new card">+</a></li> </ul> </div> </td> </tr> </table> <table id="list"> <tr class="header"> <th class="lc"> </th> <th class="lt">title</th> <th class="ld">description</th> </tr> <tr class="odd" id="listA"> <td class="lc listControls"> <a href="listA" title="view and edit card">✎</a> <a href="?op=delete;item=listA" title="delete card">×</a> </td> <td class="lt" title="drag to rearrange">Rig Sails</td> <td class="ld">The sails need to be rigged on to the mast.</td> </tr> <tr class="even" id="listB"> <td class="lc listControls"> <a href="listB" title="view and edit card">✎</a> <a href="?op=delete;item=listB" title="delete card">×</a> </td> <td class="lt" title="drag to rearrange">Erect Mast</td> <td class="ld">The mast should stand at 88.5° to the rear.</td> </tr> <tr class="odd" id="listC"> <td class="lc listControls"> <a href="listB" title="view and edit card">✎</a> <a href="?op=delete;item=listB" title="delete card">×</a> </td> <td class="lt" title="drag to rearrange">Sing Sea Chantys</td> <td class="ld">We need to all gather around the poop deck. Then we'll all drink an inordinate amount of beer. Once we are sufficiently toasty, old Bill will get out the harmonica and we'll begin.</td> </tr> </table> </div> <div id="panel"> <p><b>Stacks</b></p> <ul id="stacks"> <li id="stackA"><a href="stackA">do now</a></li> <li id="stackB"><a href="stackB">later</a></li> <li id="stackC"><a href="stackC">much later</a></li> <li id="stackD"><a href="stackD">never</a></li> <li id="stackE" class="selected"><a href="stackE">frank's</a></li> <li id="stackF"><a href="stackF">morgue</a></li> </ul> <p>❖</p> <form tt:name="blog-action" action="login" method="post"> <p> <input type="text" name="stack" size="12" /> <br /> <a href="" title="add new stack">Add</a> | <a href="" title="rename current stack">Rename</a> </p> </form> <p>❖</p> <ul> <li><a href="help">Help</a></li> <li> </li> <li><a href="cardfile">About CardFile</a></li> <li> </li> <li><a href="http://wheatfarm.org/">Powered by Wheat</a></li> </ul> </div> </div> <div id="smallcard"> <img src="card-image.png" alt="card" /> </div> </body> </html> |
From: Mark L. <mar...@us...> - 2005-03-27 21:33:37
|
Update of /cvsroot/wheat/r1/web-dev/source/cardfile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4825/web-dev/source/cardfile Log Message: Directory /cvsroot/wheat/r1/web-dev/source/cardfile added to the repository |
From: Mark L. <mar...@us...> - 2005-03-25 04:42:28
|
Update of /cvsroot/wheat/r1/grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32208/grammar Modified Files: ScriptCompiler.cpp ScriptCompiler.g Log Message: first working methods in dynamic objects! Index: ScriptCompiler.cpp =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- ScriptCompiler.cpp 24 Mar 2005 22:16:21 -0000 1.36 +++ ScriptCompiler.cpp 25 Mar 2005 04:42:20 -0000 1.37 @@ -1816,10 +1816,6 @@ i = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - v=reference(_t,mb); - _t = _retTree; - _t = __t114; - _t = _t->getNextSibling(); MethodBuilder::Call c; c.setReceiver(r); @@ -1827,33 +1823,72 @@ c.setMessage("add-member"); c.addPosArg(mb.genLiteral(op)); op.storeString(astString(i)); - c.addPosArg(v); - if (af != AccessDefault) { - c.addKeyArg("flags", - mb.genLiteral(op)); - op.storeInt(af); + + { + if (_t == antlr::RefSpanAST(antlr::nullAST) ) + _t = ASTNULL; + switch ( _t->getType()) { + case AS_LINK: + case AS_IS: + case AS_COPY: + { + v=reference(_t,mb); + _t = _retTree; + + c.addPosArg(v); + if (af != AccessDefault) { + c.addKeyArg("flags", + mb.genLiteral(op)); + op.storeInt(af); + } + + break; + } + case METHOD: + { + + c.addPosArg(mb.genLiteral(op)); + MethodBuilder::Branch around; + around = mb.genBranchAlways(); + + methodValue(_t,op); + _t = _retTree; + + mb.setTarget(around); + c.addKeyArg("flags", + mb.genLiteral(op)); + op.storeInt(af | AccessExecutable); + + break; + } + default: + { + throw antlr::NoViableAltException(antlr::RefAST(_t)); } + } + } + _t = __t114; + _t = _t->getNextSibling(); mb.genCall(c); - } else if ((_t->getType() == MODE)) { - antlr::RefSpanAST __t115 = _t; + antlr::RefSpanAST __t116 = _t; antlr::RefSpanAST tmp56_AST_in = _t; match(antlr::RefAST(_t),MODE); _t = _t->getFirstChild(); key = _t; match(antlr::RefAST(_t),ID); _t = _t->getNextSibling(); - _t = __t115; + _t = __t116; _t = _t->getNextSibling(); af = decodeMode(key); } else { - goto _loop116; + goto _loop117; } } - _loop116:; + _loop117:; } // ( ... )* { // ( ... )* for (;;) { @@ -1867,11 +1902,11 @@ "unrecognized element when building object", x); } else { - goto _loop118; + goto _loop119; } } - _loop118:; + _loop119:; } // ( ... )* _t = __t112; _t = _t->getNextSibling(); @@ -1893,7 +1928,7 @@ try { // for error handling SOURCE(buildInstance_AST_in); - antlr::RefSpanAST __t120 = _t; + antlr::RefSpanAST __t121 = _t; antlr::RefSpanAST tmp57_AST_in = _t; match(antlr::RefAST(_t),BUILD_INSTANCE); _t = _t->getFirstChild(); @@ -1907,7 +1942,7 @@ _t = ASTNULL; if ((_t->getType() == MEMBER)) { MethodBuilder::Register v; - antlr::RefSpanAST __t122 = _t; + antlr::RefSpanAST __t123 = _t; antlr::RefSpanAST tmp58_AST_in = _t; match(antlr::RefAST(_t),MEMBER); _t = _t->getFirstChild(); @@ -1916,7 +1951,7 @@ _t = _t->getNextSibling(); v=reference(_t,mb); _t = _retTree; - _t = __t122; + _t = __t123; _t = _t->getNextSibling(); MethodBuilder::Call c; @@ -1931,11 +1966,11 @@ } else { - goto _loop123; + goto _loop124; } } - _loop123:; + _loop124:; } // ( ... )* { // ( ... )* for (;;) { @@ -1949,13 +1984,13 @@ "unrecognized element when building instance", x); } else { - goto _loop125; + goto _loop126; } } - _loop125:; + _loop126:; } // ( ... )* - _t = __t120; + _t = __t121; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -1973,7 +2008,7 @@ try { // for error handling SOURCE(buildArray_AST_in); - antlr::RefSpanAST __t127 = _t; + antlr::RefSpanAST __t128 = _t; antlr::RefSpanAST tmp59_AST_in = _t; match(antlr::RefAST(_t),BUILD_ARRAY); _t = _t->getFirstChild(); @@ -1998,13 +2033,13 @@ } else { - goto _loop129; + goto _loop130; } } - _loop129:; + _loop130:; } // ( ... )* - _t = __t127; + _t = __t128; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { @@ -2022,7 +2057,7 @@ try { // for error handling SOURCE(buildError_AST_in); - antlr::RefSpanAST __t132 = _t; + antlr::RefSpanAST __t133 = _t; antlr::RefSpanAST tmp60_AST_in = _t; match(antlr::RefAST(_t),BUILD_ERROR); _t = _t->getFirstChild(); @@ -2052,13 +2087,13 @@ } else { - goto _loop134; + goto _loop135; } } - _loop134:; + _loop135:; } // ( ... )* - _t = __t132; + _t = __t133; _t = _t->getNextSibling(); } catch (const Wheat::Exception& e) { Index: ScriptCompiler.g =================================================================== RCS file: /cvsroot/wheat/r1/grammar/ScriptCompiler.g,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ScriptCompiler.g 24 Mar 2005 22:16:21 -0000 1.28 +++ ScriptCompiler.g 25 Mar 2005 04:42:20 -0000 1.29 @@ -525,22 +525,35 @@ { ObjectAccess af = AccessDefault; } p=buildProto[mb] { r = mb.genNewObject(p); } ( options{greedy=true;}: { MethodBuilder::Register v; } - #(MEMBER i:ID v=reference[mb]) - { + #(MEMBER i:ID { MethodBuilder::Call c; c.setReceiver(r); ObjectPointer op; c.setMessage("add-member"); c.addPosArg(mb.genLiteral(op)); op.storeString(astString(i)); + } + ( v=reference[mb] { c.addPosArg(v); if (af != AccessDefault) { c.addKeyArg("flags", mb.genLiteral(op)); op.storeInt(af); } - mb.genCall(c); } + | { + c.addPosArg(mb.genLiteral(op)); + MethodBuilder::Branch around; + around = mb.genBranchAlways(); + } + methodValue[op] { + mb.setTarget(around); + c.addKeyArg("flags", + mb.genLiteral(op)); + op.storeInt(af | AccessExecutable); + } + ) + ) { mb.genCall(c); } | #(MODE key:ID) { af = decodeMode(key); } )* ( x:. { throw buildException( |
From: Mark L. <mar...@us...> - 2005-03-25 04:42:28
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32208/wheat Modified Files: compiler-test.cpp Log Message: first working methods in dynamic objects! Index: compiler-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/compiler-test.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- compiler-test.cpp 24 Mar 2005 22:16:22 -0000 1.38 +++ compiler-test.cpp 25 Mar 2005 04:42:20 -0000 1.39 @@ -768,7 +768,6 @@ CHECK_SAME("alt", c.target().send("asis-link").asString()); } -#if 0 TEST(compiler, dynamicObjects) { CompilerTestSetup c( @@ -778,11 +777,11 @@ " -- public --\n" " new(n): { return {:self: var: n } }\n" " make-inner-thing(n): {\n" - " return {:self:\n" + " return {<:self:\n" " -- instance --\n" " var: n\n" " -- public --\n" - " get-var(): { return #var }\n" + " get-var(): { return #var * 2 }\n" " }\n" " }\n" "}\n" @@ -794,9 +793,8 @@ "}\n" ); - CHECK_SAME(56, c.target().send("a").asInt()); + CHECK_SAME(112, c.target().send("a").asInt()); } -#endif TEST(compiler, errorPropagation) { |