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


C++ PyObject_SetAttr函数代码示例

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


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

示例1: PyInt_FromLong

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":127 */
  __pyx_1 = PyInt_FromLong(__pyx_v_result); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("darwin_maxpriority.setpriority");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_errno);
  Py_DECREF(__pyx_v_arg0);
  Py_DECREF(__pyx_v_arg1);
  Py_DECREF(__pyx_v_arg2);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_OSError, "OSError"},
  {&__pyx_n_PRIO_PROCESS, "PRIO_PROCESS"},
  {&__pyx_n_SCHED_FIFO, "SCHED_FIFO"},
  {&__pyx_n_SCHED_OTHER, "SCHED_OTHER"},
  {&__pyx_n_SCHED_RR, "SCHED_RR"},
  {&__pyx_n_darwinsys, "darwinsys"},
  {&__pyx_n_get_bus_speed, "get_bus_speed"},
  {&__pyx_n_getpriority, "getpriority"},
  {&__pyx_n_sched_get_priority_max, "sched_get_priority_max"},
  {&__pyx_n_set_self_pthread_priority, "set_self_pthread_priority"},
  {&__pyx_n_set_self_thread_time_constraint_policy, "set_self_thread_time_constraint_policy"},
  {&__pyx_n_setpriority, "setpriority"},
  {0, 0}
};

