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


C++ PyTuple_Pack函数代码示例

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


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

示例1: KX_PythonComponent

PyObject *KX_PythonComponent::py_component_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
	KX_PythonComponent *comp = new KX_PythonComponent(type->tp_name);

	PyObject *proxy = py_base_new(type, PyTuple_Pack(1, comp->GetProxy()), kwds);
	if (!proxy) {
		delete comp;
		return NULL;
	}

	return proxy;
}
开发者ID:UPBGE,项目名称:blender,代码行数:12,代码来源:KX_PythonComponent.cpp

示例2: umpyew_utime

static long umpyew_utime(char *path, struct utimbuf *buf)
{
	PYINSYS(utime, 2);
	PYARG(0, PyString_FromString(path));
	if (buf)
		PYARG(1, PyTuple_Pack(2, PyInt_FromLong(buf->actime), PyInt_FromLong(buf->modtime)));
	else
		PYARG(1, Py_None);
	PYCALL;
	PYOUT;
	return retval;
}
开发者ID:virtualsquare,项目名称:view-os,代码行数:12,代码来源:umpyew.c

示例3: create_filter

static PyObject *
create_filter(PyObject *category, _Py_Identifier *id)
{
    PyObject *action_str = _PyUnicode_FromId(id);
    if (action_str == NULL) {
        return NULL;
    }

    /* This assumes the line number is zero for now. */
    return PyTuple_Pack(5, action_str, Py_None,
                        category, Py_None, _PyLong_Zero);
}
开发者ID:asvetlov,项目名称:cpython,代码行数:12,代码来源:_warnings.c

示例4: update_registry

