Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Modules/puremodule.c

    r2 r388  
    6060
    6161
    62 
    6362static PyObject*
    6463call_voidarg_function(VoidArgFunc func, PyObject *self, PyObject *args)
    6564{
    66         int status;
    67 
    68         if (!PyArg_ParseTuple(args, ""))
    69                 return NULL;
    70 
    71         status = func();
    72         return Py_BuildValue("i", status);
     65    int status;
     66
     67    if (!PyArg_ParseTuple(args, ""))
     68        return NULL;
     69
     70    status = func();
     71    return Py_BuildValue("i", status);
    7372}
    7473
     
    7675call_stringarg_function(StringArgFunc func, PyObject *self, PyObject *args)
    7776{
    78         int status;
    79         char* stringarg;
    80 
    81         if (!PyArg_ParseTuple(args, "s", &stringarg))
    82                 return NULL;
    83 
    84         status = func(stringarg);
    85         return Py_BuildValue("i", status);
     77    int status;
     78    char* stringarg;
     79
     80    if (!PyArg_ParseTuple(args, "s", &stringarg))
     81        return NULL;
     82
     83    status = func(stringarg);
     84    return Py_BuildValue("i", status);
    8685}
    8786
     
    8988call_stringorint_function(StringArgFunc func, PyObject *self, PyObject *args)
    9089{
    91         int status;
    92         int intarg;
    93         char* stringarg;
    94 
    95         /* according to the quantify.h file, the argument to
    96          * quantify_*_recording_system_call can be an integer or a string,
    97          * but the functions are prototyped as taking a single char*
    98          * argument. Yikes!
     90    int status;
     91    int intarg;
     92    char* stringarg;
     93
     94    /* according to the quantify.h file, the argument to
     95     * quantify_*_recording_system_call can be an integer or a string,
     96     * but the functions are prototyped as taking a single char*
     97     * argument. Yikes!
     98     */
     99    if (PyArg_ParseTuple(args, "i", &intarg))
     100        /* func is prototyped as int(*)(char*)
     101         * better shut up the compiler
    99102         */
    100         if (PyArg_ParseTuple(args, "i", &intarg))
    101                 /* func is prototyped as int(*)(char*)
    102                  * better shut up the compiler
    103                  */
    104                 status = func((char*)intarg);
    105 
    106         else {
    107                 PyErr_Clear();
    108                 if (!PyArg_ParseTuple(args, "s", &stringarg))
    109                         return NULL;
    110                 else
    111                         status = func(stringarg);
    112         }
    113         return Py_BuildValue("i", status);
     103        status = func((char*)intarg);
     104
     105    else {
     106        PyErr_Clear();
     107        if (!PyArg_ParseTuple(args, "s", &stringarg))
     108            return NULL;
     109        else
     110            status = func(stringarg);
     111    }
     112    return Py_BuildValue("i", status);
    114113}
    115114
     
    117116call_printfish_function(PrintfishFunc func, PyObject *self, PyObject *args)
    118117{
    119         /* we support the printf() style vararg functions by requiring the
    120          * formatting be done in Python.  At the C level we pass just a string
    121          * to the printf() style function.
    122          */
    123         int status;
    124         char* argstring;
    125 
    126         if (!PyArg_ParseTuple(args, "s", &argstring))
    127                 return NULL;
    128 
    129         status = func("%s", argstring);
    130         return Py_BuildValue("i", status);
     118    /* we support the printf() style vararg functions by requiring the
     119     * formatting be done in Python.  At the C level we pass just a string
     120     * to the printf() style function.
     121     */
     122    int status;
     123    char* argstring;
     124
     125    if (!PyArg_ParseTuple(args, "s", &argstring))
     126        return NULL;
     127
     128    status = func("%s", argstring);
     129    return Py_BuildValue("i", status);
    131130}
    132131
     
    134133call_intasaddr_function(StringArgFunc func, PyObject *self, PyObject *args)
    135134{
    136         long memrep;
    137         int id;
    138 
    139         if (!PyArg_ParseTuple(args, "l", &memrep))
    140                 return NULL;
    141 
    142         id = func((char*)memrep);
    143         return Py_BuildValue("i", id);
     135    long memrep;
     136    int id;
     137
     138    if (!PyArg_ParseTuple(args, "l", &memrep))
     139        return NULL;
     140
     141    id = func((char*)memrep);
     142    return Py_BuildValue("i", id);
    144143}
    145144
    146145static PyObject*
    147146call_stringandint_function(StringIntArgFunc func, PyObject *self,
    148                            PyObject *args)
    149 {
    150         long srcrep;
    151         int size;
    152         int status;
    153 
    154         if (!PyArg_ParseTuple(args, "li", &srcrep, &size))
    155                 return NULL;
    156 
    157         status = func((char*)srcrep, size);
    158         return Py_BuildValue("i", status);
    159 }
    160 
     147                           PyObject *args)
     148{
     149    long srcrep;
     150    int size;
     151    int status;
     152
     153    if (!PyArg_ParseTuple(args, "li", &srcrep, &size))
     154        return NULL;
     155
     156    status = func((char*)srcrep, size);
     157    return Py_BuildValue("i", status);
     158}
    161159
    162160
     
    177175pure_pure_logfile_printf(PyObject* self, PyObject* args)
    178176{
    179         return call_printfish_function(pure_logfile_printf, self, args);
     177    return call_printfish_function(pure_logfile_printf, self, args);
    180178}
    181179
     
    183181pure_pure_printf(PyObject* self, PyObject* args)
    184182{
    185         return call_printfish_function(pure_printf, self, args);
     183    return call_printfish_function(pure_printf, self, args);
    186184}
    187185
     
    189187pure_pure_printf_with_banner(PyObject* self, PyObject* args)
    190188{
    191         return call_printfish_function(pure_printf_with_banner, self, args);
     189    return call_printfish_function(pure_printf_with_banner, self, args);
    192190}
    193191
    194192
    195193#endif /* COMMON_PURE_FUNCTIONS */
    196 
    197194
    198195
     
    239236pure_purify_all_inuse(PyObject *self, PyObject *args)
    240237{
    241         return call_voidarg_function(purify_all_inuse, self, args);
     238    return call_voidarg_function(purify_all_inuse, self, args);
    242239}
    243240static PyObject*
    244241pure_purify_all_leaks(PyObject *self, PyObject *args)
    245242{
    246         return call_voidarg_function(purify_all_leaks, self, args);
     243    return call_voidarg_function(purify_all_leaks, self, args);
    247244}
    248245static PyObject*
    249246pure_purify_new_inuse(PyObject *self, PyObject *args)
    250247{
    251         return call_voidarg_function(purify_new_inuse, self, args);
     248    return call_voidarg_function(purify_new_inuse, self, args);
    252249}
    253250static PyObject*
    254251pure_purify_new_leaks(PyObject *self, PyObject *args)
    255252{
    256         return call_voidarg_function(purify_new_leaks, self, args);
     253    return call_voidarg_function(purify_new_leaks, self, args);
    257254}
    258255static PyObject*
    259256pure_purify_clear_inuse(PyObject *self, PyObject *args)
    260257{
    261         return call_voidarg_function(purify_clear_inuse, self, args);
     258    return call_voidarg_function(purify_clear_inuse, self, args);
    262259}
    263260static PyObject*
    264261pure_purify_clear_leaks(PyObject *self, PyObject *args)
    265262{
    266         return call_voidarg_function(purify_clear_leaks, self, args);
     263    return call_voidarg_function(purify_clear_leaks, self, args);
    267264}
    268265static PyObject*
    269266pure_purify_all_fds_inuse(PyObject *self, PyObject *args)
    270267{
    271         return call_voidarg_function(purify_all_fds_inuse, self, args);
     268    return call_voidarg_function(purify_all_fds_inuse, self, args);
    272269}
    273270static PyObject*
    274271pure_purify_new_fds_inuse(PyObject *self, PyObject *args)
    275272{
    276         return call_voidarg_function(purify_new_fds_inuse, self, args);
     273    return call_voidarg_function(purify_new_fds_inuse, self, args);
    277274}
    278275static PyObject*
    279276pure_purify_printf_with_call_chain(PyObject *self, PyObject *args)
    280277{
    281         return call_printfish_function(purify_printf_with_call_chain,
    282                                        self, args);
     278    return call_printfish_function(purify_printf_with_call_chain,
     279                                   self, args);
    283280}
    284281static PyObject*
    285282pure_purify_set_pool_id(PyObject *self, PyObject *args)
    286283{
    287         long memrep;
    288         int id;
    289 
    290         if (!PyArg_ParseTuple(args, "li:purify_set_pool_id", &memrep, &id))
    291                 return NULL;
    292 
    293         purify_set_pool_id((char*)memrep, id);
    294         Py_INCREF(Py_None);
    295         return Py_None;
     284    long memrep;
     285    int id;
     286
     287    if (!PyArg_ParseTuple(args, "li:purify_set_pool_id", &memrep, &id))
     288        return NULL;
     289
     290    purify_set_pool_id((char*)memrep, id);
     291    Py_INCREF(Py_None);
     292    return Py_None;
    296293}
    297294static PyObject*
    298295pure_purify_get_pool_id(PyObject *self, PyObject *args)
    299296{
    300         return call_intasaddr_function(purify_get_pool_id, self, args);
     297    return call_intasaddr_function(purify_get_pool_id, self, args);
    301298}
    302299static PyObject*
    303300pure_purify_set_user_data(PyObject *self, PyObject *args)
    304301{
    305         long memrep;
    306         long datarep;
    307 
    308         if (!PyArg_ParseTuple(args, "ll:purify_set_user_data", &memrep, &datarep))
    309                 return NULL;
    310 
    311         purify_set_user_data((char*)memrep, (void*)datarep);
    312         Py_INCREF(Py_None);
    313         return Py_None;
     302    long memrep;
     303    long datarep;
     304
     305    if (!PyArg_ParseTuple(args, "ll:purify_set_user_data", &memrep, &datarep))
     306        return NULL;
     307
     308    purify_set_user_data((char*)memrep, (void*)datarep);
     309    Py_INCREF(Py_None);
     310    return Py_None;
    314311}
    315312static PyObject*
    316313pure_purify_get_user_data(PyObject *self, PyObject *args)
    317314{
    318         /* can't use call_intasaddr_function() since purify_get_user_data()
    319          * returns a void*
    320          */
    321         long memrep;
    322         void* data;
    323 
    324         if (!PyArg_ParseTuple(args, "l:purify_get_user_data", &memrep))
    325                 return NULL;
    326 
    327         data = purify_get_user_data((char*)memrep);
    328         return Py_BuildValue("l", (long)data);
    329 }
    330 
     315    /* can't use call_intasaddr_function() since purify_get_user_data()
     316     * returns a void*
     317     */
     318    long memrep;
     319    void* data;
     320
     321    if (!PyArg_ParseTuple(args, "l:purify_get_user_data", &memrep))
     322        return NULL;
     323
     324    data = purify_get_user_data((char*)memrep);
     325    return Py_BuildValue("l", (long)data);
     326}
    331327
    332328
     
    346342map_pool_callback(char* mem, int user_size, void *user_aux_data)
    347343{
    348         long memrep = (long)mem;
    349         long user_aux_data_rep = (long)user_aux_data;
    350         PyObject* result;
    351         PyObject* memobj = Py_BuildValue("lil", memrep, user_size,
    352                                         user_aux_data_rep);
    353 
    354         if (memobj == NULL)
    355                 return;
    356 
    357         result = PyEval_CallObject(MapCallable, memobj);
    358         Py_DECREF(result);
    359         Py_DECREF(memobj);
     344    long memrep = (long)mem;
     345    long user_aux_data_rep = (long)user_aux_data;
     346    PyObject* result;
     347    PyObject* memobj = Py_BuildValue("lil", memrep, user_size,
     348                                    user_aux_data_rep);
     349
     350    if (memobj == NULL)
     351        return;
     352
     353    result = PyEval_CallObject(MapCallable, memobj);
     354    Py_DECREF(result);
     355    Py_DECREF(memobj);
    360356}
    361357
     
    363359pure_purify_map_pool(PyObject *self, PyObject *args)
    364360{
    365         /* cache global variable in case of recursion */
    366         PyObject* saved_callable = MapCallable;
    367         PyObject* arg_callable;
    368         int id;
    369 
    370         if (!PyArg_ParseTuple(args, "iO:purify_map_pool", &id, &arg_callable))
    371                 return NULL;
    372 
    373         if (!PyCallable_Check(arg_callable)) {
    374                 PyErr_SetString(PyExc_TypeError,
    375                                 "Second argument must be callable");
    376                 return NULL;
    377         }
    378         MapCallable = arg_callable;
    379         purify_map_pool(id, map_pool_callback);
    380         MapCallable = saved_callable;
    381 
    382         Py_INCREF(Py_None);
    383         return Py_None;
     361    /* cache global variable in case of recursion */
     362    PyObject* saved_callable = MapCallable;
     363    PyObject* arg_callable;
     364    int id;
     365
     366    if (!PyArg_ParseTuple(args, "iO:purify_map_pool", &id, &arg_callable))
     367        return NULL;
     368
     369    if (!PyCallable_Check(arg_callable)) {
     370        PyErr_SetString(PyExc_TypeError,
     371                        "Second argument must be callable");
     372        return NULL;
     373    }
     374    MapCallable = arg_callable;
     375    purify_map_pool(id, map_pool_callback);
     376    MapCallable = saved_callable;
     377
     378    Py_INCREF(Py_None);
     379    return Py_None;
    384380}
    385381
     
    387383PurifyMapPoolIdCallback(int id)
    388384{
    389         PyObject* result;
    390         PyObject* intobj = Py_BuildValue("i", id);
    391 
    392         if (intobj == NULL)
    393                 return;
    394 
    395         result = PyEval_CallObject(MapCallable, intobj);
    396         Py_DECREF(result);
    397         Py_DECREF(intobj);
     385    PyObject* result;
     386    PyObject* intobj = Py_BuildValue("i", id);
     387
     388    if (intobj == NULL)
     389        return;
     390
     391    result = PyEval_CallObject(MapCallable, intobj);
     392    Py_DECREF(result);
     393    Py_DECREF(intobj);
    398394}
    399395
     
    401397pure_purify_map_pool_id(PyObject *self, PyObject *args)
    402398{
    403         /* cache global variable in case of recursion */
    404         PyObject* saved_callable = MapCallable;
    405         PyObject* arg_callable;
    406 
    407         if (!PyArg_ParseTuple(args, "O:purify_map_pool_id", &arg_callable))
    408                 return NULL;
    409 
    410         if (!PyCallable_Check(arg_callable)) {
    411                 PyErr_SetString(PyExc_TypeError, "Argument must be callable.");
    412                 return NULL;
    413         }
    414 
    415         MapCallable = arg_callable;
    416         purify_map_pool_id(PurifyMapPoolIdCallback);
    417         MapCallable = saved_callable;
    418 
    419         Py_INCREF(Py_None);
    420         return Py_None;
    421 }
    422 
     399    /* cache global variable in case of recursion */
     400    PyObject* saved_callable = MapCallable;
     401    PyObject* arg_callable;
     402
     403    if (!PyArg_ParseTuple(args, "O:purify_map_pool_id", &arg_callable))
     404        return NULL;
     405
     406    if (!PyCallable_Check(arg_callable)) {
     407        PyErr_SetString(PyExc_TypeError, "Argument must be callable.");
     408        return NULL;
     409    }
     410
     411    MapCallable = arg_callable;
     412    purify_map_pool_id(PurifyMapPoolIdCallback);
     413    MapCallable = saved_callable;
     414
     415    Py_INCREF(Py_None);
     416    return Py_None;
     417}
    423418
    424419
     
    427422pure_purify_new_messages(PyObject *self, PyObject *args)
    428423{
    429         return call_voidarg_function(purify_new_messages, self, args);
     424    return call_voidarg_function(purify_new_messages, self, args);
    430425}
    431426static PyObject*
    432427pure_purify_all_messages(PyObject *self, PyObject *args)
    433428{
    434         return call_voidarg_function(purify_all_messages, self, args);
     429    return call_voidarg_function(purify_all_messages, self, args);
    435430}
    436431static PyObject*
    437432pure_purify_clear_messages(PyObject *self, PyObject *args)
    438433{
    439         return call_voidarg_function(purify_clear_messages, self, args);
     434    return call_voidarg_function(purify_clear_messages, self, args);
    440435}
    441436static PyObject*
    442437pure_purify_clear_new_messages(PyObject *self, PyObject *args)
    443438{
    444         return call_voidarg_function(purify_clear_new_messages, self, args);
     439    return call_voidarg_function(purify_clear_new_messages, self, args);
    445440}
    446441static PyObject*
    447442pure_purify_start_batch(PyObject *self, PyObject *args)
    448443{
    449         return call_voidarg_function(purify_start_batch, self, args);
     444    return call_voidarg_function(purify_start_batch, self, args);
    450445}
    451446static PyObject*
    452447pure_purify_start_batch_show_first(PyObject *self, PyObject *args)
    453448{
    454         return call_voidarg_function(purify_start_batch_show_first,
    455                                      self, args);
     449    return call_voidarg_function(purify_start_batch_show_first,
     450                                 self, args);
    456451}
    457452static PyObject*
    458453pure_purify_stop_batch(PyObject *self, PyObject *args)
    459454{
    460         return call_voidarg_function(purify_stop_batch, self, args);
     455    return call_voidarg_function(purify_stop_batch, self, args);
    461456}
    462457static PyObject*
    463458pure_purify_name_thread(PyObject *self, PyObject *args)
    464459{
    465         /* can't strictly use call_stringarg_function since
    466          * purify_name_thread takes a const char*, not a char*
    467          */
    468         int status;
    469         char* stringarg;
    470 
    471         if (!PyArg_ParseTuple(args, "s:purify_name_thread", &stringarg))
    472                 return NULL;
    473 
    474         status = purify_name_thread(stringarg);
    475         return Py_BuildValue("i", status);
     460    /* can't strictly use call_stringarg_function since
     461     * purify_name_thread takes a const char*, not a char*
     462     */
     463    int status;
     464    char* stringarg;
     465
     466    if (!PyArg_ParseTuple(args, "s:purify_name_thread", &stringarg))
     467        return NULL;
     468
     469    status = purify_name_thread(stringarg);
     470    return Py_BuildValue("i", status);
    476471}
    477472static PyObject*
    478473pure_purify_watch(PyObject *self, PyObject *args)
    479474{
    480         return call_intasaddr_function(purify_watch, self, args);
     475    return call_intasaddr_function(purify_watch, self, args);
    481476}
    482477static PyObject*
    483478pure_purify_watch_1(PyObject *self, PyObject *args)
    484479{
    485         return call_intasaddr_function(purify_watch_1, self, args);
     480    return call_intasaddr_function(purify_watch_1, self, args);
    486481}
    487482static PyObject*
    488483pure_purify_watch_2(PyObject *self, PyObject *args)
    489484{
    490         return call_intasaddr_function(purify_watch_2, self, args);
     485    return call_intasaddr_function(purify_watch_2, self, args);
    491486}
    492487static PyObject*
    493488pure_purify_watch_4(PyObject *self, PyObject *args)
    494489{
    495         return call_intasaddr_function(purify_watch_4, self, args);
     490    return call_intasaddr_function(purify_watch_4, self, args);
    496491}
    497492static PyObject*
    498493pure_purify_watch_8(PyObject *self, PyObject *args)
    499494{
    500         return call_intasaddr_function(purify_watch_8, self, args);
     495    return call_intasaddr_function(purify_watch_8, self, args);
    501496}
    502497static PyObject*
    503498pure_purify_watch_w_1(PyObject *self, PyObject *args)
    504499{
    505         return call_intasaddr_function(purify_watch_w_1, self, args);
     500    return call_intasaddr_function(purify_watch_w_1, self, args);
    506501}
    507502static PyObject*
    508503pure_purify_watch_w_2(PyObject *self, PyObject *args)
    509504{
    510         return call_intasaddr_function(purify_watch_w_2, self, args);
     505    return call_intasaddr_function(purify_watch_w_2, self, args);
    511506}
    512507static PyObject*
    513508pure_purify_watch_w_4(PyObject *self, PyObject *args)
    514509{
    515         return call_intasaddr_function(purify_watch_w_4, self, args);
     510    return call_intasaddr_function(purify_watch_w_4, self, args);
    516511}
    517512static PyObject*
    518513pure_purify_watch_w_8(PyObject *self, PyObject *args)
    519514{
    520         return call_intasaddr_function(purify_watch_w_8, self, args);
     515    return call_intasaddr_function(purify_watch_w_8, self, args);
    521516}
    522517static PyObject*
    523518pure_purify_watch_r_1(PyObject *self, PyObject *args)
    524519{
    525         return call_intasaddr_function(purify_watch_r_1, self, args);
     520    return call_intasaddr_function(purify_watch_r_1, self, args);
    526521}
    527522static PyObject*
    528523pure_purify_watch_r_2(PyObject *self, PyObject *args)
    529524{
    530         return call_intasaddr_function(purify_watch_r_2, self, args);
     525    return call_intasaddr_function(purify_watch_r_2, self, args);
    531526}
    532527static PyObject*
    533528pure_purify_watch_r_4(PyObject *self, PyObject *args)
    534529{
    535         return call_intasaddr_function(purify_watch_r_4, self, args);
     530    return call_intasaddr_function(purify_watch_r_4, self, args);
    536531}
    537532static PyObject*
    538533pure_purify_watch_r_8(PyObject *self, PyObject *args)
    539534{
    540         return call_intasaddr_function(purify_watch_r_8, self, args);
     535    return call_intasaddr_function(purify_watch_r_8, self, args);
    541536}
    542537static PyObject*
    543538pure_purify_watch_rw_1(PyObject *self, PyObject *args)
    544539{
    545         return call_intasaddr_function(purify_watch_rw_1, self, args);
     540    return call_intasaddr_function(purify_watch_rw_1, self, args);
    546541}
    547542static PyObject*
    548543pure_purify_watch_rw_2(PyObject *self, PyObject *args)
    549544{
    550         return call_intasaddr_function(purify_watch_rw_2, self, args);
     545    return call_intasaddr_function(purify_watch_rw_2, self, args);
    551546}
    552547static PyObject*
    553548pure_purify_watch_rw_4(PyObject *self, PyObject *args)
    554549{
    555         return call_intasaddr_function(purify_watch_rw_4, self, args);
     550    return call_intasaddr_function(purify_watch_rw_4, self, args);
    556551}
    557552static PyObject*
    558553pure_purify_watch_rw_8(PyObject *self, PyObject *args)
    559554{
    560         return call_intasaddr_function(purify_watch_rw_8, self, args);
     555    return call_intasaddr_function(purify_watch_rw_8, self, args);
    561556}
    562557
     
    564559pure_purify_watch_n(PyObject *self, PyObject *args)
    565560{
    566         long addrrep;
    567         unsigned int size;
    568         char* type;
    569         int status;
    570 
    571         if (!PyArg_ParseTuple(args, "lis:purify_watch_n", &addrrep, &size, &type))
    572                 return NULL;
    573 
    574         status = purify_watch_n((char*)addrrep, size, type);
    575         return Py_BuildValue("i", status);
     561    long addrrep;
     562    unsigned int size;
     563    char* type;
     564    int status;
     565
     566    if (!PyArg_ParseTuple(args, "lis:purify_watch_n", &addrrep, &size, &type))
     567        return NULL;
     568
     569    status = purify_watch_n((char*)addrrep, size, type);
     570    return Py_BuildValue("i", status);
    576571}
    577572
     
    579574pure_purify_watch_info(PyObject *self, PyObject *args)
    580575{
    581         return call_voidarg_function(purify_watch_info, self, args);
     576    return call_voidarg_function(purify_watch_info, self, args);
    582577}
    583578
     
    585580pure_purify_watch_remove(PyObject *self, PyObject *args)
    586581{
    587         int watchno;
    588         int status;
    589 
    590         if (!PyArg_ParseTuple(args, "i:purify_watch_remove", &watchno))
    591                 return NULL;
    592 
    593         status = purify_watch_remove(watchno);
    594         return Py_BuildValue("i", status);
     582    int watchno;
     583    int status;
     584
     585    if (!PyArg_ParseTuple(args, "i:purify_watch_remove", &watchno))
     586        return NULL;
     587
     588    status = purify_watch_remove(watchno);
     589    return Py_BuildValue("i", status);
    595590}
    596591
     
    598593pure_purify_watch_remove_all(PyObject *self, PyObject *args)
    599594{
    600         return call_voidarg_function(purify_watch_remove_all, self, args);
     595    return call_voidarg_function(purify_watch_remove_all, self, args);
    601596}
    602597static PyObject*
    603598pure_purify_describe(PyObject *self, PyObject *args)
    604599{
    605         long addrrep;
    606         char* rtn;
    607 
    608         if (!PyArg_ParseTuple(args, "l:purify_describe", &addrrep))
    609                 return NULL;
    610 
    611         rtn = purify_describe((char*)addrrep);
    612         return Py_BuildValue("l", (long)rtn);
     600    long addrrep;
     601    char* rtn;
     602
     603    if (!PyArg_ParseTuple(args, "l:purify_describe", &addrrep))
     604        return NULL;
     605
     606    rtn = purify_describe((char*)addrrep);
     607    return Py_BuildValue("l", (long)rtn);
    613608}
    614609
     
    616611pure_purify_what_colors(PyObject *self, PyObject *args)
    617612{
    618         long addrrep;
    619         unsigned int size;
    620         int status;
    621    
    622         if (!PyArg_ParseTuple(args, "li:purify_what_colors", &addrrep, &size))
    623                 return NULL;
    624 
    625         status = purify_what_colors((char*)addrrep, size);
    626         return Py_BuildValue("i", status);
     613    long addrrep;
     614    unsigned int size;
     615    int status;
     616
     617    if (!PyArg_ParseTuple(args, "li:purify_what_colors", &addrrep, &size))
     618        return NULL;
     619
     620    status = purify_what_colors((char*)addrrep, size);
     621    return Py_BuildValue("i", status);
    627622}
    628623
     
    630625pure_purify_is_running(PyObject *self, PyObject *args)
    631626{
    632         return call_voidarg_function(purify_is_running, self, args);
     627    return call_voidarg_function(purify_is_running, self, args);
    633628}
    634629
     
    636631pure_purify_assert_is_readable(PyObject *self, PyObject *args)
    637632{
    638         return call_stringandint_function(purify_assert_is_readable,
    639                                           self, args);
     633    return call_stringandint_function(purify_assert_is_readable,
     634                                      self, args);
    640635}
    641636static PyObject*
    642637pure_purify_assert_is_writable(PyObject *self, PyObject *args)
    643638{
    644         return call_stringandint_function(purify_assert_is_writable,
    645                                           self, args);
     639    return call_stringandint_function(purify_assert_is_writable,
     640                                      self, args);
    646641}
    647642
     
    655650pure_purify_exit(PyObject *self, PyObject *args)
    656651{
    657         int status;
    658 
    659         if (!PyArg_ParseTuple(args, "i:purify_exit", &status))
    660                 return NULL;
    661 
    662         /* purify_exit doesn't always act like exit(). See the manual */
    663         purify_exit(status);
    664         Py_INCREF(Py_None);
    665         return Py_None;
     652    int status;
     653
     654    if (!PyArg_ParseTuple(args, "i:purify_exit", &status))
     655        return NULL;
     656
     657    /* purify_exit doesn't always act like exit(). See the manual */
     658    purify_exit(status);
     659    Py_INCREF(Py_None);
     660    return Py_None;
    666661}
    667662#endif /* HAS_PURIFY_EXIT */
    668663
    669664#endif /* PURIFY_H */
    670 
    671665
    672666
     
    687681pure_quantify_is_running(PyObject *self, PyObject *args)
    688682{
    689         return call_voidarg_function(quantify_is_running, self, args);
     683    return call_voidarg_function(quantify_is_running, self, args);
    690684}
    691685static PyObject*
    692686pure_quantify_help(PyObject *self, PyObject *args)
    693687{
    694         return call_voidarg_function(quantify_help, self, args);
     688    return call_voidarg_function(quantify_help, self, args);
    695689}
    696690static PyObject*
    697691pure_quantify_print_recording_state(PyObject *self, PyObject *args)
    698692{
    699         return call_voidarg_function(quantify_print_recording_state,
    700                                      self, args);
     693    return call_voidarg_function(quantify_print_recording_state,
     694                                 self, args);
    701695}
    702696static PyObject*
    703697pure_quantify_start_recording_data(PyObject *self, PyObject *args)
    704698{
    705         return call_voidarg_function(quantify_start_recording_data,
    706                                      self, args);
     699    return call_voidarg_function(quantify_start_recording_data,
     700                                 self, args);
    707701}
    708702static PyObject*
    709703pure_quantify_stop_recording_data(PyObject *self, PyObject *args)
    710704{
    711         return call_voidarg_function(quantify_stop_recording_data, self, args);
     705    return call_voidarg_function(quantify_stop_recording_data, self, args);
    712706}
    713707static PyObject*
    714708pure_quantify_is_recording_data(PyObject *self, PyObject *args)
    715709{
    716         return call_voidarg_function(quantify_is_recording_data, self, args);
     710    return call_voidarg_function(quantify_is_recording_data, self, args);
    717711}
    718712static PyObject*
    719713pure_quantify_start_recording_system_calls(PyObject *self, PyObject *args)
    720714{
    721         return call_voidarg_function(quantify_start_recording_system_calls,
    722                                      self, args);
     715    return call_voidarg_function(quantify_start_recording_system_calls,
     716                                 self, args);
    723717}
    724718static PyObject*
    725719pure_quantify_stop_recording_system_calls(PyObject *self, PyObject *args)
    726720{
    727         return call_voidarg_function(quantify_stop_recording_system_calls,
    728                                      self, args);
     721    return call_voidarg_function(quantify_stop_recording_system_calls,
     722                                 self, args);
    729723}
    730724static PyObject*
    731725pure_quantify_is_recording_system_calls(PyObject *self, PyObject *args)
    732726{
    733         return call_voidarg_function(quantify_is_recording_system_calls,
    734                                      self, args);
     727    return call_voidarg_function(quantify_is_recording_system_calls,
     728                                 self, args);
    735729}
    736730static PyObject*
    737731pure_quantify_start_recording_system_call(PyObject *self, PyObject *args)
    738732{
    739         return call_stringorint_function(quantify_start_recording_system_call,
    740                                            self, args);
     733    return call_stringorint_function(quantify_start_recording_system_call,
     734                                       self, args);
    741735}
    742736static PyObject*
    743737pure_quantify_stop_recording_system_call(PyObject *self, PyObject *args)
    744738{
    745         return call_stringorint_function(quantify_stop_recording_system_call,
    746                                         self, args);
     739    return call_stringorint_function(quantify_stop_recording_system_call,
     740                                    self, args);
    747741}
    748742static PyObject*
    749743pure_quantify_is_recording_system_call(PyObject *self, PyObject *args)
    750744{
    751         return call_stringorint_function(quantify_is_recording_system_call,
    752                                         self, args);
     745    return call_stringorint_function(quantify_is_recording_system_call,
     746                                    self, args);
    753747}
    754748static PyObject*
    755749pure_quantify_start_recording_dynamic_library_data(PyObject *self, PyObject *args)
    756750{
    757         return call_voidarg_function(
    758                 quantify_start_recording_dynamic_library_data,
    759                 self, args);
     751    return call_voidarg_function(
     752        quantify_start_recording_dynamic_library_data,
     753        self, args);
    760754}
    761755static PyObject*
    762756pure_quantify_stop_recording_dynamic_library_data(PyObject *self, PyObject *args)
    763757{
    764         return call_voidarg_function(
    765                 quantify_stop_recording_dynamic_library_data,
    766                 self, args);
     758    return call_voidarg_function(
     759        quantify_stop_recording_dynamic_library_data,
     760        self, args);
    767761}
    768762static PyObject*
    769763pure_quantify_is_recording_dynamic_library_data(PyObject *self, PyObject *args)
    770764{
    771         return call_voidarg_function(
    772                 quantify_is_recording_dynamic_library_data,
    773                 self, args);
     765    return call_voidarg_function(
     766        quantify_is_recording_dynamic_library_data,
     767        self, args);
    774768}
    775769static PyObject*
    776770pure_quantify_start_recording_register_window_traps(PyObject *self, PyObject *args)
    777771{
    778         return call_voidarg_function(
    779                 quantify_start_recording_register_window_traps,
    780                 self, args);
     772    return call_voidarg_function(
     773        quantify_start_recording_register_window_traps,
     774        self, args);
    781775}
    782776static PyObject*
    783777pure_quantify_stop_recording_register_window_traps(PyObject *self, PyObject *args)
    784778{
    785         return call_voidarg_function(
    786                 quantify_stop_recording_register_window_traps,
    787                 self, args);
     779    return call_voidarg_function(
     780        quantify_stop_recording_register_window_traps,
     781        self, args);
    788782}
    789783static PyObject*
    790784pure_quantify_is_recording_register_window_traps(PyObject *self, PyObject *args)
    791785{
    792         return call_voidarg_function(
    793                 quantify_is_recording_register_window_traps,
    794                 self, args);
     786    return call_voidarg_function(
     787        quantify_is_recording_register_window_traps,
     788        self, args);
    795789}
    796790static PyObject*
    797791pure_quantify_disable_recording_data(PyObject *self, PyObject *args)
    798792{
    799         return call_voidarg_function(quantify_disable_recording_data,
    800                                      self, args);
     793    return call_voidarg_function(quantify_disable_recording_data,
     794                                 self, args);
    801795}
    802796static PyObject*
    803797pure_quantify_clear_data(PyObject *self, PyObject *args)
    804798{
    805         return call_voidarg_function(quantify_clear_data, self, args);
     799    return call_voidarg_function(quantify_clear_data, self, args);
    806800}
    807801static PyObject*
    808802pure_quantify_save_data(PyObject *self, PyObject *args)
    809803{
    810         return call_voidarg_function(quantify_save_data, self, args);
     804    return call_voidarg_function(quantify_save_data, self, args);
    811805}
    812806static PyObject*
    813807pure_quantify_save_data_to_file(PyObject *self, PyObject *args)
    814808{
    815         return call_stringarg_function(quantify_save_data_to_file, self, args);
     809    return call_stringarg_function(quantify_save_data_to_file, self, args);
    816810}
    817811static PyObject*
    818812pure_quantify_add_annotation(PyObject *self, PyObject *args)
    819813{
    820         return call_stringarg_function(quantify_add_annotation, self, args);
     814    return call_stringarg_function(quantify_add_annotation, self, args);
    821815}
    822816
    823817#endif /* QUANTIFY_H */
    824 
    825818
    826819
     
    935928    {"quantify_add_annotation",    pure_quantify_add_annotation,    METH_VARARGS},
    936929#endif /* QUANTIFY_H */
    937     {NULL,  NULL}                            /* sentinel */
     930    {NULL,  NULL}                            /* sentinel */
    938931};
    939 
    940932
    941933
     
    943935static void
    944936ins(d, name, val)
    945         PyObject *d;
    946         char* name;
    947         long val;
    948 {
    949         PyObject *v = PyInt_FromLong(val);
    950         if (v) {
    951                 (void)PyDict_SetItemString(d, name, v);
    952                 Py_DECREF(v);
    953         }
     937    PyObject *d;
     938    char* name;
     939    long val;
     940{
     941    PyObject *v = PyInt_FromLong(val);
     942    if (v) {
     943        (void)PyDict_SetItemString(d, name, v);
     944        Py_DECREF(v);
     945    }
    954946}
    955947
     
    958950initpure()
    959951{
    960         PyObject *m, *d;
    961 
    962         if (PyErr_WarnPy3k("the pure module has been removed in "
    963                            "Python 3.0", 2) < 0)
    964             return;     
    965 
    966         m = Py_InitModule("pure", pure_methods);
    967         if (m == NULL)
    968                 return;
    969         d = PyModule_GetDict(m);
    970 
    971         /* this is bogus because we should be able to find this information
    972          * out from the header files.  Pure's current versions don't
    973          * include this information!
    974          */
     952    PyObject *m, *d;
     953
     954    if (PyErr_WarnPy3k("the pure module has been removed in "
     955                       "Python 3.0", 2) < 0)
     956        return;
     957
     958    m = Py_InitModule("pure", pure_methods);
     959    if (m == NULL)
     960        return;
     961    d = PyModule_GetDict(m);
     962
     963    /* this is bogus because we should be able to find this information
     964     * out from the header files.  Pure's current versions don't
     965     * include this information!
     966     */
    975967#ifdef PURE_PURIFY_VERSION
    976         ins(d, "PURIFY_VERSION", PURE_PURIFY_VERSION);
     968    ins(d, "PURIFY_VERSION", PURE_PURIFY_VERSION);
    977969#else
    978         PyDict_SetItemString(d, "PURIFY_VERSION", Py_None);
     970    PyDict_SetItemString(d, "PURIFY_VERSION", Py_None);
    979971#endif
    980972
    981         /* these aren't terribly useful because purify_exit() isn't
    982          * exported correctly.  See the note at the top of the file.
    983          */
     973    /* these aren't terribly useful because purify_exit() isn't
     974     * exported correctly.  See the note at the top of the file.
     975     */
    984976#ifdef PURIFY_EXIT_ERRORS
    985         ins(d, "PURIFY_EXIT_ERRORS", PURIFY_EXIT_ERRORS);
     977    ins(d, "PURIFY_EXIT_ERRORS", PURIFY_EXIT_ERRORS);
    986978#endif
    987979#ifdef PURIFY_EXIT_LEAKS
    988         ins(d, "PURIFY_EXIT_LEAKS",  PURIFY_EXIT_LEAKS);
     980    ins(d, "PURIFY_EXIT_LEAKS",  PURIFY_EXIT_LEAKS);
    989981#endif
    990982#ifdef PURIFY_EXIT_PLEAKS
    991         ins(d, "PURIFY_EXIT_PLEAKS", PURIFY_EXIT_PLEAKS);
     983    ins(d, "PURIFY_EXIT_PLEAKS", PURIFY_EXIT_PLEAKS);
    992984#endif
    993985
    994986
    995987#ifdef PURE_QUANTIFY_VERSION
    996         ins(d, "QUANTIFY_VERSION", PURE_QUANTIFY_VERSION);
     988    ins(d, "QUANTIFY_VERSION", PURE_QUANTIFY_VERSION);
    997989#else
    998         PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None);
     990    PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None);
    999991#endif
    1000992}
Note: See TracChangeset for help on using the changeset viewer.