Skip to content

Commit

Permalink
Merge pull request #1926 from 9rnsr/new_alias_syntax
Browse files Browse the repository at this point in the history
Convert to new alias syntax
  • Loading branch information
monarchdodra committed Feb 11, 2014
2 parents 66b3b88 + b391b2e commit 4a7f1a9
Show file tree
Hide file tree
Showing 48 changed files with 1,137 additions and 1,248 deletions.
193 changes: 96 additions & 97 deletions std/algorithm.d

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ a special case in an overload.
ForeachType!Range[] array(Range)(Range r)
if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range)
{
alias ForeachType!Range E;
alias E = ForeachType!Range;
static if (hasLength!Range)
{
if(r.length == 0) return null;
Expand Down Expand Up @@ -243,8 +243,8 @@ auto assocArray(Range)(Range r)
if (isInputRange!Range && isTuple!(ElementType!Range) &&
ElementType!Range.length == 2)
{
alias ElementType!Range.Types[0] KeyType;
alias ElementType!Range.Types[1] ValueType;
alias KeyType = ElementType!Range.Types[0];
alias ValueType = ElementType!Range.Types[1];
ValueType[KeyType] aa;
foreach (t; r)
aa[t[0]] = t[1];
Expand Down Expand Up @@ -364,7 +364,7 @@ if(allSatisfy!(isIntegral, I))
to!string(sizes.length) ~ " dimensions specified for a " ~
to!string(nDimensions!T) ~ " dimensional array.");

alias typeof(T.init[0]) E;
alias E = typeof(T.init[0]);

auto ptr = (__ctfe) ?
{
Expand Down Expand Up @@ -693,7 +693,7 @@ slice, returns that slice. Otherwise, returns the null slice.
*/
inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow
{
alias inout(T) U;
alias U = inout(T);
static U* max(U* a, U* b) nothrow { return a > b ? a : b; }
static U* min(U* a, U* b) nothrow { return a < b ? a : b; }

Expand Down Expand Up @@ -1303,7 +1303,7 @@ returns a new array. For a lazy version, refer to $(XREF range, repeat).
*/
ElementEncodingType!S[] replicate(S)(S s, size_t n) if (isDynamicArray!S)
{
alias ElementEncodingType!S[] RetType;
alias RetType = ElementEncodingType!S[];

// Optimization for return join(std.range.repeat(s, n));
if (n == 0)
Expand Down Expand Up @@ -1529,8 +1529,8 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep)
isInputRange!R &&
is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R)))
{
alias ElementType!RoR RoRElem;
alias typeof(return) RetType;
alias RoRElem = ElementType!RoR;
alias RetType = typeof(return);

if (ror.empty)
return RetType.init;
Expand All @@ -1544,7 +1544,7 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep)
else static if (!isArray!R)
auto sepArr = array(sep);
else
alias sep sepArr;
alias sepArr = sep;

auto result = appender!RetType();
static if(isForwardRange!RoR &&
Expand Down Expand Up @@ -1574,12 +1574,12 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror)
if(isInputRange!RoR &&
isInputRange!(ElementType!RoR))
{
alias typeof(return) RetType;
alias RetType = typeof(return);

if (ror.empty)
return RetType.init;

alias ElementType!RoR R;
alias R = ElementType!RoR;
auto result = appender!RetType();
static if(isForwardRange!RoR && (hasLength!R || isNarrowString!R))
{
Expand Down Expand Up @@ -1692,7 +1692,7 @@ unittest
assert(join([[1, 2], [41, 42]]) == [1, 2, 41, 42]);
assert(join(cast(int[][])[]).empty);

alias filter!"true" f;
alias f = filter!"true";
assert(join([[1, 2], [41, 42]], [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join(f([[1, 2], [41, 42]]), [5, 6]) == [1, 2, 5, 6, 41, 42]);
assert(join([f([1, 2]), f([41, 42])], [5, 6]) == [1, 2, 5, 6, 41, 42]);
Expand Down Expand Up @@ -1792,7 +1792,7 @@ unittest
}
foreach (S; TypeTuple!(string, wstring, dstring, char[], wchar[], dchar[]))
{
alias ElementEncodingType!S Char;
alias Char = ElementEncodingType!S;
S s = to!S("yet another dummy text, yet another ...");
S from = to!S("yet another");
S into = to!S("some");
Expand Down Expand Up @@ -2068,7 +2068,7 @@ unittest
foreach(S; TypeTuple!(string, wstring, dstring, char[], wchar[], dchar[],
const(char[]), immutable(char[])))
{
alias Unqual!S T;
alias T = Unqual!S;

auto s = to!S("This is a foo foo list");
auto from = to!T("foo");
Expand Down Expand Up @@ -2350,7 +2350,7 @@ struct Appender(A : T[], T)
// Const fixing hack.
void put(Range)(Range items) if (canPutConstRange!Range)
{
alias put!(Unqual!Range) p;
alias p = put!(Unqual!Range);
p(items);
}

Expand Down Expand Up @@ -2542,7 +2542,7 @@ struct RefAppender(A : T[], T)
mixin("return impl." ~ fn ~ "(args);");
}

private alias Appender!(A, T) AppenderType;
private alias AppenderType = Appender!(A, T);

/**
* Appends one item to the managed array.
Expand Down
12 changes: 6 additions & 6 deletions std/base64.d
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ version(unittest) import std.algorithm, std.conv, std.file, std.stdio;
/**
* The Base64
*/
alias Base64Impl!('+', '/') Base64;
alias Base64 = Base64Impl!('+', '/');


/**
* The "URL and Filename safe" Base64
*/
alias Base64Impl!('-', '_') Base64URL;
alias Base64URL = Base64Impl!('-', '_');


/**
* Core implementation for Base64 format.
*
* Example:
* -----
* alias Base64Impl!('+', '/') Base64; // The Base64 format(Already defined).
* alias Base64Impl!('!', '=', Base64.NoPadding) Base64Re; // non-standard Base64 format for Regular expression
* alias Base64 = Base64Impl!('+', '/'); // The Base64 format(Already defined).
* alias Base64Re = Base64Impl!('!', '=', Base64.NoPadding); // non-standard Base64 format for Regular expression
* -----
*
* NOTE:
Expand Down Expand Up @@ -1422,7 +1422,7 @@ class Base64Exception : Exception

unittest
{
alias Base64Impl!('!', '=', Base64.NoPadding) Base64Re;
alias Base64Re = Base64Impl!('!', '=', Base64.NoPadding);

// Test vectors from RFC 4648
ubyte[][string] tv = [
Expand Down Expand Up @@ -1646,7 +1646,7 @@ unittest
}

{ // Encoder and Decoder for single character encoding and decoding
alias Base64Impl!('+', '/', Base64.NoPadding) Base64NoPadding;
alias Base64NoPadding = Base64Impl!('+', '/', Base64.NoPadding);

auto tests = [
"" : ["", "", "", ""],
Expand Down
14 changes: 7 additions & 7 deletions std/bitmanip.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private template createAccessors(
{
enum long minVal = -(1uL << (len - 1));
enum ulong maxVal = (1uL << (len - 1)) - 1;
alias Unsigned!(T) UT;
alias UT = Unsigned!(T);
enum UT extendSign = cast(UT)~((~0uL) >> (64 - len));
}
else
Expand Down Expand Up @@ -141,17 +141,17 @@ private template createFields(string store, size_t offset, Ts...)
static if (!Ts.length)
{
static if (offset == ubyte.sizeof * 8)
alias ubyte StoreType;
alias StoreType = ubyte;
else static if (offset == ushort.sizeof * 8)
alias ushort StoreType;
alias StoreType = ushort;
else static if (offset == uint.sizeof * 8)
alias uint StoreType;
alias StoreType = uint;
else static if (offset == ulong.sizeof * 8)
alias ulong StoreType;
alias StoreType = ulong;
else
{
static assert(false, "Field widths must sum to 8, 16, 32, or 64");
alias ulong StoreType; // just to avoid another error msg
alias StoreType = ulong; // just to avoid another error msg
}
enum result = "private " ~ StoreType.stringof ~ " " ~ store ~ ";";
}
Expand Down Expand Up @@ -3347,7 +3347,7 @@ unittest
foreach(endianness; TypeTuple!(Endian.bigEndian, Endian.littleEndian))
{
auto toWrite = appender!(ubyte[])();
alias TypeTuple!(uint, int, long, ulong, short, ubyte, ushort, byte, uint) Types;
alias Types = TypeTuple!(uint, int, long, ulong, short, ubyte, ushort, byte, uint);
ulong[] values = [42, -11, long.max, 1098911981329L, 16, 255, 19012, 2, 17];
assert(Types.length == values.length);

Expand Down
2 changes: 1 addition & 1 deletion std/c/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ version (Windows)
{
uint _beginthread(void function(void *),uint,void *);

extern (Windows) alias uint function (void *) stdfp;
extern (Windows) alias stdfp = uint function (void *);

uint _beginthreadex(void* security, uint stack_size,
stdfp start_addr, void* arglist, uint initflag,
Expand Down
10 changes: 5 additions & 5 deletions std/c/windows/com.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import std.c.windows.windows;
import std.string;

alias WCHAR OLECHAR;
alias OLECHAR *LPOLESTR;
alias OLECHAR *LPCOLESTR;
alias LPOLESTR = OLECHAR*;
alias LPCOLESTR = OLECHAR*;

enum
{
Expand Down Expand Up @@ -65,11 +65,11 @@ enum
COINIT_DISABLE_OLE1DDE = 0x4,
COINIT_SPEED_OVER_MEMORY = 0x8
}
alias DWORD COINIT;
alias COINIT = DWORD;
enum RPC_E_CHANGED_MODE = 0x80010106;

alias const(GUID) IID;
alias const(GUID) CLSID;
alias IID = const(GUID);
alias CLSID = const(GUID);

extern (C)
{
Expand Down
18 changes: 9 additions & 9 deletions std/c/windows/winsock.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ private import std.c.windows.windows;

extern(Windows):

alias size_t SOCKET;
alias int socklen_t;
alias SOCKET = size_t;
alias socklen_t = int;

const SOCKET INVALID_SOCKET = cast(SOCKET)~0;
const int SOCKET_ERROR = -1;
Expand All @@ -32,7 +32,7 @@ struct WSADATA
USHORT iMaxUdpDg;
char* lpVendorInfo;
}
alias WSADATA* LPWSADATA;
alias LPWSADATA = WSADATA*;


const int IOCPARM_MASK = 0x7F;
Expand Down Expand Up @@ -226,7 +226,7 @@ struct fd_set_custom(uint SETSIZE)
SOCKET[SETSIZE] fd_array;
}

alias fd_set_custom!FD_SETSIZE fd_set;
alias fd_set = fd_set_custom!FD_SETSIZE;

// Removes.
void FD_CLR(SOCKET fd, fd_set* set)
Expand Down Expand Up @@ -519,14 +519,14 @@ union in6_addr
uint16_t[8] s6_addr16;
uint32_t[4] s6_addr32;

alias s6_addr8 s6_addr;
alias s6_addr = s6_addr8;
}


const in6_addr IN6ADDR_ANY = { s6_addr8: [0] };
const in6_addr IN6ADDR_LOOPBACK = { s6_addr8: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] };
//alias IN6ADDR_ANY IN6ADDR_ANY_INIT;
//alias IN6ADDR_LOOPBACK IN6ADDR_LOOPBACK_INIT;
//alias IN6ADDR_ANY_INIT = IN6ADDR_ANY;
//alias IN6ADDR_LOOPBACK_INIT = IN6ADDR_LOOPBACK;

const uint INET_ADDRSTRLEN = 16;
const uint INET6_ADDRSTRLEN = 46;
Expand Down Expand Up @@ -587,8 +587,8 @@ struct hostent
}

struct WSAOVERLAPPED;
alias WSAOVERLAPPED* LPWSAOVERLAPPED;
alias void function(DWORD, DWORD, LPWSAOVERLAPPED, DWORD) LPWSAOVERLAPPED_COMPLETION_ROUTINE;
alias LPWSAOVERLAPPED = WSAOVERLAPPED*;
alias LPWSAOVERLAPPED_COMPLETION_ROUTINE = void function(DWORD, DWORD, LPWSAOVERLAPPED, DWORD);
int WSAIoctl(SOCKET s, DWORD dwIoControlCode,
LPVOID lpvInBuffer, DWORD cbInBuffer,
LPVOID lpvOutBuffer, DWORD cbOutBuffer,
Expand Down
8 changes: 4 additions & 4 deletions std/complex.d
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ struct Complex(T) if (isFloatingPoint!T)
// complex op complex
Complex!(CommonType!(T,R)) opBinary(string op, R)(Complex!R z) const
{
alias typeof(return) C;
alias C = typeof(return);
auto w = C(this.re, this.im);
return w.opOpAssign!(op)(z);
}
Expand All @@ -276,7 +276,7 @@ struct Complex(T) if (isFloatingPoint!T)
Complex!(CommonType!(T,R)) opBinary(string op, R)(R r) const
if (isNumeric!R)
{
alias typeof(return) C;
alias C = typeof(return);
auto w = C(this.re, this.im);
return w.opOpAssign!(op)(r);
}
Expand All @@ -300,7 +300,7 @@ struct Complex(T) if (isFloatingPoint!T)
if (op == "/" && isNumeric!R)
{
typeof(return) w;
alias FPTemporary!(typeof(w.re)) Tmp;
alias Tmp = FPTemporary!(typeof(w.re));

if (fabs(re) < fabs(im))
{
Expand Down Expand Up @@ -684,7 +684,7 @@ unittest
*/
template Complex(T) if (is(T R == Complex!R))
{
alias T Complex;
alias Complex = T;
}

unittest
Expand Down
Loading

0 comments on commit 4a7f1a9

Please sign in to comment.