diff d2/qtd/Core.d @ 372:a032df77b6ab

Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
author Max Samukha <maxter@spambox.com>
date Thu, 08 Jul 2010 17:19:05 +0300
parents 49d0a43433e7
children d2f48c4cb3e3
line wrap: on
line diff
--- a/d2/qtd/Core.d	Sun Jul 04 14:17:49 2010 +0100
+++ b/d2/qtd/Core.d	Thu Jul 08 17:19:05 2010 +0300
@@ -2,24 +2,47 @@
 
 import
     qtd.ctfe.Format,
-    std.stdio;
+    std.traits;
 
+/**
+    Casts T to U, bypassing dynamic cast checks
+ */
 T static_cast(T, U)(U obj)
 {
     return cast(T)cast(void*)obj;
 }
 
+/**
+    Strips qualifiers off the argument.
+ */
+auto ref unqual(T)(auto ref T v)
+{
+    static if (__traits(isRef, v))
+    {
+        auto p = cast(Unqual!(T)*)&v;
+        return *p;
+    }
+    else
+        return cast(Unqual!T)v;
+}
+
+/**
+    Just an alias to the type T. Useful for declarations
+    with anonymous types.
+ */
+template Type(T)
+{
+    alias T Type;
+}
+
 enum qtdExtern = "extern (C)";
 
 extern(C) alias void function() VoidFunc;
-extern(C) void qtd_initCore();
-
-immutable Object qtdMoLock;
+extern(C) void qtdInitCore();
 
 static this()
 {
-    qtdMoLock = cast(immutable)new Object;
-    qtd_initCore();
+    qtdInitCore();
 }
 
 /**