comparison 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
comparison
equal deleted inserted replaced
370:7fd4b69378bf 372:a032df77b6ab
1 module qtd.Core; 1 module qtd.Core;
2 2
3 import 3 import
4 qtd.ctfe.Format, 4 qtd.ctfe.Format,
5 std.stdio; 5 std.traits;
6 6
7 /**
8 Casts T to U, bypassing dynamic cast checks
9 */
7 T static_cast(T, U)(U obj) 10 T static_cast(T, U)(U obj)
8 { 11 {
9 return cast(T)cast(void*)obj; 12 return cast(T)cast(void*)obj;
10 } 13 }
11 14
15 /**
16 Strips qualifiers off the argument.
17 */
18 auto ref unqual(T)(auto ref T v)
19 {
20 static if (__traits(isRef, v))
21 {
22 auto p = cast(Unqual!(T)*)&v;
23 return *p;
24 }
25 else
26 return cast(Unqual!T)v;
27 }
28
29 /**
30 Just an alias to the type T. Useful for declarations
31 with anonymous types.
32 */
33 template Type(T)
34 {
35 alias T Type;
36 }
37
12 enum qtdExtern = "extern (C)"; 38 enum qtdExtern = "extern (C)";
13 39
14 extern(C) alias void function() VoidFunc; 40 extern(C) alias void function() VoidFunc;
15 extern(C) void qtd_initCore(); 41 extern(C) void qtdInitCore();
16
17 immutable Object qtdMoLock;
18 42
19 static this() 43 static this()
20 { 44 {
21 qtdMoLock = cast(immutable)new Object; 45 qtdInitCore();
22 qtd_initCore();
23 } 46 }
24 47
25 /** 48 /**
26 Defines a function that can be called from QtD C++ libraries. 49 Defines a function that can be called from QtD C++ libraries.
27 The function will be automatically 50 The function will be automatically