Mercurial > projects > qtd
comparison d2/qt/core/QMetaType.d @ 357:9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Q_CLASSINFO implementation
Now Qtd can be built on Windows
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Wed, 02 Jun 2010 19:38:05 +0300 |
parents | 96a75b1e5b26 |
children | a032df77b6ab |
comparison
equal
deleted
inserted
replaced
356:12cec2d14e1c | 357:9784459f0750 |
---|---|
1 module qt.core.QMetaType; | 1 module qt.core.QMetaType; |
2 public import qt.core.Qt; | 2 public import qt.core.Qt; |
3 private import qt.core.QDataStream; | 3 private import qt.core.QDataStream; |
4 | |
5 version (Tango) | |
6 { | |
7 import tango.core.Array; | |
8 import tango.stdc.stringz; | |
9 import tango.core.Traits; | |
10 } | |
11 | 4 |
12 alias extern(C) void *function(void *copy) Ctor; | 5 alias extern(C) void *function(void *copy) Ctor; |
13 alias extern(C) void function(void *obj) Dtor; | 6 alias extern(C) void function(void *obj) Dtor; |
14 alias extern(C) void function(void *stream, void * object) StreamOp; | 7 alias extern(C) void function(void *stream, void * object) StreamOp; |
15 | 8 |
43 if(copy) | 36 if(copy) |
44 *data = *cast(T*)copy; | 37 *data = *cast(T*)copy; |
45 return cast(void*)data; | 38 return cast(void*)data; |
46 } | 39 } |
47 } | 40 } |
48 | 41 |
49 | 42 |
50 extern(C) void dtor(void* obj) | 43 extern(C) void dtor(void* obj) |
51 { | 44 { |
52 static if (is(T == class) || is(T == interface)) | 45 static if (is(T == class) || is(T == interface)) |
53 { | 46 { |
63 } | 56 } |
64 | 57 |
65 public int qRegisterMetaType(T)(string name = null) | 58 public int qRegisterMetaType(T)(string name = null) |
66 { | 59 { |
67 if (!name.length) | 60 if (!name.length) |
68 name = typeid(T).toString; | 61 name = typeid(T).toString; |
69 | 62 |
70 return qtd_registerType(toStringz(name), &MetaTypeOps!(T).ctor, &MetaTypeOps!(T).dtor); | 63 return qtd_registerType(toStringz(name), &MetaTypeOps!(T).ctor, &MetaTypeOps!(T).dtor); |
71 } | 64 } |
72 | 65 |
73 /* Not work.... | 66 /* Not work.... |
84 { | 77 { |
85 static void function(ref QDataStream, T ) SaveOp; | 78 static void function(ref QDataStream, T ) SaveOp; |
86 static void function (ref QDataStream, ref T) LoadOp; | 79 static void function (ref QDataStream, ref T) LoadOp; |
87 SaveOp = saveOp; | 80 SaveOp = saveOp; |
88 LoadOp = loadOp; | 81 LoadOp = loadOp; |
89 | 82 |
90 if (!name.length) | 83 if (!name.length) |
91 name = typeid(T).toString; | 84 name = typeid(T).toString; |
92 | 85 |
93 extern(C) void saveOpC(void *stream, void *object) | 86 extern(C) void saveOpC(void *stream, void *object) |
94 { | 87 { |
95 QDataStream dstream = new DataStreamPriv(stream); | 88 QDataStream dstream = new DataStreamPriv(stream); |
96 Stdout(object).newline; | 89 Stdout(object).newline; |
97 static if (is(T == class) || is(T == interface)) | 90 static if (is(T == class) || is(T == interface)) |
98 SaveOp(dstream, cast(T)object); | 91 SaveOp(dstream, cast(T)object); |
99 else | 92 else |
100 SaveOp(dstream, *cast(T*)object); | 93 SaveOp(dstream, *cast(T*)object); |
101 } | 94 } |
102 | 95 |
103 extern(C) void loadOpC(void *stream, void *object) | 96 extern(C) void loadOpC(void *stream, void *object) |
104 { | 97 { |
105 //return stream; | 98 //return stream; |
106 } | 99 } |
107 | 100 |