mirror of https://github.com/adamdruppe/arsd.git
test makefile, workaround dmd regression, hack support for gdc project-wide
This commit is contained in:
parent
a1b52da48e
commit
11322448ea
36
cgi.d
36
cgi.d
|
@ -303,10 +303,15 @@ version(Posix) {
|
|||
} else version(minimal) {
|
||||
|
||||
} else {
|
||||
version(GNU) {
|
||||
// GDC doesn't support static foreach so I had to cheat on it :(
|
||||
} else {
|
||||
version=with_breaking_cgi_features;
|
||||
version=with_sendfd;
|
||||
version=with_addon_servers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the servers must know about the connections to talk to them; the interfaces are vital
|
||||
version(with_addon_servers)
|
||||
|
@ -2305,6 +2310,7 @@ class Cgi {
|
|||
}
|
||||
|
||||
// if it is in test mode; triggers mock sessions. Used by CgiTester
|
||||
version(with_breaking_cgi_features)
|
||||
private CgiTester testInProcess;
|
||||
|
||||
/* Hooks for redirecting input and output */
|
||||
|
@ -2418,6 +2424,7 @@ Cgi dummyCgi(Cgi.RequestMethod method = Cgi.RequestMethod.GET, string url = null
|
|||
/++
|
||||
A helper test class for request handler unittests.
|
||||
+/
|
||||
version(with_breaking_cgi_features)
|
||||
class CgiTester {
|
||||
private {
|
||||
SessionObject[TypeInfo] mockSessions;
|
||||
|
@ -4863,8 +4870,12 @@ version(Windows)
|
|||
else static assert(0);
|
||||
}
|
||||
|
||||
version(Posix)
|
||||
version(Posix) {
|
||||
version(CRuntime_Musl) {} else {
|
||||
import core.sys.posix.unistd;
|
||||
private extern(C) int posix_spawn(pid_t*, const char*, void*, void*, const char**, const char**);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FIXME: these aren't quite public yet.
|
||||
|
@ -5303,6 +5314,12 @@ unittest {
|
|||
FIXME: overloads aren't supported
|
||||
*/
|
||||
|
||||
/// Base for storing sessions in an array. Exists primarily for internal purposes and you should generally not use this.
|
||||
interface SessionObject {}
|
||||
|
||||
version(with_breaking_cgi_features)
|
||||
mixin(q{
|
||||
|
||||
mixin template ImplementRpcClientInterface(T, string serverPath) {
|
||||
static import std.traits;
|
||||
|
||||
|
@ -5457,9 +5474,6 @@ private struct SerializationBuffer {
|
|||
will have to have dump and restore too, so i can restart without losing stuff.
|
||||
*/
|
||||
|
||||
/// Base for storing sessions in an array. Exists primarily for internal purposes and you should generally not use this.
|
||||
interface SessionObject {}
|
||||
|
||||
/++
|
||||
A convenience object for talking to the [BasicDataServer] from a higher level.
|
||||
See: [Cgi.getSessionObject].
|
||||
|
@ -6885,6 +6899,8 @@ auto callFromCgi(alias method, T)(T dg, Cgi cgi) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else static if(isSomeString!T || isIntegral!T || isFloatingPoint!T) {
|
||||
*what = to!T(value);
|
||||
return true;
|
||||
|
@ -6945,11 +6961,13 @@ auto callFromCgi(alias method, T)(T dg, Cgi cgi) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
static assert(0, "unsupported type for cgi call " ~ T.stringof);
|
||||
}
|
||||
|
||||
return false;
|
||||
//return false;
|
||||
}
|
||||
|
||||
void setArgument(string name, string value) {
|
||||
|
@ -7838,9 +7856,9 @@ private auto serveApiInternal(T)(string urlPrefix) {
|
|||
return true;
|
||||
default:
|
||||
throw t;
|
||||
return true;
|
||||
// return true;
|
||||
}
|
||||
return true;
|
||||
// return true;
|
||||
}
|
||||
|
||||
assert(0);
|
||||
|
@ -8081,8 +8099,10 @@ private auto serveApiInternal(T)(string urlPrefix) {
|
|||
}
|
||||
|
||||
string defaultFormat(alias method)() {
|
||||
bool nonConstConditionForWorkingAroundASpuriousDmdWarning = true;
|
||||
static foreach(attr; __traits(getAttributes, method)) {
|
||||
static if(is(typeof(attr) == DefaultFormat)) {
|
||||
if(nonConstConditionForWorkingAroundASpuriousDmdWarning)
|
||||
return attr.value;
|
||||
}
|
||||
}
|
||||
|
@ -8974,6 +8994,8 @@ template dispatcher(definitions...) {
|
|||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/+
|
||||
/++
|
||||
This is the beginnings of my web.d 2.0 - it dispatches web requests to a class object.
|
||||
|
|
|
@ -444,7 +444,10 @@ QueryBuilderHelper!(T[]) children(T, B)(B base) {
|
|||
}}
|
||||
}
|
||||
|
||||
return QueryBuilderHelper!(T[])(toTableName(T.stringof)).where!(mixin(keyName ~ " => base.id"));
|
||||
// return QueryBuilderHelper!(T[])(toTableName(T.stringof)).where!(mixin(keyName ~ " => base.id"));
|
||||
|
||||
// changing mixin cuz of regression in dmd 2.088
|
||||
mixin("return QueryBuilderHelper!(T[])(toTableName(T.stringof)).where!("~keyName ~ " => base.id);");
|
||||
}
|
||||
|
||||
/++
|
||||
|
|
17
jsvar.d
17
jsvar.d
|
@ -125,6 +125,21 @@ enum scriptable = "arsd_jsvar_compatible";
|
|||
it would be nice if delegates on native types could work
|
||||
*/
|
||||
|
||||
static if(__VERSION__ <= 2076) {
|
||||
// compatibility shims with gdc
|
||||
enum JSONType {
|
||||
object = JSON_TYPE.OBJECT,
|
||||
null_ = JSON_TYPE.NULL,
|
||||
false_ = JSON_TYPE.FALSE,
|
||||
true_ = JSON_TYPE.TRUE,
|
||||
integer = JSON_TYPE.INTEGER,
|
||||
float_ = JSON_TYPE.FLOAT,
|
||||
array = JSON_TYPE.ARRAY,
|
||||
string = JSON_TYPE.STRING,
|
||||
uinteger = JSON_TYPE.UINTEGER
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Script notes:
|
||||
|
@ -1819,9 +1834,11 @@ WrappedNativeObject wrapUfcs(alias Module, Type)(Type obj) {
|
|||
}
|
||||
|
||||
bool isScriptable(attributes...)() {
|
||||
bool nonConstConditionForWorkingAroundASpuriousDmdWarning = true;
|
||||
foreach(attribute; attributes) {
|
||||
static if(is(typeof(attribute) == string)) {
|
||||
static if(attribute == scriptable) {
|
||||
if(nonConstConditionForWorkingAroundASpuriousDmdWarning)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
15
oauth.d
15
oauth.d
|
@ -14,6 +14,21 @@ import std.exception;
|
|||
import std.datetime;
|
||||
|
||||
|
||||
static if(__VERSION__ <= 2076) {
|
||||
// compatibility shims with gdc
|
||||
enum JSONType {
|
||||
object = JSON_TYPE.OBJECT,
|
||||
null_ = JSON_TYPE.NULL,
|
||||
false_ = JSON_TYPE.FALSE,
|
||||
true_ = JSON_TYPE.TRUE,
|
||||
integer = JSON_TYPE.INTEGER,
|
||||
float_ = JSON_TYPE.FLOAT,
|
||||
array = JSON_TYPE.ARRAY,
|
||||
string = JSON_TYPE.STRING,
|
||||
uinteger = JSON_TYPE.UINTEGER
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
|
|
4
script.d
4
script.d
|
@ -1133,7 +1133,9 @@ class BinaryExpression : Expression {
|
|||
|
||||
var n;
|
||||
sw: switch(op) {
|
||||
static foreach(ctOp; CtList!("+", "-", "*", "/", "==", "!=", "<=", ">=", ">", "<", "~", "&&", "||", "&", "|", "^", "%"))
|
||||
// I would actually kinda prefer this to be static foreach, but normal
|
||||
// tuple foreach here has broaded compiler compatibility.
|
||||
foreach(ctOp; CtList!("+", "-", "*", "/", "==", "!=", "<=", ">=", ">", "<", "~", "&&", "||", "&", "|", "^", "%"))
|
||||
case ctOp: {
|
||||
n = mixin("left "~ctOp~" right");
|
||||
break sw;
|
||||
|
|
16
sha.d
16
sha.d
|
@ -7,6 +7,20 @@ module arsd.sha;
|
|||
*/
|
||||
import std.stdio;
|
||||
|
||||
version(GNU) {
|
||||
immutable(ubyte)[] SHA1(T)(T data) {
|
||||
import std.digest.sha;
|
||||
auto i = sha1Of(data);
|
||||
return i.idup;
|
||||
}
|
||||
|
||||
immutable(ubyte)[] SHA256(T)(T data) {
|
||||
import std.digest.sha;
|
||||
auto i = sha256Of(data);
|
||||
return i.idup;
|
||||
}
|
||||
} else {
|
||||
|
||||
immutable(ubyte)[/*20*/] SHA1(T)(T data) if(isInputRange!(T)) /*const(ubyte)[] data)*/ {
|
||||
uint[5] h = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
|
||||
|
||||
|
@ -369,6 +383,8 @@ immutable(ubyte)[] SHA256(T)(T data) if ( isInputRange!(T)) {
|
|||
return hash.idup;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
import std.exception;
|
||||
|
||||
string hashToString(const(ubyte)[] hash) {
|
||||
|
|
20
web.d
20
web.d
|
@ -1,6 +1,24 @@
|
|||
/// magic web wrapper
|
||||
module arsd.web;
|
||||
|
||||
|
||||
static if(__VERSION__ <= 2076) {
|
||||
// compatibility shims with gdc
|
||||
enum JSONType {
|
||||
object = JSON_TYPE.OBJECT,
|
||||
null_ = JSON_TYPE.NULL,
|
||||
false_ = JSON_TYPE.FALSE,
|
||||
true_ = JSON_TYPE.TRUE,
|
||||
integer = JSON_TYPE.INTEGER,
|
||||
float_ = JSON_TYPE.FLOAT,
|
||||
array = JSON_TYPE.ARRAY,
|
||||
string = JSON_TYPE.STRING,
|
||||
uinteger = JSON_TYPE.UINTEGER
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// it would be nice to be able to add meta info to a returned envelope
|
||||
|
||||
// with cookie sessions, you must commit your session yourself before writing any content
|
||||
|
@ -2565,7 +2583,7 @@ type fromUrlParam(type)(in string ofInterest, in string name, in string[][string
|
|||
}
|
||||
} else static if(is(type == enum)) {
|
||||
sw: switch(ofInterest) {
|
||||
static foreach(N; __traits(allMembers, type)) {
|
||||
/*static*/ foreach(N; __traits(allMembers, type)) {
|
||||
case N:
|
||||
ret = __traits(getMember, type, N);
|
||||
break sw;
|
||||
|
|
Loading…
Reference in New Issue