示例#1
0
  void idaapi get_row(
          qstrvec_t *cols,
          int *icon_,
          chooser_item_attrs_t *attrs,
          size_t n) const
  {
    PYW_GIL_GET;

    // Call Python
    PYW_GIL_CHECK_LOCKED_SCOPE();
    pycall_res_t list(
            PyObject_CallMethod(
                    self, (char *)S_ON_GET_LINE,
                    "i", int(n)));
    if ( list.result != NULL )
    {
      // Go over the List returned by Python and convert to C strings
      for ( int i = chobj->columns - 1; i >= 0; --i )
      {
        borref_t item(PyList_GetItem(list.result.o, Py_ssize_t(i)));
        if ( item == NULL )
          continue;

        const char *str = PyString_AsString(item.o);
        if ( str != NULL )
          (*cols)[i] = str;
      }
    }

    *icon_ = chobj->icon;
    if ( (cb_flags & CHOOSE_HAVE_GETICON) != 0 )
    {
      pycall_res_t pyres(
              PyObject_CallMethod(
                      self, (char *)S_ON_GET_ICON,
                      "i", int(n)));
      if ( pyres.result != NULL )
        *icon_ = PyInt_AsLong(pyres.result.o);
    }

    if ( (cb_flags & CHOOSE_HAVE_GETATTR) != 0 )
    {
      pycall_res_t pyres(
              PyObject_CallMethod(
                      self, (char *)S_ON_GET_LINE_ATTR,
                      "i", int(n)));
      if ( pyres.result != NULL && PyList_Check(pyres.result.o) )
      {
        PyObject *item;
        if ( (item = PyList_GetItem(pyres.result.o, 0)) != NULL )
          attrs->color = PyInt_AsLong(item);
        if ( (item = PyList_GetItem(pyres.result.o, 1)) != NULL )
          attrs->flags = PyInt_AsLong(item);
      }
    }
  }
示例#2
0
  void on_close()
  {
    PYW_GIL_GET;
    newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_CLOSE, NULL));

    // Delete this instance if none modal and not embedded
    if ( !is_modal() && get_embedded() == NULL )
      delete this;
  }
示例#3
0
  size_t on_get_size()
  {
    PYW_GIL_GET;
    newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_GET_SIZE, NULL));
    if ( pyres == NULL )
      return 0;

    return PyInt_AsLong(pyres.o);
  }
示例#4
0
  size_t idaapi get_count() const
  {
    PYW_GIL_GET;
    pycall_res_t pyres(PyObject_CallMethod(self, (char *)S_ON_GET_SIZE, NULL));
    if ( pyres.result == NULL || pyres.result.o == Py_None )
      return 0;

    return size_t(PyInt_AsLong(pyres.result.o));
  }
示例#5
0
 void on_edit_line(int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_EDIT_LINE,
                   "i",
                   lineno - 1));
 }
示例#6
0
 void on_enter(int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_SELECT_LINE,
                   "i",
                   lineno - 1));
 }
示例#7
0
 // common callbacks
 bool idaapi init()
 {
   if ( (cb_flags & CHOOSE_HAVE_INIT) == 0 )
     return chobj->chooser_base_t::init();
   PYW_GIL_GET;
   pycall_res_t pyres(PyObject_CallMethod(self, (char *)S_ON_INIT, NULL));
   if ( pyres.result == NULL || pyres.result.o == Py_None )
     return chobj->chooser_base_t::init();
   return bool(PyInt_AsLong(pyres.result.o));
 }
示例#8
0
 int on_get_icon(int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_GET_ICON,
                   "i",
                   lineno - 1));
   return PyInt_AsLong(pyres.o);
 }
示例#9
0
 int on_refresh(int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_REFRESH,
                   "i",
                   lineno - 1));
   return pyres == NULL ? lineno : PyInt_AsLong(pyres.o) + 1;
 }
示例#10
0
 int on_delete_line(int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_DELETE_LINE,
                   "i",
                   IS_CHOOSER_EVENT(lineno) ? lineno : lineno-1));
   return pyres == NULL ? 1 : PyInt_AsLong(pyres.o);
 }
示例#11
0
 int on_command(int cmd_id, int lineno)
 {
   PYW_GIL_GET;
   newref_t pyres(
           PyObject_CallMethod(
                   self,
                   (char *)S_ON_COMMAND,
                   "ii",
                   lineno - 1,
                   cmd_id));
   return pyres == NULL ? lineno : PyInt_AsLong(pyres.o);
 }
示例#12
0
 void idaapi closed()
 {
   if ( (cb_flags & CHOOSE_HAVE_ONCLOSE) == 0 )
   {
     chobj->chooser_base_t::closed();
     return;
   }
   PYW_GIL_GET;
   pycall_res_t pyres(
           PyObject_CallMethod(self, (char *)S_ON_CLOSE, NULL));
   // delete UI hook
   PyObject_DelAttrString(self, "ui_hooks_trampoline");
 }
示例#13
0
 void on_get_line_attr(int lineno, chooser_item_attrs_t *attr)
 {
   PYW_GIL_GET;
   newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_GET_LINE_ATTR, "i", lineno - 1));
   if ( pyres != NULL )
   {
     if ( PyList_Check(pyres.o) )
     {
       PyObject *item;
       if ( (item = PyList_GetItem(pyres.o, 0)) != NULL )
         attr->color = PyInt_AsLong(item);
       if ( (item = PyList_GetItem(pyres.o, 1)) != NULL )
         attr->flags = PyInt_AsLong(item);
     }
   }
 }
示例#14
0
 void on_insert_line()
 {
   PYW_GIL_GET;
   newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_INSERT_LINE, NULL));
 }
示例#15
0
 void on_select(const intvec_t &intvec)
 {
   PYW_GIL_GET;
   ref_t py_list(PyW_IntVecToPyList(intvec));
   newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_SELECT, "O", py_list.o));
 }
示例#16
0
 void on_refreshed()
 {
   PYW_GIL_GET;
   newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_REFRESHED, NULL));
 }