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); } } }
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; }
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); }
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)); }
void on_edit_line(int lineno) { PYW_GIL_GET; newref_t pyres( PyObject_CallMethod( self, (char *)S_ON_EDIT_LINE, "i", lineno - 1)); }
void on_enter(int lineno) { PYW_GIL_GET; newref_t pyres( PyObject_CallMethod( self, (char *)S_ON_SELECT_LINE, "i", lineno - 1)); }
// 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)); }
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); }
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; }
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); }
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); }
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"); }
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); } } }
void on_insert_line() { PYW_GIL_GET; newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_INSERT_LINE, NULL)); }
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)); }
void on_refreshed() { PYW_GIL_GET; newref_t pyres(PyObject_CallMethod(self, (char *)S_ON_REFRESHED, NULL)); }