mirror of
https://github.com/mbierlee/poodinis.git
synced 2025-02-22 18:12:41 +01:00
Add Phobos 2.066.1 forwards-compatibility for GDC
This commit is contained in:
parent
d3f049eb9f
commit
5ed3a6ae29
6 changed files with 62 additions and 5 deletions
|
@ -6,10 +6,13 @@ d:
|
|||
- dmd-2.070.2
|
||||
- dmd-2.069.2
|
||||
- dmd-2.068.2
|
||||
- dmd-2.068.0
|
||||
- dmd-2.067.2
|
||||
- dmd-2.066.2
|
||||
- dmd-2.066.1
|
||||
- ldc
|
||||
- ldc-1.1.0-beta5
|
||||
- ldc-0.17.2
|
||||
- gdc
|
||||
|
||||
sudo: false
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Master: [;
|
||||
|
|
|
@ -14,18 +14,70 @@
|
|||
module poodinis.polyfill;
|
||||
|
||||
import std.exception;
|
||||
import std.traits;
|
||||
|
||||
static if (!__traits(compiles, basicExceptionCtors)) {
|
||||
mixin template basicExceptionCtors()
|
||||
{
|
||||
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) @nogc @safe pure nothrow
|
||||
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) @safe pure nothrow
|
||||
{
|
||||
super(msg, file, line, next);
|
||||
}
|
||||
|
||||
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) @nogc @safe pure nothrow
|
||||
this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) @safe pure nothrow
|
||||
{
|
||||
super(msg, file, line, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static if (!__traits(compiles, enforce!Exception(true, "Message"))) {
|
||||
T enforce(E: Exception, T)(T value, string message) {
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
throw new E(message);
|
||||
}
|
||||
}
|
||||
|
||||
static if (!__traits(compiles, FieldNameTuple)) {
|
||||
private enum NameOf(alias T) = T.stringof;
|
||||
|
||||
template FieldNameTuple(T)
|
||||
{
|
||||
import std.typetuple : staticMap;
|
||||
static if (is(T == struct) || is(T == union))
|
||||
alias FieldNameTuple = staticMap!(NameOf, T.tupleof[0 .. $ - isNested!T]);
|
||||
else static if (is(T == class))
|
||||
alias FieldNameTuple = staticMap!(NameOf, T.tupleof);
|
||||
else
|
||||
alias FieldNameTuple = TypeTuple!"";
|
||||
}
|
||||
}
|
||||
|
||||
static if (!__traits(compiles, hasUDA)) {
|
||||
template hasUDA(alias symbol, alias attribute)
|
||||
{
|
||||
public static bool hasUda() {
|
||||
foreach(uda; __traits(getAttributes, symbol)) {
|
||||
if (is(uda == attribute)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
enum hasUDA = hasUda();
|
||||
}
|
||||
}
|
||||
|
||||
static if (!__traits(compiles, Parameters)) {
|
||||
template Parameters(func...)
|
||||
if (func.length == 1 && isCallable!func)
|
||||
{
|
||||
static if (is(FunctionTypeOf!func P == function))
|
||||
alias Parameters = P;
|
||||
else
|
||||
static assert(0, "argument has no parameters");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue