This commit is contained in:
Adam D. Ruppe 2019-02-25 09:42:47 -05:00
parent 26868a7526
commit 2fa8f7cfa9
2 changed files with 25 additions and 1 deletions

20
cgi.d
View File

@ -6774,8 +6774,10 @@ bool restObjectServeHandler(T)(Cgi cgi, string url) {
auto div = Element.make("div");
div.addClass("Dclass_" ~ T.stringof);
div.dataset.url = urlId;
bool first = true;
static foreach(idx, memberName; __traits(derivedMembers, T))
static if(__traits(compiles, __traits(getMember, obj, memberName).offsetof)) {
if(!first) div.addChild("br"); else first = false;
div.appendChild(formatReturnValueAsHtml(__traits(getMember, obj, memberName)));
}
return div;
@ -6986,6 +6988,24 @@ bool restObjectServeHandler(T)(Cgi cgi, string url) {
return true;
}
/+
struct SetOfFields(T) {
private void[0][string] storage;
void set(string what) {
//storage[what] =
}
void unset(string what) {}
void setAll() {}
void unsetAll() {}
bool isPresent(string what) { return false; }
}
+/
/+
enum readonly;
enum hideonindex;
+/
/++
Serves a static file. To be used with [dispatcher].
+/

View File

@ -90,6 +90,8 @@
obj.__prop("name", value); // bypasses operator overloading, useful for use inside the opIndexAssign especially
Note: if opIndex is not overloaded, getting a non-existent member will actually add it to the member. This might be a bug but is needed right now in the D impl for nice chaining. Or is it? FIXME
FIXME: it doesn't do opIndex with multiple args.
* if/else
* array slicing, but note that slices are rvalues currently
* variables must start with A-Z, a-z, _, or $, then must be [A-Za-z0-9_]*.
@ -2304,7 +2306,9 @@ Expression parseExpression(MyTokenStreamHere)(ref MyTokenStreamHere tokens, bool
auto ident = tokens.requireNextToken(ScriptToken.Type.identifier);
tokens.requireNextToken(ScriptToken.Type.symbol, "(");
auto args = parseVariableDeclaration(tokens, ")");
VariableDeclaration args;
if(!tokens.peekNextToken(ScriptToken.Type.symbol, ")"))
args = parseVariableDeclaration(tokens, ")");
tokens.requireNextToken(ScriptToken.Type.symbol, ")");
auto bod = parseExpression(tokens);