• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyList_SET_ITEM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyList_SET_ITEM函数的典型用法代码示例。如果您正苦于以下问题:C++ PyList_SET_ITEM函数的具体用法?C++ PyList_SET_ITEM怎么用?C++ PyList_SET_ITEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyList_SET_ITEM函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PyList_New

PyObject *eStreamServer::getConnectedClients()
{
	ePyObject ret;
	int idx = 0;
	int cnt = clients.size();
	ret = PyList_New(cnt);
	for (eSmartPtrList<eStreamClient>::iterator it = clients.begin(); it != clients.end(); ++it)
	{
		ePyObject tuple = PyTuple_New(3);
		PyTuple_SET_ITEM(tuple, 0, PyString_FromString((char *)it->getRemoteHost().c_str()));
		PyTuple_SET_ITEM(tuple, 1, PyString_FromString((char *)it->getServiceref().c_str()));
		PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(it->isUsingEncoder()));
		PyList_SET_ITEM(ret, idx++, tuple);
	}
	return ret;
}
开发者ID:OpenLD,项目名称:enigma2,代码行数:16,代码来源:streamserver.cpp


示例2: while

static PyObject *t_locale_getISOLanguages(PyTypeObject *type)
{
    const char *const *languages = Locale::getISOLanguages();
    PyObject *list;
    int len = 0;

    while (languages[len] != NULL) len += 1;
    list = PyList_New(len);

    for (int i = 0; i < len; i++) {
        PyObject *str = PyString_FromString(languages[i]);
        PyList_SET_ITEM(list, i, str);
    }

    return list;
}
开发者ID:nikolamilosevic86,项目名称:SerbianComparisonExtractor,代码行数:16,代码来源:locale.cpp


示例3: WM_operatortype_iter

static PyObject *pyop_dir(PyObject *UNUSED(self))
{
	GHashIterator iter;
	PyObject *list;
	int i;

	WM_operatortype_iter(&iter);
	list = PyList_New(BLI_ghash_size(iter.gh));

	for (i = 0; !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter), i++) {
		wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
		PyList_SET_ITEM(list, i, PyUnicode_FromString(ot->idname));
	}

	return list;
}
开发者ID:sntulix,项目名称:blender-api-javascript,代码行数:16,代码来源:bpy_operator.c


示例4: PyList_New

PyObject *eServiceEvent::getComponentData() const
{
	ePyObject ret = PyList_New(m_component_data.size());
	int cnt=0;
	for (std::list<eComponentData>::const_iterator it(m_component_data.begin()); it != m_component_data.end(); ++it)
	{
		ePyObject tuple = PyTuple_New(5);
		PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->m_componentTag));
		PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(it->m_componentType));
		PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(it->m_streamContent));
		PyTuple_SET_ITEM(tuple, 3, PyString_FromString(it->m_iso639LanguageCode.c_str()));
		PyTuple_SET_ITEM(tuple, 4, PyString_FromString(it->m_text.c_str()));
		PyList_SET_ITEM(ret, cnt++, tuple);
	}
	return ret;
}
开发者ID:Caught,项目名称:openpliPC,代码行数:16,代码来源:event.cpp


示例5: PyList_New

PyObject *PyMAPIObject_FromSPropValueArray(SPropValue *pv, ULONG nvalues)
{
	PyObject *ret = PyList_New(nvalues);
	if (!ret)
		return NULL;
	ULONG i;
	for (i=0;i<nvalues;i++) {
		PyObject *sub = PyMAPIObject_FromSPropValue(pv+i);
		if (!sub) {
			Py_DECREF(ret);
			return NULL;
		}
		PyList_SET_ITEM(ret, i, sub);
	}
	return ret;
}
开发者ID:GreatFruitOmsk,项目名称:pywin32,代码行数:16,代码来源:mapiutil.cpp


示例6: Py_LOCAL

Py_LOCAL(PyObject *) avl_tree_repr(avl_tree_Object * self)
{
	PyObject *result = NULL;
	avl_size_t len;
	int rc;

	len = avl_size(self->tree);

	rc = Py_ReprEnter((PyObject *) self);
	if (rc != 0)
		return rc > 0 ? PyString_FromString("[...]") : NULL;

	if (len == 0) {
		result = PyString_FromString("[]");
		goto finish;
	}

	{
		avl_iterator iter;
		PyObject *list, *ob;
		Py_ssize_t i = 0;

		iter = avl_iterator_new(self->tree, AVL_ITERATOR_INI_PRE);
		if (iter == NULL)
			goto finish;

		list = PyList_New(len);
		if (list == NULL)
			goto finish;

		do {
			ob = objectAt(avl_iterator_next(iter));
			Py_INCREF(ob);
			PyList_SET_ITEM(list, i, ob);
			++i;
		} while (--len);

		avl_iterator_kill(iter);

		result = PyObject_Repr(list);
		list->ob_type->tp_dealloc(list);
	}

  finish:
	Py_ReprLeave((PyObject *) self);
	return result;
}
开发者ID:PypeBros,项目名称:skiptree,代码行数:47,代码来源:avlmodule.c


