本文整理汇总了C++中PyTuple_Pack函数的典型用法代码示例。如果您正苦于以下问题:C++ PyTuple_Pack函数的具体用法?C++ PyTuple_Pack怎么用?C++ PyTuple_Pack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyTuple_Pack函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: pyrapidjson_dump
static PyObject *
pyrapidjson_dump(PyObject *self, PyObject *args, PyObject *kwargs)
{
// TODO: not support kwargs like json.dump() (encoding, etc...)
static char *kwlist[] = {(char *)"obj", (char *)"fp", NULL};
PyObject *py_file, *py_json, *py_string, *write_method, *write_arg, *write_ret;
rapidjson::Document doc;
/* Parse arguments */
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO", kwlist, &py_json, &py_file))
return NULL;
if (!PyObject_HasAttrString(py_file, "write")) {
PyErr_Format(PyExc_TypeError, "expected file object. has not write() method.");
return NULL;
}
write_method = PyObject_GetAttrString(py_file, "write");
if (!PyCallable_Check(write_method)) {
Py_XDECREF(write_method);
PyErr_Format(PyExc_TypeError, "expected file object. write() method is not callable.");
return NULL;
}
py_string = pyobj2pystring(py_json);
if (py_string == NULL) {
Py_XDECREF(write_method);
PyErr_SetString(PyExc_RuntimeError, "pyobj2pystring() error.");
return NULL;
}
write_arg = PyTuple_Pack(1, py_string);
if (write_arg == NULL) {
Py_XDECREF(write_method);
return NULL;
}
write_ret = PyObject_CallObject(write_method, write_arg);
if (write_ret == NULL) {
Py_XDECREF(write_method);
Py_XDECREF(write_arg);
Py_XDECREF(py_string);
return NULL;
}
Py_XDECREF(write_method);
Py_XDECREF(write_arg);
Py_XDECREF(write_ret);
Py_XDECREF(py_string);
Py_RETURN_NONE;
}
开发者ID:hhatto,项目名称:pyrapidjson,代码行数:51,代码来源:_pyrapidjson.cpp
示例17: init_pyjava
PyMODINIT_FUNC init_pyjava(void)
{
PyObject *mod;
mod = Py_InitModule("_pyjava", methods);
if(mod == NULL)
return ;
Err_Base = PyErr_NewException("pyjava.Error", NULL, NULL);
Py_INCREF(Err_Base);
PyModule_AddObject(mod, "Error", Err_Base);
Err_ClassNotFound = PyErr_NewException(
"pyjava.ClassNotFound", Err_Base, NULL);
Py_INCREF(Err_ClassNotFound);
PyModule_AddObject(mod, "ClassNotFound", Err_ClassNotFound);
{
PyObject *bases = PyTuple_Pack(2, Err_Base, PyExc_TypeError);
Err_NoMatchingOverload = PyErr_NewException(
"pyjava.NoMatchingOverload", bases, NULL);
Py_INCREF(Err_NoMatchingOverload);
PyModule_AddObject(mod, "NoMatchingOverload", Err_NoMatchingOverload);
Py_DECREF(bases);
}
{
PyObject *bases = PyTuple_Pack(3, Err_Base,
PyExc_TypeError, PyExc_AttributeError);
Err_FieldTypeError = PyErr_NewException(
"pyjava.NoMatchingOverload", bases, NULL);
Py_INCREF(Err_FieldTypeError);
PyModule_AddObject(mod, "FieldTypeError", Err_FieldTypeError);
Py_DECREF(bases);
}
javawrapper_init(mod);
}
开发者ID:remram44,项目名称:pyjava,代码行数:38,代码来源:pyjava.c
示例18: dot_alignment_error
NPY_NO_EXPORT void
dot_alignment_error(PyArrayObject *a, int i, PyArrayObject *b, int j)
{
PyObject *errmsg = NULL, *format = NULL, *fmt_args = NULL,
*i_obj = NULL, *j_obj = NULL,
*shape1 = NULL, *shape2 = NULL,
*shape1_i = NULL, *shape2_j = NULL;
format = PyUString_FromString("shapes %s and %s not aligned:"
" %d (dim %d) != %d (dim %d)");
shape1 = convert_shape_to_string(PyArray_NDIM(a), PyArray_DIMS(a), "");
shape2 = convert_shape_to_string(PyArray_NDIM(b), PyArray_DIMS(b), "");
i_obj = PyLong_FromLong(i);
j_obj = PyLong_FromLong(j);
shape1_i = PyLong_FromSsize_t(PyArray_DIM(a, i));
shape2_j = PyLong_FromSsize_t(PyArray_DIM(b, j));
if (!format || !shape1 || !shape2 || !i_obj || !j_obj ||
!shape1_i || !shape2_j) {
goto end;
}
fmt_args = PyTuple_Pack(6, shape1, shape2,
shape1_i, i_obj, shape2_j, j_obj);
if (fmt_args == NULL) {
goto end;
}
errmsg = PyUString_Format(format, fmt_args);
if (errmsg != NULL) {
PyErr_SetObject(PyExc_ValueError, errmsg);
}
else {
PyErr_SetString(PyExc_ValueError, "shapes are not aligned");
}
end:
Py_XDECREF(errmsg);
Py_XDECREF(fmt_args);
Py_XDECREF(format);
Py_XDECREF(i_obj);
Py_XDECREF(j_obj);
Py_XDECREF(shape1);
Py_XDECREF(shape2);
Py_XDECREF(shape1_i);
Py_XDECREF(shape2_j);
}
开发者ID:naghmouchi,项目名称:numpy,代码行数:50,代码来源:common.c
示例19: forms_do_or_check_forms
static PyObject *
forms_do_or_check_forms(PyObject *dummy, FL_OBJECT *(*func)(void))
{
FL_OBJECT *generic;
genericobject *g;
PyObject *arg, *res;
for (;;) {
Py_BEGIN_ALLOW_THREADS
generic = (*func)();
Py_END_ALLOW_THREADS
if (generic == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
if (generic == FL_EVENT) {
int dev;
short val;
if (my_event_callback == NULL)
return PyInt_FromLong(-1L);
dev = fl_qread(&val);
arg = Py_BuildValue("(ih)", dev, val);
if (arg == NULL)
return NULL;
res = PyEval_CallObject(my_event_callback, arg);
Py_XDECREF(res);
Py_DECREF(arg);
if (res == NULL)
return NULL; /* Callback raised exception */
continue;
}
g = findgeneric(generic);
if (g == NULL) {
/* Object not known to us (some dialogs cause this) */
continue; /* Ignore it */
}
if (g->ob_callback == NULL) {
Py_INCREF(g);
return ((PyObject *) g);
}
arg = PyTuple_Pack(2, (PyObject *)g, g->ob_callback_arg);
if (arg == NULL)
return NULL;
res = PyEval_CallObject(g->ob_callback, arg);
Py_XDECREF(res);
Py_DECREF(arg);
if (res == NULL)
return NULL; /* Callback raised exception */
}
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:50,代码来源:flmodule.c
示例20: Snmp_oid2string
static PyObject*
Snmp_oid2string(PyObject *resultvalue)
{
PyObject *dot, *tmp, *tmp2, *list;
int i;
if ((list = PyTuple_New(PyTuple_Size(resultvalue))) == NULL)
return NULL;
for (i = 0; i < PyTuple_Size(resultvalue); i++) {
if ((tmp = PyTuple_GetItem(resultvalue, i)) == NULL) {
Py_DECREF(list);
return NULL;
}
if ((tmp2 = PyObject_Str(tmp)) == NULL) {
Py_DECREF(list);
return NULL;
}
PyTuple_SetItem(list, i, tmp2);
if (PyErr_Occurred()) {
Py_DECREF(tmp2);
Py_DECREF(list);
return NULL;
}
}
Py_DECREF(resultvalue);
resultvalue = list;
if ((dot = PyString_FromString(".")) == NULL)
return NULL;
if ((tmp = PyObject_CallMethod(dot,
"join", "(O)", resultvalue)) == NULL) {
Py_DECREF(dot);
return NULL;
}
Py_DECREF(resultvalue);
Py_DECREF(dot);
resultvalue = tmp;
if ((tmp = PyTuple_Pack(1, resultvalue)) == NULL)
return NULL;
Py_DECREF(resultvalue);
resultvalue = tmp;
if ((tmp2 = PyString_FromString(".%s")) == NULL)
return NULL;
if ((tmp = PyString_Format(tmp2,
resultvalue)) == NULL) {
Py_DECREF(tmp2);
return NULL;
}
Py_DECREF(tmp2);
Py_DECREF(resultvalue);
return tmp;
}
开发者ID:arielsalvo,项目名称:wiremaps,代码行数:50,代码来源:snmp.c
注:本文中的PyTuple_Pack函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论