static int
update_registry(PyObject *registry, PyObject *text, PyObject *category,
                int add_zero)
{
    PyObject *altkey, *zero = NULL;
    int rc;

    if (add_zero) {
        zero = PyInt_FromLong(0);
        if (zero == NULL)
            return -1;
        altkey = PyTuple_Pack(3, text, category, zero);
    }
    else
        altkey = PyTuple_Pack(2, text, category);

    rc = already_warned(registry, altkey, 1);
    Py_XDECREF(zero);
    Py_XDECREF(altkey);
    return rc;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:21,代码来源:_warnings.c

示例5: KyotoDB_iteritems

static PyObject *
KyotoDB_iteritems(KyotoDB *self)
{
    KyotoCursor *cursor = PyObject_New(KyotoCursor, &yakc_CursorType);
    APR type(PyInt_FromLong((long)KYOTO_ITEMS));
    APR tuple(PyTuple_Pack(2, self, type.get()));
    int re = Cursor_init(cursor, tuple.get(), NULL);
    if (re == 0)
        return (PyObject *)cursor;
    PyErr_SetString(PyExc_RuntimeError, "Cannot create cursor");
    return NULL;
}
开发者ID:informationsea,项目名称:Yet-Another-Kyoto-Cabinet-Python-Binding,代码行数:12,代码来源:yakc.cpp

示例6: PyDict_New

static PyObject *PyKAdminPrincipal_get_keys(PyKAdminPrincipalObject *self, void *closure) { 

    /*

    key structure:

        {
            kvno: [("enctype", "salt"), ("enctype", "salt")],
            kvno: ...
        }

    */

    PyObject *kvno     = NULL;
    PyObject *enctype  = NULL;
    PyObject *salttype = NULL;
    PyObject *tuple    = NULL;
    PyObject *list     = NULL;

    PyObject *keys = PyDict_New();

    ssize_t index = 0; 

    for (; index < self->entry.n_key_data; index++) {

        krb5_key_data *key_data = &self->entry.key_data[index];

        kvno = PyUnifiedLongInt_FromLong(key_data->key_data_kvno);

        enctype  = pykadmin_key_enctype_name(key_data);
        salttype = pykadmin_key_salttype_name(key_data);

        tuple = PyTuple_Pack(2, enctype, salttype);


        if (kvno) {
            if (PyDict_Contains(keys, kvno)) {
                list = PyDict_GetItem(keys, kvno);
            } else {
                list = PyList_New(0);
                PyDict_SetItem(keys, kvno, list);
            }
        }

        if (list && tuple) {
            PyList_Append(list, tuple);
        }

    }

    return keys;
}
开发者ID:Kowh,项目名称:python-kadmin,代码行数:52,代码来源:PyKAdminPrincipalObject.c

示例7: objToJSONFile

PyObject* objToJSONFile(PyObject* self, PyObject *args)
{
	PyObject *data;
	PyObject *file;
	PyObject *string;
	PyObject *write;
	PyObject *argtuple;

	if (!PyArg_ParseTuple (args, "OO", &data, &file)) {
		return NULL;
	}

	if (!PyObject_HasAttrString (file, "write"))
	{
		PyErr_Format (PyExc_TypeError, "expected file");
		return NULL;
	}

	write = PyObject_GetAttrString (file, "write");

	if (!PyCallable_Check (write)) {
		Py_XDECREF(write);
		PyErr_Format (PyExc_TypeError, "expected file");
		return NULL;
	}

	string = objToJSON (self, data);

	if (string == NULL)
	{
		Py_XDECREF(write);
		return NULL;
	}

	argtuple = PyTuple_Pack (1, string);
	if (argtuple == NULL)
	{
		Py_XDECREF(write);
		return NULL;
	}
	if (PyObject_CallObject (write, argtuple) == NULL)
	{
		Py_XDECREF(write);
		Py_XDECREF(argtuple);
		return NULL;
	}

	Py_XDECREF(write);
	Py_XDECREF(argtuple);
	Py_XDECREF(string);
	Py_RETURN_NONE;
}
开发者ID:dahlia,项目名称:ultrajson,代码行数:52,代码来源:objToJSON.c

示例8: prop_descr_set

int prop_descr_set(PyObject *self, PyObject *obj, PyObject *value)
{
    int res;
    if (value != NULL) {
	PyObject *result = PyTuple_Pack(2, self, value);
	res = PyObject_SetAttrString(obj, "y", result);
	Py_DECREF(result);
    }
    else {
	res = PyObject_SetAttrString(obj, "z", self);
    }
    return res;
}
开发者ID:mozillazg,项目名称:pypy,代码行数:13,代码来源:foo.c

示例9: set_reduce

static PyObject* set_reduce(BoxedSet* so) noexcept {
    PyObject* keys = NULL, * args = NULL, * result = NULL, * dict = NULL;

    keys = PySequence_List((PyObject*)so);
    if (keys == NULL)
        goto done;
    args = PyTuple_Pack(1, keys);
    if (args == NULL)
        goto done;
    dict = PyObject_GetAttrString((PyObject*)so, "__dict__");
    if (dict == NULL) {
        PyErr_Clear();
        dict = Py_None;
        Py_INCREF(dict);
    }
    result = PyTuple_Pack(3, Py_TYPE(so), args, dict);
done:
    Py_XDECREF(args);
    Py_XDECREF(keys);
    Py_XDECREF(dict);
    return result;
}
开发者ID:tralivali1234,项目名称:pyston,代码行数:22,代码来源:set.cpp

示例10: __pycomps_dict_pair_out

PyObject* __pycomps_dict_pair_out(COMPS_HSListItem *hsit) {
    PyObject *key, *val, *tuple;
    char *x;

    key = PyUnicode_FromString((char*) ((COMPS_ObjRTreePair*)hsit->data)->key);
    x = comps_object_tostr(((COMPS_ObjRTreePair*)hsit->data)->data);
    val = PyUnicode_FromString(x);
    free(x);
    tuple = PyTuple_Pack(2, key, val);
    Py_DECREF(key);
    Py_DECREF(val);
    return tuple;
}
开发者ID:rpm-software-management,项目名称:libcomps,代码行数:13,代码来源:pycomps_dict.c

示例11: PyErr_SetObject

static PyObject *t_descriptor_isValueRequired(t_descriptor *self, t_item *item)
{
    t_attribute *attr = self->attr;

    if (!PyObject_TypeCheck(item, CItem))
    {
        PyErr_SetObject(PyExc_TypeError, (PyObject *) item);
        return NULL;
    }

    if (attr)
    {
        int flags = attr->flags;
        t_values *attrDict = get_attrdict(item, flags);

        return PyTuple_Pack(2,
                            attrDict ? (PyObject *) attrDict : Py_None,
                            attrDict && flags & A_REQUIRED ? Py_True : Py_False);
    }
    else
        return PyTuple_Pack(2, Py_None, Py_False);
}
开发者ID:HackLinux,项目名称:chandler,代码行数:22,代码来源:descriptor.c

示例12: math_log

static PyObject *
math_log(PyObject *self, PyObject *args)
{
    PyObject *arg;
    PyObject *base = NULL;
    PyObject *num, *den;
    PyObject *ans;
    PyObject *newargs;

    if (!PyArg_UnpackTuple(args, "log", 1, 2, &arg, &base))
        return NULL;
    if (base == NULL)
        return loghelper(args, log, "d:log", arg);

    newargs = PyTuple_Pack(1, arg);
    if (newargs == NULL)
        return NULL;
    num = loghelper(newargs, log, "d:log", arg);
    Py_DECREF(newargs);
    if (num == NULL)
        return NULL;

    newargs = PyTuple_Pack(1, base);
    if (newargs == NULL) {
        Py_DECREF(num);
        return NULL;
    }
    den = loghelper(newargs, log, "d:log", base);
    Py_DECREF(newargs);
    if (den == NULL) {
        Py_DECREF(num);
        return NULL;
    }

    ans = PyNumber_Divide(num, den);
    Py_DECREF(num);
    Py_DECREF(den);
    return ans;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:39,代码来源:mathmodule.c

示例13: HasOwnership

static bool HasOwnership(PyObject* obj) {
    PyObject* addr = GetPointer(obj);
    PyObject* name = GetName(obj);
    auto_pyobject nameaddr = PyTuple_Pack(2, name, addr);
    Py_DECREF(name);
    Py_DECREF(addr);
    PyObject* dtor = PyDict_GetItem(GetAddrDtorDict(), *nameaddr);
    if (!dtor || dtor == Py_None) {
        return false;
    } else {
        return true;
    }
}
开发者ID:KennethNielsen,项目名称:llvmpy,代码行数:13,代码来源:capsule.cpp

示例14: KyotoDB_array

static PyObject *
KyotoDB_array(KyotoDB *self, int type)
{
    PyObject *result = PyList_New(self->m_db->count());
    Py_ssize_t i = 0;

    kyotocabinet::BasicDB::Cursor *cursor = self->m_db->cursor();
    cursor->jump();
    std::string key;
    std::string value;
    while (cursor->get(&key, &value, true)) {
        switch (type) {
        case 0: {
            PyObject *pkey = KyotoDB_load(key, self->use_pickle);
            if (pkey == NULL)
                goto onerror;
            PyList_SetItem(result, i++, pkey);
            break;
        }
        case 1: {
            PyObject *pvalue = KyotoDB_load(value, self->use_pickle);
            if (pvalue == NULL)
                goto onerror;
            PyList_SetItem(result, i++, pvalue);
            break;
        }
        case 2: {
            APR pkey(KyotoDB_load(key, self->use_pickle));
            if (pkey == NULL)
                goto onerror;

            APR pvalue(KyotoDB_load(value, self->use_pickle));
            if (pvalue == NULL)
                goto onerror;

            PyList_SetItem(result, i++,
                           PyTuple_Pack(2, (PyObject *)pkey, (PyObject *)pvalue));
            break;
        }
        }
    }
    delete cursor;
    return result;
  onerror:
    for (Py_ssize_t j = 0; j < i; j++) {
        PyObject *obj = PyList_GetItem(result, j);
        Py_DECREF(obj);
    }
    delete cursor;
    return NULL;
}
开发者ID:informationsea,项目名称:Yet-Another-Kyoto-Cabinet-Python-Binding,代码行数:51,代码来源:yakc.cpp

示例15: range_index

static PyObject *
range_index(rangeobject *r, PyObject *ob)
{
    PyObject *idx, *tmp;
    int contains;
    PyObject *format_tuple, *err_string;
    static PyObject *err_format = NULL;

    if (!PyLong_CheckExact(ob) && !PyBool_Check(ob)) {
        Py_ssize_t index;
        index = _PySequence_IterSearch((PyObject*)r, ob, PY_ITERSEARCH_INDEX);
        if (index == -1)
            return NULL;
        return PyLong_FromSsize_t(index);
    }

    contains = range_contains_long(r, ob);
    if (contains == -1)
        return NULL;

    if (!contains)
        goto value_error;

    tmp = PyNumber_Subtract(ob, r->start);
    if (tmp == NULL)
        return NULL;

    /* idx = (ob - r.start) // r.step */
    idx = PyNumber_FloorDivide(tmp, r->step);
    Py_DECREF(tmp);
    return idx;

value_error:

    /* object is not in the range */
    if (err_format == NULL) {
        err_format = PyUnicode_FromString("%r is not in range");
        if (err_format == NULL)
            return NULL;
    }
    format_tuple = PyTuple_Pack(1, ob);
    if (format_tuple == NULL)
        return NULL;
    err_string = PyUnicode_Format(err_format, format_tuple);
    Py_DECREF(format_tuple);
    if (err_string == NULL)
        return NULL;
    PyErr_SetObject(PyExc_ValueError, err_string);
    Py_DECREF(err_string);
    return NULL;
}
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:51,代码来源:rangeobject.c


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