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

C++ PyLong_FromVoidPtr函数代码示例

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

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



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

示例1: multiprocessing_address_of_buffer

static PyObject*
multiprocessing_address_of_buffer(PyObject *self, PyObject *obj)
{
    void *buffer;
    Py_ssize_t buffer_len;

    if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len) < 0)
        return NULL;

    return Py_BuildValue("N" F_PY_SSIZE_T,
                         PyLong_FromVoidPtr(buffer), buffer_len);
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:12,代码来源:multiprocessing.c


示例2: py_newterm

static PyObject* py_newterm(PyObject *self, PyObject *args){
  int fd;
  SCREEN *screen;
  if (!PyArg_ParseTuple(args, "i", &fd))
    return NULL;

  Py_BEGIN_ALLOW_THREADS
  FILE *fp = fdopen(fd, "w+");
  screen = newterm(NULL, fp, fp);
  Py_END_ALLOW_THREADS

  return PyLong_FromVoidPtr(screen);
}
开发者ID:Lucnsy,项目名称:winterpy,代码行数:13,代码来源:mytermutil.c


示例3: EnumVisibleWindowsProc

BOOL CALLBACK
EnumVisibleWindowsProc(HWND hwnd, LPARAM lParam)
{
	if (IsWindowVisible(hwnd))
	{	
		PyObject *item;

		item = PyLong_FromVoidPtr(hwnd);
		PyList_Append((PyObject *) lParam, item);
		Py_DECREF(item); 
	}
	return TRUE;
}
开发者ID:AssetsInc,项目名称:EventGhost,代码行数:13,代码来源:win_funcs.c


示例4: PyTuple_Size

static PyObject *register_nextstep_callback(PyObject *self, PyObject *args)
{
    FENTER

    PyObject *fArgs;
    PyObject *function;
    gpi_sim_hdl hdl;

    p_callback_data callback_data_p;

    Py_ssize_t numargs = PyTuple_Size(args);

    if (numargs < 1) {
        fprintf(stderr, "Attempt to register ReadOnly callback with!\n");
        return NULL;
    }

    // Extract the callback function
    function = PyTuple_GetItem(args, 0);
    if (!PyCallable_Check(function)) {
        fprintf(stderr, "Attempt to register ReadOnly without supplying a callback!\n");
        return NULL;
    }
    Py_INCREF(function);

    // Remaining args for function
    fArgs = PyTuple_GetSlice(args, 1, numargs);   // New reference
    if (fArgs == NULL) {
        return NULL;
    }

    callback_data_p = (p_callback_data)malloc(sizeof(s_callback_data));
    if (callback_data_p == NULL) {
        return PyErr_NoMemory();
    }

    // Set up the user data (no more python API calls after this!)
    callback_data_p->_saved_thread_state = PyThreadState_Get();
    callback_data_p->id_value = COCOTB_ACTIVE_ID;
    callback_data_p->function = function;
    callback_data_p->args = fArgs;
    callback_data_p->kwargs = NULL;

    hdl = gpi_register_nexttime_callback((gpi_function_t)handle_gpi_callback, callback_data_p);

    PyObject *rv = PyLong_FromVoidPtr(hdl);
    FEXIT

    return rv;
}
开发者ID:TC01,项目名称:cocotb,代码行数:50,代码来源:simulatormodule.c


示例5: meminfo_new

/*
 * Create a new MemInfo with a owner PyObject
 */
static PyObject *
meminfo_new(PyObject *self, PyObject *args) {
    PyObject *addr_data_obj;
    void *addr_data;
    PyObject *ownerobj;
    NRT_MemInfo *mi;
    if (!PyArg_ParseTuple(args, "OO", &addr_data_obj, &ownerobj)) {
        return NULL;
    }
    addr_data = PyLong_AsVoidPtr(addr_data_obj);
    if (PyErr_Occurred())
        return NULL;
    mi = meminfo_new_from_pyobject(addr_data, ownerobj);
    return PyLong_FromVoidPtr(mi);
}
开发者ID:DashYang,项目名称:sim,代码行数:18,代码来源:_nrt_pythonmod.c


示例6: Mouse_GetMouseData

PyObject *PythonImport_GetMouse( PyObject *self, PyObject *args )
{
	SMouseInfo *pMouse = Mouse_GetMouseData();

	// mouse always needs to be returned
	PyObject* pObject = PyLong_FromVoidPtr( (void*)pMouse );
	if( pObject )
	{
		// increment the reference count?
		Py_INCREF( pObject );
		return pObject;
	}

	// throw exception
	return PyErr_NoMemory();
}
开发者ID:rwlaschin,项目名称:Visionary,代码行数:16,代码来源:PythonImport.cpp


