bool PythonScripting::setQObject(QObject *val, const char *name, PyObject *dict)
{
  if(!val) return false;
  PyObject *pyobj=NULL;
  sipTypeDef *t;
#if SIP_VERSION >= 0x040301 && SIP_VERSION <= 0x040403
#error "SIP versions between 4.3.1 and 4.4.3 are currently not supported. Please install another version of SIP and try again."
#endif
#if SIP_VERSION >= 0x040400
  for (int i=0; i<sipModuleAPI_qti.em_nrtypes; i++)
#else
  for (int i=0; sipModuleAPI_qti.em_types[i] != 0; i++)
#endif
  // Note that the SIP API is a bit confusing here.
  // sipTypeDef.td_cname holds the C++ class name, but is NULL if that's the same as the Python class name.
  // sipTypeDef.td_name OTOH always holds the Python class name, but prepended by the module name ("qti.")
    if (((t=sipModuleAPI_qti.em_types[i]->type)->td_cname && !strcmp(val->className(),t->td_cname)) ||
	  (!t->td_cname && !strcmp(val->className(),t->td_name+4)))
    {
#if SIP_VERSION >= 0x040400
      pyobj=sipConvertFromInstance(val,sipModuleAPI_qti.em_types[i],NULL);
#else
      pyobj=sipBuildResult(NULL, "M", val, sipModuleAPI_qti.em_types[i]);
#endif
      if (!pyobj) return false;
      break;
    }
  if (!pyobj) {
#if SIP_VERSION >= 0x040400
    for (int i=0; i<sipModuleAPI_qti_qt->em_nrtypes; i++)
#else
    for (int i=0; sipModuleAPI_qti_qt->em_types[i] != 0; i++)
#endif
    if (((t=sipModuleAPI_qti_qt->em_types[i]->type)->td_cname && !strcmp(val->className(),t->td_cname)) ||
	  (!t->td_cname && !strcmp(val->className(),t->td_name+3)))
      {
#if SIP_VERSION >= 0x040400
	pyobj=sipConvertFromInstance(val,sipModuleAPI_qti_qt->em_types[i],NULL);
#else
	pyobj=sipBuildResult(NULL, "M", val, sipModuleAPI_qti_qt->em_types[i]);
#endif
	if (!pyobj) return false;
	break;
      }
  } 
  if (!pyobj) return false;

  if (dict)
    PyDict_SetItemString(dict,name,pyobj);
  else
    PyDict_SetItemString(globals,name,pyobj);
  Py_DECREF(pyobj);
  return true;
}
static PyObject *convertFrom_std_vector_0101OrientedBB(void *sipCppV,PyObject *sipTransferObj)
{
   std::vector<OrientedBB *> *sipCpp = reinterpret_cast<std::vector<OrientedBB *> *>(sipCppV);

#line 568 "/home/rbianchi/projects/draw_areas/src/sipbin/stl.sip"
    PyObject *l;

    // Create the Python list of the correct length.
    if ((l = PyList_New(sipCpp -> size())) == NULL)
        return NULL;

    // Go through each element in the C++ instance and convert it to the
    // corresponding Python object.
    for (std::vector<OrientedBB *>::size_type i = 0; i < sipCpp -> size(); ++i)
    {
        OrientedBB *t = sipCpp -> at(i);
        PyObject *tobj;

        if ((tobj = sipConvertFromInstance(t, sipClass_OrientedBB, sipTransferObj)) == NULL)
        {
            // There was an error so garbage collect the Python list.
            Py_DECREF(l);
            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    // Return the Python list.
    return l;
#line 136 "sip_geo2dcppstdvector0101OrientedBB.cpp"
}
static PyObject *var_PySemsB2BDialog_dlg(PyObject *sipSelf,PyObject *sipPy)
{
    int sipIsErr = 0;
   AmSipDialog *sipVal;
    PySemsB2BDialog *sipCpp = reinterpret_cast<PySemsB2BDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_PySemsB2BDialog));

    if (!sipCpp)
        return NULL;

    if (sipPy == NULL)
    {
        sipVal = &sipCpp->dlg;

        sipPy = sipConvertFromInstance(sipVal,sipClass_AmSipDialog,NULL);

        return sipPy;
    }

    sipVal = reinterpret_cast<AmSipDialog *>(sipForceConvertToInstance(sipPy,sipClass_AmSipDialog,NULL,SIP_NOT_NONE,NULL,&sipIsErr));

    if (sipIsErr)
        return NULL;

    sipCpp->dlg = *sipVal;

    Py_INCREF(Py_None);
    return Py_None;
}
Exemple #4
0
/**
 * Creates a PyObject that wraps the calling C++ instance.
 * Ownership is transferred to the caller, i.e. the caller
 * is responsible for calling Py_DECREF
 * @return A PyObject wrapping this instance
 */
PyObject * PythonScript::createSipInstanceFromMe()
{
    static sipWrapperType *sipClass(NULL);
    if(!sipClass)
    {
        sipClass = sipFindClass("PythonScript");
    }
    PyObject *sipWrapper = sipConvertFromInstance(this, sipClass, NULL);
    assert(sipWrapper);
    return sipWrapper;
}