1 /* Generated by Pyrex 0.9.6.4 on Fri Sep 11 01:26:01 2009 */ 2 3 #define PY_SSIZE_T_CLEAN 4 #include "Python.h" 5 #include "structmember.h" 6 #ifndef PY_LONG_LONG 7 #define PY_LONG_LONG LONG_LONG 8 #endif 9 #if PY_VERSION_HEX < 0x02050000 10 typedef int Py_ssize_t; 11 #define PY_SSIZE_T_MAX INT_MAX 12 #define PY_SSIZE_T_MIN INT_MIN 13 #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 14 #define PyInt_AsSsize_t(o) PyInt_AsLong(o) 15 #endif 16 #ifndef WIN32 17 #ifndef __stdcall 18 #define __stdcall 19 #endif 20 #ifndef __cdecl 21 #define __cdecl 22 #endif 23 #endif 24 #ifdef __cplusplus 25 #define __PYX_EXTERN_C extern "C" 26 #else 27 #define __PYX_EXTERN_C extern 28 #endif 29 #include <math.h> 30 31 32 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ 33 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 34 35 static PyObject *__pyx_m; 36 static PyObject *__pyx_b; 37 static int __pyx_lineno; 38 static char *__pyx_filename; 39 static char **__pyx_f; 40 41 static void __Pyx_AddTraceback(char *funcname); /*proto*/ 42 43 /* Declarations from vint */ 44 45 46 47 /* Implementation of vint */ 48 49 static PyObject *__pyx_f_4vint_vint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 50 static PyObject *__pyx_f_4vint_vint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 51 int __pyx_v_number; 52 char __pyx_v_bytes[40]; 53 int __pyx_v_lsd; 54 int __pyx_v_i; 55 PyObject *__pyx_v_s; 56 PyObject *__pyx_r; 57 int __pyx_1; 58 PyObject *__pyx_2 = 0; 59 static char *__pyx_argnames[] = {"number",0}; 60 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_number)) return 0; 61 __pyx_v_s = Py_None; Py_INCREF(Py_None); 62 63 /* "/home/paulb/Software/Python/iixr/vint.pyx":11 */ 64 __pyx_1 = (__pyx_v_number < 128); 65 if (__pyx_1) { 66 67 /* "/home/paulb/Software/Python/iixr/vint.pyx":12 */ 68 (__pyx_v_bytes[0]) = __pyx_v_number; 69 70 /* "/home/paulb/Software/Python/iixr/vint.pyx":13 */ 71 __pyx_2 = PyString_FromStringAndSize(__pyx_v_bytes,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} 72 Py_DECREF(__pyx_v_s); 73 __pyx_v_s = __pyx_2; 74 __pyx_2 = 0; 75 76 /* "/home/paulb/Software/Python/iixr/vint.pyx":14 */ 77 Py_INCREF(__pyx_v_s); 78 __pyx_r = __pyx_v_s; 79 goto __pyx_L0; 80 goto __pyx_L2; 81 } 82 __pyx_L2:; 83 84 /* "/home/paulb/Software/Python/iixr/vint.pyx":16 */ 85 __pyx_v_i = 0; 86 87 /* "/home/paulb/Software/Python/iixr/vint.pyx":17 */ 88 while (1) { 89 __pyx_1 = (__pyx_v_number != 0); 90 if (!__pyx_1) break; 91 92 /* "/home/paulb/Software/Python/iixr/vint.pyx":18 */ 93 __pyx_v_lsd = (__pyx_v_number & 127); 94 95 /* "/home/paulb/Software/Python/iixr/vint.pyx":19 */ 96 __pyx_v_number = (__pyx_v_number >> 7); 97 98 /* "/home/paulb/Software/Python/iixr/vint.pyx":20 */ 99 __pyx_1 = (__pyx_v_number != 0); 100 if (__pyx_1) { 101 __pyx_v_lsd = (__pyx_v_lsd | 128); 102 goto __pyx_L5; 103 } 104 __pyx_L5:; 105 106 /* "/home/paulb/Software/Python/iixr/vint.pyx":22 */ 107 (__pyx_v_bytes[__pyx_v_i]) = __pyx_v_lsd; 108 109 /* "/home/paulb/Software/Python/iixr/vint.pyx":23 */ 110 __pyx_v_i = (__pyx_v_i + 1); 111 } 112 113 /* "/home/paulb/Software/Python/iixr/vint.pyx":25 */ 114 __pyx_2 = PyString_FromStringAndSize(__pyx_v_bytes,__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} 115 Py_DECREF(__pyx_v_s); 116 __pyx_v_s = __pyx_2; 117 __pyx_2 = 0; 118 119 /* "/home/paulb/Software/Python/iixr/vint.pyx":26 */ 120 Py_INCREF(__pyx_v_s); 121 __pyx_r = __pyx_v_s; 122 goto __pyx_L0; 123 124 __pyx_r = Py_None; Py_INCREF(Py_None); 125 goto __pyx_L0; 126 __pyx_L1:; 127 Py_XDECREF(__pyx_2); 128 __Pyx_AddTraceback("vint.vint"); 129 __pyx_r = 0; 130 __pyx_L0:; 131 Py_DECREF(__pyx_v_s); 132 return __pyx_r; 133 } 134 135 static struct PyMethodDef __pyx_methods[] = { 136 {"vint", (PyCFunction)__pyx_f_4vint_vint, METH_VARARGS|METH_KEYWORDS, 0}, 137 {0, 0, 0, 0} 138 }; 139 140 static void __pyx_init_filenames(void); /*proto*/ 141 142 PyMODINIT_FUNC initvint(void); /*proto*/ 143 PyMODINIT_FUNC initvint(void) { 144 __pyx_init_filenames(); 145 __pyx_m = Py_InitModule4("vint", __pyx_methods, 0, 0, PYTHON_API_VERSION); 146 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; 147 Py_INCREF(__pyx_m); 148 __pyx_b = PyImport_AddModule("__builtin__"); 149 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; 150 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; 151 152 /* "/home/paulb/Software/Python/iixr/vint.pyx":6 */ 153 return; 154 __pyx_L1:; 155 __Pyx_AddTraceback("vint"); 156 } 157 158 static char *__pyx_filenames[] = { 159 "vint.pyx", 160 }; 161 162 /* Runtime support code */ 163 164 static void __pyx_init_filenames(void) { 165 __pyx_f = __pyx_filenames; 166 } 167 168 #include "compile.h" 169 #include "frameobject.h" 170 #include "traceback.h" 171 172 static void __Pyx_AddTraceback(char *funcname) { 173 PyObject *py_srcfile = 0; 174 PyObject *py_funcname = 0; 175 PyObject *py_globals = 0; 176 PyObject *empty_tuple = 0; 177 PyObject *empty_string = 0; 178 PyCodeObject *py_code = 0; 179 PyFrameObject *py_frame = 0; 180 181 py_srcfile = PyString_FromString(__pyx_filename); 182 if (!py_srcfile) goto bad; 183 py_funcname = PyString_FromString(funcname); 184 if (!py_funcname) goto bad; 185 py_globals = PyModule_GetDict(__pyx_m); 186 if (!py_globals) goto bad; 187 empty_tuple = PyTuple_New(0); 188 if (!empty_tuple) goto bad; 189 empty_string = PyString_FromString(""); 190 if (!empty_string) goto bad; 191 py_code = PyCode_New( 192 0, /*int argcount,*/ 193 0, /*int nlocals,*/ 194 0, /*int stacksize,*/ 195 0, /*int flags,*/ 196 empty_string, /*PyObject *code,*/ 197 empty_tuple, /*PyObject *consts,*/ 198 empty_tuple, /*PyObject *names,*/ 199 empty_tuple, /*PyObject *varnames,*/ 200 empty_tuple, /*PyObject *freevars,*/ 201 empty_tuple, /*PyObject *cellvars,*/ 202 py_srcfile, /*PyObject *filename,*/ 203 py_funcname, /*PyObject *name,*/ 204 __pyx_lineno, /*int firstlineno,*/ 205 empty_string /*PyObject *lnotab*/ 206 ); 207 if (!py_code) goto bad; 208 py_frame = PyFrame_New( 209 PyThreadState_Get(), /*PyThreadState *tstate,*/ 210 py_code, /*PyCodeObject *code,*/ 211 py_globals, /*PyObject *globals,*/ 212 0 /*PyObject *locals*/ 213 ); 214 if (!py_frame) goto bad; 215 py_frame->f_lineno = __pyx_lineno; 216 PyTraceBack_Here(py_frame); 217 bad: 218 Py_XDECREF(py_srcfile); 219 Py_XDECREF(py_funcname); 220 Py_XDECREF(empty_tuple); 221 Py_XDECREF(empty_string); 222 Py_XDECREF(py_code); 223 Py_XDECREF(py_frame); 224 }