##// END OF EJS Templates
Modify typesystems to #ifdef PyString
Orochimarufan -
r210:d5ac67324004
parent child
Show More
@@ -125,7 +125,7 void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
125 125 AbstractMetaArgumentList args = fun->arguments();
126 126
127 127 s << "if (_wrapper && (_wrapper->ob_refcnt > 0)) {" << endl;
128 s << " static PyObject* name = PyString_FromString(\"" << fun->name() << "\");" << endl;
128 s << "#ifdef PY3K\n static PyObject* name = PyUnicode_FromString(\"" << fun->name() << "\");\n#else\n static PyObject* name = PyString_FromString(\"" << fun->name() << "\");\n#endif" << endl;
129 129 s << " PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);" << endl;
130 130 s << " if (obj) {" << endl;
131 131 s << " static const char* argumentList[] ={\"";
@@ -353,7 +353,11
353 353 <inject-code class="pywrap-h">
354 354 PyObject* data(QByteArray* b) {
355 355 if (b->data()) {
356 #ifdef PY3K
357 return PyUnicode_FromStringAndSize(b->data(), b->size());
358 #else
356 359 return PyString_FromStringAndSize(b->data(), b->size());
360 #endif
357 361 } else {
358 362 Py_INCREF(Py_None);
359 363 return Py_None;
@@ -1163,7 +1163,11
1163 1163
1164 1164 <inject-code class="pywrap-h">
1165 1165 PyObject* data(QByteArray* b) {
1166 #ifdef PY3K
1167 return PyUnicode_FromStringAndSize(b-&gt;data(), b-&gt;size());
1168 #else
1166 1169 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1170 #endif
1167 1171 }
1168 1172 </inject-code>
1169 1173
@@ -1948,7 +1952,11
1948 1952 r.resize(len);
1949 1953 int result = d-&gt;readRawData(r.data(), r.size());
1950 1954 if (result&gt;=0) {
1955 #ifdef PY3K
1956 return PyUnicode_FromStringAndSize(r.data(), result);
1957 #else
1951 1958 return PyString_FromStringAndSize(r.data(), result);
1959 #endif
1952 1960 } else {
1953 1961 Py_INCREF(Py_None);
1954 1962 return Py_None;
@@ -356,16 +356,20
356 356 </object-type>
357 357
358 358 <value-type name="QByteArray">
359 <inject-code class="pywrap-h">
360 PyObject* data(QByteArray* b) {
361 if (b->data()) {
362 return PyString_FromStringAndSize(b->data(), b->size());
363 } else {
364 Py_INCREF(Py_None);
365 return Py_None;
366 }
367 }
368 </inject-code>
359 <inject-code class="pywrap-h">
360 PyObject* data(QByteArray* b) {
361 if (b->data()) {
362 #ifdef PY3K
363 return PyUnicode_FromStringAndSize(b-&gt;data(), b-&gt;size());
364 #else
365 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
366 #endif
367 } else {
368 Py_INCREF(Py_None);
369 return Py_None;
370 }
371 }
372 </inject-code>
369 373
370 374 <inject-code class="native" position="beginning">
371 375 Q_DECLARE_METATYPE(QScriptValue)
@@ -1174,7 +1174,11
1174 1174 <inject-code class="pywrap-h">
1175 1175 PyObject* data(QByteArray* b) {
1176 1176 if (b-&gt;data()) {
1177 #ifdef PY3K
1178 return PyUnicode_FromStringAndSize(b-&gt;data(), b-&gt;size());
1179 #else
1177 1180 return PyString_FromStringAndSize(b-&gt;data(), b-&gt;size());
1181 #endif
1178 1182 } else {
1179 1183 Py_INCREF(Py_None);
1180 1184 return Py_None;
General Comments 0
You need to be logged in to leave comments. Login now