示例7: zen_controller_run_action

void zen_controller_run_action(ZenController *zen, const char *action_name)
{
	PyObject *addr, *result;
	GeanyDocument *doc;

	g_return_if_fail(zen != NULL);
	g_return_if_fail(action_name != NULL);

	ui_set_statusbar(FALSE, _("Zen Coding: Running '%s' action"), action_name);

	doc = document_get_current();
	if (!DOC_VALID(doc))
	{
		g_warning("No valid document detected.");
		return;
	}

	addr = PyLong_FromVoidPtr((void *) doc);
	if (addr == NULL)
	{
		if (PyErr_Occurred())
			PyErr_Print();
		g_warning("Unable to convert document pointer to Python object.");
		return;
	}

	result = PyObject_CallMethod(zen->editor, "set_context", "O", addr);
	Py_DECREF(addr);
	if (result == NULL)
	{
		if (PyErr_Occurred())
			PyErr_Print();
		g_warning("Unable to call set_context() function.");
		return;
	}
	Py_XDECREF(result);

	result = PyObject_CallFunction(zen->run_action, "sO", action_name, zen->editor);
	if (result == NULL)
	{
		if (PyErr_Occurred())
			PyErr_Print();
		g_warning("Call to run_action() failed.");
		return;
	}
	Py_XDECREF(result);
}
开发者ID:b4n,项目名称:geany-zencoding,代码行数:47,代码来源:zen-controller.c


示例8: gpi_get_handle_by_index

static PyObject *get_handle_by_index(PyObject *self, PyObject *args)
{
    int32_t index;
    gpi_sim_hdl hdl;
    gpi_sim_hdl result;
    PyObject *value;

    if (!PyArg_ParseTuple(args, "O&i", gpi_sim_hdl_converter, &hdl, &index)) {
        return NULL;
    }

    result = gpi_get_handle_by_index((gpi_sim_hdl)hdl, index);

    value = PyLong_FromVoidPtr(result);

    return value;
}
开发者ID:TC01,项目名称:cocotb,代码行数:17,代码来源:simulatormodule.c


示例9: gpi_get_handle_by_name

static PyObject *get_handle_by_name(PyObject *self, PyObject *args)
{
    const char *name;
    gpi_sim_hdl hdl;
    gpi_sim_hdl result;
    PyObject *res;

    if (!PyArg_ParseTuple(args, "O&s", gpi_sim_hdl_converter, &hdl, &name)) {
        return NULL;
    }

    result = gpi_get_handle_by_name((gpi_sim_hdl)hdl, name);

    res = PyLong_FromVoidPtr(result);

    return res;
}
开发者ID:TC01,项目名称:cocotb,代码行数:17,代码来源:simulatormodule.c


示例10: gpi_iterate

static PyObject *iterate(PyObject *self, PyObject *args)
{
    gpi_sim_hdl hdl;
    int type;
    gpi_iterator_hdl result;
    PyObject *res;

    if (!PyArg_ParseTuple(args, "O&i", gpi_sim_hdl_converter, &hdl, &type)) {
        return NULL;
    }

    result = gpi_iterate(hdl, (gpi_iterator_sel_t)type);

    res = PyLong_FromVoidPtr(result);

    return res;
}
开发者ID:TC01,项目名称:cocotb,代码行数:17,代码来源:simulatormodule.c


示例11: _get_osfhandle

// Convert a C runtime file descriptor to an OS file handle.
static PyObject *msvcrt_get_osfhandle(PyObject *self, PyObject *args)
{
	int fd;
	intptr_t handle;

	if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
		return NULL;

	handle = _get_osfhandle(fd);
	if (handle == -1)
		return PyErr_SetFromErrno(PyExc_IOError);

	/* technically 'handle' is not a pointer, but a integer as
	   large as a pointer, Python's *VoidPtr interface is the
	   most appropriate here */
	return PyLong_FromVoidPtr((void*)handle);
}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:18,代码来源:msvcrtmodule.c


示例12: dbus_py_variant_level_get

long
dbus_py_variant_level_get(PyObject *obj)
{
    PyObject *vl_obj;
    PyObject *key = PyLong_FromVoidPtr(obj);

    if (!key) {
        return 0;
    }

    vl_obj = PyDict_GetItem(_dbus_py_variant_levels, key);
    Py_DECREF(key);

    if (!vl_obj)
        return 0;
    return PyInt_AsLong(vl_obj);
}
开发者ID:mahomahomaho,项目名称:dbus-python-egg,代码行数:17,代码来源:abstract.c


