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

C++ PyLong_AsVoidPtr函数代码示例

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

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



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

示例1:

static PyObject *_tkinit(PyObject *self, PyObject *args)
{
    Tcl_Interp *interp;
    TkappObject *app;

    PyObject *arg;
    int is_interp;
    if (!PyArg_ParseTuple(args, "Oi", &arg, &is_interp)) {
        return NULL;
    }

    if (is_interp) {
        interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
    } else {
        /* Do it the hard way.  This will break if the TkappObject
           layout changes */
        app = (TkappObject *)PyLong_AsVoidPtr(arg);
        interp = app->interp;
    }

    /* This will bomb if interp is invalid... */

    TCL_CREATE_COMMAND(interp,
                       "PyAggImagePhoto",
                       (Tcl_CmdProc *)PyAggImagePhoto,
                       (ClientData)0,
                       (Tcl_CmdDeleteProc *)NULL);

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:AlexandreAbraham,项目名称:matplotlib,代码行数:31,代码来源:_tkagg.cpp


示例2: memsys_set_atomic_inc_dec

static PyObject *
memsys_set_atomic_inc_dec(PyObject *self, PyObject *args) {
    PyObject *addr_inc_obj, *addr_dec_obj;
    void *addr_inc, *addr_dec;
    if (!PyArg_ParseTuple(args, "OO", &addr_inc_obj, &addr_dec_obj)) {
        return NULL;
    }
    addr_inc = PyLong_AsVoidPtr(addr_inc_obj);
    if(PyErr_Occurred()) return NULL;
    addr_dec = PyLong_AsVoidPtr(addr_dec_obj);
    if(PyErr_Occurred()) return NULL;
    NRT_MemSys_set_atomic_inc_dec(addr_inc, addr_dec);
    Py_RETURN_NONE;
}
开发者ID:DashYang,项目名称:sim,代码行数:14,代码来源:_nrt_pythonmod.c


示例3: set_void_ptr

static int
set_void_ptr(void **vpp, PyObject *o, const char *name)
{
    void *vp = 0;

    if (check_value(o, name)) {
        return -1;
    }
    if (INT_CHECK(o)) {
        vp = PyLong_AsVoidPtr(o);
        if (PyErr_Occurred()) {
            return -1;
        }
    }
    else if (o == Py_None) {
        vp = 0;
    }
    else {
        PyErr_Format(PyExc_TypeError,
                     "property %400s must be a Python integer, not '%400s'",
                     name, Py_TYPE(o)->tp_name);
        return -1;
    }
    *vpp = vp;
    return 0;
}
开发者ID:Anugrahaa,项目名称:anagrammatic,代码行数:26,代码来源:newbuffer.c


示例4: SharedMemory_attach

PyObject *
SharedMemory_attach(SharedMemory *self, PyObject *args, PyObject *keywords) {
    PyObject *py_address = NULL;
    void *address = NULL;
    int flags = 0;
    static char *keyword_list[ ] = {"address", "flags", NULL};

    DPRINTF("Inside SharedMemory_attach()\n");

    if (!PyArg_ParseTupleAndKeywords(args, keywords, "|Oi", keyword_list,
                                     &py_address, &flags))
        goto error_return;

    if ((!py_address) || (py_address == Py_None))
        address = NULL;
    else {
        if (PyLong_Check(py_address))
            address = PyLong_AsVoidPtr(py_address);
        else {
            PyErr_SetString(PyExc_TypeError, "address must be a long");
            goto error_return;
        }
    }

    return shm_attach(self, address, flags);

    error_return:
    return NULL;
}
开发者ID:mruffalo,项目名称:sysv_ipc,代码行数:29,代码来源:memory.c


示例5: PyBlosc_decompress_ptr

static PyObject *
PyBlosc_decompress_ptr(PyObject *self, PyObject *args)
{
    PyObject * pointer, * return_int;
    void * input, * output;
    size_t cbytes, nbytes;

    /* require a compressed string and a pointer  */
    if (!PyArg_ParseTuple(args, "s#O:decompress", &input, &cbytes, &pointer))
      return NULL;

    /*  convert the int or long Python object to a void * */
    output = PyLong_AsVoidPtr(pointer);
    if (output == NULL)
      return NULL;

    /*  fetch the uncompressed size into nbytes */
    if (!get_nbytes(input, cbytes, &nbytes))
      return NULL;

    /* do decompression */
    if (!decompress_helper(input, nbytes, output))
      return NULL;

    /*  Return nbytes as python integer. This is legitimate, because
     *  decompress_helper above has checked that the number of bytes written
     *  was indeed nbytes.
     *  */
    return_int = PyLong_FromSize_t(nbytes);
    Py_INCREF(return_int);
    return return_int;
}
开发者ID:B-Rich,项目名称:python-blosc,代码行数:32,代码来源:blosc_extension.c


示例6: PyErr_SetString

/*
 * A convenience function to convert a C/C++ void pointer from a Python object.
 */
void *sip_api_convert_to_void_ptr(PyObject *obj)
{
    if (obj == NULL)
    {
        PyErr_SetString(PyExc_TypeError, "sip.voidptr is NULL");
        return NULL;
    }

    if (obj == Py_None)
        return NULL;

    if (PyObject_TypeCheck(obj, &sipVoidPtr_Type))
        return ((sipVoidPtrObject *)obj)->voidptr;

#if defined(SIP_USE_PYCAPSULE)
    if (PyCapsule_CheckExact(obj))
        return PyCapsule_GetPointer(obj, NULL);
#endif

#if defined(SIP_SUPPORT_PYCOBJECT)
    if (PyCObject_Check(obj))
        return PyCObject_AsVoidPtr(obj);
#endif

    return PyLong_AsVoidPtr(obj);
}
开发者ID:Werkov,项目名称:SIP,代码行数:29,代码来源:voidptr.c


示例7: _pygi_marshal_from_py_void

static gboolean
_pygi_marshal_from_py_void (PyGIInvokeState   *state,
                            PyGICallableCache *callable_cache,
                            PyGIArgCache      *arg_cache,
                            PyObject          *py_arg,
                            GIArgument        *arg,
                            gpointer          *cleanup_data)
{
    g_warn_if_fail (arg_cache->transfer == GI_TRANSFER_NOTHING);

    if (py_arg == Py_None) {
        arg->v_pointer = NULL;
    } else if (PYGLIB_CPointer_Check(py_arg)) {
        arg->v_pointer = PYGLIB_CPointer_GetPointer (py_arg, NULL);
    } else if (PYGLIB_PyLong_Check(py_arg) || PyLong_Check(py_arg)) {
        arg->v_pointer = PyLong_AsVoidPtr (py_arg);
    } else {
        PyErr_SetString(PyExc_ValueError,
                        "Pointer arguments are restricted to integers, capsules, and None. "
                        "See: https://bugzilla.gnome.org/show_bug.cgi?id=683599");
        return FALSE;
    }

    *cleanup_data = arg->v_pointer;
    return TRUE;
}
开发者ID:Distrotech,项目名称:pygobject,代码行数:26,代码来源:pygi-basictype.c


示例8: Dispatcher_init

static int
Dispatcher_init(DispatcherObject *self, PyObject *args, PyObject *kwds)
{
    PyObject *tmaddrobj;
    void *tmaddr;
    int argct;
    int can_fallback;
    int has_stararg = 0;
    int exact_match_required = 0;

    if (!PyArg_ParseTuple(args, "OiiO!O!i|ii", &tmaddrobj, &argct,
                          &self->fold_args,
                          &PyTuple_Type, &self->argnames,
                          &PyTuple_Type, &self->defargs,
                          &can_fallback,
                          &has_stararg,
                          &exact_match_required
                         )) {
        return -1;
    }
    Py_INCREF(self->argnames);
    Py_INCREF(self->defargs);
    tmaddr = PyLong_AsVoidPtr(tmaddrobj);
    self->dispatcher = dispatcher_new(tmaddr, argct);
    self->can_compile = 1;
    self->can_fallback = can_fallback;
    self->firstdef = NULL;
    self->fallbackdef = NULL;
    self->interpdef = NULL;
    self->has_stararg = has_stararg;
    self->exact_match_required = exact_match_required;
    return 0;
}
开发者ID:esc,项目名称:numba,代码行数:33,代码来源:_dispatcher.c


示例9: PyObject_CallMethod

static Tcl_Interp *get_interpreter(PyObject *tkapp) {
    PyObject *interpaddrobj = PyObject_CallMethod(tkapp, "interpaddr", NULL);
    if(interpaddrobj == NULL) { return NULL; }
    void *interpaddr = PyLong_AsVoidPtr(interpaddrobj);
    Py_DECREF(interpaddrobj);
    if(interpaddr == -1) { return NULL; }
    return (Tcl_Interp*)interpaddr;
}
开发者ID:safarir,项目名称:LinuxCNC,代码行数:8,代码来源:_toglmodule.c


示例10: PyErr_Clear

// Get an array of OpenGL fundamental types from a sequence or an object that
// implements a compatible buffer.  Cache the array so that it persists until a
// similar call.
const GLvoid *qpyopengl_value_array_cached(sipErrorState *estate,
        PyObject *values, GLenum gl_type, PyObject *bindings, const char *pkey,
        GLuint skey)
{
    // Handle the trivial byte offset case first.
    PyErr_Clear();

    void *data = PyLong_AsVoidPtr(values);

    if (!PyErr_Occurred())
        return data;

    PyErr_Clear();

    qpyopengl_dataCache *data_cache = get_cache(bindings);

    if (!data_cache)
    {
        *estate = sipErrorFail;
        return 0;
    }

    if (!data_cache->pcache)
        data_cache->pcache = new PrimaryCache;

    // Get an empty wrapper for the array.
    PrimaryCacheEntry *pce = (*data_cache->pcache)[pkey];

    if (!pce)
    {
        pce = new PrimaryCacheEntry;
        data_cache->pcache->insert(pkey, pce);
    }

    Array *array;

    if (skey == 0)
    {
        array = &pce->skey_0;
    }
    else
    {
        if (!pce->skey_n)
            pce->skey_n = new SecondaryCache;

        array = (*pce->skey_n)[skey];

        if (!array)
        {
            array = new Array;
            pce->skey_n->insert(skey, array);
        }
    }

    array->clear();

    return convert_values(array, values, gl_type, estate);
}
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:61,代码来源:qpyopengl_value_array.cpp


示例11: send_action_python

static PyObject* send_action_python(PyObject* self, PyObject* args){
	int action;
	PyObject* d;
	if (!PyArg_ParseTuple(args, "Oi", &d,&action))
		return NULL;
	struct ms_control* data;
	data = (struct ms_control*)PyLong_AsVoidPtr(d);
	send_action(data,action);
	return Py_BuildValue("i",0);
}
开发者ID:jiefxxx,项目名称:pbot,代码行数:10,代码来源:motor-lib-python.c


示例12: get_motor_rawValue_python

static PyObject* get_motor_rawValue_python(PyObject* self, PyObject* args){
	int ret,motor,val;
	PyObject* d;
	if (!PyArg_ParseTuple(args, "Oi", &d,&motor))
		return NULL;
	struct ms_control* data;
	data = (struct ms_control*)PyLong_AsVoidPtr(d);
	ret=get_motor_rawValue(data,motor);
	return Py_BuildValue("i", ret);
}
开发者ID:jiefxxx,项目名称:pbot,代码行数:10,代码来源:motor-lib-python.c


示例13: return

static ach_channel_t *parse_channel_pointer( PyObject *i ) {
    if( PyInt_Check(i) ) {
        return (ach_channel_t*)PyInt_AsLong(i);
    } else if ( PyLong_Check(i) ) {
        return (ach_channel_t*)PyLong_AsVoidPtr(i);
    } else {
        PyErr_SetString( PyExc_TypeError, "invalid channel pointer" );
        return NULL;
    }
}
开发者ID:LofaroLabs,项目名称:ach,代码行数:10,代码来源:ach_py.c


示例14: set_servo_value_python

static PyObject* set_servo_value_python(PyObject* self, PyObject* args){
	int ret,servo,val;
	PyObject* d;
	if (!PyArg_ParseTuple(args, "Oii", &d,&servo,&val))
		return NULL;
	struct ms_control* data;
	data = (struct ms_control*)PyLong_AsVoidPtr(d);
	ret=set_servo_value(data,servo,val);
	return Py_BuildValue("i", ret);
}
开发者ID:jiefxxx,项目名称:pbot,代码行数:10,代码来源:motor-lib-python.c


示例15: read_memory_in

PyObject *
read_memory_in(PyObject *self, PyObject *args)
{
    PyObject *address_object;
    if (!PyArg_UnpackTuple(args, "read_memory_in", 1, 1, &address_object))
        return NULL;

    void *address = PyLong_AsVoidPtr(address_object);
    return PyLong_FromUnsignedLong(*((unsigned char *)address));
}
开发者ID:magniff,项目名称:hacky,代码行数:10,代码来源:hacky.c


示例16: dump_motor_python

static PyObject* dump_motor_python(PyObject* self, PyObject* args){
	int motor;
	PyObject* d;
	if (!PyArg_ParseTuple(args, "Oi", &d,&motor))
		return NULL;
	struct ms_control* data;
	data = (struct ms_control*)PyLong_AsVoidPtr(d);
	dump_motor(data,motor);
	return Py_BuildValue("i",0);
}
开发者ID:jiefxxx,项目名称:pbot,代码行数:10,代码来源:motor-lib-python.c


示例17: PyObject_CallObject

void * Pythonize::runFunctionVoid (PyObject *object, PyObject *args)
{

    if (!PyCallable_Check (object))
        return NULL;

    PyObject *pyRes = PyObject_CallObject (object, args ? args : PyTuple_New (0));
    void *res = PyLong_AsVoidPtr (pyRes);

    return res;
}
开发者ID:moceap,项目名称:scribus,代码行数:11,代码来源:pythonize.cpp


示例18: memsys_set_atomic_cas

static PyObject *
memsys_set_atomic_cas(PyObject *self, PyObject *args) {
    PyObject *addr_cas_obj;
    void *addr_cas;
    if (!PyArg_ParseTuple(args, "O", &addr_cas_obj)) {
        return NULL;
    }
    addr_cas = PyLong_AsVoidPtr(addr_cas_obj);
    if(PyErr_Occurred()) return NULL;
    NRT_MemSys_set_atomic_cas(addr_cas);
    Py_RETURN_NONE;
}
开发者ID:DashYang,项目名称:sim,代码行数:12,代码来源:_nrt_pythonmod.c


示例19: gpi_iterator_hdl_converter

// Same as above, for an iterator handle.
static int gpi_iterator_hdl_converter(PyObject *o, gpi_iterator_hdl *data)
{
    void *p = PyLong_AsVoidPtr(o);
    if ((p == NULL) && PyErr_Occurred()) {
        return 0;
    }
    if (p == NULL) {
        PyErr_SetString(PyExc_ValueError, "handle cannot be 0");
        return 0;
    }
    *data = (gpi_iterator_hdl)p;
    return 1;
}
开发者ID:TC01,项目名称:cocotb,代码行数:14,代码来源:simulatormodule.c


示例20: PyImport_ImportModule

static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
开发者ID:skipperkongen,项目名称:the_education_of,代码行数:13,代码来源:hello.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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