diff lphobos/std/array.d @ 86:fd32135dca3e trunk

[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!! Lots of bugfixes. Added support for special foreach on strings. Added std.array, std.utf, std.ctype and std.uni to phobos. Changed all the .c files in the gen dir to .cpp (it *is* C++ after all)
author lindquist
date Sat, 03 Nov 2007 14:44:58 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lphobos/std/array.d	Sat Nov 03 14:44:58 2007 +0100
@@ -0,0 +1,38 @@
+
+module std.array;
+
+private import std.c.stdio;
+
+class ArrayBoundsError : Error
+{
+  private:
+
+    uint linnum;
+    char[] filename;
+
+  public:
+    this(char[] filename, uint linnum)
+    {
+	this.linnum = linnum;
+	this.filename = filename;
+
+	char[] buffer = new char[19 + filename.length + linnum.sizeof * 3 + 1];
+	int len;
+	len = sprintf(buffer.ptr, "ArrayBoundsError %.*s(%u)", filename, linnum);
+	super(buffer[0..len]);
+    }
+}
+
+
+/********************************************
+ * Called by the compiler generated module assert function.
+ * Builds an ArrayBoundsError exception and throws it.
+ */
+
+extern (C) static void _d_array_bounds(char[] filename, uint line)
+{
+    //printf("_d_assert(%s, %d)\n", (char *)filename, line);
+    ArrayBoundsError a = new ArrayBoundsError(filename, line);
+    //printf("assertion %p created\n", a);
+    throw a;
+}