| 1 |
/* |
|---|
| 2 |
Copyright (c) 2006 Kirk McDonald |
|---|
| 3 |
|
|---|
| 4 |
Permission is hereby granted, free of charge, to any person obtaining a copy of |
|---|
| 5 |
this software and associated documentation files (the "Software"), to deal in |
|---|
| 6 |
the Software without restriction, including without limitation the rights to |
|---|
| 7 |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
|---|
| 8 |
of the Software, and to permit persons to whom the Software is furnished to do |
|---|
| 9 |
so, subject to the following conditions: |
|---|
| 10 |
|
|---|
| 11 |
The above copyright notice and this permission notice shall be included in all |
|---|
| 12 |
copies or substantial portions of the Software. |
|---|
| 13 |
|
|---|
| 14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 15 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 16 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|---|
| 17 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 18 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 19 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|---|
| 20 |
SOFTWARE. |
|---|
| 21 |
*/ |
|---|
| 22 |
|
|---|
| 23 |
// This module abstracts out all of the uses of Phobos, Tango, and meta, easing |
|---|
| 24 |
// the ability to switch between Phobos and Tango arbitrarily. |
|---|
| 25 |
module pyd.lib_abstract; |
|---|
| 26 |
|
|---|
| 27 |
version (Tango) { |
|---|
| 28 |
import tango.stdc.string : strlen; |
|---|
| 29 |
import tango.text.convert.Integer : qadut; |
|---|
| 30 |
char[] toString(char* s) { |
|---|
| 31 |
return s[0 .. strlen(s)]; |
|---|
| 32 |
} |
|---|
| 33 |
char[] toString(uint i) { |
|---|
| 34 |
char[64] tmp; |
|---|
| 35 |
return qadut(tmp, i); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
public import tango.util.meta.Nameof : symbolnameof, prettytypeof, prettynameof; |
|---|
| 39 |
public import meta.Default : minArgs, ParameterTypeTuple, ReturnType; |
|---|
| 40 |
char[] objToStr(Object o) { |
|---|
| 41 |
return o.toUtf8(); |
|---|
| 42 |
} |
|---|
| 43 |
} else { |
|---|
| 44 |
string objToStr(Object o) { |
|---|
| 45 |
return o.toString(); |
|---|
| 46 |
} |
|---|
| 47 |
version (D_Version2) { |
|---|
| 48 |
// D1 issues? |
|---|
| 49 |
template symbolnameof(alias symbol) { |
|---|
| 50 |
static if (is(typeof(symbol) == function)) { |
|---|
| 51 |
const char[] symbolnameof = (&symbol).stringof[2 .. $]; |
|---|
| 52 |
} else { |
|---|
| 53 |
const char[] symbolnameof = symbol.stringof; |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
} else { |
|---|
| 57 |
public import meta.Nameof : symbolnameof; |
|---|
| 58 |
} |
|---|
| 59 |
public import meta.Nameof : /*symbolnameof,*/ prettytypeof, prettynameof; |
|---|
| 60 |
|
|---|
| 61 |
public import std.string : toString; |
|---|
| 62 |
public import std.traits : ParameterTypeTuple, ReturnType; |
|---|
| 63 |
public import meta.Default : minArgs; |
|---|
| 64 |
public import std.metastrings : ToString; |
|---|
| 65 |
} |
|---|