示例7: PY_DEF

PY_DEF(pyketama_Continuum_get_points, self, args) {
    PyObject *ret = NULL;
    pyketama_Continuum *pkc = (pyketama_Continuum *)self;

    if (pkc->cont->data->array) {
        int i;
        mcs (*mcsarr)[pkc->cont->data->numpoints] = &pkc->cont->data->array;

        ret = PyList_New(pkc->cont->data->numpoints);
        for (i = 0; i < pkc->cont->data->numpoints; i++) {
            PyList_SET_ITEM(ret, i,
                Py_BuildValue("Is", (*mcsarr)[i].point, (*mcsarr)[i].ip));
        }
    }

    return ret;
}
开发者ID:wayfair,项目名称:ketama,代码行数:17,代码来源:ketamamodule.c


示例8: hash

static PyObject * hash(PyObject * self, PyObject * args)
{
    PyArrayObject * desc;
    PyObject * out_list;     
    int cnt = 0;   
 
    // get reference to the numpy.ndarray that OpenCV stores the descriptor matrix in
    if(!PyArg_ParseTuple(args, "O!", &PyArray_Type, &desc)) 
    {
        PyErr_SetString(lsh_error, "Invalid arguments.");
        return NULL;
    }
    
    // get a pointer to the input matrix (must be contiguous!!!!!)
    unsigned char * arr = (unsigned char *)PyArray_DATA(desc);

    // get the dimensions of the input matrix
    npy_intp * dims = PyArray_DIMS(desc);
    
    // allocate output
    out_list = PyList_New(dims[0] * NUMBER_OF_TABLES);
    if(!out_list)
    {
        PyErr_SetString(lsh_error, "Failed to allocate list.");
        return NULL;
    }

    // for each feature...
    for(int i = 0; i < dims[0]; i++)
    {
        // for each table...
        for(int tb = 0; tb < NUMBER_OF_TABLES; tb++)
        {
            // hash the feature
            size_t key_raw = get_key(tb, arr);
            
            // store in the output
            PyObject * key = PyInt_FromSize_t(key_raw);
            PyList_SET_ITEM(out_list, cnt, key);
            cnt++;
        }    
        // move to the next feature
        arr += FEATURE_SIZE;
    }
    return out_list;
}
开发者ID:Sapphirine,项目名称:Image-Matching-And-Localization,代码行数:46,代码来源:lshmodule.cpp


示例9: PyList_New

