Ejemplo n.º 1
0
  /* "/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");
}
Ejemplo n.º 2
0
/* 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");
}
Ejemplo n.º 3
0
  /* "G:/Projekte/svn_mynew/svnroot/os2/usb/k8055/pyk8055/pyk8055lib.pyx":84 */
  Py_INCREF(__pyx_v_strwrite);
  __pyx_r = __pyx_v_strwrite;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("pyk8055lib.K8055LibClass.WriteasString");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_strwrite);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_writedata);
  return __pyx_r;
}

static PyObject *__pyx_tp_new_10pyk8055lib_K8055LibClass(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  if (__pyx_f_10pyk8055lib_13K8055LibClass___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10pyk8055lib_K8055LibClass(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_10pyk8055lib_13K8055LibClass___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  (*o->ob_type->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_10pyk8055lib_K8055LibClass[] = {
  {"ReadasString", (PyCFunction)__pyx_f_10pyk8055lib_13K8055LibClass_ReadasString, METH_VARARGS|METH_KEYWORDS, 0},
  {"ReadData", (PyCFunction)__pyx_f_10pyk8055lib_13K8055LibClass_ReadData, METH_VARARGS|METH_KEYWORDS, 0},
  {"WriteData", (PyCFunction)__pyx_f_10pyk8055lib_13K8055LibClass_WriteData, METH_VARARGS|METH_KEYWORDS, 0},
  {"WriteasString", (PyCFunction)__pyx_f_10pyk8055lib_13K8055LibClass_WriteasString, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_K8055LibClass = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_K8055LibClass = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

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");
}
Ejemplo n.º 4
0
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;
    }
}
Ejemplo n.º 5
0
  /* "/home/jose/tmp/ssdeep-2.2/pyssdeep-read-only/ssdeep.pyx":53 */
  __pyx_1 = PyString_AsString(__pyx_v_hash1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
  __pyx_2 = PyString_AsString(__pyx_v_hash2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(fuzzy_compare(__pyx_1,__pyx_2)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("ssdeep.ssdeep.compare");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_hash1);
  Py_DECREF(__pyx_v_hash2);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_Exception, "Exception"},
  {&__pyx_n_SsdeepException, "SsdeepException"},
  {&__pyx_n_len, "len"},
  {&__pyx_n_replace, "replace"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k3p, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_k4p, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k5p, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)},
  {0, 0, 0}
};

static PyObject *__pyx_tp_new_6ssdeep_ssdeep(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_6ssdeep_ssdeep *p = (struct __pyx_obj_6ssdeep_ssdeep *)o;
  return o;
}

static void __pyx_tp_dealloc_6ssdeep_ssdeep(PyObject *o) {
  struct __pyx_obj_6ssdeep_ssdeep *p = (struct __pyx_obj_6ssdeep_ssdeep *)o;
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_6ssdeep_ssdeep(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6ssdeep_ssdeep *p = (struct __pyx_obj_6ssdeep_ssdeep *)o;
  return 0;
}

static int __pyx_tp_clear_6ssdeep_ssdeep(PyObject *o) {
  struct __pyx_obj_6ssdeep_ssdeep *p = (struct __pyx_obj_6ssdeep_ssdeep *)o;
  return 0;
}

static struct PyMethodDef __pyx_methods_6ssdeep_ssdeep[] = {
  {"hash_file", (PyCFunction)__pyx_f_6ssdeep_6ssdeep_hash_file, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6ssdeep_6ssdeep_hash_file},
  {"hash_bytes", (PyCFunction)__pyx_f_6ssdeep_6ssdeep_hash_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6ssdeep_6ssdeep_hash_bytes},
  {"compare", (PyCFunction)__pyx_f_6ssdeep_6ssdeep_compare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6ssdeep_6ssdeep_compare},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ssdeep = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_ssdeep = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ssdeep = {
  0, /*mp_length*/
  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");
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
  /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":218 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("Stemmer.Stemmer.stemWords");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_word);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_words);
  return __pyx_r;
}

static PyObject *__pyx_tp_new_7Stemmer_Stemmer(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_7Stemmer_Stemmer *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_7Stemmer_Stemmer *)o);
  p->cache = Py_None; Py_INCREF(Py_None);
  p->counter = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_7Stemmer_Stemmer(PyObject *o) {
  struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_7Stemmer_7Stemmer___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->cache);
  Py_XDECREF(p->counter);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_7Stemmer_Stemmer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
  if (p->cache) {
    e = (*v)(p->cache, a); if (e) return e;
  }
  if (p->counter) {
    e = (*v)(p->counter, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7Stemmer_Stemmer(PyObject *o) {
  struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
  PyObject *t;
  t = p->cache; 
  p->cache = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(t);
  t = p->counter; 
  p->counter = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

static PyObject *__pyx_getprop_7Stemmer_7Stemmer_maxCacheSize(PyObject *o, void *x) {
  return __pyx_f_7Stemmer_7Stemmer_12maxCacheSize___get__(o);
}

static int __pyx_setprop_7Stemmer_7Stemmer_maxCacheSize(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_7Stemmer_7Stemmer_12maxCacheSize___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_7Stemmer_Stemmer[] = {
  {"__purgeCache", (PyCFunction)__pyx_f_7Stemmer_7Stemmer___purgeCache, METH_VARARGS|METH_KEYWORDS, 0},
  {"stemWord", (PyCFunction)__pyx_f_7Stemmer_7Stemmer_stemWord, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7Stemmer_7Stemmer_stemWord},
  {"stemWords", (PyCFunction)__pyx_f_7Stemmer_7Stemmer_stemWords, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7Stemmer_7Stemmer_stemWords},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_7Stemmer_Stemmer[] = {
  {"maxCacheSize", __pyx_getprop_7Stemmer_7Stemmer_maxCacheSize, __pyx_setprop_7Stemmer_7Stemmer_maxCacheSize, __pyx_k12, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Stemmer = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Stemmer = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

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");
}
Ejemplo n.º 9
0
void pyllbc_FacadeEvBuilder::SetAttr(PyObject *ev, PyObject *attr, sint64 val)
{
    PyObject *pyVal = PyLong_FromLongLong(val);
    PyObject_SetAttr(ev, attr, pyVal);

    Py_DECREF(pyVal);
}
Ejemplo n.º 10
0
  /*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");
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
0
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);
}
Ejemplo n.º 13
0
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);
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
void pyllbc_FacadeEvBuilder::SetAttr(PyObject *ev, PyObject *attr, double val)
{
    PyObject *pyVal = PyFloat_FromDouble(val);
    PyObject_SetAttr(ev, attr, pyVal);

    Py_DECREF(pyVal);
}
Ejemplo n.º 16
0
static bool
decode_struct(DecodeBuffer* input, PyObject* output, PyObject* spec_seq) {
  int spec_seq_len = PyTuple_Size(spec_seq);
  if (spec_seq_len == -1) {
    return false;
  }

  while (true) {
    TType type;
    int16_t tag;
    PyObject* item_spec;
    PyObject* fieldval = NULL;
    StructItemSpec parsedspec;

    type = readByte(input);
    if (type == -1) {
      return false;
    }
    if (type == T_STOP) {
      break;
    }
    tag = readI16(input);
    if (INT_CONV_ERROR_OCCURRED(tag)) {
      return false;
    }
    if (tag >= 0 && tag < spec_seq_len) {
      item_spec = PyTuple_GET_ITEM(spec_seq, tag);
    } else {
      item_spec = Py_None;
    }

    if (item_spec == Py_None) {
      if (!skip(input, type)) {
        return false;
      } else {
        continue;
      }
    }

    if (!parse_struct_item_spec(&parsedspec, item_spec)) {
      return false;
    }
    if (parsedspec.type != type) {
      PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading");
      return false;
    }

    fieldval = decode_val(input, parsedspec.type, parsedspec.typeargs);
    if (fieldval == NULL) {
      return false;
    }

    if (PyObject_SetAttr(output, parsedspec.attrname, fieldval) == -1) {
      Py_DECREF(fieldval);
      return false;
    }
    Py_DECREF(fieldval);
  }
  return true;
}
Ejemplo n.º 17
0
Archivo: redir.c Proyecto: rkern/redir
/* Implementation of redir */


static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_os;

static PyObject *__pyx_n_False;
static PyObject *__pyx_n_started;

static int __pyx_f_5redir_10Redirector___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5redir_10Redirector___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_fd;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"fd",0};
  __pyx_v_fd = __pyx_k3;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_fd)) return -1;
  Py_INCREF(__pyx_v_self);

  /* "/Users/kern/projects/redir/redir.pyx":29 */
  ((struct __pyx_obj_5redir_Redirector *)__pyx_v_self)->fd = __pyx_v_fd;

  /* "/Users/kern/projects/redir/redir.pyx":30 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_started, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("redir.Redirector.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}
Ejemplo n.º 18
0
/* out: */
PyObject *supp_convertDocumentToPythonDocument(lucene::document::Document *doc) {
  lucene::document::DocumentFieldEnumeration *fieldEnum = NULL;
  PyObject *docFields = NULL;
  PyObject *pyDoc = PyObject_CallFunctionObjArgs(global_DocumentConstructor, Py_False, NULL);
  FAIL_IF_NULL(pyDoc);
  docFields = PyDict_New();
  FAIL_IF_NULL(docFields);

  fieldEnum = doc->fields();
  while (fieldEnum->hasMoreElements()) {
    lucene::document::Field *field = fieldEnum->nextElement();

    PyObject *pyName;
    CONVERT_STRING_OUT(field->Name(), pyName);
    if (pyName == NULL) goto fail;
    PyObject *pyValue;
    CONVERT_STRING_OUT(field->StringValue(), pyValue);
    if (pyValue == NULL) {
      Py_DECREF(pyName);
      goto fail;
    }
    PyObject *pyIsStored = PyBool_FromLong( (long) field->IsStored() );
    PyObject *pyIsIndexed = PyBool_FromLong( (long) field->IsIndexed() );
    PyObject *pyIsTokenized = PyBool_FromLong( (long) field->IsTokenized() );

    PyObject *pyField = PyObject_CallFunctionObjArgs(global_FieldConstructor,
        pyName, pyValue, pyIsStored, pyIsIndexed, pyIsTokenized,
        NULL
      );
    Py_DECREF(pyValue);
    Py_DECREF(pyIsStored);
    Py_DECREF(pyIsIndexed);
    Py_DECREF(pyIsTokenized);
    if (pyField == NULL) {
      Py_DECREF(pyName);
      goto fail;
    }

    if ( PyDict_SetItem(docFields, pyName, pyField) == -1) goto fail;
    /* PyDict_SetItem established its own references to pyName and pyField. */
    Py_DECREF(pyName);
    Py_DECREF(pyField);
  }
  /* Now we have a dict containing the fields.  Attach it to pyDoc. */
  if ( PyObject_SetAttr(pyDoc, global_string__fields, docFields) == -1) goto fail;
  Py_DECREF(docFields);

  delete fieldEnum;
  return pyDoc;
  fail:
    if (!PyErr_Occurred()) PyErr_NoMemory();
    Py_XDECREF(pyDoc);
    Py_XDECREF(docFields);
    delete fieldEnum;
    return NULL;
}
Ejemplo n.º 19
0
static int Proxy_setattro(
        ProxyObject *self, PyObject *name, PyObject *value)
{
    if (PyObject_HasAttr((PyObject *)Py_TYPE(self), name))
        return PyObject_GenericSetAttr((PyObject *)self, name, value);

    Proxy__ENSURE_WRAPPED_OR_RETURN_MINUS1(self);

    return PyObject_SetAttr(self->wrapped, name, value);
}
Ejemplo n.º 20
0
static int
wrap_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PyObject *wrapped;
    PyObject *descriptor;
    const char *name_as_string;
    int res = -1;

#if PY_MAJOR_VERSION < 3 && defined(Py_USING_UNICODE)
    /* The Unicode to string conversion is done here because the
       existing tp_setattro slots expect a string object as name
       (except under Python 3) and we wouldn't want to break those. */

    if (PyUnicode_Check(name)) {
        name = PyUnicode_AsEncodedString(name, NULL, NULL);
        if (name == NULL)
            return -1;
    }
    else
#endif

    if (!IS_STRING(name)){
        PyErr_SetString(PyExc_TypeError, "attribute name must be string");
        return -1;
    }
    else
        Py_INCREF(name);

    descriptor = WrapperType_Lookup(self->ob_type, name);

    if (descriptor != NULL
#if PY_MAJOR_VERSION < 3 // This is always true in Python 3 (I think)
        && PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS)
#endif
        && descriptor->ob_type->tp_descr_set != NULL)
      {
        res = descriptor->ob_type->tp_descr_set(descriptor, self, value);
        goto finally;
      }

    name_as_string = MAKE_STRING(name);

    wrapped = Proxy_GET_OBJECT(self);
    if (wrapped == NULL) {
        PyErr_Format(PyExc_RuntimeError,
            "object is NULL; requested to set attribute '%s'",
            name_as_string);
        goto finally;
    }
    res = PyObject_SetAttr(wrapped, name, value);

finally:
    Py_DECREF(name);
    return res;
}
Ejemplo n.º 21
0
static int
thunk_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PyObject *normal;

    if (!(normal = _strict_eval_borrowed(self))) {
        return -1;
    }

    return PyObject_SetAttr(normal, name, value);
}
static int __init__(PyObject *self, PyObject *args, PyObject *kwds)
{
	PyObject *key, *value;
	Py_ssize_t pos = 0;

	if(kwds)
		while(PyDict_Next(kwds, &pos, &key, &value))
			if(PyObject_SetAttr(self, key, value) < 0)
				return -1;
	return 0;
}
Ejemplo n.º 23
0
Archivo: redir.c Proyecto: rkern/redir
    /* "/Users/kern/projects/redir/redir.pyx":66 */
    __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stop); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_v_output);
    __pyx_v_output = __pyx_7;
    __pyx_7 = 0;
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        PyErr_Restore(__pyx_1, __pyx_2, __pyx_3);
        __pyx_lineno = __pyx_4;
        __pyx_1 = 0;
        __pyx_2 = 0;
        __pyx_3 = 0;
        goto __pyx_L1;
      }
    }
  }

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("redir.Redirector.test");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_xyzzy);
  Py_DECREF(__pyx_v_output);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_False, "False"},
  {&__pyx_n_True, "True"},
  {&__pyx_n_close, "close"},
  {&__pyx_n_fdopen, "fdopen"},
  {&__pyx_n_foo, "foo"},
  {&__pyx_n_os, "os"},
  {&__pyx_n_pipe, "pipe"},
  {&__pyx_n_r, "r"},
  {&__pyx_n_read, "read"},
  {&__pyx_n_start, "start"},
  {&__pyx_n_started, "started"},
  {&__pyx_n_stop, "stop"},
  {&__pyx_n_sys, "sys"},
  {&__pyx_n_xyzzy, "xyzzy"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},
  {0, 0, 0}
};
static struct __pyx_vtabstruct_5redir_Redirector __pyx_vtable_5redir_Redirector;

