Changeset 7202 for lang/d

Show
Ignore:
Timestamp:
02/27/08 23:26:48 (9 months ago)
Author:
itkz
Message:

call Python interpreter

Location:
lang/d/pythond
Files:
4 added
6 modified

Legend:

Unmodified
Added
Removed
  • lang/d/pythond/Makefile

    r232 r7202  
    11 
     2DC = gdc 
    23CC = gdc 
    34 
    4 SOURCES=main.d physical_object.d physical_object_action.d python.d $(wildcard SDL/*.d) 
    5 OBJS=$(SOURCES:.d=.o) 
    6 LIBS=libs/libpython24.a libs/libpcl.a libs/libSDLmain.a libs/libSDL.dll.a libs/libSDL_image.a libs/libgphobos.a 
     5D_SOURCES=main.d physical_object.d physical_object_action.d python.d python_base.d python_super.d noddy.d pcl.d $(wildcard SDL/*.d) 
     6D_OBJS=$(D_SOURCES:.d=.o) 
     7 
     8C_SOURCES=python_glue_to_d.c 
     9C_OBJS=$(C_SOURCES:.c=.o) 
     10 
     11OBJS=$(D_OBJS) $(C_OBJS) 
     12 
     13LIBS=libs/libpython24.a libs/libpcl.a libs/libSDL.dll.a 
     14# libs/libSDLmain.a libs/libSDL.dll.a libs/libSDL_image.a 
    715TARGET=test 
    816 
    9 CFLAGS=-g -Wall -ISDL -I/usr/local/include/d 
    10 LDFLAGS= 
     17D_CFLAGS=-g -Wall -ISDL -Iopengl `sdl-config --cflags` 
     18# -I/usr/local/include/d 
     19C_CFLAGS=-g -Wall -IPython-2.4.3 -IPython-2.4.3/Include `sdl-config --cflags` 
     20 
     21LDFLAGS=-lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDLmain -lSDL `sdl-config --libs` 
    1122 
    1223all: $(TARGET) 
    1324 
    14 $(OBJS): %o: %d 
    15         $(CC) $(CFLAGS) -c $< -o $@ 
     25$(D_OBJS): %o: %d 
     26        $(DC) $(D_CFLAGS) -c $< -o $@ 
     27 
     28$(C_OBJS): %o: %c 
     29        $(CC) $(C_CFLAGS) -c $< -o $@ 
    1630 
    1731$(TARGET): $(OBJS) 
    18         $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 
     32        $(DC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 
    1933 
    20 main.o: physical_object.d physical_object_action.d 
     34main.o: main.d physical_object.d physical_object_action.d 
    2135 
    22 physical_object.o: physical_object_action.d 
     36physical_object.o: physical_object.d physical_object_action.d pcl.d 
    2337 
    24 physical_object_action.o: physical_object.d 
     38physical_object_action.o: physical_object_action.d physical_object.d python.d 
     39 
     40python_super.o: python_super.d python.d python_base.d physical_object.d 
     41 
     42python_base.o: python_base.d python.d 
     43 
     44python.o: python.d python_glue_to_d.c 
     45 
     46pcl.o: pcl.d 
     47 
     48python_glue_to_d.o: python_glue_to_d.c 
    2549 
    2650clean: 
  • lang/d/pythond/main.d

    r232 r7202  
    11 
    22 
    3 private import std.string; 
     3import std.string; 
    44 
    5 private import python; 
    6 private import SDL; 
     5import python; 
     6import SDL; 
     7import SDL_video; 
     8import SDL_events; 
     9import SDL_timer; 
     10import SDL_types; 
    711 
    8 private import physical_object_action; 
    9 private import physical_object; 
     12import physical_object_action; 
     13import physical_object; 
     14 
     15import python_super; 
     16import noddy; 
    1017 
    1118 
     
    2734                return -1; 
    2835        } 
     36        scope(exit) { 
     37                SDL_Quit(); 
     38        } 
    2939         
    3040        screen = SDL_SetVideoMode(640, 480, 0, SDL_HWSURFACE); 
    3141        if (screen == null) { 
    32                 SDL_Quit(); 
    3342                return -1; 
     43        } 
     44        scope(exit) { 
     45                if (buffer != null) { 
     46                        SDL_FreeSurface(buffer); 
     47                } 
     48                SDL_FreeSurface(screen); 
    3449        } 
    3550         
     
    4358         
    4459        SDL_WM_SetCaption("shine", null); 
     60         
     61        Py_Initialize(); 
     62        NoddyModule noddyModule = new NoddyModule(); 
     63        noddyModule.initModule(); 
     64         
    4565        po = new PhysicalObject(new PhysicalObjectAction()); 
     66        PythonSuperModule pythonSuperModule = new PythonSuperModule(po); 
     67        pythonSuperModule.initModule(); 
     68         
    4669        nextFrameTime = SDL_GetTicks() + 50; 
    47          
    4870        isGotMessage = false; 
    4971        while(1) { 
     
    5779                        if (nextFrameTime < SDL_GetTicks()) { 
    5880                                po.actFiber(); 
    59                                 nextFrameTime += 50; 
     81                                nextFrameTime += 1000 / 60; 
    6082                                event.type = SDL_VIDEOEXPOSE; 
    6183                                SDL_PushEvent(&event); 
     
    6486                } 
    6587        } 
    66          
    67         if (buffer != null) { 
    68                 SDL_FreeSurface(buffer); 
    69         } 
    70         SDL_FreeSurface(screen); 
    71          
    72         SDL_Quit(); 
    7388         
    7489        return 0; 
  • lang/d/pythond/physical_object.d

    r232 r7202  
    11 
     2 
     3private import std.string; 
    24 
    35private import pcl; 
     
    1921        int y; 
    2022 
    21  
    2223        this(PhysicalObjectAction action) 
    2324        { 
     
    2728                action_ = action; 
    2829 
    29                 version (MacOSX) { 
     30                version (Darwin) { 
    3031                        static const int CO_STACK_SIZE = (8 * 1024); 
    3132                } 
    3233                else {  
    33                         static const int CO_STACK_SIZE = (16 * 1024); 
     34                        static const int CO_STACK_SIZE = (16 * 1024 * 2); 
    3435                } 
    35                 co_ = co_create(&spawner, this, null, CO_STACK_SIZE); 
     36                co_ = co_create(&spawner, cast(void*)this, null, CO_STACK_SIZE); 
    3637 
    3738                action_.init(this); 
     
    5152           in action_.act() with co_resume(). 
    5253         */ 
    53         void actTask() { 
     54        void actTask() 
     55        { 
    5456                action_.act(); 
    5557        } 
  • lang/d/pythond/physical_object_action.d

    r232 r7202  
    22 
    33private import physical_object; 
     4 
     5private import python; 
    46 
    57 
     
    1618        void init(PhysicalObject physicalObject) 
    1719        { 
    18                 physicalObject_ = physicalObject; 
     20                _physicalObject = physicalObject; 
    1921        } 
    2022 
    2123 
    22         void act() 
     24        int act() 
    2325        { 
    2426                for(int i = 0; i < 5; i++) { 
    25                         physicalObject_.x++; 
    26                         physicalObject_.y++; 
    27                         physicalObject_.resume(); 
     27                        _physicalObject.x++; 
     28                        _physicalObject.y++; 
     29                        _physicalObject.resume(); 
    2830                } 
    29                 physicalObject_.sleep(10); 
     31                _physicalObject.sleep(60); 
     32 
     33                PyObject* pyName; 
     34                PyObject* pyModule; 
     35                PyObject* pyDict; 
     36                PyObject* pyFunc; 
     37                PyObject* pyValue; 
     38 
     39                pyName = PyString_FromString(cast(char*)"unko\0"); 
     40                if (!pyName) { 
     41                        printf("name?\n"); 
     42                        PyErr_Print(); 
     43                } 
     44                pyModule = PyImport_Import(pyName); 
     45                Py_DECREF(pyName); 
     46                if (!pyModule) { 
     47                        printf("module?\n"); 
     48                        PyErr_Print(); 
     49                        return -1; 
     50                } 
     51                pyDict = PyModule_GetDict(pyModule); 
     52                pyFunc = PyDict_GetItemString(pyDict, cast(char*)"yamada\0"); 
     53                if (!pyFunc || !PyCallable_Check(pyFunc)) { 
     54                        Py_DECREF(pyModule); 
     55                        printf("func?\n"); 
     56                        PyErr_Print(); 
     57                        return -1; 
     58                } 
     59                pyValue = PyObject_CallObject(pyFunc, null); 
     60                if (pyValue == null) { 
     61                        Py_DECREF(pyModule); 
     62                        printf("call?\n"); 
     63                        PyErr_Print(); 
     64_physicalObject.sleep(6000); 
     65                        return -1; 
     66                } 
     67                Py_DECREF(pyValue); 
     68                Py_DECREF(pyModule); 
     69 
     70                while (true) { 
     71                        for(int i = 0; i < 5; i++) { 
     72                                _physicalObject.x++; 
     73                                _physicalObject.y++; 
     74                                _physicalObject.resume(); 
     75                        } 
     76                        _physicalObject.sleep(60); 
     77                } 
     78 
     79                return 0; 
    3080        } 
    3181 
    3282 
    3383private: 
    34         PhysicalObject physicalObject_; 
     84        PhysicalObject _physicalObject; 
    3585} 
    36  
  • lang/d/pythond/python.d

    r232 r7202  
     1/* DSR:2005.10.26.16.28: 
     2 
     3XXX: 
     4 
     5- In a build process controlled by Python distutils, need to detect whether the 
     6  Python interpreter was built in debug build mode, and if so, make the 
     7  appropriate adjustments to the header mixins. 
     8 
     9*/ 
     10 
    111module python; 
     12 
    213import std.c.stdio; 
    3  
    4 extern (C) 
    5 { 
    6 /////////////////////////////////////////////////////////////////////////////////////////////// 
     14import std.c.time; 
     15import std.string; 
     16 
     17/* D long is always 64 bits, but when the Python/C API mentions long, it is of 
     18 * course referring to the C type long, the size of which is 32 bits on both 
     19 * X86 and X86_64 under Windows, but 32 bits on X86 and 64 bits on X86_64 under 
     20 * most other operating systems. */ 
     21 
     22alias long C_longlong; 
     23alias ulong C_ulonglong; 
     24 
     25version(Windows) { 
     26  alias int C_long; 
     27  alias uint C_ulong; 
     28} else { 
     29  version (X86) { 
     30    alias int C_long; 
     31    alias uint C_ulong; 
     32  } else { 
     33    alias long C_long; 
     34    alias ulong C_ulong; 
     35  } 
     36} 
     37 
     38 
     39extern (C) { 
     40/////////////////////////////////////////////////////////////////////////////// 
    741// PYTHON DATA STRUCTURES AND ALIASES 
    8 /////////////////////////////////////////////////////////////////////////////////////////////// 
    9  
    10         struct _object { 
    11                  int ob_refcnt; 
    12                  _typeobject *ob_type; 
    13         } 
    14         alias _object PyObject; 
    15  
    16         struct PyVarObject { 
    17                  int ob_refcnt;  
    18                  _typeobject *ob_type;  
    19                  int ob_size; 
    20         } 
    21  
    22         alias PyObject * (*unaryfunc)(PyObject *); 
    23         alias PyObject * (*binaryfunc)(PyObject *, PyObject *); 
    24         alias PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); 
    25         alias int (*inquiry)(PyObject *); 
    26         alias int (*coercion)(PyObject **, PyObject **); 
    27         alias PyObject *(*intargfunc)(PyObject *, int); 
    28         alias PyObject *(*intintargfunc)(PyObject *, int, int); 
    29         alias int(*intobjargproc)(PyObject *, int, PyObject *); 
    30         alias int(*intintobjargproc)(PyObject *, int, int, PyObject *); 
    31         alias int(*objobjargproc)(PyObject *, PyObject *, PyObject *); 
    32         alias int (*getreadbufferproc)(PyObject *, int, void **); 
    33         alias int (*getwritebufferproc)(PyObject *, int, void **); 
    34         alias int (*getsegcountproc)(PyObject *, int *); 
    35         alias int (*getcharbufferproc)(PyObject *, int, char **); 
    36         alias int (*objobjproc)(PyObject *, PyObject *); 
    37         alias int (*visitproc)(PyObject *, void *); 
    38         alias int (*traverseproc)(PyObject *, visitproc, void *); 
    39  
    40         struct PyMemberDef { 
    41                 char *name; 
    42                 int type; 
    43                 int offset; 
    44                 int flags; 
    45                 char *doc; 
    46         } 
    47  
    48         struct PyNumberMethods { 
    49                 binaryfunc nb_add; 
    50                 binaryfunc nb_subtract; 
    51                 binaryfunc nb_multiply; 
    52                 binaryfunc nb_divide; 
    53                 binaryfunc nb_remainder; 
    54                 binaryfunc nb_divmod; 
    55                 ternaryfunc nb_power; 
    56                 unaryfunc nb_negative; 
    57                 unaryfunc nb_positive; 
    58                 unaryfunc nb_absolute; 
    59                 inquiry nb_nonzero; 
    60                 unaryfunc nb_invert; 
    61                 binaryfunc nb_lshift; 
    62                 binaryfunc nb_rshift; 
    63                 binaryfunc nb_and; 
    64                 binaryfunc nb_xor; 
    65                 binaryfunc nb_or; 
    66                 coercion nb_coerce; 
    67                 unaryfunc nb_int; 
    68                 unaryfunc nb_long; 
    69                 unaryfunc nb_float; 
    70                 unaryfunc nb_oct; 
    71                 unaryfunc nb_hex; 
    72  
    73                 binaryfunc nb_inplace_add; 
    74                 binaryfunc nb_inplace_subtract; 
    75                 binaryfunc nb_inplace_multiply; 
    76                 binaryfunc nb_inplace_divide; 
    77                 binaryfunc nb_inplace_remainder; 
    78                 ternaryfunc nb_inplace_power; 
    79                 binaryfunc nb_inplace_lshift; 
    80                 binaryfunc nb_inplace_rshift; 
    81                 binaryfunc nb_inplace_and; 
    82                 binaryfunc nb_inplace_xor; 
    83                 binaryfunc nb_inplace_or; 
    84  
    85  
    86                 binaryfunc nb_floor_divide; 
    87                 binaryfunc nb_true_divide; 
    88                 binaryfunc nb_inplace_floor_divide; 
    89                 binaryfunc nb_inplace_true_divide; 
    90         }; 
    91  
    92         struct PySequenceMethods { 
    93                 inquiry sq_length; 
    94                 binaryfunc sq_concat; 
    95                 intargfunc sq_repeat; 
    96                 intargfunc sq_item; 
    97                 intintargfunc sq_slice; 
    98                 intobjargproc sq_ass_item; 
    99                 intintobjargproc sq_ass_slice; 
    100                 objobjproc sq_contains; 
    101                 binaryfunc sq_inplace_concat; 
    102                 intargfunc sq_inplace_repeat; 
    103         }; 
    104  
    105         struct PyMappingMethods { 
    106                 inquiry mp_length; 
    107                 binaryfunc mp_subscript; 
    108                 objobjargproc mp_ass_subscript; 
    109         }; 
    110  
    111         struct PyBufferProcs { 
    112                 getreadbufferproc bf_getreadbuffer; 
    113                 getwritebufferproc bf_getwritebuffer; 
    114                 getsegcountproc bf_getsegcount; 
    115                 getcharbufferproc bf_getcharbuffer; 
    116         }; 
    117  
    118  
    119         alias void (*freefunc)(void *); 
    120         alias void (*destructor)(PyObject *); 
    121         alias int (*printfunc)(PyObject *, FILE *, int); 
    122         alias PyObject *(*getattrfunc)(PyObject *, char *); 
    123         alias PyObject *(*getattrofunc)(PyObject *, PyObject *); 
    124         alias int (*setattrfunc)(PyObject *, char *, PyObject *); 
    125         alias int (*setattrofunc)(PyObject *, PyObject *, PyObject *); 
    126         alias int (*cmpfunc)(PyObject *, PyObject *); 
    127         alias PyObject *(*reprfunc)(PyObject *); 
    128         alias long (*hashfunc)(PyObject *); 
    129         alias PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); 
    130         alias PyObject *(*getiterfunc) (PyObject *); 
    131         alias PyObject *(*iternextfunc) (PyObject *); 
    132         alias PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); 
    133         alias int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); 
    134         alias int (*initproc)(PyObject *, PyObject *, PyObject *); 
    135         alias PyObject *(*newfunc)(_typeobject *, PyObject *, PyObject *); 
    136         alias PyObject *(*allocfunc)(_typeobject *, int); 
    137  
    138         struct _typeobject { 
    139                 int ob_refcnt;  
    140                 _typeobject *ob_type;  
    141                 int ob_size; 
    142                 char *tp_name; 
    143                 int tp_basicsize, tp_itemsize; 
    144  
    145                 destructor tp_dealloc; 
    146                 printfunc tp_print; 
    147                 getattrfunc tp_getattr; 
    148                 setattrfunc tp_setattr; 
    149                 cmpfunc tp_compare; 
    150                 reprfunc tp_repr; 
    151  
    152                 PyNumberMethods *tp_as_number; 
    153                 PySequenceMethods *tp_as_sequence; 
    154                 PyMappingMethods *tp_as_mapping; 
    155  
    156                 hashfunc tp_hash; 
    157                 ternaryfunc tp_call; 
    158                 reprfunc tp_str; 
    159                 getattrofunc tp_getattro; 
    160                 setattrofunc tp_setattro; 
    161  
    162                 PyBufferProcs *tp_as_buffer; 
    163  
    164                 long tp_flags; 
    165  
    166                 char *tp_doc; 
    167  
    168                 traverseproc tp_traverse; 
    169  
    170                 inquiry tp_clear; 
    171  
    172                 richcmpfunc tp_richcompare; 
    173  
    174                 long tp_weaklistoffset; 
    175  
    176                 getiterfunc tp_iter; 
    177                 iternextfunc tp_iternext; 
    178  
    179                 PyMethodDef *tp_methods; 
    180                 PyMemberDef *tp_members; 
    181                 PyGetSetDef *tp_getset; 
    182                 _typeobject *tp_base; 
    183                 PyObject *tp_dict; 
    184                 descrgetfunc tp_descr_get; 
    185                 descrsetfunc tp_descr_set; 
    186                 long tp_dictoffset; 
    187                 initproc tp_init; 
    188                 allocfunc tp_alloc; 
    189                 newfunc tp_new; 
    190                 freefunc tp_free; 
    191                 inquiry tp_is_gc; 
    192                 PyObject *tp_bases; 
    193                 PyObject *tp_mro; 
    194                 PyObject *tp_cache; 
    195                 PyObject *tp_subclasses; 
    196                 PyObject *tp_weaklist; 
    197                 destructor tp_del; 
    198         } 
    199  
    200         alias _typeobject PyTypeObject; 
    201  
    202         struct _heaptypeobject { 
    203                 PyTypeObject type; 
    204                 PyNumberMethods as_number; 
    205                 PyMappingMethods as_mapping; 
    206                 PySequenceMethods as_sequence; 
    207                 PyBufferProcs as_buffer; 
    208                 PyObject *name, slots; 
    209         } 
    210         alias _heaptypeobject PyHeapTypeObject; 
    211  
    212         void * PyMem_Malloc(size_t); 
    213         void * PyMem_Realloc(void *, size_t); 
    214         void PyMem_Free(void *); 
    215  
    216  
    217 /////////////////////////////////////////////////////////////////////////////////////////////// 
     42/////////////////////////////////////////////////////////////////////////////// 
     43  // Python-header-file: Include/Python.h: 
     44  const int Py_single_input = 256; 
     45  const int Py_file_input = 257; 
     46  const int Py_eval_input = 258; 
     47 
     48  // Python-header-file: Include/object.h: 
     49 
     50  // XXX:Conditionalize in if running debug build of Python interpreter: 
     51  /* 
     52  version (Python_Debug_Build) { 
     53    template _PyObject_HEAD_EXTRA() { 
     54      PyObject *_ob_next; 
     55      PyObject *_ob_prev; 
     56    } 
     57  } else { 
     58  */ 
     59    template _PyObject_HEAD_EXTRA() {} 
     60  /*}*/ 
     61 
     62  template PyObject_HEAD() { 
     63    mixin _PyObject_HEAD_EXTRA; 
     64    int ob_refcnt; 
     65    PyTypeObject *ob_type; 
     66  } 
     67 
     68  struct PyObject { 
     69    mixin PyObject_HEAD; 
     70  } 
     71 
     72  template PyObject_VAR_HEAD() { 
     73    mixin PyObject_HEAD; 
     74    int ob_size; /* Number of items in variable part */ 
     75  } 
     76 
     77  struct PyVarObject { 
     78    mixin PyObject_VAR_HEAD; 
     79  } 
     80 
     81  alias PyObject * (*unaryfunc)(PyObject *); 
     82  alias PyObject * (*binaryfunc)(PyObject *, PyObject *); 
     83  alias PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); 
     84  alias int (*inquiry)(PyObject *); 
     85  alias int (*coercion)(PyObject **, PyObject **); 
     86  alias PyObject *(*intargfunc)(PyObject *, int); 
     87  alias PyObject *(*intintargfunc)(PyObject *, int, int); 
     88  alias int(*intobjargproc)(PyObject *, int, PyObject *); 
     89  alias int(*intintobjargproc)(PyObject *, int, int, PyObject *); 
     90  alias int(*objobjargproc)(PyObject *, PyObject *, PyObject *); 
     91  alias int (*getreadbufferproc)(PyObject *, int, void **); 
     92  alias int (*getwritebufferproc)(PyObject *, int, void **); 
     93  alias int (*getsegcountproc)(PyObject *, int *); 
     94  alias int (*getcharbufferproc)(PyObject *, int, char **); 
     95  alias int (*objobjproc)(PyObject *, PyObject *); 
     96  alias int (*visitproc)(PyObject *, void *); 
     97  alias int (*traverseproc)(PyObject *, visitproc, void *); 
     98 
     99  // Python-header-file: Include/object.h: 
     100  struct PyNumberMethods { 
     101    binaryfunc nb_add; 
     102    binaryfunc nb_subtract; 
     103    binaryfunc nb_multiply; 
     104    binaryfunc nb_divide; 
     105    binaryfunc nb_remainder; 
     106    binaryfunc nb_divmod; 
     107    ternaryfunc nb_power; 
     108    unaryfunc nb_negative; 
     109    unaryfunc nb_positive; 
     110    unaryfunc nb_absolute; 
     111    inquiry nb_nonzero; 
     112    unaryfunc nb_invert; 
     113    binaryfunc nb_lshift; 
     114    binaryfunc nb_rshift; 
     115    binaryfunc nb_and; 
     116    binaryfunc nb_xor; 
     117    binaryfunc nb_or; 
     118    coercion nb_coerce; 
     119    unaryfunc nb_int; 
     120    unaryfunc nb_long; 
     121    unaryfunc nb_float; 
     122    unaryfunc nb_oct; 
     123    unaryfunc nb_hex; 
     124 
     125    binaryfunc nb_inplace_add; 
     126    binaryfunc nb_inplace_subtract; 
     127    binaryfunc nb_inplace_multiply; 
     128    binaryfunc nb_inplace_divide; 
     129    binaryfunc nb_inplace_remainder; 
     130    ternaryfunc nb_inplace_power; 
     131    binaryfunc nb_inplace_lshift; 
     132    binaryfunc nb_inplace_rshift; 
     133    binaryfunc nb_inplace_and; 
     134    binaryfunc nb_inplace_xor; 
     135    binaryfunc nb_inplace_or; 
     136 
     137 
     138    binaryfunc nb_floor_divide; 
     139    binaryfunc nb_true_divide; 
     140    binaryfunc nb_inplace_floor_divide; 
     141    binaryfunc nb_inplace_true_divide; 
     142  } 
     143 
     144  struct PySequenceMethods { 
     145    inquiry sq_length; 
     146    binaryfunc sq_concat; 
     147    intargfunc sq_repeat; 
     148    intargfunc sq_item; 
     149    intintargfunc sq_slice; 
     150    intobjargproc sq_ass_item; 
     151    intintobjargproc sq_ass_slice; 
     152    objobjproc sq_contains; 
     153    binaryfunc sq_inplace_concat; 
     154    intargfunc sq_inplace_repeat; 
     155  } 
     156 
     157  struct PyMappingMethods { 
     158    inquiry mp_length; 
     159    binaryfunc mp_subscript; 
     160    objobjargproc mp_ass_subscript; 
     161  } 
     162 
     163  struct PyBufferProcs { 
     164    getreadbufferproc bf_getreadbuffer; 
     165    getwritebufferproc bf_getwritebuffer; 
     166    getsegcountproc bf_getsegcount; 
     167    getcharbufferproc bf_getcharbuffer; 
     168  } 
     169 
     170 
     171  alias void (*freefunc)(void *); 
     172  alias void (*destructor)(PyObject *); 
     173  alias int (*printfunc)(PyObject *, FILE *, int); 
     174  alias PyObject *(*getattrfunc)(PyObject *, char *); 
     175  alias PyObject *(*getattrofunc)(PyObject *, PyObject *); 
     176  alias int (*setattrfunc)(PyObject *, char *, PyObject *); 
     177  alias int (*setattrofunc)(PyObject *, PyObject *, PyObject *); 
     178  alias int (*cmpfunc)(PyObject *, PyObject *); 
     179  alias PyObject *(*reprfunc)(PyObject *); 
     180  alias C_long (*hashfunc)(PyObject *); 
     181  alias PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); 
     182  alias PyObject *(*getiterfunc) (PyObject *); 
     183  alias PyObject *(*iternextfunc) (PyObject *); 
     184  alias PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); 
     185  alias int (*descrsetfunc) (PyObject *,