##// 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 foreach(QString line, lines) {
75 foreach(QString line, lines) {
76 if (line.startsWith("#include")) {
76 if (line.startsWith("#include")) {
77 includes.insert(line);
77 includes.insert(line);
78 } else if (line.startsWith("#")) {
78 } else if (line.startsWith("#") && line.contains("PYTHONQTWRAPPER_")) {
79 // skip preprocessor stuff
79 // skip preprocessor defines for single wrapped classes
80 } else {
80 } else {
81 result += line + "\n";
81 result += line + "\n";
82 }
82 }
@@ -198,7 +198,9 void SetupGenerator::generate()
198
198
199 QStringList cppClassNames;
199 QStringList cppClassNames;
200 foreach (const AbstractMetaClass *cls, list) {
200 foreach (const AbstractMetaClass *cls, list) {
201
201 if (cls->qualifiedCppName().contains("Ssl")) {
202 s << "#ifndef QT_NO_OPENSSL" << endl;
203 }
202 QString shellCreator;
204 QString shellCreator;
203 if (cls->generateShellClass()) {
205 if (cls->generateShellClass()) {
204 shellCreator = ", PythonQtSetInstanceWrapperOnShell<" + ShellGenerator::shellClassName(cls) + ">";
206 shellCreator = ", PythonQtSetInstanceWrapperOnShell<" + ShellGenerator::shellClassName(cls) + ">";
@@ -221,6 +223,9 void SetupGenerator::generate()
221 s << "PythonQt::self()->addParentClass(\""<< cls->qualifiedCppName() << "\", \"" << interface->qualifiedCppName() << "\",PythonQtUpcastingOffset<" << cls->qualifiedCppName() <<","<<interface->qualifiedCppName()<<">());" << endl;
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 s << endl;
230 s << endl;
226 foreach (QString handler, polymorphicHandlers) {
231 foreach (QString handler, polymorphicHandlers) {
@@ -104,6 +104,10 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
104 | AbstractMetaClass::WasVisible
104 | AbstractMetaClass::WasVisible
105 | AbstractMetaClass::NotRemovedFromTargetLang);
105 | AbstractMetaClass::NotRemovedFromTargetLang);
106
106
107 if (meta_class->qualifiedCppName().contains("Ssl")) {
108 s << "#ifndef QT_NO_OPENSSL" << endl;
109 }
110
107 // Shell-------------------------------------------------------------------
111 // Shell-------------------------------------------------------------------
108 if (meta_class->generateShellClass()) {
112 if (meta_class->generateShellClass()) {
109
113
@@ -128,7 +132,6 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
128 }
132 }
129 s << endl;
133 s << endl;
130 s << " ~" << shellClassName(meta_class) << "();" << endl;
134 s << " ~" << shellClassName(meta_class) << "();" << endl;
131 s << endl;
132
135
133 foreach(AbstractMetaFunction* fun, virtualsForShell) {
136 foreach(AbstractMetaFunction* fun, virtualsForShell) {
134 s << "virtual ";
137 s << "virtual ";
@@ -293,8 +296,13 void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
293 writeInjectedCode(s, meta_class);
296 writeInjectedCode(s, meta_class);
294
297
295
298
296 s << "};" << endl << endl
299 s << "};" << endl << endl;
297 << "#endif // " << include_block << 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 // declareFunctionMetaTypes(s, functions, registeredTypeNames);
102 // declareFunctionMetaTypes(s, functions, registeredTypeNames);
103 // s << endl;
103 // s << endl;
104 }
104 }
105 if (meta_class->qualifiedCppName().contains("Ssl")) {
106 s << "#ifndef QT_NO_OPENSSL" << endl;
107 }
105
108
106 if (meta_class->generateShellClass()) {
109 if (meta_class->generateShellClass()) {
107
110
@@ -311,6 +314,9 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
311
314
312 writeInjectedCode(s, meta_class);
315 writeInjectedCode(s, meta_class);
313
316
317 if (meta_class->qualifiedCppName().contains("Ssl")) {
318 s << "#endif" << endl;
319 }
314 }
320 }
315
321
316 void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
322 void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class)
@@ -1163,12 +1163,7
1163
1163
1164 <inject-code class="pywrap-h">
1164 <inject-code class="pywrap-h">
1165 PyObject* data(QByteArray* b) {
1165 PyObject* data(QByteArray* b) {
1166 if (b-&gt;data()) {
1166 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1167 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1168 } else {
1169 Py_INCREF(Py_None);
1170 return Py_None;
1171 }
1172 }
1167 }
1173 </inject-code>
1168 </inject-code>
1174
1169
@@ -1550,10 +1545,6
1550 </modify-function>
1545 </modify-function>
1551 <modify-function signature="connectNotify(const char *)" remove="all"/>
1546 <modify-function signature="connectNotify(const char *)" remove="all"/>
1552 <modify-function signature="disconnectNotify(const char *)" remove="all"/>
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 <modify-function signature="setData(const char*,int)" remove="all"/>
1549 <modify-function signature="setData(const char*,int)" remove="all"/>
1559 </object-type>
1550 </object-type>
@@ -1098,6 +1098,12
1098 <modify-function signature="scanLine(int)const">
1098 <modify-function signature="scanLine(int)const">
1099 <remove/>
1099 <remove/>
1100 </modify-function>
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 <modify-function signature="QImage(const unsigned char *, int, int, QImage::Format)">
1107 <modify-function signature="QImage(const unsigned char *, int, int, QImage::Format)">
1102 <remove/>
1108 <remove/>
1103 </modify-function>
1109 </modify-function>
@@ -1260,6 +1266,27 QImage* new_QImage( const uchar * data, int width, int height, QImage::Format fo
1260 memcpy(image-&gt;bits(), data, image-&gt;byteCount());
1266 memcpy(image-&gt;bits(), data, image-&gt;byteCount());
1261 return image;
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 </inject-code>
1290 </inject-code>
1264 </value-type>
1291 </value-type>
1265
1292
General Comments 0
You need to be logged in to leave comments. Login now