static struct PyMethodDef __pyx_methods[] = {
  {"get_bus_speed", (PyCFunction)__pyx_f_18darwin_maxpriority_get_bus_speed, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_self_thread_time_constraint_policy", (PyCFunction)__pyx_f_18darwin_maxpriority_set_self_thread_time_constraint_policy, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_self_pthread_priority", (PyCFunction)__pyx_f_18darwin_maxpriority_set_self_pthread_priority, METH_VARARGS|METH_KEYWORDS, 0},
  {"getpriority", (PyCFunction)__pyx_f_18darwin_maxpriority_getpriority, METH_VARARGS|METH_KEYWORDS, 0},
  {"sched_get_priority_max", (PyCFunction)__pyx_f_18darwin_maxpriority_sched_get_priority_max, METH_VARARGS|METH_KEYWORDS, 0},
  {"setpriority", (PyCFunction)__pyx_f_18darwin_maxpriority_setpriority, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

DL_EXPORT(void) initdarwin_maxpriority(void); /*proto*/
DL_EXPORT(void) initdarwin_maxpriority(void) {
  PyObject *__pyx_1 = 0;
  __pyx_m = Py_InitModule4("darwin_maxpriority", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":62 */
  __pyx_1 = PyInt_FromLong(PRIO_PROCESS); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_PRIO_PROCESS, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":64 */
  __pyx_1 = PyInt_FromLong(SCHED_OTHER); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SCHED_OTHER, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":65 */
  __pyx_1 = PyInt_FromLong(SCHED_RR); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SCHED_RR, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":66 */
  __pyx_1 = PyInt_FromLong(SCHED_FIFO); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SCHED_FIFO, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Volumes/astraw/src/ve/visionegg-devel.clean/src/darwin_maxpriority.pyx":121 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("darwin_maxpriority");
}
开发者ID:Complex501,项目名称:visionegg,代码行数:83,代码来源:darwin_maxpriority.c

示例2: __pyx_init_filenames

/* Implementation of kostyrka2 */

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initkostyrka2(void); /*proto*/
PyMODINIT_FUNC initkostyrka2(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("kostyrka2", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  __pyx_3 = __Pyx_CreateClass(__pyx_2, __pyx_1, __pyx_n_X, "kostyrka2"); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_INCREF(__pyx_k2p);
  PyList_SET_ITEM(__pyx_2, 0, __pyx_k2p);
  if (PyObject_SetAttr(__pyx_3, __pyx_n_slots, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_X, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("kostyrka2");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:40,代码来源:kostyrka2.c

示例3: Py_INCREF


//.........这里部分代码省略.........

static PyMappingMethods __pyx_tp_as_mapping_K8055LibClass = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_K8055LibClass = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_10pyk8055lib_K8055LibClass = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "pyk8055lib.K8055LibClass", /*tp_name*/
  sizeof(struct __pyx_obj_10pyk8055lib_K8055LibClass), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pyk8055lib_K8055LibClass, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_K8055LibClass, /*tp_as_number*/
  &__pyx_tp_as_sequence_K8055LibClass, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_K8055LibClass, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_K8055LibClass, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pyk8055lib_K8055LibClass, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_10pyk8055lib_13K8055LibClass___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pyk8055lib_K8055LibClass, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initpyk8055lib(void); /*proto*/
PyMODINIT_FUNC initpyk8055lib(void) {
  PyObject *__pyx_1 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("pyk8055lib", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyType_Ready(&__pyx_type_10pyk8055lib_K8055LibClass) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "K8055LibClass", (PyObject *)&__pyx_type_10pyk8055lib_K8055LibClass) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_ptype_10pyk8055lib_K8055LibClass = &__pyx_type_10pyk8055lib_K8055LibClass;

  /* "G:/Projekte/svn_mynew/svnroot/os2/usb/k8055/pyk8055/pyk8055lib.pyx":1 */
  __pyx_1 = __Pyx_Import(__pyx_n_re, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_re, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "G:/Projekte/svn_mynew/svnroot/os2/usb/k8055/pyk8055/pyk8055lib.pyx":2 */
  __pyx_1 = __Pyx_Import(__pyx_n_struct, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_struct, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "G:/Projekte/svn_mynew/svnroot/os2/usb/k8055/pyk8055/pyk8055lib.pyx":73 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("pyk8055lib");
}
开发者ID:OS2World,项目名称:LIB-K8055S01,代码行数:101,代码来源:pyk8055lib.c

示例4: lua_obj_newindex

static int lua_obj_newindex(lua_State *L)
{
    PyObject *o, *key, *val;
    LuaState *lua;
    int ret;

    lua = (LuaState *)lua_touserdata(L, lua_upvalueindex(1));
    o = *(PyObject **)luaL_checkudata(L, 1, PYOBJECT);
    if (PyDict_Check(o))
    {
        return luaL_error(L, "todo: implement dict __index");
    }
    else
    {
        key = Lua_topython(lua, 2);
        if (!PyString_Check(key))
        {
            Py_DECREF(key);
            return luaL_error(L, "attribute name isn't a string");
        }
        val = Lua_topython(lua, 3);
        ret = PyObject_SetAttr(o, key, val);
        Py_DECREF(key);
        Py_DECREF(val);
        if (ret == -1)
            return luaL_error(L, "failed to set attribute");
        return 0;
    }
}
开发者ID:arkeet,项目名称:pylua,代码行数:29,代码来源:luamodule.c

示例5: PyString_AsString


//.........这里部分代码省略.........
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ssdeep = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_6ssdeep_ssdeep = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "ssdeep.ssdeep", /*tp_name*/
  sizeof(struct __pyx_obj_6ssdeep_ssdeep), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6ssdeep_ssdeep, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ssdeep, /*tp_as_number*/
  &__pyx_tp_as_sequence_ssdeep, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ssdeep, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ssdeep, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6ssdeep_ssdeep, /*tp_traverse*/
  __pyx_tp_clear_6ssdeep_ssdeep, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6ssdeep_ssdeep, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_6ssdeep_6ssdeep___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6ssdeep_ssdeep, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

DL_EXPORT(void) initssdeep(void); /*proto*/
DL_EXPORT(void) initssdeep(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_m = Py_InitModule4("ssdeep", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyType_Ready(&__pyx_type_6ssdeep_ssdeep) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "ssdeep", (PyObject *)&__pyx_type_6ssdeep_ssdeep) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}
  __pyx_ptype_6ssdeep_ssdeep = &__pyx_type_6ssdeep_ssdeep;

  /* "/home/jose/tmp/ssdeep-2.2/pyssdeep-read-only/ssdeep.pyx":22 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_Exception); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_SsdeepException, "ssdeep"); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SsdeepException, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jose/tmp/ssdeep-2.2/pyssdeep-read-only/ssdeep.pyx":48 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("ssdeep");
}
开发者ID:0xDeva,项目名称:pyssdeep,代码行数:101,代码来源:ssdeep.c

示例6: _p_object_newindex_set

static int _p_object_newindex_set(lua_State *L, py_object *pobj, int keyn, int valuen) {
    lua_Object lkey = lua_getparam(L, keyn);
    PyObject *key = lua_stack_convert(L, keyn, lkey);
    if (!key) luaL_argerror(L, 1, "failed to convert key");
    lua_Object lval = lua_getparam(L, valuen);
    if (!lua_isnil(L, lval)) {
        PyObject *value = lua_stack_convert(L, valuen, lval);
        if (!value) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            luaL_argerror(L, 1, "failed to convert value");
        }
        // setitem (obj[0] = 1) if int else setattr(obj.val = 1)
        if (pobj->asindx) {
            if (PyObject_SetItem(pobj->object, key, value) == -1) {
                if (!is_object_container(L, lkey)) Py_DECREF(key);
                if (!is_object_container(L, lval)) Py_DECREF(value);
                lua_new_error(L, "failed to set item");
            }
        } else if (PyObject_SetAttr(pobj->object, key, value) == -1) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            if (!is_object_container(L, lval)) Py_DECREF(value);
            lua_new_error(L, "failed to set attribute");
        }
        if (!is_object_container(L, lval))
            Py_DECREF(value);
    } else {
        if (PyObject_DelItem(pobj->object, key) == -1) {
            if (!is_object_container(L, lkey)) Py_DECREF(key);
            lua_new_error(L, "failed to delete item");
        }
    }
    if (!is_object_container(L, lkey))
        Py_DECREF(key);
    return 0;
}
开发者ID:alexsilva,项目名称:lunatic-python,代码行数:35,代码来源:pythoninlua.c

示例7: pytrap_recv

static PyObject *
pytrap_recv(PyObject *self, PyObject *args, PyObject *keywds)
{
    uint32_t ifcidx;
    const void *in_rec;
    uint16_t in_rec_size;
    PyObject *data;
    PyObject *attr;

    static char *kwlist[] = {"ifcidx", NULL};
    if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &ifcidx)) {
        return NULL;
    }

    int ret = trap_recv(ifcidx, &in_rec, &in_rec_size);
    if (ret == TRAP_E_TIMEOUT) {
        PyErr_SetString(TimeoutError, "Timeout");
        return NULL;
    } else if (ret == TRAP_E_BAD_IFC_INDEX) {
        PyErr_SetString(TrapError, "Bad index of IFC.");
        return NULL;
    } else if (ret == TRAP_E_FORMAT_MISMATCH) {
        PyErr_SetString(TrapFMTMismatch, "Format mismatch, incompatible data format of sender and receiver.");
        return NULL;
    }
    data = PyBytes_FromStringAndSize(in_rec, in_rec_size);
    if (ret == TRAP_E_FORMAT_CHANGED) {
        attr = Py_BuildValue("s", "data");
        PyObject_SetAttr(TrapFMTChanged, attr, data);
        PyErr_SetString(TrapFMTChanged, "Format changed.");
        return NULL;
    }
    return data;
}
开发者ID:DarthJuri,项目名称:Nemea-Framework,代码行数:34,代码来源:pytrapmodule.c

示例8: Py_INCREF


//.........这里部分代码省略.........
static PyMappingMethods __pyx_tp_as_mapping_Stemmer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Stemmer = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_7Stemmer_Stemmer = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "Stemmer.Stemmer", /*tp_name*/
  sizeof(struct __pyx_obj_7Stemmer_Stemmer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7Stemmer_Stemmer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Stemmer, /*tp_as_number*/
  &__pyx_tp_as_sequence_Stemmer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Stemmer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Stemmer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "An instance of a stemming algorithm.\n\n    The algorithm has internal state, so must not be called concurrently.\n    ie, only a single thread should access the instance at any given time.\n\n    When creating a `Stemmer` object, there is one required argument: the\n    name of the algorithm to use in the new stemmer.  A list of the valid\n    algorithm names may be obtained by calling the `algorithms()` function\n    in this module.  In addition, the appropriate stemming algorithm for a\n    given language may be obtained by using the 2 or 3 letter ISO 639\n    language codes.\n\n    A second optional argument to the constructor for `Stemmer` is the size\n    of cache to use.  The cache implemented in this module is not terribly\n    efficient, but benchmarks show that it approximately doubles\n    performance for typical text processing operations, without too much\n    memory overhead.  The cache may be disabled by passing a size of 0.\n    The default size (10000 words) is probably appropriate in most\n    situations.  In pathological cases (for example, when no word is\n    presented to the stemming algorithm more than once, so the cache is\n    useless), the cache can severely damage performance.\n\n    The \"benchmark.py\" script supplied with the PyStemmer distribution can\n    be used to test the performance of the stemming algorithms with various\n    cache sizes.\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_7Stemmer_Stemmer, /*tp_traverse*/
  __pyx_tp_clear_7Stemmer_Stemmer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_7Stemmer_Stemmer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_7Stemmer_Stemmer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_7Stemmer_7Stemmer___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7Stemmer_Stemmer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"algorithms", (PyCFunction)__pyx_f_7Stemmer_algorithms, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7Stemmer_algorithms},
  {"version", (PyCFunction)__pyx_f_7Stemmer_version, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7Stemmer_version},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initStemmer(void); /*proto*/
PyMODINIT_FUNC initStemmer(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("Stemmer", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;};
  __pyx_type_7Stemmer_Stemmer.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_7Stemmer_Stemmer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Stemmer", (PyObject *)&__pyx_type_7Stemmer_Stemmer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
  __pyx_ptype_7Stemmer_Stemmer = &__pyx_type_7Stemmer_Stemmer;

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":25 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n___docformat__, __pyx_k13p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":43 */
  Py_INCREF(Py_False);
  __pyx_d1 = Py_False;

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":112 */
  __pyx_d2 = 10000;

  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":200 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("Stemmer");
}
开发者ID:buriy,项目名称:pystemmer,代码行数:101,代码来源:Stemmer.c

示例9: PyLong_FromLongLong

void pyllbc_FacadeEvBuilder::SetAttr(PyObject *ev, PyObject *attr, sint64 val)
{
    PyObject *pyVal = PyLong_FromLongLong(val);
    PyObject_SetAttr(ev, attr, pyVal);

    Py_DECREF(pyVal);
}
开发者ID:lailongwei,项目名称:llbc,代码行数:7,代码来源:PyFacadeEvBuilder.cpp

示例10: PyFloat_FromDouble

  /*else*/ {
    __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("Domain.CCS.utils.dactivation");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initutils(void); /*proto*/
PyMODINIT_FUNC initutils(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("utils", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};

  /* "d:\Dropbox\Dropbox\devsimpy\Domain\CCS\utils.pyx":2 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_INCREF(__pyx_n_expit);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_expit);
  __pyx_2 = __Pyx_Import(__pyx_k2p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_expit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_expit, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "d:\Dropbox\Dropbox\devsimpy\Domain\CCS\utils.pyx":7 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("Domain.CCS.utils");
}
开发者ID:capocchi,项目名称:DEVSimPy-lib-nn,代码行数:57,代码来源:utils.c

示例11: proxy_setattr

static int
proxy_setattr(PyWeakReference *proxy, PyObject *name, PyObject *value)
{
    if (!proxy_checkref(proxy))
        return -1;
    return PyObject_SetAttr(PyWeakref_GET_OBJECT(proxy), name, value);
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:7,代码来源:weakrefobject.c

示例12: get_local_dict

static PyObject*
get_local_dict(void)
{
    PyObject *current;
    PyObject *dict = NULL;

    current = greenlet_getcurrent();
    Py_XDECREF(current);
    if (current == NULL) {
        return NULL;
    }

    if (PyObject_HasAttr(current, dict_key) == 0) {
        dict = PyDict_New();
        if (dict == NULL) {
            return NULL;
        }
        if(PyObject_SetAttr(current, dict_key, dict) == -1) {
            Py_DECREF(dict);
            return NULL;
        }
    }
    
    return PyObject_GetAttr(current, dict_key);
}
开发者ID:chenbk85,项目名称:jega,代码行数:25,代码来源:local.c

示例13: PyString_FromStringAndSize

void pyllbc_FacadeEvBuilder::SetAttr(PyObject *ev, PyObject *attr, const LLBC_String &val)
{
    PyObject *pyVal = PyString_FromStringAndSize(val.data(), val.size());
    PyObject_SetAttr(ev, attr, pyVal);
    
    Py_DECREF(pyVal);
}
开发者ID:lailongwei,项目名称:llbc,代码行数:7,代码来源:PyFacadeEvBuilder.cpp

示例14: _p_object_newindex_set

static int _p_object_newindex_set(lua_State *L, py_object *obj, int keyn, int valuen) {
    PyObject *value;
    PyObject *key = LuaConvert(L, keyn);
    if (!key) luaL_argerror(L, 1, "failed to convert key");

    lua_Object lobj = lua_getparam(L, valuen);

    if (!lua_isnil(L, lobj)) {
        value = LuaConvert(L, valuen);
        if (!value) {
            Py_DECREF(key);
            luaL_argerror(L, 1, "failed to convert value");
        }
        // setitem (obj[0] = 1) if int else setattr(obj.val = 1)
        if (obj->asindx) {
            if (PyObject_SetItem(obj->o, key, value) == -1) {
                PyErr_Print();
                lua_error(L, "failed to set item");
            }
        } else if (PyObject_SetAttr(obj->o, key, value) == -1) {
            PyErr_Print();
            lua_error(L, "failed to set item");
        }
        Py_DECREF(value);
    } else {
        if (PyObject_DelItem(obj->o, key) == -1) {
            PyErr_Print();
            lua_error(L, "failed to delete item");
        }
    }
    Py_DECREF(key);
    return 0;
}
开发者ID:alessandrohc,项目名称:lunatic-python,代码行数:33,代码来源:pythoninlua.c

示例15: PyFloat_FromDouble

void pyllbc_FacadeEvBuilder::SetAttr(PyObject *ev, PyObject *attr, double val)
{
    PyObject *pyVal = PyFloat_FromDouble(val);
    PyObject_SetAttr(ev, attr, pyVal);

    Py_DECREF(pyVal);
}
开发者ID:lailongwei,项目名称:llbc,代码行数:7,代码来源:PyFacadeEvBuilder.cpp


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