static PyObject *__pyx_tp_new_5redir_Redirector(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5redir_Redirector *p = (struct __pyx_obj_5redir_Redirector *)o;
  (struct __pyx_vtabstruct_5redir_Redirector *)p->__pyx_vtab = __pyx_vtabptr_5redir_Redirector;
  return o;
}

static void __pyx_tp_dealloc_5redir_Redirector(PyObject *o) {
  struct __pyx_obj_5redir_Redirector *p = (struct __pyx_obj_5redir_Redirector *)o;
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5redir_Redirector(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5redir_Redirector *p = (struct __pyx_obj_5redir_Redirector *)o;
  return 0;
}

static int __pyx_tp_clear_5redir_Redirector(PyObject *o) {
  struct __pyx_obj_5redir_Redirector *p = (struct __pyx_obj_5redir_Redirector *)o;
  return 0;
}

static struct PyMethodDef __pyx_methods_5redir_Redirector[] = {
  {"start", (PyCFunction)__pyx_f_5redir_10Redirector_start, METH_VARARGS|METH_KEYWORDS, 0},
  {"stop", (PyCFunction)__pyx_f_5redir_10Redirector_stop, METH_VARARGS|METH_KEYWORDS, 0},
  {"test", (PyCFunction)__pyx_f_5redir_10Redirector_test, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Redirector = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Redirector = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

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

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

statichere PyTypeObject __pyx_type_5redir_Redirector = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "redir.Redirector", /*tp_name*/
  sizeof(struct __pyx_obj_5redir_Redirector), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5redir_Redirector, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Redirector, /*tp_as_number*/
  &__pyx_tp_as_sequence_Redirector, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Redirector, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Redirector, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5redir_Redirector, /*tp_traverse*/
  __pyx_tp_clear_5redir_Redirector, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5redir_Redirector, /*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_5redir_10Redirector___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5redir_Redirector, /*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) initredir(void); /*proto*/
DL_EXPORT(void) initredir(void) {
  PyObject *__pyx_1 = 0;
  __pyx_m = Py_InitModule4("redir", __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;};
  __pyx_vtabptr_5redir_Redirector = &__pyx_vtable_5redir_Redirector;
  __pyx_vtable_5redir_Redirector.flush = (void *)__pyx_f_5redir_10Redirector_flush;
  if (PyType_Ready(&__pyx_type_5redir_Redirector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5redir_Redirector.tp_dict, __pyx_vtabptr_5redir_Redirector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Redirector", (PyObject *)&__pyx_type_5redir_Redirector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
  __pyx_ptype_5redir_Redirector = &__pyx_type_5redir_Redirector;

  /* "/Users/kern/projects/redir/redir.pyx":14 */
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/kern/projects/redir/redir.pyx":15 */
  __pyx_1 = __Pyx_Import(__pyx_n_os, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_os, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/kern/projects/redir/redir.pyx":20 */
  __pyx_v_5redir_STDOUT = 1;

  /* "/Users/kern/projects/redir/redir.pyx":21 */
  __pyx_v_5redir_STDERR = 2;

  /* "/Users/kern/projects/redir/redir.pyx":28 */
  __pyx_k3 = __pyx_v_5redir_STDOUT;

  /* "/Users/kern/projects/redir/redir.pyx":59 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("redir");
}
Ejemplo n.º 24
0
static int
wrap_setattro(PyObject *self, PyObject *name, PyObject *value)
{
    PyObject *wrapped;
    PyObject *descriptor;
    int res = -1;

#ifdef Py_USING_UNICODE
    /* The Unicode to string conversion is done here because the
       existing tp_setattro slots expect a string object as name
       and we wouldn't want to break those. */
    if (PyUnicode_Check(name)) {
        name = PyUnicode_AsEncodedString(name, NULL, NULL);
        if (name == NULL)
            return -1;
    }
    else
#endif
    if (!PyString_Check(name)){
        PyErr_SetString(PyExc_TypeError, "attribute name must be string");
        return -1;
    }
    else
        Py_INCREF(name);

    descriptor = WrapperType_Lookup(self->ob_type, name);
    if (descriptor != NULL) {
        if (PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS) &&
            descriptor->ob_type->tp_descr_set != NULL) {
            res = descriptor->ob_type->tp_descr_set(descriptor, self, value);
        } else {
            PyErr_Format(PyExc_TypeError,
                "Tried to set attribute '%s' on wrapper, but it is not"
                " a data descriptor", PyString_AS_STRING(name));
        }
        goto finally;
    }

    wrapped = Proxy_GET_OBJECT(self);
    if (wrapped == NULL) {
        PyErr_Format(PyExc_RuntimeError,
            "object is NULL; requested to set attribute '%s'",
            PyString_AS_STRING(name));
        goto finally;
    }
    res = PyObject_SetAttr(wrapped, name, value);

finally:
    Py_DECREF(name);
    return res;
}
Ejemplo n.º 25
0
/* Implementation of pinard6 */

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

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

PyMODINIT_FUNC initpinard6(void); /*proto*/
PyMODINIT_FUNC initpinard6(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("pinard6", __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;};

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/pinard/pinard6.pyx":1 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_x, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/pinard/pinard6.pyx":2 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_x, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("pinard6");
}
Ejemplo n.º 26
0
static PyObject *
rsetattr(PyObject *self, PyObject *args)
{
	PyObject *ob, *attr, *val;

	if (!PyArg_ParseTuple(args, "OOO", &attr, &val, &ob))
		return(NULL);

	if (PyObject_SetAttr(ob, attr, val) < 0)
		return(NULL);

	Py_INCREF(ob);
	return(ob);
}
Ejemplo n.º 27
0
int
PyObject_SetAttrString(PyObject *v, char *name, PyObject *w)
{
	PyObject *s;
	int res;

	if (v->ob_type->tp_setattr != NULL)
		return (*v->ob_type->tp_setattr)(v, name, w);
	s = PyString_InternFromString(name);
	if (s == NULL)
		return -1;
	res = PyObject_SetAttr(v, s, w);
	Py_XDECREF(s);
	return res;
}
Ejemplo n.º 28
0
PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
{
    static PyObject* pySlotName = 0;
    PyObject* callback;
    callback = PyTuple_GetItem(args, 0);
    Py_INCREF(callback);

    if (PyFunction_Check(callback)) {
        PySideSlot *data = reinterpret_cast<PySideSlot*>(self);

        if (!data->slotName) {
            PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
            data->slotName = strdup(Shiboken::String::toCString(funcName));
        }


        QByteArray returnType = QMetaObject::normalizedType(data->resultType);
        QByteArray signature = QString().sprintf("%s(%s)", data->slotName, data->args).toUtf8();
        signature = returnType + " " + signature;

        if (!pySlotName)
            pySlotName = Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR);

        PyObject *pySignature = Shiboken::String::fromCString(signature);
        PyObject *signatureList = 0;
        if (PyObject_HasAttr(callback, pySlotName)) {
            signatureList = PyObject_GetAttr(callback, pySlotName);
        } else {
            signatureList = PyList_New(0);
            PyObject_SetAttr(callback, pySlotName, signatureList);
            Py_DECREF(signatureList);
        }

        PyList_Append(signatureList, pySignature);
        Py_DECREF(pySignature);

        //clear data
        free(data->slotName);
        data->slotName = 0;
        free(data->resultType);
        data->resultType = 0;
        free(data->args);
        data->args = 0;
        return callback;
    }
    return callback;
}
Ejemplo n.º 29
0
PyObject*
get_thread_local(PyObject *current)
{
    PyObject *dict = 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);
}
Ejemplo n.º 30
0
/* Implementation of concatcstrings */

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

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

PyMODINIT_FUNC initconcatcstrings(void); /*proto*/
PyMODINIT_FUNC initconcatcstrings(void) {
  PyObject *__pyx_1 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("concatcstrings", __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 = PyNumber_Add(__pyx_k1p, __pyx_k2p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_spam, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("concatcstrings");
}