示例13: dbus_py_variant_level_getattro

PyObject *
dbus_py_variant_level_getattro(PyObject *obj, PyObject *name)
{
    PyObject *key, *value;

#ifdef PY3
    if (PyUnicode_CompareWithASCIIString(name, "variant_level"))
        return PyObject_GenericGetAttr(obj, name);
#else
    if (PyBytes_Check(name)) {
        Py_INCREF(name);
    }
    else if (PyUnicode_Check(name)) {
        name = PyUnicode_AsEncodedString(name, NULL, NULL);
        if (!name) {
            return NULL;
        }
    }
    else {
        PyErr_SetString(PyExc_TypeError, "attribute name must be string");
        return NULL;
    }

    if (strcmp(PyBytes_AS_STRING(name), "variant_level")) {
        value = PyObject_GenericGetAttr(obj, name);
        Py_CLEAR(name);
        return value;
    }

    Py_CLEAR(name);
#endif  /* PY3 */

    key = PyLong_FromVoidPtr(obj);

    if (!key) {
        return NULL;
    }

    value = PyDict_GetItem(_dbus_py_variant_levels, key);
    Py_CLEAR(key);

    if (!value)
        return NATIVEINT_FROMLONG(0);
    Py_INCREF(value);
    return value;
}
开发者ID:lichinka,项目名称:dbus-python,代码行数:46,代码来源:abstract.c


示例14: call_getnewargs

static PyObject *node_deepcopy(PyObject *self, PyObject *memo)
{
  PyObject *args, *state, *temp;
  PyObject *result=NULL;

  args = call_getnewargs(self);
  if (args == NULL)
    return NULL;
  args = PyObject_CallFunction(deepcopy_function, "NO", args, memo);
  if (args == NULL)
    return NULL;
  result = self->ob_type->tp_new(self->ob_type, args, NULL);
  Py_DECREF(args);
  if (result == NULL)
    return NULL;
  temp = PyLong_FromVoidPtr(self);
  if (temp == NULL) {
    Py_DECREF(result);
    return NULL;
  }
  if (PyDict_SetItem(memo, temp, result) < 0) {
    Py_DECREF(temp);
    Py_DECREF(result);
    return NULL;
  }
  Py_DECREF(temp);

  /* __getstate__(deep=True) is our extension for deepcopying nodes */
  state = PyObject_CallMethod(self, "__getstate__", "O", Py_True);
  if (state == NULL) {
    Py_DECREF(result);
    return NULL;
  }
  state = PyObject_CallFunction(deepcopy_function, "NO", state, memo);
  if (state == NULL) {
    Py_DECREF(result);
    return NULL;
  }
  temp = PyObject_CallMethod(result, "__setstate__", "(N)", state);
  if (temp == NULL) {
    Py_DECREF(result);
    return NULL;
  }
  return result;
}
开发者ID:abed-hawa,项目名称:amara,代码行数:45,代码来源:node.c


示例15: node_hash

static long node_hash(NodeObject *self)
{
#if SIZEOF_LONG >= SIZEOF_VOID_P
  return (long)self;
#else
  /* convert to a Python long and hash that */
  PyObject *longobj;
  long hash;

  if ((longobj = PyLong_FromVoidPtr(self)) == NULL) {
    return -1;
  }

  hash = PyObject_Hash(longobj);
  Py_DECREF(longobj);
  return hash;
#endif
}
开发者ID:abed-hawa,项目名称:amara,代码行数:18,代码来源:node.c


示例16: Struct_tp_repr

static PyObject *
Struct_tp_repr(PyObject *self)
{
    PyObject *parent_repr = (PyTuple_Type.tp_repr)((PyObject *)self);
    PyObject *sig;
    PyObject *sig_repr = NULL;
    PyObject *key;
    long variant_level;
    PyObject *my_repr = NULL;

    if (!parent_repr) goto finally;
    key = PyLong_FromVoidPtr(self);
    if (!key) goto finally;
    sig = PyDict_GetItem(struct_signatures, key);
    Py_CLEAR(key);
    if (!sig) sig = Py_None;
    sig_repr = PyObject_Repr(sig);
    if (!sig_repr) goto finally;

    variant_level = dbus_py_variant_level_get(self);
    if (variant_level < 0)
        goto finally;

    if (variant_level > 0) {
        my_repr = PyUnicode_FromFormat("%s(%V, signature=%V, "
                                       "variant_level=%ld)",
                                       Py_TYPE(self)->tp_name,
                                       REPRV(parent_repr),
                                       REPRV(sig_repr),
                                       variant_level);
    }
    else {
        my_repr = PyUnicode_FromFormat("%s(%V, signature=%V)",
                                       Py_TYPE(self)->tp_name,
                                       REPRV(parent_repr),
                                       REPRV(sig_repr));
    }

finally:
    Py_CLEAR(parent_repr);
    Py_CLEAR(sig_repr);
    return my_repr;
}
开发者ID:smcv,项目名称:dbus-python,代码行数:43,代码来源:containers.c


