static*/
| 295 | |
| 296 | /*static*/ |
| 297 | int PythonScript::setAttribute(PyObject * o, PyObject * attr_name, PyObject * v) |
| 298 | { |
| 299 | QString propName; |
| 300 | QMetaProperty prop; |
| 301 | |
| 302 | // Get the QObject* we operate on |
| 303 | if (!PyObject_TypeCheck(o, &pyQObjectType)) { |
| 304 | PyErr_SetString(PyExc_TypeError, qPrintable(tr("setattr: not a valid TW object"))); |
| 305 | return -1; |
| 306 | } |
| 307 | if (!IS_ENCAPSULATED_C_POINTER(((pyQObject*)o)->_TWcontext)) { |
| 308 | PyErr_SetString(PyExc_TypeError, qPrintable(tr("setattr: not a valid TW object"))); |
| 309 | return -1; |
| 310 | } |
| 311 | QObject * obj = (QObject*)GET_ENCAPSULATED_C_POINTER((PyObject*)(((pyQObject*)o)->_TWcontext)); |
| 312 | |
| 313 | // Get the parameters |
| 314 | if (!asQString(attr_name, propName)) { |
| 315 | PyErr_SetString(PyExc_TypeError, qPrintable(tr("setattr: invalid property name"))); |
| 316 | return -1; |
| 317 | } |
| 318 | |
| 319 | switch (doSetProperty(obj, propName, PythonScript::PythonToVariant(v))) { |
| 320 | case Property_DoesNotExist: |
| 321 | PyErr_Format(PyExc_AttributeError, qPrintable(tr("setattr: object doesn't have property %s")), qPrintable(propName)); |
| 322 | return -1; |
| 323 | case Property_NotWritable: |
| 324 | PyErr_Format(PyExc_AttributeError, qPrintable(tr("setattr: property %s is not writable")), qPrintable(propName)); |
| 325 | return -1; |
| 326 | case Property_OK: |
| 327 | return 0; |
| 328 | default: |
| 329 | break; |
| 330 | } |
| 331 | // we should never reach this point |
| 332 | return -1; |
| 333 | } |
| 334 | |
| 335 | /*static*/ |
| 336 | PyObject * PythonScript::callMethod(PyObject * o, PyObject * pyArgs, PyObject * kw) |
no outgoing calls