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