Permalink
Browse files

phobos 2.001

  • Loading branch information...
1 parent 9d8828a commit 52f3c4c4dd4b124d666aabc1aadc0ac9dc944849 @braddr braddr committed Sep 10, 2007
View
@@ -378,13 +378,13 @@ class TypeInfo
}
/// Returns a hash of the instance of a type.
- hash_t getHash(void *p) { return cast(uint)p; }
+ hash_t getHash(in void *p) { return cast(uint)p; }
/// Compares two instances for equality.
- int equals(void *p1, void *p2) { return cast(int)(p1 == p2); }
+ int equals(in void *p1, in void *p2) { return cast(int)(p1 == p2); }
/// Compares two instances for <, ==, or >.
- int compare(void *p1, void *p2) { return 0; }
+ int compare(in void *p1, in void *p2) { return 0; }
/// Returns size of the type.
size_t tsize() { return 0; }
@@ -430,9 +430,9 @@ class TypeInfo_Typedef : TypeInfo
this.base == c.base));
}
- hash_t getHash(void *p) { return base.getHash(p); }
- int equals(void *p1, void *p2) { return base.equals(p1, p2); }
- int compare(void *p1, void *p2) { return base.compare(p1, p2); }
+ hash_t getHash(in void *p) { return base.getHash(p); }
+ int equals(in void *p1, in void *p2) { return base.equals(p1, p2); }
+ int compare(in void *p1, in void *p2) { return base.compare(p1, p2); }
size_t tsize() { return base.tsize(); }
void swap(void *p1, void *p2) { return base.swap(p1, p2); }
@@ -461,17 +461,17 @@ class TypeInfo_Pointer : TypeInfo
this.m_next == c.m_next);
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{
return cast(uint)*cast(void* *)p;
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
return cast(int)(*cast(void* *)p1 == *cast(void* *)p2);
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
if (*cast(void* *)p1 < *cast(void* *)p2)
return -1;
@@ -512,7 +512,7 @@ class TypeInfo_Array : TypeInfo
this.value == c.value));
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{ size_t sz = value.tsize();
hash_t hash = 0;
void[] a = *cast(void[]*)p;
@@ -521,7 +521,7 @@ class TypeInfo_Array : TypeInfo
return hash;
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
@@ -536,7 +536,7 @@ class TypeInfo_Array : TypeInfo
return 1;
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
@@ -593,15 +593,15 @@ class TypeInfo_StaticArray : TypeInfo
this.value == c.value));
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{ size_t sz = value.tsize();
hash_t hash = 0;
for (size_t i = 0; i < len; i++)
hash += value.getHash(p + i * sz);
return hash;
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
size_t sz = value.tsize();
@@ -613,7 +613,7 @@ class TypeInfo_StaticArray : TypeInfo
return 1;
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
size_t sz = value.tsize();
@@ -754,22 +754,22 @@ class TypeInfo_Class : TypeInfo
this.info.name == c.classinfo.name);
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{
Object o = *cast(Object*)p;
assert(o);
return o.toHash();
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return (o1 is o2) || (o1 && o1.opEquals(o2));
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
@@ -817,15 +817,15 @@ class TypeInfo_Interface : TypeInfo
this.info.name == c.classinfo.name);
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{
Interface* pi = **cast(Interface ***)*cast(void**)p;
Object o = cast(Object)(*cast(void**)p - pi.offset);
assert(o);
return o.toHash();
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
@@ -835,7 +835,7 @@ class TypeInfo_Interface : TypeInfo
return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
@@ -881,7 +881,7 @@ class TypeInfo_Struct : TypeInfo
this.init.length == s.init.length);
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{ hash_t h;
assert(p);
@@ -895,15 +895,16 @@ class TypeInfo_Struct : TypeInfo
// A sorry hash algorithm.
// Should use the one for strings.
// BUG: relies on the GC not moving objects
+ auto q = p;
for (size_t i = 0; i < init.length; i++)
- { h = h * 9 + *cast(ubyte*)p;
- p++;
+ { h = h * 9 + *cast(ubyte*)q;
+ q++;
}
}
return h;
}
- int equals(void *p2, void *p1)
+ int equals(in void *p2, in void *p1)
{ int c;
if (p1 == p2)
@@ -918,7 +919,7 @@ class TypeInfo_Struct : TypeInfo
return c;
}
- int compare(void *p2, void *p1)
+ int compare(in void *p2, in void *p1)
{
int c = 0;
@@ -952,10 +953,10 @@ class TypeInfo_Struct : TypeInfo
string name;
void[] m_init; // initializer; init.ptr == null if 0 initialize
- hash_t function(void*) xtoHash;
- int function(void*,void*) xopEquals;
- int function(void*,void*) xopCmp;
- string function(void*) xtoString;
+ hash_t function(in void*) xtoHash;
+ int function(in void*, in void*) xopEquals;
+ int function(in void*, in void*) xopCmp;
+ string function(const(void)*) xtoString;
uint m_flags;
}
@@ -996,17 +997,17 @@ class TypeInfo_Tuple : TypeInfo
return 0;
}
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{
assert(0);
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
assert(0);
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
assert(0);
}
@@ -1027,9 +1028,9 @@ class TypeInfo_Const : TypeInfo
string toString() { return "const " ~ base.toString(); }
int opEquals(Object o) { return base.opEquals(o); }
- hash_t getHash(void *p) { return base.getHash(p); }
- int equals(void *p1, void *p2) { return base.equals(p1, p2); }
- int compare(void *p1, void *p2) { return base.compare(p1, p2); }
+ hash_t getHash(in void *p) { return base.getHash(p); }
+ int equals(in void *p1, in void *p2) { return base.equals(p1, p2); }
+ int compare(in void *p1, in void *p2) { return base.compare(p1, p2); }
size_t tsize() { return base.tsize(); }
void swap(void *p1, void *p2) { return base.swap(p1, p2); }
View
@@ -68,9 +68,9 @@ struct OffsetTypeInfo
class TypeInfo
{
- hash_t getHash(void *p);
- int equals(void *p1, void *p2);
- int compare(void *p1, void *p2);
+ hash_t getHash(in void *p);
+ int equals(in void *p1, in void *p2);
+ int compare(in void *p1, in void *p2);
size_t tsize();
void swap(void *p1, void *p2);
TypeInfo next();
@@ -138,10 +138,10 @@ class TypeInfo_Struct : TypeInfo
string name;
void[] m_init;
- uint function(void*) xtoHash;
- int function(void*,void*) xopEquals;
- int function(void*,void*) xopCmp;
- string function(void*) xtoString;
+ uint function(in void*) xtoHash;
+ int function(in void*, in void*) xopEquals;
+ int function(in void*, in void*) xopCmp;
+ string function(const(void)*) xtoString;
uint m_flags;
}
View
@@ -234,17 +234,17 @@ struct Box
* This is initially null and cannot be assigned directly.
* Returns: the type of the contained object.
*/
- TypeInfo type()
+ const TypeInfo type()
{
- return p_type;
+ return cast(TypeInfo)p_type;
}
/**
* Property for the data pointer to the value of the box.
* This is initially null and cannot be assigned directly.
* Returns: the data array.
*/
- void[] data()
+ const const(void)[] data()
{
size_t size = type.tsize();
View
@@ -26,8 +26,8 @@ int accept(int s, sockaddr* addr, int* addrlen);
int shutdown(int s, int how);
int getpeername(int s, sockaddr* name, int* namelen);
int getsockname(int s, sockaddr* name, int* namelen);
-int send(int s, void* buf, int len, int flags);
-int sendto(int s, void* buf, int len, int flags, sockaddr* to, int tolen);
+int send(int s, const(void)* buf, int len, int flags);
+int sendto(int s, const(void)* buf, int len, int flags, sockaddr* to, int tolen);
int recv(int s, void* buf, int len, int flags);
int recvfrom(int s, void* buf, int len, int flags, sockaddr* from, int* fromlen);
int getsockopt(int s, int level, int optname, void* optval, int* optlen);
View
@@ -51,8 +51,8 @@ int closesocket(SOCKET s);
int shutdown(SOCKET s, int how);
int getpeername(SOCKET s, sockaddr* name, int* namelen);
int getsockname(SOCKET s, sockaddr* name, int* namelen);
-int send(SOCKET s, void* buf, int len, int flags);
-int sendto(SOCKET s, void* buf, int len, int flags, sockaddr* to, int tolen);
+int send(SOCKET s, const(void)* buf, int len, int flags);
+int sendto(SOCKET s, const(void)* buf, int len, int flags, sockaddr* to, int tolen);
int recv(SOCKET s, void* buf, int len, int flags);
int recvfrom(SOCKET s, void* buf, int len, int flags, sockaddr* from, int* fromlen);
int getsockopt(SOCKET s, int level, int optname, void* optval, int* optlen);
View
@@ -1307,37 +1307,37 @@ class Socket
* buffer space left, send waits.
*/
//returns number of bytes actually sent, or -1 on error
- int send(void[] buf, SocketFlags flags)
+ int send(const(void)[] buf, SocketFlags flags)
{
int sent = .send(sock, buf.ptr, buf.length, cast(int)flags);
return sent;
}
/// ditto
- int send(void[] buf)
+ int send(const(void)[] buf)
{
return send(buf, SocketFlags.NONE);
}
/**
* Send data to a specific destination Address. If the destination address is not specified, a connection must have been made and that address is used. If the socket is blocking and there is no buffer space left, sendTo waits.
*/
- int sendTo(void[] buf, SocketFlags flags, Address to)
+ int sendTo(const(void)[] buf, SocketFlags flags, Address to)
{
int sent = .sendto(sock, buf.ptr, buf.length, cast(int)flags, to.name(), to.nameLen());
return sent;
}
/// ditto
- int sendTo(void[] buf, Address to)
+ int sendTo(const(void)[] buf, Address to)
{
return sendTo(buf, SocketFlags.NONE, to);
}
//assumes you connect()ed
/// ditto
- int sendTo(void[] buf, SocketFlags flags)
+ int sendTo(const(void)[] buf, SocketFlags flags)
{
int sent = .sendto(sock, buf.ptr, buf.length, cast(int)flags, null, 0);
return sent;
@@ -1346,7 +1346,7 @@ class Socket
//assumes you connect()ed
/// ditto
- int sendTo(void[] buf)
+ int sendTo(const(void)[] buf)
{
return sendTo(buf, SocketFlags.NONE);
}
View
@@ -4,7 +4,7 @@ module std.typeinfo.ti_AC;
class TypeInfo_AC : TypeInfo
{
- hash_t getHash(void *p)
+ hash_t getHash(in void *p)
{ Object[] s = *cast(Object[]*)p;
hash_t hash = 0;
@@ -16,7 +16,7 @@ class TypeInfo_AC : TypeInfo
return hash;
}
- int equals(void *p1, void *p2)
+ int equals(in void *p1, in void *p2)
{
Object[] s1 = *cast(Object[]*)p1;
Object[] s2 = *cast(Object[]*)p2;
@@ -38,7 +38,7 @@ class TypeInfo_AC : TypeInfo
return 0;
}
- int compare(void *p1, void *p2)
+ int compare(in void *p1, in void *p2)
{
Object[] s1 = *cast(Object[]*)p1;
Object[] s2 = *cast(Object[]*)p2;
Oops, something went wrong.

0 comments on commit 52f3c4c

Please sign in to comment.