1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/vint.c Fri Sep 11 01:21:09 2009 +0200
1.3 @@ -0,0 +1,203 @@
1.4 +/* Generated by Pyrex 0.9.6.4 on Fri Sep 11 01:17:16 2009 */
1.5 +
1.6 +#define PY_SSIZE_T_CLEAN
1.7 +#include "Python.h"
1.8 +#include "structmember.h"
1.9 +#ifndef PY_LONG_LONG
1.10 + #define PY_LONG_LONG LONG_LONG
1.11 +#endif
1.12 +#if PY_VERSION_HEX < 0x02050000
1.13 + typedef int Py_ssize_t;
1.14 + #define PY_SSIZE_T_MAX INT_MAX
1.15 + #define PY_SSIZE_T_MIN INT_MIN
1.16 + #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
1.17 + #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
1.18 +#endif
1.19 +#ifndef WIN32
1.20 + #ifndef __stdcall
1.21 + #define __stdcall
1.22 + #endif
1.23 + #ifndef __cdecl
1.24 + #define __cdecl
1.25 + #endif
1.26 +#endif
1.27 +#ifdef __cplusplus
1.28 +#define __PYX_EXTERN_C extern "C"
1.29 +#else
1.30 +#define __PYX_EXTERN_C extern
1.31 +#endif
1.32 +#include <math.h>
1.33 +
1.34 +
1.35 +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
1.36 +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
1.37 +
1.38 +static PyObject *__pyx_m;
1.39 +static PyObject *__pyx_b;
1.40 +static int __pyx_lineno;
1.41 +static char *__pyx_filename;
1.42 +static char **__pyx_f;
1.43 +
1.44 +static void __Pyx_AddTraceback(char *funcname); /*proto*/
1.45 +
1.46 +/* Declarations from vint */
1.47 +
1.48 +
1.49 +
1.50 +/* Implementation of vint */
1.51 +
1.52 +static PyObject *__pyx_f_4vint_vint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1.53 +static PyObject *__pyx_f_4vint_vint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1.54 + int __pyx_v_number;
1.55 + char __pyx_v_bytes[40];
1.56 + int __pyx_v_lsd;
1.57 + int __pyx_v_i;
1.58 + PyObject *__pyx_v_s;
1.59 + PyObject *__pyx_r;
1.60 + int __pyx_1;
1.61 + PyObject *__pyx_2 = 0;
1.62 + static char *__pyx_argnames[] = {"number",0};
1.63 + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_number)) return 0;
1.64 + __pyx_v_s = Py_None; Py_INCREF(Py_None);
1.65 +
1.66 + /* "/home/paulb/Software/Python/iixr/vint.pyx":11 */
1.67 + __pyx_v_i = 0;
1.68 +
1.69 + /* "/home/paulb/Software/Python/iixr/vint.pyx":12 */
1.70 + while (1) {
1.71 + __pyx_1 = (__pyx_v_number != 0);
1.72 + if (!__pyx_1) break;
1.73 +
1.74 + /* "/home/paulb/Software/Python/iixr/vint.pyx":13 */
1.75 + __pyx_v_lsd = (__pyx_v_number & 127);
1.76 +
1.77 + /* "/home/paulb/Software/Python/iixr/vint.pyx":14 */
1.78 + __pyx_v_number = (__pyx_v_number >> 7);
1.79 +
1.80 + /* "/home/paulb/Software/Python/iixr/vint.pyx":15 */
1.81 + __pyx_1 = (__pyx_v_number != 0);
1.82 + if (__pyx_1) {
1.83 + __pyx_v_lsd = (__pyx_v_lsd | 128);
1.84 + goto __pyx_L4;
1.85 + }
1.86 + __pyx_L4:;
1.87 +
1.88 + /* "/home/paulb/Software/Python/iixr/vint.pyx":17 */
1.89 + (__pyx_v_bytes[__pyx_v_i]) = __pyx_v_lsd;
1.90 +
1.91 + /* "/home/paulb/Software/Python/iixr/vint.pyx":18 */
1.92 + __pyx_v_i = (__pyx_v_i + 1);
1.93 + }
1.94 +
1.95 + /* "/home/paulb/Software/Python/iixr/vint.pyx":20 */
1.96 + __pyx_2 = PyString_FromStringAndSize(__pyx_v_bytes,__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
1.97 + Py_DECREF(__pyx_v_s);
1.98 + __pyx_v_s = __pyx_2;
1.99 + __pyx_2 = 0;
1.100 +
1.101 + /* "/home/paulb/Software/Python/iixr/vint.pyx":21 */
1.102 + Py_INCREF(__pyx_v_s);
1.103 + __pyx_r = __pyx_v_s;
1.104 + goto __pyx_L0;
1.105 +
1.106 + __pyx_r = Py_None; Py_INCREF(Py_None);
1.107 + goto __pyx_L0;
1.108 + __pyx_L1:;
1.109 + Py_XDECREF(__pyx_2);
1.110 + __Pyx_AddTraceback("vint.vint");
1.111 + __pyx_r = 0;
1.112 + __pyx_L0:;
1.113 + Py_DECREF(__pyx_v_s);
1.114 + return __pyx_r;
1.115 +}
1.116 +
1.117 +static struct PyMethodDef __pyx_methods[] = {
1.118 + {"vint", (PyCFunction)__pyx_f_4vint_vint, METH_VARARGS|METH_KEYWORDS, 0},
1.119 + {0, 0, 0, 0}
1.120 +};
1.121 +
1.122 +static void __pyx_init_filenames(void); /*proto*/
1.123 +
1.124 +PyMODINIT_FUNC initvint(void); /*proto*/
1.125 +PyMODINIT_FUNC initvint(void) {
1.126 + __pyx_init_filenames();
1.127 + __pyx_m = Py_InitModule4("vint", __pyx_methods, 0, 0, PYTHON_API_VERSION);
1.128 + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
1.129 + Py_INCREF(__pyx_m);
1.130 + __pyx_b = PyImport_AddModule("__builtin__");
1.131 + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
1.132 + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;};
1.133 +
1.134 + /* "/home/paulb/Software/Python/iixr/vint.pyx":6 */
1.135 + return;
1.136 + __pyx_L1:;
1.137 + __Pyx_AddTraceback("vint");
1.138 +}
1.139 +
1.140 +static char *__pyx_filenames[] = {
1.141 + "vint.pyx",
1.142 +};
1.143 +
1.144 +/* Runtime support code */
1.145 +
1.146 +static void __pyx_init_filenames(void) {
1.147 + __pyx_f = __pyx_filenames;
1.148 +}
1.149 +
1.150 +#include "compile.h"
1.151 +#include "frameobject.h"
1.152 +#include "traceback.h"
1.153 +
1.154 +static void __Pyx_AddTraceback(char *funcname) {
1.155 + PyObject *py_srcfile = 0;
1.156 + PyObject *py_funcname = 0;
1.157 + PyObject *py_globals = 0;
1.158 + PyObject *empty_tuple = 0;
1.159 + PyObject *empty_string = 0;
1.160 + PyCodeObject *py_code = 0;
1.161 + PyFrameObject *py_frame = 0;
1.162 +
1.163 + py_srcfile = PyString_FromString(__pyx_filename);
1.164 + if (!py_srcfile) goto bad;
1.165 + py_funcname = PyString_FromString(funcname);
1.166 + if (!py_funcname) goto bad;
1.167 + py_globals = PyModule_GetDict(__pyx_m);
1.168 + if (!py_globals) goto bad;
1.169 + empty_tuple = PyTuple_New(0);
1.170 + if (!empty_tuple) goto bad;
1.171 + empty_string = PyString_FromString("");
1.172 + if (!empty_string) goto bad;
1.173 + py_code = PyCode_New(
1.174 + 0, /*int argcount,*/
1.175 + 0, /*int nlocals,*/
1.176 + 0, /*int stacksize,*/
1.177 + 0, /*int flags,*/
1.178 + empty_string, /*PyObject *code,*/
1.179 + empty_tuple, /*PyObject *consts,*/
1.180 + empty_tuple, /*PyObject *names,*/
1.181 + empty_tuple, /*PyObject *varnames,*/
1.182 + empty_tuple, /*PyObject *freevars,*/
1.183 + empty_tuple, /*PyObject *cellvars,*/
1.184 + py_srcfile, /*PyObject *filename,*/
1.185 + py_funcname, /*PyObject *name,*/
1.186 + __pyx_lineno, /*int firstlineno,*/
1.187 + empty_string /*PyObject *lnotab*/
1.188 + );
1.189 + if (!py_code) goto bad;
1.190 + py_frame = PyFrame_New(
1.191 + PyThreadState_Get(), /*PyThreadState *tstate,*/
1.192 + py_code, /*PyCodeObject *code,*/
1.193 + py_globals, /*PyObject *globals,*/
1.194 + 0 /*PyObject *locals*/
1.195 + );
1.196 + if (!py_frame) goto bad;
1.197 + py_frame->f_lineno = __pyx_lineno;
1.198 + PyTraceBack_Here(py_frame);
1.199 +bad:
1.200 + Py_XDECREF(py_srcfile);
1.201 + Py_XDECREF(py_funcname);
1.202 + Py_XDECREF(empty_tuple);
1.203 + Py_XDECREF(empty_string);
1.204 + Py_XDECREF(py_code);
1.205 + Py_XDECREF(py_frame);
1.206 +}