当前位置: 首页>>代码示例>>C++>>正文


C++ PyTypeObject::tp_init方法代码示例

本文整理汇总了C++中PyTypeObject::tp_init方法的典型用法代码示例。如果您正苦于以下问题:C++ PyTypeObject::tp_init方法的具体用法?C++ PyTypeObject::tp_init怎么用?C++ PyTypeObject::tp_init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyTypeObject的用法示例。


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

示例1:

static int
FSRequest_tp_init(FSRequest *self, PyObject *args, PyObject *kwargs)
{
    int r;
    Loop *loop;
    PyObject *callback, *tmp, *loopargs;

    UNUSED_ARG(kwargs);

    if (!PyArg_ParseTuple(args, "O!O:__init__", &LoopType, &loop, &callback)) {
        return -1;
    }

    loopargs = PySequence_GetSlice(args, 0, 1);
    if (!loopargs) {
        return -1;
    }

    r = RequestType.tp_init((PyObject *)self, loopargs, kwargs);
    if (r < 0) {
        Py_DECREF(loopargs);
        return r;
    }

    tmp = (PyObject *)self->callback;
    Py_INCREF(callback);
    self->callback = callback;
    Py_XDECREF(tmp);

    Py_DECREF(loopargs);

    return 0;
}
开发者ID:ConchLikeSun,项目名称:pyuv,代码行数:33,代码来源:request.c

示例2:

AerospikeKey * AerospikeKey_New(AerospikeClient * client, PyObject * args, PyObject * kwds)
{
	Py_INCREF(client);
	Py_INCREF(args);

    AerospikeKey * self = (AerospikeKey *) AerospikeKey_Type.tp_new(&AerospikeKey_Type, args, kwds);
    self->client = client;
	self->key = args;
    AerospikeKey_Type.tp_init((PyObject *) self, args, kwds);
	return self;
}
开发者ID:Kavec,项目名称:aerospike-client-python,代码行数:11,代码来源:type.c

示例3:

AerospikeLList * AerospikeLList_New(AerospikeClient * client, PyObject * args, PyObject * kwds)
{
	AerospikeLList * self = (AerospikeLList *) AerospikeLList_Type.tp_new(&AerospikeLList_Type, args, kwds);
	self->client = client;
	Py_INCREF(client);

	if (AerospikeLList_Type.tp_init((PyObject *)self, args, kwds) == 0) {
		return self;
	} else {
		as_error err;
		as_error_init(&err);
		as_error_update(&err, AEROSPIKE_ERR_PARAM, "Parameters are incorrect");
		PyObject * py_err = NULL;
		PyObject * py_key = NULL;
		PyObject *exception_type = raise_exception(&err);
		error_to_pyobject(&err, &py_err);
		if(PyObject_HasAttrString(exception_type, "key")) {
			if(&self->key) {
				key_to_pyobject(&err, &self->key, &py_key);
				PyObject_SetAttrString(exception_type, "key", py_key);
				Py_DECREF(py_key);
			} else {
				PyObject_SetAttrString(exception_type, "key", Py_None);
			}
		} 
		if(PyObject_HasAttrString(exception_type, "bin")) {
			if(&self->bin_name) {
				PyObject *py_bins = PyStr_FromString((char *)&self->bin_name);
				PyObject_SetAttrString(exception_type, "bin", py_bins);
				Py_DECREF(py_bins);
			} else {
				PyObject_SetAttrString(exception_type, "bin", Py_None);
			}
		}
		PyErr_SetObject(exception_type, py_err);
		Py_DECREF(py_err);
		return NULL;
	}
}
开发者ID:andersonbd1,项目名称:aerospike-client-python,代码行数:39,代码来源:type.c


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