示例17: register_npymath_exports

static int
register_npymath_exports(PyObject *dct)
{
    size_t count = sizeof(npymath_exports) / sizeof(npymath_exports[0]);
    size_t i;

    for (i = 0; i < count; ++i) {
        PyObject *ptr = PyLong_FromVoidPtr(npymath_exports[i].func);
        if (ptr == NULL)
            return -1;
        if (PyDict_SetItemString(dct, npymath_exports[i].name, ptr) < 0) {
            Py_DECREF(ptr);
            return -1;
        }
        Py_DECREF(ptr);
    }

    return 0;
}
开发者ID:digideskio,项目名称:numba,代码行数:19,代码来源:_helpermod.c


示例18: l

bool CPythonEngine::InitMainInterp(void)
{
	// ensure only 1 engine/thread initialises this only
	CSLock l(m_initLock);
	if (!m_haveInit) {
		PyGILState_STATE old_state;
		if (Py_IsInitialized())
			old_state = PyGILState_Ensure();
		else {
			Py_Initialize();
			old_state = PyGILState_UNLOCKED;
		}
		PyEval_InitThreads();
	
		if (!g_IsFrozen) {
			TCHAR *dll_path = GetModulePath();
			AddToPythonPath(dll_path);
			free(dll_path);
			PyErr_Clear();
			}
	
		// isapidllhandle to match dllhandle, frozendllhandle, etc :)  Also a 
		// nice way for a program to know they are in an ISAPI context.
		PyObject *obh = PyLong_FromVoidPtr(g_hInstance);
		PySys_SetObject("isapidllhandle", obh);
		Py_XDECREF(obh);
		// Locate the special exception we use to trigger a reload.
		PyObject *isapi_package = PyImport_ImportModule("isapi");
		if (isapi_package)
			m_reload_exception = PyObject_GetAttrString(isapi_package,
			                             "InternalReloadException");
		Py_XDECREF(isapi_package);

		// ready our types.
		InitExtensionTypes();
		InitFilterTypes();

		PyGILState_Release(old_state);
		FindModuleName();
		m_haveInit = true;
	}
	return true;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:43,代码来源:PythonEng.cpp


示例19: gpi_get_root_handle

static PyObject *get_root_handle(PyObject *self, PyObject *args)
{
    const char *name;
    gpi_sim_hdl result;
    PyObject *value;

    if (!PyArg_ParseTuple(args, "z", &name)) {
        return NULL;
    }

    result = gpi_get_root_handle(name);
    if (NULL == result) {
       Py_RETURN_NONE;
    }


    value = PyLong_FromVoidPtr(result);

    return value;
}
开发者ID:TC01,项目名称:cocotb,代码行数:20,代码来源:simulatormodule.c


示例20: dbus_py_variant_level_getattro

PyObject *
dbus_py_variant_level_getattro(PyObject *obj, PyObject *name)
{
    PyObject *key, *value;

    if (PyString_Check(name)) {
        Py_INCREF(name);
    }
    else if (PyUnicode_Check(name)) {
        name = PyUnicode_AsEncodedString(name, NULL, NULL);
        if (!name) {
            return NULL;
        }
    }
    else {
        PyErr_SetString(PyExc_TypeError, "attribute name must be string");
        return NULL;
    }

    if (strcmp(PyString_AS_STRING(name), "variant_level")) {
        value = PyObject_GenericGetAttr(obj, name);
        Py_DECREF(name);
        return value;
    }

    Py_DECREF(name);

    key = PyLong_FromVoidPtr(obj);

    if (!key) {
        return NULL;
    }

    value = PyDict_GetItem(_dbus_py_variant_levels, key);
    Py_DECREF(key);

    if (!value)
        return PyInt_FromLong(0);
    Py_INCREF(value);
    return value;
}
开发者ID:mahomahomaho,项目名称:dbus-python-egg,代码行数:41,代码来源:abstract.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PyMac_Error函数代码示例发布时间:2022-05-30
下一篇:
C++ PyLong_FromUnsignedLong函数代码示例发布时间: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