ULONG PyGMAPIAdviseSink::OnNotify(ULONG cNotif,  LPNOTIFICATION lpNotifications  )
{
	PY_GATEWAY_METHOD;
	PyObject *arg = PyList_New(cNotif);
	if (!arg)
		return MAKE_PYCOM_GATEWAY_FAILURE_CODE("OnNotify");
	ULONG i;
	for (i=0;i<cNotif;i++) {
		PyObject *sub = PyObject_FromNOTIFICATION(lpNotifications+i);
		if (!sub) {
			Py_DECREF(arg);
			return MAKE_PYCOM_GATEWAY_FAILURE_CODE("OnNotify");
		}
		PyList_SET_ITEM(arg, i, sub);
	}
	return InvokeViaPolicy("OnNotify", NULL, "(N)", arg);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:17,代码来源:PyIMAPIAdviseSink.cpp


示例10: callback_dualtree2

static void callback_dualtree2(void* v, int ind1, int ind2, double dist2) {
    struct dualtree_results2* dt = v;
    PyObject* lst;
    if (dt->permute) {
        ind1 = kdtree_permute(dt->kd1, ind1);
        ind2 = kdtree_permute(dt->kd2, ind2);
    }
    lst = PyList_GET_ITEM(dt->indlist, ind1);
    if (!lst) {
        lst = PyList_New(1);
        // SetItem steals a ref -- that's what we want.
        PyList_SetItem(dt->indlist, ind1, lst);
        PyList_SET_ITEM(lst, 0, PyInt_FromLong(ind2));
    } else {
        PyList_Append(lst, PyInt_FromLong(ind2));
    }
}
开发者ID:Carl4,项目名称:astrometry.net,代码行数:17,代码来源:pyspherematch.c


示例11: launcharray2python

static PyObject* 
launcharray2python(launch_data_t data)
{
	size_t count = launch_data_array_get_count(data);
	size_t i;
	PyObject* result = PyList_New(count);

	for (i = 0; i < 0; i ++) {
		launch_data_t v = launch_data_array_get_index(data, i);
		PyList_SET_ITEM(result, i, launch2python(data));
	}
	if (PyErr_Occurred()) {
		Py_DECREF(result);
		return NULL;
	}
	return result;
}
开发者ID:discoverykid,项目名称:pyobjc,代码行数:17,代码来源:_launch.c


示例12: Py_INCREF

// return Python list of values for this label.  Return None if this label
// has no values (e.g. Atom labels), or NULL on error.
static PyObject *getvalues(GeometryMol *g) {
  if (!g->has_value()) {
    Py_INCREF(Py_None);
    return Py_None;
  }
  ResizeArray<float> gValues(1024);
  if (!g->calculate_all(gValues)) {
    PyErr_SetString(PyExc_ValueError, (char *)"Invalid label");
    return NULL;
  }
  const int n = gValues.num();
  PyObject *newlist = PyList_New(n);
  for (int i=0; i<n; i++) {
    PyList_SET_ITEM(newlist, i, PyFloat_FromDouble(gValues[i]));
  }
  return newlist;
}
开发者ID:VictorMion,项目名称:vmd-cvs-github,代码行数:19,代码来源:py_label.C


示例13: PyList_New

 /**
 * Creates a Python list from a Mantid vector
 * @param values :: A reference to the MantidVec
 * @returns A standard Python list object
 */
 PyObject * MantidVecHelper::createPythonList(const MantidVec & values)
 {
   const Py_ssize_t nVals = static_cast<Py_ssize_t>(values.size());
   PyObject * pyValues = PyList_New(nVals);
   if( !pyValues )
   {
     throw std::runtime_error("Cannot create Python list from Mantid vector.");
   }
   MantidVec::const_iterator iend = values.end();
   Py_ssize_t index(0);
   for( MantidVec::const_iterator itr = values.begin(); itr != iend; ++itr )
   {
     PyList_SET_ITEM(pyValues, index, PyFloat_FromDouble((*itr)));
     ++index;
   }
   return pyValues;
 }
开发者ID:trnielsen,项目名称:mantid,代码行数:22,代码来源:MantidVecHelper.cpp


示例14: psutil_get_cmdline

/*
 * returns a Python list representing the arguments for the process
 * with given pid or NULL on error.
 */
PyObject *
psutil_get_cmdline(long pid) {
    PyObject *ret = NULL;
    WCHAR *data = NULL;
    SIZE_T size;
    PyObject *py_retlist = NULL;
    PyObject *py_unicode = NULL;
    LPWSTR *szArglist = NULL;
    int nArgs, i;

    if (psutil_get_process_data(pid, KIND_CMDLINE, &data, &size) != 0)
        goto out;

    // attempt to parse the command line using Win32 API
    szArglist = CommandLineToArgvW(data, &nArgs);
    if (szArglist == NULL) {
        PyErr_SetFromWindowsErr(0);
        goto out;
    }

    // arglist parsed as array of UNICODE_STRING, so convert each to
    // Python string object and add to arg list
    py_retlist = PyList_New(nArgs);
    if (py_retlist == NULL)
        goto out;
    for (i = 0; i < nArgs; i++) {
        py_unicode = PyUnicode_FromWideChar(szArglist[i],
                                            wcslen(szArglist[i]));
        if (py_unicode == NULL)
            goto out;
        PyList_SET_ITEM(py_retlist, i, py_unicode);
        py_unicode = NULL;
    }

    ret = py_retlist;
    py_retlist = NULL;

out:
    LocalFree(szArglist);
    free(data);
    Py_XDECREF(py_unicode);
    Py_XDECREF(py_retlist);

    return ret;
}
开发者ID:Colorado4Wheeler,项目名称:Mac-Commander,代码行数:49,代码来源:process_info.c


示例15: getEntities

PyObject* EntityGarbages<T>::pyValues()
{
	ENTITYS_MAP& entities = getEntities();
	PyObject* pyList = PyList_New(entities.size());
	int i = 0;

	ENTITYS_MAP::const_iterator iter = entities.begin();
	while (iter != entities.end())
	{
		Py_INCREF(iter->second);
		PyList_SET_ITEM(pyList, i, iter->second);

		i++;
		iter++;
	}

	return pyList;
}
开发者ID:Anehta,项目名称:kbengine,代码行数:18,代码来源:entity_garbages.hpp


示例16: CreatePyListFromStringVector

 PyObject* CreatePyListFromStringVector(const std::vector<std::string> &data)
 {
     PyObject* returnlist = PyList_New( data.size() );
     if(!returnlist) return 0;
     
     for(unsigned int i =0; i<data.size(); ++i)
     {
         PyObject *str =  PyString_FromString(data[i].c_str());
         if (str == NULL)
         {
             Py_DECREF(returnlist);
             return NULL;
         }
         PyList_SET_ITEM(returnlist, i, str);
     }
     
     return returnlist;
 }
开发者ID:heesoo,项目名称:OpenColorIO,代码行数:18,代码来源:PyUtil.cpp


示例17: PyList_New

static PyObject *bpy_bmdeformvert_items(BPy_BMDeformVert *self)
{
	PyObject *ret;
	PyObject *item;
	int i;
	MDeformWeight *dw = self->data->dw;

	ret = PyList_New(self->data->totweight);
	for (i = 0; i < self->data->totweight; i++, dw++) {
		item = PyTuple_New(2);
		PyTuple_SET_ITEMS(item,
		        PyLong_FromLong(dw->def_nr),
		        PyFloat_FromDouble(dw->weight));
		PyList_SET_ITEM(ret, i, item);
	}

	return ret;
}
开发者ID:wchargin,项目名称:blender,代码行数:18,代码来源:bmesh_py_types_meshdata.c


示例18: PyList_New

//-------------------------------------------------------------------------------------
PyObject* PyBots::pyValues()
{
	Bots::CLIENTS& refclients = Bots::getSingleton().clients();
	PyObject* pyList = PyList_New(refclients.size());
	int i = 0;

	Bots::CLIENTS::const_iterator iter = refclients.begin();
	while (iter != refclients.end())
	{
		Py_INCREF(iter->second);
		PyList_SET_ITEM(pyList, i, iter->second);

		i++;
		iter++;
	}

	return pyList;
}
开发者ID:AddictXQ,项目名称:kbengine,代码行数:19,代码来源:pybots.cpp


示例19: py_guestfs_event_callback_wrapper

/* http://docs.python.org/release/2.5.2/ext/callingPython.html */
static void
py_guestfs_event_callback_wrapper (guestfs_h *g,
                                   void *callback,
                                   uint64_t event,
                                   int event_handle,
                                   int flags,
                                   const char *buf, size_t buf_len,
                                   const uint64_t *array, size_t array_len)
{
  PyGILState_STATE py_save = PyGILState_UNLOCKED;
  PyObject *py_callback = callback;
  PyObject *py_array;
  PyObject *args;
  PyObject *a;
  size_t i;
  PyObject *py_r;

  py_array = PyList_New (array_len);
  for (i = 0; i < array_len; ++i) {
    a = PyLong_FromLongLong (array[i]);
    PyList_SET_ITEM (py_array, i, a);
  }

  /* XXX As with Perl we don't pass the guestfs_h handle here. */
  args = Py_BuildValue ("(Kis#O)",
                        (unsigned PY_LONG_LONG) event, event_handle,
                        buf, buf_len, py_array);

  if (PyEval_ThreadsInitialized ())
    py_save = PyGILState_Ensure ();

  py_r = PyEval_CallObject (py_callback, args);

  if (PyEval_ThreadsInitialized ())
    PyGILState_Release (py_save);

  Py_DECREF (args);

  if (py_r != NULL)
    Py_DECREF (py_r);
  else
    /* Callback threw an exception: print it. */
    PyErr_PrintEx (0);
}
开发者ID:gaowanlong,项目名称:libguestfs,代码行数:45,代码来源:guestfs-py-byhand.c


示例20: py_get_colorlist

static PyObject* py_get_colorlist(PyObject *self, PyObject *args)
{

  PyObject *newlist = NULL, *newtuple = NULL;
  int i, j, listlen;
  const char *name;
  float col[3];
  VMDApp *app;

  if (!(app = get_vmdapp()))
    return NULL;

  listlen = app->num_regular_colors();
  if (!(newlist = PyList_New(listlen)))
    goto failure;

  for (i = 0; i < listlen; i++) {

    name = app->color_name(i);
    if (!app->color_value(name, col, col+1, col+2))
      goto failure;

    if (!(newtuple = PyTuple_New(3)))
      goto failure;

    for (j = 0; j < 3; j++) {
      PyTuple_SET_ITEM(newtuple, j, PyFloat_FromDouble(col[j]));
      if (PyErr_Occurred())
        goto failure;
    }

    PyList_SET_ITEM(newlist, i, newtuple);
    if (PyErr_Occurred())
      goto failure;

  }
  return newlist;

failure:
  PyErr_SetString(PyExc_RuntimeError, "Problem getting color list");
  Py_XDECREF(newlist);
  Py_XDECREF(newtuple);
  return NULL;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:44,代码来源:py_color.C



注:本文中的PyList_SET_ITEM函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyList_SetItem函数代码示例发布时间:2022-05-30
下一篇:
C++ PyList_New函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap