Add Phobos 2.066.1 forwards-compatibility for GDC

This commit is contained in:
Mike Bierlee 2016-12-13 22:00:34 +01:00
parent d3f049eb9f
commit 5ed3a6ae29
6 changed files with 62 additions and 5 deletions

View file

@ -6,10 +6,13 @@ d:
- dmd-2.070.2 - dmd-2.070.2
- dmd-2.069.2 - dmd-2.069.2
- dmd-2.068.2 - dmd-2.068.2
- dmd-2.068.0 - dmd-2.067.2
- dmd-2.066.2
- dmd-2.066.1
- ldc - ldc
- ldc-1.1.0-beta5 - ldc-1.1.0-beta5
- ldc-0.17.2 - ldc-0.17.2
- gdc
sudo: false sudo: false

View file

@ -8,7 +8,7 @@ Master: [![Build Status](https://api.travis-ci.org/mbierlee/poodinis.png?branch=
Poodinis is a dependency injection framework for the D programming language. It is inspired by the [Spring Framework] and [Hypodermic] IoC container for C++. Poodinis supports registering and resolving classes either by concrete type or interface. Automatic injection of dependencies is supported through the use of UDAs or constructors. Poodinis is a dependency injection framework for the D programming language. It is inspired by the [Spring Framework] and [Hypodermic] IoC container for C++. Poodinis supports registering and resolving classes either by concrete type or interface. Automatic injection of dependencies is supported through the use of UDAs or constructors.
Requires at least a D 2.068.0 compatible compiler Requires at least a D 2.066.1 compatible compiler
Uses the Phobos standard library Uses the Phobos standard library
Can be built with DUB 0.9.24 or higher Can be built with DUB 0.9.24 or higher

View file

@ -21,6 +21,7 @@ import poodinis.container;
import poodinis.registration; import poodinis.registration;
import poodinis.factory; import poodinis.factory;
import poodinis.valueinjection; import poodinis.valueinjection;
import poodinis.polyfill;
import std.exception; import std.exception;
import std.stdio; import std.stdio;

View file

@ -16,6 +16,7 @@ module poodinis.context;
import poodinis.container; import poodinis.container;
import poodinis.registration; import poodinis.registration;
import poodinis.factory; import poodinis.factory;
import poodinis.polyfill;
import std.traits; import std.traits;

View file

@ -16,9 +16,9 @@ import poodinis.container;
import std.typecons; import std.typecons;
import std.exception; import std.exception;
import std.traits; import std.traits;
import std.meta;
import std.string; import std.string;
import std.stdio; import std.stdio;
import poodinis.polyfill;
alias CreatesSingleton = Flag!"CreatesSingleton"; alias CreatesSingleton = Flag!"CreatesSingleton";
alias InstanceFactoryMethod = Object delegate(); alias InstanceFactoryMethod = Object delegate();

View file

@ -14,18 +14,70 @@
module poodinis.polyfill; module poodinis.polyfill;
import std.exception; import std.exception;
import std.traits;
static if (!__traits(compiles, basicExceptionCtors)) { static if (!__traits(compiles, basicExceptionCtors)) {
mixin template 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); 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); 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");
}
}