mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 07:00:37 +03:00
phobos 0.175
This commit is contained in:
parent
e001ab7bfe
commit
00fe9a970d
8 changed files with 184 additions and 48 deletions
|
@ -324,6 +324,16 @@ class TypeInfo
|
||||||
class TypeInfo_Typedef : TypeInfo
|
class TypeInfo_Typedef : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return name; }
|
char[] toString() { return name; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Typedef c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Typedef)o) !is null &&
|
||||||
|
this.name == c.name &&
|
||||||
|
this.base == c.base);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p) { return base.getHash(p); }
|
hash_t getHash(void *p) { return base.getHash(p); }
|
||||||
int equals(void *p1, void *p2) { return base.equals(p1, p2); }
|
int equals(void *p1, void *p2) { return base.equals(p1, p2); }
|
||||||
int compare(void *p1, void *p2) { return base.compare(p1, p2); }
|
int compare(void *p1, void *p2) { return base.compare(p1, p2); }
|
||||||
|
@ -342,6 +352,14 @@ class TypeInfo_Pointer : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return next.toString() ~ "*"; }
|
char[] toString() { return next.toString() ~ "*"; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Pointer c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Pointer)o) !is null &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{
|
{
|
||||||
return cast(uint)*cast(void* *)p;
|
return cast(uint)*cast(void* *)p;
|
||||||
|
@ -376,6 +394,14 @@ class TypeInfo_Array : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return next.toString() ~ "[]"; }
|
char[] toString() { return next.toString() ~ "[]"; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Array c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Array)o) !is null &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{ size_t sz = next.tsize();
|
{ size_t sz = next.tsize();
|
||||||
hash_t hash = 0;
|
hash_t hash = 0;
|
||||||
|
@ -440,6 +466,15 @@ class TypeInfo_StaticArray : TypeInfo
|
||||||
return next.toString() ~ "[" ~ std.string.toString(len) ~ "]";
|
return next.toString() ~ "[" ~ std.string.toString(len) ~ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_StaticArray c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_StaticArray)o) !is null &&
|
||||||
|
this.len == c.len &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{ size_t sz = next.tsize();
|
{ size_t sz = next.tsize();
|
||||||
hash_t hash = 0;
|
hash_t hash = 0;
|
||||||
|
@ -510,6 +545,15 @@ class TypeInfo_AssociativeArray : TypeInfo
|
||||||
return next.toString() ~ "[" ~ key.toString() ~ "]";
|
return next.toString() ~ "[" ~ key.toString() ~ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_AssociativeArray c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_AssociativeArray)o) !is null &&
|
||||||
|
this.key == c.key &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
// BUG: need to add the rest of the functions
|
// BUG: need to add the rest of the functions
|
||||||
|
|
||||||
size_t tsize()
|
size_t tsize()
|
||||||
|
@ -528,6 +572,14 @@ class TypeInfo_Function : TypeInfo
|
||||||
return next.toString() ~ "()";
|
return next.toString() ~ "()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Function c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Function)o) !is null &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
// BUG: need to add the rest of the functions
|
// BUG: need to add the rest of the functions
|
||||||
|
|
||||||
size_t tsize()
|
size_t tsize()
|
||||||
|
@ -545,6 +597,14 @@ class TypeInfo_Delegate : TypeInfo
|
||||||
return next.toString() ~ " delegate()";
|
return next.toString() ~ " delegate()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Delegate c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Delegate)o) !is null &&
|
||||||
|
this.next == c.next);
|
||||||
|
}
|
||||||
|
|
||||||
// BUG: need to add the rest of the functions
|
// BUG: need to add the rest of the functions
|
||||||
|
|
||||||
size_t tsize()
|
size_t tsize()
|
||||||
|
@ -559,6 +619,14 @@ class TypeInfo_Class : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return info.name; }
|
char[] toString() { return info.name; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Class c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Class)o) !is null &&
|
||||||
|
this.info.name == c.classinfo.name);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{
|
{
|
||||||
Object o = *cast(Object*)p;
|
Object o = *cast(Object*)p;
|
||||||
|
@ -607,6 +675,14 @@ class TypeInfo_Interface : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return info.name; }
|
char[] toString() { return info.name; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Interface c;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((c = cast(TypeInfo_Interface)o) !is null &&
|
||||||
|
this.info.name == c.classinfo.name);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{
|
{
|
||||||
Interface* pi = **cast(Interface ***)*cast(void**)p;
|
Interface* pi = **cast(Interface ***)*cast(void**)p;
|
||||||
|
@ -660,6 +736,15 @@ class TypeInfo_Struct : TypeInfo
|
||||||
{
|
{
|
||||||
char[] toString() { return name; }
|
char[] toString() { return name; }
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{ TypeInfo_Struct s;
|
||||||
|
|
||||||
|
return this is o ||
|
||||||
|
((s = cast(TypeInfo_Struct)o) !is null &&
|
||||||
|
this.name == s.name &&
|
||||||
|
this.xsize == s.xsize);
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{ hash_t h;
|
{ hash_t h;
|
||||||
|
|
||||||
|
@ -751,6 +836,24 @@ class TypeInfo_Tuple : TypeInfo
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opEquals(Object o)
|
||||||
|
{
|
||||||
|
if (this is o)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
auto t = cast(TypeInfo_Tuple)o;
|
||||||
|
if (t && elements.length == t.elements.length)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < elements.length; i++)
|
||||||
|
{
|
||||||
|
if (elements[i] != t.elements[i])
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
2
std.ddoc
2
std.ddoc
|
@ -144,6 +144,8 @@ NAVIGATION_PHOBOS=
|
||||||
$(LI <a href="std_string.html" title="Basic string operations">std.string</a>)
|
$(LI <a href="std_string.html" title="Basic string operations">std.string</a>)
|
||||||
$(LI <a href="std_system.html" title="Inquire about the CPU, operating system">std.system</a>)
|
$(LI <a href="std_system.html" title="Inquire about the CPU, operating system">std.system</a>)
|
||||||
$(LI <a href="std_thread.html" title="Thread operations">std.thread</a>)
|
$(LI <a href="std_thread.html" title="Thread operations">std.thread</a>)
|
||||||
|
$(LI <a href="std_traits.html" title="Type traits">std.traits</a>)
|
||||||
|
$(LI <a href="std_typetuple.html" title="Type tuples">std.typetuple</a>)
|
||||||
$(LI <a href="std_uni.html" title="Unicode classification">std.uni</a>)
|
$(LI <a href="std_uni.html" title="Unicode classification">std.uni</a>)
|
||||||
$(LI <a href="std_uri.html" title="Encode and decode Uniform Resource Identifiers (URIs)">std.uri</a>)
|
$(LI <a href="std_uri.html" title="Encode and decode Uniform Resource Identifiers (URIs)">std.uri</a>)
|
||||||
$(LI <a href="std_utf.html" title="Encode and decode utf character encodings">std.utf</a>)
|
$(LI <a href="std_utf.html" title="Encode and decode utf character encodings">std.utf</a>)
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
|
|
||||||
|
// Written in the D programming language.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Placed into the Public Domain.
|
||||||
|
*/
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* Demangle D mangled names.
|
* Demangle D mangled names.
|
||||||
* Macros:
|
* Macros:
|
||||||
* WIKI = Phobos/StdDemangle
|
* WIKI = Phobos/StdDemangle
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Author:
|
/* Authors:
|
||||||
* Walter Bright, Digital Mars, www.digitalmars.com
|
* Walter Bright, Digital Mars, www.digitalmars.com
|
||||||
|
* Thomas Kuehne
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module std.demangle;
|
module std.demangle;
|
||||||
|
@ -234,6 +242,11 @@ char[] demangle(char[] name)
|
||||||
char c = name[ni];
|
char c = name[ni];
|
||||||
if (c == 'Z')
|
if (c == 'Z')
|
||||||
break;
|
break;
|
||||||
|
if (c == 'X')
|
||||||
|
{
|
||||||
|
args ~= " ...";
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (args.length)
|
if (args.length)
|
||||||
args ~= ", ";
|
args ~= ", ";
|
||||||
switch (c)
|
switch (c)
|
||||||
|
@ -248,6 +261,11 @@ char[] demangle(char[] name)
|
||||||
ni++;
|
ni++;
|
||||||
goto default;
|
goto default;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
args ~= "lazy ";
|
||||||
|
ni++;
|
||||||
|
goto default;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
args ~= parseType();
|
args ~= parseType();
|
||||||
continue;
|
continue;
|
||||||
|
@ -472,6 +490,9 @@ unittest
|
||||||
[ "_D4test58__T9factorialVde67666666666666860140VG5aa5_68656c6c6fVPvnZ9factorialf", "float test.factorial!(double 4.2, char[5] \"hello\"c, void* null).factorial" ],
|
[ "_D4test58__T9factorialVde67666666666666860140VG5aa5_68656c6c6fVPvnZ9factorialf", "float test.factorial!(double 4.2, char[5] \"hello\"c, void* null).factorial" ],
|
||||||
[ "_D4test101__T9factorialVde67666666666666860140Vrc9a999999999999d9014000000000000000c00040VG5aa5_68656c6c6fVPvnZ9factorialf", "float test.factorial!(double 4.2, cdouble 6.8+3i, char[5] \"hello\"c, void* null).factorial" ],
|
[ "_D4test101__T9factorialVde67666666666666860140Vrc9a999999999999d9014000000000000000c00040VG5aa5_68656c6c6fVPvnZ9factorialf", "float test.factorial!(double 4.2, cdouble 6.8+3i, char[5] \"hello\"c, void* null).factorial" ],
|
||||||
[ "_D4test34__T3barVG3uw3_616263VG3wd3_646566Z1xi", "int test.bar!(wchar[3] \"abc\"w, dchar[3] \"def\"d).x" ],
|
[ "_D4test34__T3barVG3uw3_616263VG3wd3_646566Z1xi", "int test.bar!(wchar[3] \"abc\"w, dchar[3] \"def\"d).x" ],
|
||||||
|
[ "_D8demangle4testFLC6ObjectLDFLiZiZi", "int demangle.test(lazy class Object, lazy int delegate(lazy int))"],
|
||||||
|
[ "_D8demangle4testFAiXi", "int demangle.test(int[] ...)"],
|
||||||
|
[ "_D8demangle4testFLAiXi", "int demangle.test(lazy int[] ...)"]
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach (char[][2] name; table)
|
foreach (char[][2] name; table)
|
||||||
|
@ -481,3 +502,5 @@ unittest
|
||||||
assert(r == name[1]);
|
assert(r == name[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -696,6 +696,9 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
|
|
||||||
case Mangle.Tclass:
|
case Mangle.Tclass:
|
||||||
vobject = va_arg!(Object)(argptr);
|
vobject = va_arg!(Object)(argptr);
|
||||||
|
if (vobject is null)
|
||||||
|
s = "null";
|
||||||
|
else
|
||||||
s = vobject.toString();
|
s = vobject.toString();
|
||||||
goto Lputstr;
|
goto Lputstr;
|
||||||
|
|
||||||
|
@ -1363,5 +1366,9 @@ unittest
|
||||||
assert(r == "f");
|
assert(r == "f");
|
||||||
r = std.string.format("%X", 15);
|
r = std.string.format("%X", 15);
|
||||||
assert(r == "F");
|
assert(r == "F");
|
||||||
|
|
||||||
|
Object c = null;
|
||||||
|
r = std.string.format(c);
|
||||||
|
assert(r == "null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
44
std/socket.d
44
std/socket.d
|
@ -1593,47 +1593,3 @@ class Socket
|
||||||
+/
|
+/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// TcpSocket is a shortcut class for a TCP Socket.
|
|
||||||
class TcpSocket: Socket
|
|
||||||
{
|
|
||||||
/// Constructs a blocking TCP Socket.
|
|
||||||
this(AddressFamily family)
|
|
||||||
{
|
|
||||||
super(family, SocketType.STREAM, ProtocolType.TCP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Constructs a blocking TCP Socket.
|
|
||||||
this()
|
|
||||||
{
|
|
||||||
this(cast(AddressFamily)AddressFamily.INET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//shortcut
|
|
||||||
/// Constructs a blocking TCP Socket and connects to an InternetAddress.
|
|
||||||
this(Address connectTo)
|
|
||||||
{
|
|
||||||
this(connectTo.addressFamily());
|
|
||||||
connect(connectTo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// UdpSocket is a shortcut class for a UDP Socket.
|
|
||||||
class UdpSocket: Socket
|
|
||||||
{
|
|
||||||
/// Constructs a blocking UDP Socket.
|
|
||||||
this(AddressFamily family)
|
|
||||||
{
|
|
||||||
super(family, SocketType.DGRAM, ProtocolType.UDP);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Constructs a blocking UDP Socket.
|
|
||||||
this()
|
|
||||||
{
|
|
||||||
this(cast(AddressFamily)AddressFamily.INET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
// Written in the D programming language.
|
||||||
|
|
||||||
/* Written by Walter Bright
|
/* Written by Walter Bright
|
||||||
* www.digitalmars.com
|
* www.digitalmars.com
|
||||||
* Placed in the Public Domain.
|
* Placed in the Public Domain.
|
||||||
|
|
40
std/traits.d
40
std/traits.d
|
@ -85,3 +85,43 @@ template FieldTypeTuple(S)
|
||||||
else
|
else
|
||||||
static assert(0, "argument is not struct or class");
|
static assert(0, "argument is not struct or class");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Get a TypeTuple of the base class and base interfaces of
|
||||||
|
* this class or interface.
|
||||||
|
* Example:
|
||||||
|
* ---
|
||||||
|
* import std.traits, std.typetuple, std.stdio;
|
||||||
|
* interface I { }
|
||||||
|
* class A { }
|
||||||
|
* class B : A, I { }
|
||||||
|
*
|
||||||
|
* void main()
|
||||||
|
* {
|
||||||
|
* alias BaseTypeTuple!(B) TL;
|
||||||
|
* writefln(typeid(TL)); // prints: (A,I)
|
||||||
|
* }
|
||||||
|
* ---
|
||||||
|
*/
|
||||||
|
|
||||||
|
template BaseTypeTuple(A)
|
||||||
|
{
|
||||||
|
static if (is(A P == super))
|
||||||
|
alias P BaseTypeTuple;
|
||||||
|
else
|
||||||
|
static assert(0, "argument is not a class or interface");
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
interface I { }
|
||||||
|
class A { }
|
||||||
|
class B : A, I { }
|
||||||
|
|
||||||
|
alias BaseTypeTuple!(B) TL;
|
||||||
|
assert(TL.length == 2);
|
||||||
|
assert(is (TL[0] == A));
|
||||||
|
assert(is (TL[1] == I));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
|
||||||
|
// Written in the D programming language.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Placed into the Public Domain.
|
* Placed into the Public Domain.
|
||||||
* Digital Mars, www.digitalmars.com
|
* Digital Mars, www.digitalmars.com
|
||||||
|
@ -52,7 +55,7 @@ dchar toUniLower(dchar c)
|
||||||
{
|
{
|
||||||
c += 32;
|
c += 32;
|
||||||
}
|
}
|
||||||
if (c >= 0x00C0)
|
else if (c >= 0x00C0)
|
||||||
{
|
{
|
||||||
if ((c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE))
|
if ((c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE))
|
||||||
{
|
{
|
||||||
|
@ -118,7 +121,7 @@ dchar toUniUpper(dchar c)
|
||||||
{
|
{
|
||||||
c -= 32;
|
c -= 32;
|
||||||
}
|
}
|
||||||
if (c >= 0x00E0)
|
else if (c >= 0x00E0)
|
||||||
{
|
{
|
||||||
if ((c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE))
|
if ((c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue