Mercurial > projects > qtd
view qt/qtd/MetaMarshall.d @ 294:bb37b0ed94c9 signals
some more QList
author | eldar |
---|---|
date | Fri, 13 Nov 2009 20:42:51 +0000 |
parents | 8627891e4556 |
children | 55ee4603365d |
line wrap: on
line source
module qt.qtd.MetaMarshall; import std.traits; template isQObjectType(T) // is a QObject type that belongs to the library { enum isQObjectType = is(T.__isQObjectType); } template isObjectType(T) // is a Qt Object type that belongs to the library { enum isObjectType = is(T.__isObjectType); } template isValueType(T) // is a Qt Value type that belongs to the library { enum isValueType = is(T.__isValueType); } template isNativeType(T) // type that doesn't require conversion i.e. is the same in C++ and D { enum isNativeType = isNumeric!T || is(T == bool); } // converts an argumnent from C++ to D in qt_metacall string metaCallArgument(T)(string ptr) { static if (isQObjectType!T) return T.stringof ~ ".__getObject(*cast(void**)(" ~ ptr ~ "))"; else static if (isNativeType!T) return "*(cast(" ~ T.stringof ~ "*)" ~ ptr ~ ")"; else return "*(cast(" ~ T.stringof ~ "*)" ~ ptr ~ ")"; //res = T.stringof; } // converts a D argument type to C++ for registering in Qt meta system string qtDeclArg(T)() { static if (isQObjectType!T) return T.stringof ~ "*"; else static if (isNativeType!T) return T.stringof; else return T.stringof; } // converts an argument from D to C++ in a signal emitter string convertSignalArgument(T)(string arg) { static if (isQObjectType!T) return arg ~ ".__nativeId"; else static if (isNativeType!T) return arg; else return arg; }