Mercurial > projects > qtd
diff mini/test1/main.d @ 361:beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
author | Max Samukha <maxter@maxter.com> |
---|---|
date | Wed, 09 Jun 2010 11:08:56 +0300 |
parents | 49bfc86ff583 |
children | bcbfffef4f9e |
line wrap: on
line diff
--- a/mini/test1/main.d Thu Jun 03 10:12:29 2010 +0300 +++ b/mini/test1/main.d Wed Jun 09 11:08:56 2010 +0300 @@ -1,31 +1,62 @@ -import qt.core.QCoreApplication; +import qt.core.QMetaType; + +import std.stdio; +import std.conv; +import qtd.QtdObject; + +class A +{ + string name; -version(Tango) { import tango.io.Stdout; } else { import std.stdio; } + this(A copy) + { + writeln("Creating new from ", copy.name); + name = "Copy of " ~ copy.name; + } -int main(string[] args) + this(string name) + { + this.name = name; + } + + void dispose() + { + writeln("Disposing ", name); + } +} + +void main(string[] args) { - auto app = new QCoreApplication(args); - - auto parent = new QObject(); - parent.setObjectName("papa"); - auto child1 = new QObject(parent); - child1.setObjectName("child1"); - auto child2 = new QObject(parent); - child2.setObjectName("child2"); - auto child3 = new QObject(parent); - child3.setObjectName("child3"); - - auto cd = parent.children; - Stdout(parent.children.length).newline; + int id = qRegisterMetaType!A(); + qRegisterMetaTypeStreamOperators!A(); + + foreach (i; 0..10) + { + writeln("Iter ", i); + + void foo(int x, int y, int z) + { + auto a = new A("A" ~ to!string(i)); + auto b = cast(A)QMetaType.construct(id, cast(void*)a); + writeln(b.name); + + QMetaType.destroy(id, cast(void*)a); + QMetaType.destroy(id, cast(void*)b); - Stdout(app.arguments).newline; - foreach(child; cd) - Stdout(child.objectName).newline; - - app.setLibraryPaths(["freakin", "bloody", "awesome!"]); + scope ds = new QDataStream(cast(void*)3, QtdObjectFlags.nativeOwnership); + QMetaType.save(ds, id, cast(void*)i); + QMetaType.load(ds, id, cast(void*)i); + writeln("Done iterating ", x, " ", y, " ", z); + } - Stdout(app.libraryPaths).newline; - - return 5; -// return app.exec(); + foo(i + 1, i + 2, i + 3); + } + /+ + + writeln("Great!"); + + + writeln("Even greater!"); + +/ + }