Mercurial > projects > qtd
comparison qt/qtd/MetaMarshall.d @ 309:8a0cf14e3419 signals
wrong merge
author | eldar_ins@eldar-laptop |
---|---|
date | Wed, 23 Dec 2009 04:48:11 +0500 |
parents | 2485419c5c63 |
children | ce07227f00c1 |
comparison
equal
deleted
inserted
replaced
308:2485419c5c63 | 309:8a0cf14e3419 |
---|---|
1 module qt.qtd.MetaMarshall; | 1 module qt.qtd.MetaMarshall; |
2 | 2 |
3 import std.traits; | 3 import std.traits; |
4 | 4 |
5 // utilities | |
5 // shouldn't be here | 6 // shouldn't be here |
7 | |
8 public bool startsWith(T)(T[] source, T[] pattern) | |
9 { | |
10 return source.length >= pattern.length && source[0 .. pattern.length] == pattern[]; | |
11 } | |
6 | 12 |
7 string __toString(long v) | 13 string __toString(long v) |
8 { | 14 { |
9 if (v == 0) | 15 if (v == 0) |
10 return "0"; | 16 return "0"; |
28 ret = "-" ~ ret; | 34 ret = "-" ~ ret; |
29 | 35 |
30 return ret; | 36 return ret; |
31 } | 37 } |
32 | 38 |
39 template templateParam(U : V!(U), alias V) | |
40 { | |
41 alias U templateParam; | |
42 } | |
43 | |
44 | |
45 /* | |
46 * actual stuff | |
47 */ | |
48 | |
33 template isQObjectType(T) // is a QObject type that belongs to the library | 49 template isQObjectType(T) // is a QObject type that belongs to the library |
34 { | 50 { |
35 enum isQObjectType = is(T.__isQObjectType); | 51 enum isQObjectType = is(T.__isQObjectType); |
36 } | 52 } |
37 | 53 |
53 template isStringType(T) // string type | 69 template isStringType(T) // string type |
54 { | 70 { |
55 enum isStringType = is(T == string); | 71 enum isStringType = is(T == string); |
56 } | 72 } |
57 | 73 |
74 template isQList(T) | |
75 { | |
76 enum isQList = startsWith(Unqual!(T).stringof, "QList!"); | |
77 } | |
78 | |
58 // converts an argumnent from C++ to D in qt_metacall | 79 // converts an argumnent from C++ to D in qt_metacall |
59 string metaCallArgument(T)(string ptr) | 80 string metaCallArgument(T)(string ptr) |
60 { | 81 { |
61 static if (isQObjectType!T || isObjectType!T) | 82 static if (isQObjectType!T || isObjectType!T) |
62 return T.stringof ~ ".__getObject(*cast(void**)(" ~ ptr ~ "))"; | 83 return T.stringof ~ ".__getObject(*cast(void**)(" ~ ptr ~ "))"; |
74 { | 95 { |
75 static if (isQObjectType!T || isObjectType!T) | 96 static if (isQObjectType!T || isObjectType!T) |
76 return T.stringof ~ "*"; | 97 return T.stringof ~ "*"; |
77 else static if (isStringType!T) | 98 else static if (isStringType!T) |
78 return "QString"; | 99 return "QString"; |
100 else static if (isQList!T) | |
101 return "QList<" ~ qtDeclArg!(templateParam!T)() ~ ">"; | |
79 else static if (isNativeType!T) | 102 else static if (isNativeType!T) |
80 return Unqual!T.stringof; | 103 return Unqual!T.stringof; |
81 else | 104 else |
82 return T.stringof; | 105 return T.stringof; |
83 } | 106 } |