mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
phobos 0.176
This commit is contained in:
parent
00fe9a970d
commit
76dac5da92
18 changed files with 1233 additions and 40 deletions
|
@ -42,6 +42,13 @@ static uint[] prime_list = [
|
|||
1610612741UL, 4294967291UL
|
||||
];
|
||||
|
||||
/* This is the type of the return value for dynamic arrays.
|
||||
* It should be a type that is returned in registers.
|
||||
* Although DMD will return types of Array in registers,
|
||||
* gcc will not, so we instead use a 'long'.
|
||||
*/
|
||||
alias long ArrayRet_t;
|
||||
|
||||
struct Array
|
||||
{
|
||||
size_t length;
|
||||
|
@ -77,7 +84,7 @@ struct AA
|
|||
{
|
||||
// This is here only to retain binary compatibility with the
|
||||
// old way we did AA's. Should eventually be removed.
|
||||
int reserved;
|
||||
//int reserved;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,7 +458,7 @@ void _aaDel(AA aa, TypeInfo keyti, ...)
|
|||
* Produce array of values from aa.
|
||||
*/
|
||||
|
||||
long _aaValues(AA aa, size_t keysize, size_t valuesize)
|
||||
ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize)
|
||||
in
|
||||
{
|
||||
assert(keysize == aligntsize(keysize));
|
||||
|
@ -492,7 +499,7 @@ long _aaValues(AA aa, size_t keysize, size_t valuesize)
|
|||
}
|
||||
assert(resi == a.length);
|
||||
}
|
||||
return *cast(long*)(&a);
|
||||
return *cast(ArrayRet_t*)(&a);
|
||||
}
|
||||
|
||||
|
||||
|
@ -500,7 +507,7 @@ long _aaValues(AA aa, size_t keysize, size_t valuesize)
|
|||
* Rehash an array.
|
||||
*/
|
||||
|
||||
long _aaRehash(AA* paa, TypeInfo keyti)
|
||||
void* _aaRehash(AA* paa, TypeInfo keyti)
|
||||
in
|
||||
{
|
||||
//_aaInvAh(paa);
|
||||
|
@ -587,7 +594,7 @@ long _aaRehash(AA* paa, TypeInfo keyti)
|
|||
|
||||
*paa.a = newb;
|
||||
}
|
||||
return *cast(long*)paa;
|
||||
return (*paa).a;
|
||||
}
|
||||
|
||||
|
||||
|
@ -595,7 +602,7 @@ long _aaRehash(AA* paa, TypeInfo keyti)
|
|||
* Produce array of N byte keys from aa.
|
||||
*/
|
||||
|
||||
long _aaKeys(AA aa, size_t keysize)
|
||||
ArrayRet_t _aaKeys(AA aa, size_t keysize)
|
||||
{
|
||||
byte[] res;
|
||||
size_t resi;
|
||||
|
@ -632,7 +639,7 @@ long _aaKeys(AA aa, size_t keysize)
|
|||
Array a;
|
||||
a.length = len;
|
||||
a.ptr = res;
|
||||
return *cast(long*)(&a);
|
||||
return *cast(ArrayRet_t*)(&a);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ void _Cmul()
|
|||
* ST0 imaginary part
|
||||
*/
|
||||
|
||||
creal _Cdiv()
|
||||
void _Cdiv()
|
||||
{
|
||||
real x_re, x_im;
|
||||
real y_re, y_im;
|
||||
|
@ -166,8 +166,13 @@ creal _Cdiv()
|
|||
q_im = 0.0 * (x_im * y_re - x_re * y_im);
|
||||
}
|
||||
}
|
||||
+/
|
||||
return q_re + q_im * 1.0i;
|
||||
+/
|
||||
asm
|
||||
{
|
||||
fld q_re;
|
||||
fld q_im;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************
|
||||
|
|
|
@ -33,7 +33,9 @@ extern DWORD _except_list;
|
|||
|
||||
#include "mars.h"
|
||||
|
||||
extern ClassInfo _Class_9Exception;
|
||||
extern ClassInfo D9Exception7__ClassZ;
|
||||
|
||||
#define _Class_9Exception D9Exception7__ClassZ
|
||||
|
||||
typedef int (__pascal *fp_t)(); // function pointer in ambient memory model
|
||||
|
||||
|
@ -411,7 +413,9 @@ void _d_monitor_epilog(void *x, void *y, Object *h)
|
|||
|
||||
#include "mars.h"
|
||||
|
||||
extern ClassInfo _Class_9Exception;
|
||||
extern ClassInfo D9Exception7__ClassZ;
|
||||
|
||||
#define _Class_9Exception D9Exception7__ClassZ
|
||||
|
||||
typedef int (*fp_t)(); // function pointer in ambient memory model
|
||||
|
||||
|
|
|
@ -558,7 +558,7 @@ class TypeInfo_AssociativeArray : TypeInfo
|
|||
|
||||
size_t tsize()
|
||||
{
|
||||
return (void[]).sizeof;
|
||||
return (char[int]).sizeof;
|
||||
}
|
||||
|
||||
TypeInfo next;
|
||||
|
|
|
@ -57,7 +57,7 @@ OBJS = asserterror.o deh2.o switch.o complex.o gcstats.o \
|
|||
process.o syserror.o \
|
||||
socket.o socketstream.o stdarg.o stdio.o format.o \
|
||||
perf.o openrj.o uni.o trace.o boxer.o \
|
||||
demangle.o cover.o bitarray.o aApplyR.o \
|
||||
demangle.o cover.o bitarray.o bind.o aApplyR.o \
|
||||
signals.o cpuid.o traits.o typetuple.o \
|
||||
ti_wchar.o ti_uint.o ti_short.o ti_ushort.o \
|
||||
ti_byte.o ti_ubyte.o ti_long.o ti_ulong.o ti_ptr.o \
|
||||
|
@ -94,7 +94,7 @@ SRC_STD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \
|
|||
std/socket.d std/socketstream.d std/loader.d std/stdarg.d \
|
||||
std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \
|
||||
std/boxer.d std/cstream.d std/demangle.d std/cover.d std/bitarray.d \
|
||||
std/signals.d std/cpuid.d std/typetuple.d std/traits.d
|
||||
std/signals.d std/cpuid.d std/typetuple.d std/traits.d std/bind.d
|
||||
|
||||
SRC_STD_C= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d \
|
||||
std/c/math.d std/c/stdarg.d std/c/stddef.d std/c/fenv.d std/c/string.d \
|
||||
|
@ -307,6 +307,9 @@ asserterror.o : std/asserterror.d
|
|||
base64.o : std/base64.d
|
||||
$(DMD) -c $(DFLAGS) std/base64.d
|
||||
|
||||
bind.o : std/bind.d
|
||||
$(DMD) -c $(DFLAGS) std/bind.d
|
||||
|
||||
bitarray.o : std/bitarray.d
|
||||
$(DMD) -c $(DFLAGS) std/bitarray.d
|
||||
|
||||
|
@ -601,4 +604,4 @@ zip : $(ALLSRCS) linux.mak win32.mak phoboslicense.txt
|
|||
zip phobos $(ALLSRCS) linux.mak win32.mak phoboslicense.txt
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) unittest unittest.o
|
||||
$(RM) libphobos.a $(OBJS) unittest unittest.o
|
||||
|
|
6
phobos.d
6
phobos.d
|
@ -124,6 +124,12 @@ D language compiler. Also, check out the
|
|||
<dt><a href="std_base64.html"><b>std.base64</b></a>
|
||||
<dd>Encode/decode base64 format.
|
||||
|
||||
<dt><a href="std_bind.html"><b>std.bind</b></a>
|
||||
<dd>Bind function arguments.
|
||||
|
||||
<dt><a href="std_bitarray.html"><b>std.bitarray</b></a>
|
||||
<dd>Arrays of bits.
|
||||
|
||||
<dt><a href="std_boxer.html"><b>std.boxer</b></a>
|
||||
<dd>Box/unbox types.
|
||||
|
||||
|
|
1
std.ddoc
1
std.ddoc
|
@ -111,6 +111,7 @@ NAVIGATION_PHOBOS=
|
|||
<h2><a href="phobos.html#std" title="D standard modules">std</a></h2>
|
||||
$(UL
|
||||
$(LI <a href="std_base64.html" title="Encode/decode base64 format">std.base64</a>)
|
||||
$(LI <a href="std_bind" title="Function argument binding">std.bind</a>)
|
||||
$(LI <a href="std_bitarray.html" title="Arrays of bits">std.bitarray</a>)
|
||||
$(LI <a href="std_boxer.html" title="Box/unbox types">std.boxer</a>)
|
||||
$(LI <a href="std_compiler.html" title="Information about the D compiler implementation">std.compiler</a>)
|
||||
|
|
1053
std/bind.d
Normal file
1053
std/bind.d
Normal file
File diff suppressed because it is too large
Load diff
|
@ -173,6 +173,10 @@ extern (C)
|
|||
tm* gmtime(__time_t*);
|
||||
tm* localtime(__time_t*);
|
||||
__time_t mktime(tm*);
|
||||
char* asctime_r(tm* t, char* buf);
|
||||
char* ctime_r(__time_t* timep, char* buf);
|
||||
tm* gmtime_r(__time_t* timep, tm* result);
|
||||
tm* localtime_r(__time_t* timep, tm* result);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
|
|
@ -35,6 +35,8 @@ int setsockopt(int s, int level, int optname, void* optval, int optlen);
|
|||
uint inet_addr(char* cp);
|
||||
char* inet_ntoa(in_addr ina);
|
||||
hostent* gethostbyname(char* name);
|
||||
int gethostbyname_r(char* name, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop);
|
||||
int gethostbyname2_r(char* name, int af, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop);
|
||||
hostent* gethostbyaddr(void* addr, int len, int type);
|
||||
protoent* getprotobyname(char* name);
|
||||
protoent* getprotobynumber(int number);
|
||||
|
@ -46,6 +48,7 @@ void freeaddrinfo(addrinfo* ai);
|
|||
int getnameinfo(sockaddr* sa, socklen_t salen, char* node, socklen_t nodelen, char* service, socklen_t servicelen, int flags);
|
||||
|
||||
|
||||
|
||||
enum: int
|
||||
{
|
||||
AF_UNSPEC = 0,
|
||||
|
|
|
@ -33,13 +33,13 @@ const
|
|||
* version_major.version_minor
|
||||
*/
|
||||
uint version_major = 0;
|
||||
uint version_minor = 0; /// ditto
|
||||
uint version_minor = 176; /// ditto
|
||||
|
||||
|
||||
/**
|
||||
* The version of the D Programming Language Specification
|
||||
* supported by the compiler.
|
||||
*/
|
||||
uint D_major = 0;
|
||||
uint D_minor = 134;
|
||||
uint D_major = 1;
|
||||
uint D_minor = 0;
|
||||
}
|
||||
|
|
32
std/math.d
32
std/math.d
|
@ -347,24 +347,24 @@ real atan(real x) { return std.c.math.atanl(x); }
|
|||
* Calculates the arc tangent of y / x,
|
||||
* returning a value ranging from -π/2 to π/2.
|
||||
*
|
||||
* $(TABLE_SV
|
||||
* <tr> <th> x <th> y <th> atan(x, y)
|
||||
* <tr> <td> $(NAN) <td> anything <td> $(NAN)
|
||||
* <tr> <td> anything <td> $(NAN) <td> $(NAN)
|
||||
* <tr> <td> ±0.0 <td> > 0.0 <td> ±0.0
|
||||
* <tr> <td> ±0.0 <td> ±0.0 <td> ±0.0
|
||||
* <tr> <td> ±0.0 <td> < 0.0 <td> ±π
|
||||
* <tr> <td> ±0.0 <td> -0.0 <td> ±π
|
||||
* <tr> <td> > 0.0 <td> ±0.0 <td> π/2
|
||||
* <tr> <td> < 0.0 <td> ±0.0 <td> π/2
|
||||
* <tr> <td> > 0.0 <td> ∞ <td> ±0.0
|
||||
* <tr> <td> ±∞ <td> anything <td> ±π/2
|
||||
* <tr> <td> > 0.0 <td> -∞ <td> ±π
|
||||
* <tr> <td> ±∞ <td> ∞ <td> ±π/4
|
||||
* <tr> <td> ±∞ <td> -∞ <td> ±3π/4
|
||||
* $(TABLE_SV
|
||||
* <tr> <th> y <th> x <th> atan(y, x)
|
||||
* <tr> <td> $(NAN) <td> anything <td> $(NAN)
|
||||
* <tr> <td> anything <td> $(NAN) <td> $(NAN)
|
||||
* <tr> <td> ±0.0 <td> > 0.0 <td> ±0.0
|
||||
* <tr> <td> ±0.0 <td> ±0.0 <td> ±0.0
|
||||
* <tr> <td> ±0.0 <td> < 0.0 <td> ±π
|
||||
* <tr> <td> ±0.0 <td> -0.0 <td> ±π
|
||||
* <tr> <td> > 0.0 <td> ±0.0 <td> π/2
|
||||
* <tr> <td> < 0.0 <td> ±0.0 <td> π/2
|
||||
* <tr> <td> > 0.0 <td> ∞ <td> ±0.0
|
||||
* <tr> <td> ±∞ <td> anything <td> ±π/2
|
||||
* <tr> <td> > 0.0 <td> -∞ <td> ±π
|
||||
* <tr> <td> ±∞ <td> ∞ <td> ±π/4
|
||||
* <tr> <td> ±∞ <td> -∞ <td> ±3π/4
|
||||
* )
|
||||
*/
|
||||
real atan2(real x, real y) { return std.c.math.atan2l(x,y); }
|
||||
real atan2(real y, real x) { return std.c.math.atan2l(y,x); }
|
||||
|
||||
/***********************************
|
||||
* Calculates the hyperbolic cosine of x.
|
||||
|
|
44
std/socket.d
44
std/socket.d
|
@ -1593,3 +1593,47 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ const dchar PS = '\u2029'; /// UTF paragraph separator
|
|||
version (Windows)
|
||||
const char[2] newline = "\r\n";
|
||||
else version (linux)
|
||||
const char[2] newline = "\n";
|
||||
const char[1] newline = "\n";
|
||||
|
||||
/**********************************
|
||||
* Returns !=0 if c is whitespace
|
||||
|
|
58
std/traits.d
58
std/traits.d
|
@ -11,8 +11,10 @@
|
|||
* Public Domain
|
||||
*/
|
||||
|
||||
/* Author:
|
||||
/*
|
||||
* Authors:
|
||||
* Walter Bright, Digital Mars, www.digitalmars.com
|
||||
* Tomasz Stachowiak (isStaticArray, isExpressionTuple)
|
||||
*/
|
||||
|
||||
module std.traits;
|
||||
|
@ -125,3 +127,57 @@ unittest
|
|||
assert(is (TL[1] == I));
|
||||
}
|
||||
|
||||
/* *******************************************
|
||||
*/
|
||||
template isStaticArray_impl(T)
|
||||
{
|
||||
const T inst = void;
|
||||
|
||||
static if (is(typeof(T.length)))
|
||||
{
|
||||
static if (!is(typeof(T) == typeof(T.init)))
|
||||
{ // abuses the fact that int[5].init == int
|
||||
static if (is(T == typeof(T[0])[inst.length]))
|
||||
{ // sanity check. this check alone isn't enough because dmd complains about dynamic arrays
|
||||
const bool res = true;
|
||||
}
|
||||
else
|
||||
const bool res = false;
|
||||
}
|
||||
else
|
||||
const bool res = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool res = false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Detect whether type T is a static array.
|
||||
*/
|
||||
template isStaticArray(T)
|
||||
{
|
||||
const bool isStaticArray = isStaticArray_impl!(T).res;
|
||||
}
|
||||
|
||||
|
||||
static assert (isStaticArray!(int[51]));
|
||||
static assert (isStaticArray!(int[][2]));
|
||||
static assert (isStaticArray!(char[][int][11]));
|
||||
static assert (!isStaticArray!(int[]));
|
||||
static assert (!isStaticArray!(int[char]));
|
||||
static assert (!isStaticArray!(int[1][]));
|
||||
|
||||
/**
|
||||
* Tells whether the tuple T is an expression tuple.
|
||||
*/
|
||||
template isExpressionTuple(T ...)
|
||||
{
|
||||
static if (is(void function(T)))
|
||||
const bool isExpressionTuple = false;
|
||||
else
|
||||
const bool isExpressionTuple = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class TypeInfo_Av : TypeInfo_Ah
|
|||
|
||||
// bool[]
|
||||
|
||||
class TypeInfo_Ax : TypeInfo_Ah
|
||||
class TypeInfo_Ab : TypeInfo_Ah
|
||||
{
|
||||
char[] toString() { return "bool[]"; }
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class TypeInfo_h : TypeInfo
|
|||
}
|
||||
}
|
||||
|
||||
class TypeInfo_x : TypeInfo_h
|
||||
class TypeInfo_b : TypeInfo_h
|
||||
{
|
||||
char[] toString() { return "bool"; }
|
||||
}
|
||||
|
|
11
win32.mak
11
win32.mak
|
@ -74,7 +74,7 @@ OBJS= asserterror.obj deh.obj switch.obj complex.obj gcstats.obj \
|
|||
perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \
|
||||
errno.obj boxer.obj cstream.obj charset.obj \
|
||||
gamma.obj demangle.obj cover.obj bitarray.obj aApplyR.obj \
|
||||
signals.obj cpuid.obj typetuple.obj traits.obj \
|
||||
signals.obj cpuid.obj typetuple.obj traits.obj bind.obj \
|
||||
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
||||
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
||||
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
||||
|
@ -95,6 +95,7 @@ DOCS= $(DOC)\std_path.html $(DOC)\std_math.html $(DOC)\std_outbuffer.html \
|
|||
$(DOC)\object.html $(DOC)\std_compiler.html $(DOC)\std_format.html \
|
||||
$(DOC)\std_random.html $(DOC)\std_file.html $(DOC)\std_date.html \
|
||||
$(DOC)\std_md5.html $(DOC)\std_zip.html $(DOC)\std_zlib.html \
|
||||
$(DOC)\std_bind.html \
|
||||
$(DOC)\std_bitarray.html \
|
||||
$(DOC)\std_conv.html \
|
||||
$(DOC)\std_boxer.html \
|
||||
|
@ -148,7 +149,7 @@ SRC_STD= std\zlib.d std\zip.d std\stdint.d std\conv.d std\utf.d std\uri.d \
|
|||
std\socket.d std\socketstream.d std\loader.d std\stdarg.d std\format.d \
|
||||
std\stdio.d std\perf.d std\openrj.d std\uni.d std\boxer.d \
|
||||
std\cstream.d std\demangle.d std\cover.d std\bitarray.d \
|
||||
std\signals.d std\cpuid.d std\typetuple.d std\traits.d
|
||||
std\signals.d std\cpuid.d std\typetuple.d std\traits.d std\bind.d
|
||||
|
||||
SRC_STD_C= std\c\process.d std\c\stdlib.d std\c\time.d std\c\stdio.d \
|
||||
std\c\math.d std\c\stdarg.d std\c\stddef.d std\c\fenv.d std\c\string.d \
|
||||
|
@ -339,6 +340,9 @@ asserterror.obj : std\asserterror.d
|
|||
base64.obj : std\base64.d
|
||||
$(DMD) -c $(DFLAGS) -inline std\base64.d
|
||||
|
||||
bind.obj : std\bind.d
|
||||
$(DMD) -c $(DFLAGS) -inline std\bind.d
|
||||
|
||||
bitarray.obj : std\bitarray.d
|
||||
$(DMD) -c $(DFLAGS) -inline std\bitarray.d
|
||||
|
||||
|
@ -663,6 +667,9 @@ $(DOC)\phobos.html : std.ddoc phobos.d
|
|||
$(DOC)\std_base64.html : std.ddoc std\base64.d
|
||||
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_base64.html std.ddoc std\base64.d
|
||||
|
||||
$(DOC)\std_bind.html : std.ddoc std\bind.d
|
||||
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_bind.html std.ddoc std\bind.d
|
||||
|
||||
$(DOC)\std_bitarray.html : std.ddoc std\bitarray.d
|
||||
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_bitarray.html std.ddoc std\bitarray.d
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue