本文整理汇总了C++中PyStructSequence_New函数的典型用法代码示例。如果您正苦于以下问题:C++ PyStructSequence_New函数的具体用法?C++ PyStructSequence_New怎么用?C++ PyStructSequence_New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyStructSequence_New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Util_func_cpu_info
static PyObject *
Util_func_cpu_info(PyObject *obj)
{
int i, count;
uv_cpu_info_t* cpus;
int err;
PyObject *result, *item, *times, *exc_data;
UNUSED_ARG(obj);
err = uv_cpu_info(&cpus, &count);
if (err == 0) {
result = PyList_New(count);
if (!result) {
uv_free_cpu_info(cpus, count);
return NULL;
}
for (i = 0; i < count; i++) {
item = PyStructSequence_New(&CPUInfoResultType);
times = PyStructSequence_New(&CPUInfoTimesResultType);
if (!item || !times) {
Py_XDECREF(item);
Py_XDECREF(times);
Py_DECREF(result);
uv_free_cpu_info(cpus, count);
return NULL;
}
PyStructSequence_SET_ITEM(item, 0, Py_BuildValue("s", cpus[i].model));
PyStructSequence_SET_ITEM(item, 1, PyInt_FromLong((long)cpus[i].speed));
PyStructSequence_SET_ITEM(item, 2, times);
PyList_SET_ITEM(result, i, item);
PyStructSequence_SET_ITEM(times, 0, PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)cpus[i].cpu_times.sys));
PyStructSequence_SET_ITEM(times, 1, PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)cpus[i].cpu_times.user));
PyStructSequence_SET_ITEM(times, 2, PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)cpus[i].cpu_times.idle));
PyStructSequence_SET_ITEM(times, 3, PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)cpus[i].cpu_times.irq));
PyStructSequence_SET_ITEM(times, 4, PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)cpus[i].cpu_times.nice));
}
uv_free_cpu_info(cpus, count);
return result;
} else {
exc_data = Py_BuildValue("(is)", err, uv_strerror(err));
if (exc_data != NULL) {
PyErr_SetObject(PyExc_UVError, exc_data);
Py_DECREF(exc_data);
}
return NULL;
}
}
开发者ID:Sevenops,项目名称:pyuv,代码行数:48,代码来源:util.c
示例2: PyStructSequence_New
static PyObject *app_translations_contexts_make(void)
{
PyObject *translations_contexts;
BLT_i18n_contexts_descriptor *ctxt;
int pos = 0;
translations_contexts = PyStructSequence_New(&BlenderAppTranslationsContextsType);
if (translations_contexts == NULL) {
return NULL;
}
#define SetObjString(item) PyStructSequence_SET_ITEM(translations_contexts, pos++, PyUnicode_FromString((item)))
#define SetObjNone() PyStructSequence_SET_ITEM(translations_contexts, pos++, Py_INCREF_RET(Py_None))
for (ctxt = _contexts; ctxt->c_id; ctxt++) {
if (ctxt->value) {
SetObjString(ctxt->value);
}
else {
SetObjNone();
}
}
#undef SetObjString
#undef SetObjNone
return translations_contexts;
}
开发者ID:diekev,项目名称:blender,代码行数:28,代码来源:bpy_app_translations.c
示例3: tmtotuple
static PyObject *
tmtotuple(struct tm *p)
{
PyObject *v = PyStructSequence_New(&StructTimeType);
if (v == NULL)
return NULL;
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val))
SET(0, p->tm_year + 1900);
SET(1, p->tm_mon + 1); /* Want January == 1 */
SET(2, p->tm_mday);
SET(3, p->tm_hour);
SET(4, p->tm_min);
SET(5, p->tm_sec);
SET(6, (p->tm_wday + 6) % 7); /* Want Monday == 0 */
SET(7, p->tm_yday + 1); /* Want January, 1 == 1 */
SET(8, p->tm_isdst);
#ifdef HAVE_STRUCT_TM_TM_ZONE
PyStructSequence_SET_ITEM(v, 9,
PyUnicode_DecodeLocale(p->tm_zone, "surrogateescape"));
SET(10, p->tm_gmtoff);
#endif /* HAVE_STRUCT_TM_TM_ZONE */
#undef SET
if (PyErr_Occurred()) {
Py_XDECREF(v);
return NULL;
}
return v;
}
开发者ID:dougmassay,项目名称:cpython3.4.4,代码行数:31,代码来源:timemodule.c
示例4: Locale_localeconv
static PyObject* Locale_localeconv(Locale* self) {
struct lconv* lc = localeconv_l(self->locale);
int i = 0;
PyObject* result = PyStructSequence_New(&LconvType);
_seq_set_string(result, self->locale, i++, lc->decimal_point);
_seq_set_string(result, self->locale, i++, lc->thousands_sep);
_seq_set_grouping(result, self->locale, i++, lc->grouping);
_seq_set_string(result, self->locale, i++, lc->int_curr_symbol);
_seq_set_string(result, self->locale, i++, lc->currency_symbol);
_seq_set_string(result, self->locale, i++, lc->mon_decimal_point);
_seq_set_string(result, self->locale, i++, lc->mon_thousands_sep);
_seq_set_grouping(result, self->locale, i++, lc->mon_grouping);
_seq_set_string(result, self->locale, i++, lc->positive_sign);
_seq_set_string(result, self->locale, i++, lc->negative_sign);
_seq_set_int(result, self->locale, i++, lc->int_frac_digits);
_seq_set_int(result, self->locale, i++, lc->frac_digits);
_seq_set_bool(result, self->locale, i++, lc->p_cs_precedes);
_seq_set_bool(result, self->locale, i++, lc->p_sep_by_space);
_seq_set_int(result, self->locale, i++, lc->n_cs_precedes);
_seq_set_int(result, self->locale, i++, lc->n_sep_by_space);
_seq_set_int(result, self->locale, i++, lc->p_sign_posn);
_seq_set_int(result, self->locale, i++, lc->n_sign_posn);
_seq_set_bool(result, self->locale, i++, lc->int_p_cs_precedes);
_seq_set_bool(result, self->locale, i++, lc->int_n_cs_precedes);
_seq_set_bool(result, self->locale, i++, lc->int_p_sep_by_space);
_seq_set_bool(result, self->locale, i++, lc->int_n_sep_by_space);
_seq_set_int(result, self->locale, i++, lc->int_p_sign_posn);
_seq_set_int(result, self->locale, i++, lc->int_n_sign_posn);
assert(i==lconv_desc.n_in_sequence);
return result;
}
开发者ID:lowks,项目名称:xlocale,代码行数:33,代码来源:localeconv.c
示例5: mkpwent
static PyObject *
mkpwent(struct passwd *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructPwdType);
if (v == NULL)
return NULL;
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->pw_name);
#ifdef __VMS
SETS(setIndex++, "");
#else
SETS(setIndex++, p->pw_passwd);
#endif
SETI(setIndex++, p->pw_uid);
SETI(setIndex++, p->pw_gid);
SETS(setIndex++, p->pw_dir);
SETS(setIndex++, p->pw_shell);
#undef SETS
#undef SETI
if (PyErr_Occurred()) {
Py_XDECREF(v);
return NULL;
}
return v;
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:32,代码来源:pwdmodule.c
示例6: PyStructSequence_InitType
/**
* Simple utility function to initialize #PyStructSequence_Desc
*/
static PyObject *py_structseq_from_strings(
PyTypeObject *py_type,
PyStructSequence_Desc *py_sseq_desc,
const char **str_items)
{
PyObject *py_struct_seq;
int pos = 0;
const char **str_iter;
PyStructSequence_Field *desc;
/* initialize array */
/* We really populate the contexts' fields here! */
for (str_iter = str_items, desc = py_sseq_desc->fields; *str_iter; str_iter++, desc++) {
desc->name = (char *)*str_iter;
desc->doc = NULL;
}
/* end sentinel */
desc->name = desc->doc = NULL;
PyStructSequence_InitType(py_type, py_sseq_desc);
/* initialize pytype */
py_struct_seq = PyStructSequence_New(py_type);
BLI_assert(py_struct_seq != NULL);
for (str_iter = str_items; *str_iter; str_iter++) {
PyStructSequence_SET_ITEM(py_struct_seq, pos++, PyUnicode_FromString((*str_iter)));
}
return py_struct_seq;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:35,代码来源:bpy_utils_units.c
示例7: PyStructSequence_New
static PyObject *make_app_cb_info(void)
{
PyObject *app_cb_info;
int pos;
app_cb_info = PyStructSequence_New(&BlenderAppCbType);
if (app_cb_info == NULL) {
return NULL;
}
for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
if (app_cb_info_fields[pos].name == NULL) {
Py_FatalError("invalid callback slots 1");
}
PyStructSequence_SET_ITEM(app_cb_info, pos, (py_cb_array[pos] = PyList_New(0)));
}
if (app_cb_info_fields[pos + APP_CB_OTHER_FIELDS].name != NULL) {
Py_FatalError("invalid callback slots 2");
}
/* custom function */
PyStructSequence_SET_ITEM(app_cb_info, pos++, (PyObject *)&BPyPersistent_Type);
return app_cb_info;
}
开发者ID:diekev,项目名称:blender,代码行数:25,代码来源:bpy_app_handlers.c
示例8: PyStructSequence_New
static PyObject *mkspent(struct spwd *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructSpwdType);
if (v == NULL)
return NULL;
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->sp_namp);
SETS(setIndex++, p->sp_pwdp);
#ifndef __HAIKU__
SETI(setIndex++, p->sp_lstchg);
#endif
SETI(setIndex++, p->sp_min);
SETI(setIndex++, p->sp_max);
SETI(setIndex++, p->sp_warn);
SETI(setIndex++, p->sp_inact);
SETI(setIndex++, p->sp_expire);
SETI(setIndex++, p->sp_flag);
#undef SETS
#undef SETI
if (PyErr_Occurred()) {
Py_DECREF(v);
return NULL;
}
return v;
}
开发者ID:Linuxcpa,项目名称:Confederate-Patches,代码行数:32,代码来源:spwdmodule.c
示例9: PyFloat_GetInfo
PyObject* PyFloat_GetInfo(void) {
PyObject* floatinfo;
int pos = 0;
floatinfo = PyStructSequence_New(&FloatInfoType);
if (floatinfo == NULL) {
return NULL;
}
#define SetIntFlag(flag) PyStructSequence_SET_ITEM(floatinfo, pos++, PyInt_FromLong(flag))
#define SetDblFlag(flag) PyStructSequence_SET_ITEM(floatinfo, pos++, PyFloat_FromDouble(flag))
SetDblFlag(DBL_MAX);
SetIntFlag(DBL_MAX_EXP);
SetIntFlag(DBL_MAX_10_EXP);
SetDblFlag(DBL_MIN);
SetIntFlag(DBL_MIN_EXP);
SetIntFlag(DBL_MIN_10_EXP);
SetIntFlag(DBL_DIG);
SetIntFlag(DBL_MANT_DIG);
SetDblFlag(DBL_EPSILON);
SetIntFlag(FLT_RADIX);
SetIntFlag(FLT_ROUNDS);
#undef SetIntFlag
#undef SetDblFlag
if (PyErr_Occurred()) {
Py_CLEAR(floatinfo);
return NULL;
}
return floatinfo;
}
开发者ID:Thooms,项目名称:pyston,代码行数:32,代码来源:sys.cpp
示例10: tmtotuple
static PyObject *
tmtotuple(struct tm *p)
{
PyObject *v = PyStructSequence_New(&StructTimeType);
if (v == NULL)
return NULL;
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
SET(0, p->tm_year + 1900);
SET(1, p->tm_mon + 1); /* Want January == 1 */
SET(2, p->tm_mday);
SET(3, p->tm_hour);
SET(4, p->tm_min);
SET(5, p->tm_sec);
SET(6, (p->tm_wday + 6) % 7); /* Want Monday == 0 */
SET(7, p->tm_yday + 1); /* Want January, 1 == 1 */
SET(8, p->tm_isdst);
#undef SET
if (PyErr_Occurred()) {
Py_XDECREF(v);
return NULL;
}
return v;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:26,代码来源:timemodule.c
示例11: nameinfo_cb
static void
nameinfo_cb(void *arg, int status, int timeouts, char *node, char *service)
{
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject *callback, *errorno, *dns_node, *dns_service, *dns_result, *result;
callback = (PyObject *)arg;
ASSERT(callback);
if (status != ARES_SUCCESS) {
errorno = PyInt_FromLong((long)status);
dns_result = Py_None;
Py_INCREF(Py_None);
goto callback;
}
dns_result = PyStructSequence_New(&AresNameinfoResultType);
if (!dns_result) {
PyErr_NoMemory();
PyErr_WriteUnraisable(Py_None);
errorno = PyInt_FromLong((long)ARES_ENOMEM);
dns_result = Py_None;
Py_INCREF(Py_None);
goto callback;
}
dns_node = Py_BuildValue("s", node);
if (service) {
dns_service = Py_BuildValue("s", service);
} else {
dns_service = Py_None;
Py_INCREF(Py_None);
}
PyStructSequence_SET_ITEM(dns_result, 0, dns_node);
PyStructSequence_SET_ITEM(dns_result, 1, dns_service);
errorno = Py_None;
Py_INCREF(Py_None);
callback:
result = PyObject_CallFunctionObjArgs(callback, dns_result, errorno, NULL);
if (result == NULL) {
PyErr_WriteUnraisable(callback);
}
Py_XDECREF(result);
Py_DECREF(dns_result);
Py_DECREF(errorno);
Py_DECREF(callback);
PyGILState_Release(gstate);
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_python-pycares,代码行数:51,代码来源:cares.c
示例12: resource_getrusage
static PyObject *
resource_getrusage(PyObject *self, PyObject *args)
{
int who;
struct rusage ru;
PyObject *result;
if (!PyArg_ParseTuple(args, "i:getrusage", &who))
return NULL;
if (getrusage(who, &ru) == -1) {
if (errno == EINVAL) {
PyErr_SetString(PyExc_ValueError,
"invalid who parameter");
return NULL;
}
PyErr_SetFromErrno(ResourceError);
return NULL;
}
result = PyStructSequence_New(&StructRUsageType);
if (!result)
return NULL;
PyStructSequence_SET_ITEM(result, 0,
PyFloat_FromDouble(doubletime(ru.ru_utime)));
PyStructSequence_SET_ITEM(result, 1,
PyFloat_FromDouble(doubletime(ru.ru_stime)));
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss));
PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss));
PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(ru.ru_isrss));
PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(ru.ru_minflt));
PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(ru.ru_majflt));
PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(ru.ru_nswap));
PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(ru.ru_inblock));
PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(ru.ru_oublock));
PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(ru.ru_msgsnd));
PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(ru.ru_msgrcv));
PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals));
PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw));
PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw));
if (PyErr_Occurred()) {
Py_DECREF(result);
return NULL;
}
return result;
}
开发者ID:Jimlan,项目名称:kbengine,代码行数:50,代码来源:resource.c
示例13: mkgrent
static PyObject *
mkgrent(struct group *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructGrpType), *w;
char **member;
if (v == NULL)
return NULL;
if ((w = PyList_New(0)) == NULL) {
Py_DECREF(v);
return NULL;
}
for (member = p->gr_mem; *member != NULL; member++) {
PyObject *x = PyString_FromString(*member);
if (x == NULL || PyList_Append(w, x) != 0) {
Py_XDECREF(x);
Py_DECREF(w);
Py_DECREF(v);
return NULL;
}
Py_DECREF(x);
}
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
SET(setIndex++, PyString_FromString(p->gr_name));
#if defined(__VMS) || defined(PLAN9APE)
SET(setIndex++, Py_None);
Py_INCREF(Py_None);
#else
if (p->gr_passwd)
SET(setIndex++, PyString_FromString(p->gr_passwd));
else {
SET(setIndex++, Py_None);
Py_INCREF(Py_None);
}
#endif
SET(setIndex++, PyInt_FromLong((long) p->gr_gid));
SET(setIndex++, w);
#undef SET
if (PyErr_Occurred()) {
Py_DECREF(v);
Py_DECREF(w);
return NULL;
}
return v;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:50,代码来源:grpmodule.c
示例14: PyStructSequence_New
static PyObject *make_oiio_info(void)
{
PyObject *oiio_info;
int pos = 0;
#ifdef WITH_OPENIMAGEIO
int curversion;
#endif
oiio_info = PyStructSequence_New(&BlenderAppOIIOType);
if (oiio_info == NULL) {
return NULL;
}
#ifndef WITH_OPENIMAGEIO
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(oiio_info, pos++, PyUnicode_FromString(str))
#endif
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(oiio_info, pos++, obj)
#ifdef WITH_OPENIMAGEIO
curversion = OIIO_getVersionHex();
SetObjItem(PyBool_FromLong(1));
SetObjItem(Py_BuildValue("(iii)",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
SetObjItem(PyBool_FromLong(0));
SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
SetStrItem("Unknown");
#endif
if (PyErr_Occurred()) {
Py_CLEAR(oiio_info);
return NULL;
}
#undef SetStrItem
#undef SetObjItem
return oiio_info;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:45,代码来源:bpy_app_oiio.c
示例15: Util_func_getrusage
static PyObject *
Util_func_getrusage(PyObject *obj)
{
int err;
uv_rusage_t ru;
PyObject *result;
UNUSED_ARG(obj);
err = uv_getrusage(&ru);
if (err < 0) {
RAISE_UV_EXCEPTION(err, PyExc_UVError);
return NULL;
}
result = PyStructSequence_New(&RusageResultType);
if (!result)
return NULL;
#define pyuv__doubletime(TV) ((double)(TV).tv_sec + 1e-6*(TV).tv_usec)
PyStructSequence_SET_ITEM(result, 0, PyFloat_FromDouble(pyuv__doubletime(ru.ru_utime)));
PyStructSequence_SET_ITEM(result, 1, PyFloat_FromDouble(pyuv__doubletime(ru.ru_stime)));
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss));
PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss));
PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(ru.ru_isrss));
PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(ru.ru_minflt));
PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(ru.ru_majflt));
PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(ru.ru_nswap));
PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(ru.ru_inblock));
PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(ru.ru_oublock));
PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(ru.ru_msgsnd));
PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(ru.ru_msgrcv));
PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals));
PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw));
PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw));
#undef pyuv__doubletime
if (PyErr_Occurred()) {
Py_DECREF(result);
return NULL;
}
return result;
}
开发者ID:Sevenops,项目名称:pyuv,代码行数:45,代码来源:util.c
示例16: mkgrent
static PyObject *
mkgrent(struct group *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructGrpType), *w;
char **member;
if (v == NULL)
return NULL;
if ((w = PyList_New(0)) == NULL) {
Py_DECREF(v);
return NULL;
}
for (member = p->gr_mem; *member != NULL; member++) {
PyObject *x = PyUnicode_DecodeFSDefault(*member);
if (x == NULL || PyList_Append(w, x) != 0) {
Py_XDECREF(x);
Py_DECREF(w);
Py_DECREF(v);
return NULL;
}
Py_DECREF(x);
}
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
if (p->gr_passwd)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
else {
SET(setIndex++, Py_None);
Py_INCREF(Py_None);
}
SET(setIndex++, _PyLong_FromGid(p->gr_gid));
SET(setIndex++, w);
#undef SET
if (PyErr_Occurred()) {
Py_DECREF(v);
return NULL;
}
return v;
}
开发者ID:ARK4579,项目名称:cpython,代码行数:44,代码来源:grpmodule.c
示例17: test
PyObject *
test(PyObject *self, PyObject *args)
{
/*
FWIW, this assumes that we called:
PyStructSequence_InitType(&CoordType, &coord_desc);
when initializing the module:
*/
PyObject *obj = PyStructSequence_New(&CoordType);
if (!obj) {
return NULL;
}
/*
These PyInt_ calls can't fail; the SET_ITEM macros steal the new ref
they give us, so this is correct:
*/
PyStructSequence_SET_ITEM(obj, 0, PyInt_FromLong(0));
PyStructSequence_SET_ITEM(obj, 1, PyInt_FromLong(0));
return obj;
}
开发者ID:B-Rich,项目名称:gcc-python-plugin,代码行数:21,代码来源:input.c
示例18: make_version_info
static PyObject* make_version_info(void) noexcept {
PyObject* version_info;
const char* s;
int pos = 0;
version_info = PyStructSequence_New(&VersionInfoType);
if (version_info == NULL) {
return NULL;
}
/*
* These release level checks are mutually exclusive and cover
* the field, so don't get too fancy with the pre-processor!
*/
#if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA
s = "alpha";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA
s = "beta";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA
s = "candidate";
#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
s = "final";
#endif
#define SetIntItem(flag) PyStructSequence_SET_ITEM(version_info, pos++, PyInt_FromLong(flag))
#define SetStrItem(flag) PyStructSequence_SET_ITEM(version_info, pos++, PyString_FromString(flag))
SetIntItem(PY_MAJOR_VERSION);
SetIntItem(PY_MINOR_VERSION);
SetIntItem(PY_MICRO_VERSION);
SetStrItem(s);
SetIntItem(PY_RELEASE_SERIAL);
#undef SetIntItem
#undef SetStrItem
if (PyErr_Occurred()) {
Py_CLEAR(version_info);
return NULL;
}
return version_info;
}
开发者ID:Thooms,项目名称:pyston,代码行数:40,代码来源:sys.cpp
示例19: mkpwent
static PyObject *
mkpwent(struct passwd *p)
{
int setIndex = 0;
PyObject *v = PyStructSequence_New(&StructPwdType);
if (v == NULL)
return NULL;
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val))
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->pw_name);
#if defined(HAVE_STRUCT_PASSWD_PW_PASSWD) && !defined(__ANDROID__)
SETS(setIndex++, p->pw_passwd);
#else
SETS(setIndex++, "");
#endif
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid));
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid));
#if defined(HAVE_STRUCT_PASSWD_PW_GECOS)
SETS(setIndex++, p->pw_gecos);
#else
SETS(setIndex++, "");
#endif
SETS(setIndex++, p->pw_dir);
SETS(setIndex++, p->pw_shell);
#undef SETS
#undef SETI
if (PyErr_Occurred()) {
Py_XDECREF(v);
return NULL;
}
return v;
}
开发者ID:DinoV,项目名称:gilectomy,代码行数:37,代码来源:pwdmodule.c
示例20: PyStructSequence_New
static PyObject *make_ffmpeg_info(void)
{
PyObject *ffmpeg_info;
int pos = 0;
#ifdef WITH_FFMPEG
int curversion;
#endif
ffmpeg_info = PyStructSequence_New(&BlenderAppFFmpegType);
if (ffmpeg_info == NULL) {
return NULL;
}
#if 0 // UNUSED
#define SetIntItem(flag) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag))
#endif
#ifndef WITH_FFMPEG
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyUnicode_FromString(str))
#endif
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj)
#ifdef WITH_FFMPEG
# define FFMPEG_LIB_VERSION(lib) { \
curversion = lib ## _version(); \
SetObjItem(PyC_Tuple_Pack_I32(curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", \
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
} (void)0
#else
# define FFMPEG_LIB_VERSION(lib) { \
SetStrItem("Unknown"); \
SetStrItem("Unknown"); \
} (void)0
#endif
#ifdef WITH_FFMPEG
SetObjItem(PyBool_FromLong(1));
#else
SetObjItem(PyBool_FromLong(0));
#endif
FFMPEG_LIB_VERSION(avcodec);
FFMPEG_LIB_VERSION(avdevice);
FFMPEG_LIB_VERSION(avformat);
FFMPEG_LIB_VERSION(avutil);
FFMPEG_LIB_VERSION(swscale);
#undef FFMPEG_LIB_VERSION
if (PyErr_Occurred()) {
Py_CLEAR(ffmpeg_info);
return NULL;
}
// #undef SetIntItem
#undef SetStrItem
#undef SetObjItem
return ffmpeg_info;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:64,代码来源:bpy_app_ffmpeg.c
注:本文中的PyStructSequence_New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论