comparison qt/qtd/MetaMarshall.d @ 318:ce07227f00c1 signals

more signals and QList
author eldar_ins@eldar-laptop
date Thu, 24 Dec 2009 05:19:40 +0500
parents 8a0cf14e3419
children 894d40eb89b6
comparison
equal deleted inserted replaced
309:8a0cf14e3419 318:ce07227f00c1
79 // converts an argumnent from C++ to D in qt_metacall 79 // converts an argumnent from C++ to D in qt_metacall
80 string metaCallArgument(T)(string ptr) 80 string metaCallArgument(T)(string ptr)
81 { 81 {
82 static if (isQObjectType!T || isObjectType!T) 82 static if (isQObjectType!T || isObjectType!T)
83 return T.stringof ~ ".__getObject(*cast(void**)(" ~ ptr ~ "))"; 83 return T.stringof ~ ".__getObject(*cast(void**)(" ~ ptr ~ "))";
84 else static if (isValueType!T)
85 return "new " ~ T.stringof ~ "(" ~ T.stringof ~ ".__constructNativeCopy(" ~ ptr ~ "))";
84 else static if (isNativeType!T) 86 else static if (isNativeType!T)
85 return "*(cast(" ~ T.stringof ~ "*)" ~ ptr ~ ")"; 87 return "*(cast(" ~ T.stringof ~ "*)" ~ ptr ~ ")";
86 else static if (isStringType!T) 88 else static if (isStringType!T)
87 return "QStringUtil.toNativeString(" ~ ptr ~ ")"; 89 return "QStringUtil.toNativeString(" ~ ptr ~ ")";
88 else 90 else
93 // converts a D argument type to C++ for registering in Qt meta system 95 // converts a D argument type to C++ for registering in Qt meta system
94 string qtDeclArg(T)() 96 string qtDeclArg(T)()
95 { 97 {
96 static if (isQObjectType!T || isObjectType!T) 98 static if (isQObjectType!T || isObjectType!T)
97 return T.stringof ~ "*"; 99 return T.stringof ~ "*";
100 else static if (isValueType!T)
101 return T.stringof;
98 else static if (isStringType!T) 102 else static if (isStringType!T)
99 return "QString"; 103 return "QString";
100 else static if (isQList!T) 104 else static if (isQList!T)
101 return "QList<" ~ qtDeclArg!(templateParam!T)() ~ ">"; 105 {
106 alias templateParam!T ElementType;
107 static if (is(ElementType == string))
108 return "QStringList";
109 else
110 return "QList<" ~ qtDeclArg!(templateParam!T)() ~ ">";
111 }
102 else static if (isNativeType!T) 112 else static if (isNativeType!T)
103 return Unqual!T.stringof; 113 return Unqual!T.stringof;
104 else 114 else
105 return T.stringof; 115 return T.stringof;
106 } 116 }
107 117
108 // converts an argument from D to C++ in a signal emitter 118 // converts an argument from D to C++ in a signal emitter
109 string convertSignalArgument(T)(string arg) 119 string convertSignalArgument(T)(string arg)
110 { 120 {
111 static if (isQObjectType!T || isObjectType!T) 121 static if (isQObjectType!T || isObjectType!T)
122 return "&" ~ arg ~ ".__nativeId";
123 else static if (isValueType!T)
112 return arg ~ ".__nativeId"; 124 return arg ~ ".__nativeId";
113 else static if (isStringType!T) 125 else static if (isStringType!T)
114 return "_qt" ~ arg; 126 return "&_qt" ~ arg;
115 else static if (isNativeType!T) 127 else static if (isNativeType!T)
116 return arg; 128 return "&" ~ arg;
117 else 129 else
118 return arg; 130 return "&" ~ arg;
119 } 131 }
120 132
121 string prepareSignalArguments(Args...)() 133 string prepareSignalArguments(Args...)()
122 { 134 {
123 string res; 135 string res;