##// END OF EJS Templates
added data accessors for QImage (bits()/scanLine() and const versions)...
florianlink -
r192:b923cb867b60
parent child
Show More
@@ -75,8 +75,8 static QString combineIncludes(const QString& text) {
75 75 foreach(QString line, lines) {
76 76 if (line.startsWith("#include")) {
77 77 includes.insert(line);
78 } else if (line.startsWith("#")) {
79 // skip preprocessor stuff
78 } else if (line.startsWith("#") && line.contains("PYTHONQTWRAPPER_")) {
79 // skip preprocessor defines for single wrapped classes
80 80 } else {
81 81 result += line + "\n";
82 82 }
@@ -198,7 +198,9 void SetupGenerator::generate()
198 198
199 199 QStringList cppClassNames;
200 200 foreach (const AbstractMetaClass *cls, list) {
201
201 if (cls->qualifiedCppName().contains("Ssl")) {
202 s << "#ifndef QT_NO_OPENSSL" << endl;
203 }
202 204 QString shellCreator;
203 205 if (cls->generateShellClass()) {
204 206 shellCreator = ", PythonQtSetInstanceWrapperOnShell<" + ShellGenerator::shellClassName(cls) + ">";
@@ -221,6 +223,9 void SetupGenerator::generate()
221 223 s << "PythonQt::self()->addParentClass(\""<< cls->qualifiedCppName() << "\", \"" << interface->qualifiedCppName() << "\",PythonQtUpcastingOffset<" << cls->qualifiedCppName() <<","<<interface->qualifiedCppName()<<">());" << endl;
222 224 }
223 225 }
226 if (cls->qualifiedCppName().contains("Ssl")) {
227 s << "#endif" << endl;
228 }
224 229 }
225 230 s << endl;
226 231 foreach (QString handler, polymorphicHandlers) {
@@ -104,6 +104,10 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
104 104 | AbstractMetaClass::WasVisible
105 105 | AbstractMetaClass::NotRemovedFromTargetLang);
106 106
107 if (meta_class->qualifiedCppName().contains("Ssl")) {
108 s << "#ifndef QT_NO_OPENSSL" << endl;
109 }
110
107 111 // Shell-------------------------------------------------------------------
108 112 if (meta_class->generateShellClass()) {
109 113
@@ -128,7 +132,6 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
128 132 }
129 133 s << endl;
130 134 s << " ~" << shellClassName(meta_class) << "();" << endl;
131 s << endl;
132 135
133 136 foreach(AbstractMetaFunction* fun, virtualsForShell) {
134 137 s << "virtual ";
@@ -293,8 +296,13 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
293 296 writeInjectedCode(s, meta_class);
294 297
295 298
296 s << "};" << endl << endl
297 << "#endif // " << include_block << endl;
299 s << "};" << endl << endl;
300 if (meta_class->qualifiedCppName().contains("Ssl")) {
301 s << "#endif" << endl << endl;
302 }
303
304 s << "#endif // " << include_block << endl;
305
298 306
299 307 }
300 308
@@ -102,6 +102,9 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
102 102 // declareFunctionMetaTypes(s, functions, registeredTypeNames);
103 103 // s << endl;
104 104 }
105 if (meta_class->qualifiedCppName().contains("Ssl")) {
106 s << "#ifndef QT_NO_OPENSSL" << endl;
107 }
105 108
106 109 if (meta_class->generateShellClass()) {
107 110
@@ -311,6 +314,9 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
311 314
312 315 writeInjectedCode(s, meta_class);
313 316
317 if (meta_class->qualifiedCppName().contains("Ssl")) {
318 s << "#endif" << endl;
319 }
314 320 }
315 321
316 322 void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
@@ -1163,12 +1163,7
1163 1163
1164 1164 <inject-code class="pywrap-h">
1165 1165 PyObject* data(QByteArray* b) {
1166 if (b-&gt;data()) {
1167 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1168 } else {
1169 Py_INCREF(Py_None);
1170 return Py_None;
1171 }
1166 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1172 1167 }
1173 1168 </inject-code>
1174 1169
@@ -1550,10 +1545,6
1550 1545 </modify-function>
1551 1546 <modify-function signature="connectNotify(const char *)" remove="all"/>
1552 1547 <modify-function signature="disconnectNotify(const char *)" remove="all"/>
1553
1554 <!-- ### modify to return value by pointer? -->
1555 <modify-function signature="buffer()const" remove="all"/>
1556 <modify-function signature="data()const" remove="all"/>
1557 1548
1558 1549 <modify-function signature="setData(const char*,int)" remove="all"/>
1559 1550 </object-type>
@@ -1098,6 +1098,12
1098 1098 <modify-function signature="scanLine(int)const">
1099 1099 <remove/>
1100 1100 </modify-function>
1101 <modify-function signature="constBits()const">
1102 <remove/>
1103 </modify-function>
1104 <modify-function signature="constScanLine(int)const">
1105 <remove/>
1106 </modify-function>
1101 1107 <modify-function signature="QImage(const unsigned char *, int, int, QImage::Format)">
1102 1108 <remove/>
1103 1109 </modify-function>
@@ -1260,6 +1266,27 QImage* new_QImage( const uchar * data, int width, int height, QImage::Format fo
1260 1266 memcpy(image-&gt;bits(), data, image-&gt;byteCount());
1261 1267 return image;
1262 1268 }
1269
1270 PyObject* bits(QImage* image) {
1271 return PythonQtPrivate::wrapMemoryAsBuffer(image-&gt;bits(), image-&gt;bytesPerLine()* image-&gt;height());
1272 }
1273
1274 #if QT_VERSION &gt;= QT_VERSION_CHECK(4,7,0)
1275 PyObject* constBits(QImage* image) {
1276 return PythonQtPrivate::wrapMemoryAsBuffer(image-&gt;constBits(), image-&gt;byteCount());
1277 }
1278 #endif
1279
1280 PyObject* scanLine(QImage* image, int line) {
1281 return PythonQtPrivate::wrapMemoryAsBuffer(image-&gt;scanLine(line), image-&gt;bytesPerLine());
1282 }
1283
1284 #if QT_VERSION &gt;= QT_VERSION_CHECK(4,7,0)
1285 PyObject* constScanLine(QImage* image, int line) {
1286 return PythonQtPrivate::wrapMemoryAsBuffer(image-&gt;constScanLine(line), image-&gt;bytesPerLine());
1287 }
1288 #endif
1289
1263 1290 </inject-code>
1264 1291 </value-type>
1265 1292
General Comments 0
You need to be logged in to leave comments. Login now