Mercurial > projects > ldc
diff lphobos/internal/arrays.d @ 52:0c77619e803b trunk
[svn r56] Initial support for TypeInfo.
Enums not work.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 23 Oct 2007 05:55:12 +0200 |
parents | 8b0e809563df |
children | b688ad419f8c |
line wrap: on
line diff
--- a/lphobos/internal/arrays.d Mon Oct 22 17:25:44 2007 +0200 +++ b/lphobos/internal/arrays.d Tue Oct 23 05:55:12 2007 +0200 @@ -85,3 +85,32 @@ return memcmp(lhs,rhs,bytesize) != 0; } +bool _d_dyn_array_eq(void[] lhs, void[] rhs) +{ + if (lhs.length != rhs.length) + return false; + else if (lhs is rhs) + return true; + return memcmp(lhs.ptr,rhs.ptr,lhs.length) == 0; +} + +bool _d_dyn_array_neq(void[] lhs, void[] rhs) +{ + if (lhs.length != rhs.length) + return true; + else if (lhs is rhs) + return false; + return memcmp(lhs.ptr,rhs.ptr,lhs.length) != 0; +} + +// for array cast +size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz) +{ + if (newelemsz == 1) { + return len*elemsz; + } + else if (len % newelemsz) { + throw new Exception("Bad array cast"); + } + return (len*elemsz)/newelemsz; +}