Changeset 388 for python/vendor/current/Modules/puremodule.c
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Modules/puremodule.c
r2 r388 60 60 61 61 62 63 62 static PyObject* 64 63 call_voidarg_function(VoidArgFunc func, PyObject *self, PyObject *args) 65 64 { 66 67 68 69 70 71 72 65 int status; 66 67 if (!PyArg_ParseTuple(args, "")) 68 return NULL; 69 70 status = func(); 71 return Py_BuildValue("i", status); 73 72 } 74 73 … … 76 75 call_stringarg_function(StringArgFunc func, PyObject *self, PyObject *args) 77 76 { 78 79 80 81 82 83 84 85 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); 86 85 } 87 86 … … 89 88 call_stringorint_function(StringArgFunc func, PyObject *self, PyObject *args) 90 89 { 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 99 102 */ 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); 114 113 } 115 114 … … 117 116 call_printfish_function(PrintfishFunc func, PyObject *self, PyObject *args) 118 117 { 119 120 121 122 123 124 125 126 127 128 129 130 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); 131 130 } 132 131 … … 134 133 call_intasaddr_function(StringArgFunc func, PyObject *self, PyObject *args) 135 134 { 136 137 138 139 140 141 142 143 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); 144 143 } 145 144 146 145 static PyObject* 147 146 call_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 } 161 159 162 160 … … 177 175 pure_pure_logfile_printf(PyObject* self, PyObject* args) 178 176 { 179 177 return call_printfish_function(pure_logfile_printf, self, args); 180 178 } 181 179 … … 183 181 pure_pure_printf(PyObject* self, PyObject* args) 184 182 { 185 183 return call_printfish_function(pure_printf, self, args); 186 184 } 187 185 … … 189 187 pure_pure_printf_with_banner(PyObject* self, PyObject* args) 190 188 { 191 189 return call_printfish_function(pure_printf_with_banner, self, args); 192 190 } 193 191 194 192 195 193 #endif /* COMMON_PURE_FUNCTIONS */ 196 197 194 198 195 … … 239 236 pure_purify_all_inuse(PyObject *self, PyObject *args) 240 237 { 241 238 return call_voidarg_function(purify_all_inuse, self, args); 242 239 } 243 240 static PyObject* 244 241 pure_purify_all_leaks(PyObject *self, PyObject *args) 245 242 { 246 243 return call_voidarg_function(purify_all_leaks, self, args); 247 244 } 248 245 static PyObject* 249 246 pure_purify_new_inuse(PyObject *self, PyObject *args) 250 247 { 251 248 return call_voidarg_function(purify_new_inuse, self, args); 252 249 } 253 250 static PyObject* 254 251 pure_purify_new_leaks(PyObject *self, PyObject *args) 255 252 { 256 253 return call_voidarg_function(purify_new_leaks, self, args); 257 254 } 258 255 static PyObject* 259 256 pure_purify_clear_inuse(PyObject *self, PyObject *args) 260 257 { 261 258 return call_voidarg_function(purify_clear_inuse, self, args); 262 259 } 263 260 static PyObject* 264 261 pure_purify_clear_leaks(PyObject *self, PyObject *args) 265 262 { 266 263 return call_voidarg_function(purify_clear_leaks, self, args); 267 264 } 268 265 static PyObject* 269 266 pure_purify_all_fds_inuse(PyObject *self, PyObject *args) 270 267 { 271 268 return call_voidarg_function(purify_all_fds_inuse, self, args); 272 269 } 273 270 static PyObject* 274 271 pure_purify_new_fds_inuse(PyObject *self, PyObject *args) 275 272 { 276 273 return call_voidarg_function(purify_new_fds_inuse, self, args); 277 274 } 278 275 static PyObject* 279 276 pure_purify_printf_with_call_chain(PyObject *self, PyObject *args) 280 277 { 281 282 278 return call_printfish_function(purify_printf_with_call_chain, 279 self, args); 283 280 } 284 281 static PyObject* 285 282 pure_purify_set_pool_id(PyObject *self, PyObject *args) 286 283 { 287 288 289 290 291 292 293 294 295 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; 296 293 } 297 294 static PyObject* 298 295 pure_purify_get_pool_id(PyObject *self, PyObject *args) 299 296 { 300 297 return call_intasaddr_function(purify_get_pool_id, self, args); 301 298 } 302 299 static PyObject* 303 300 pure_purify_set_user_data(PyObject *self, PyObject *args) 304 301 { 305 306 307 308 309 310 311 312 313 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; 314 311 } 315 312 static PyObject* 316 313 pure_purify_get_user_data(PyObject *self, PyObject *args) 317 314 { 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 } 331 327 332 328 … … 346 342 map_pool_callback(char* mem, int user_size, void *user_aux_data) 347 343 { 348 349 350 351 352 353 354 355 356 357 358 359 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); 360 356 } 361 357 … … 363 359 pure_purify_map_pool(PyObject *self, PyObject *args) 364 360 { 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 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; 384 380 } 385 381 … … 387 383 PurifyMapPoolIdCallback(int id) 388 384 { 389 390 391 392 393 394 395 396 397 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); 398 394 } 399 395 … … 401 397 pure_purify_map_pool_id(PyObject *self, PyObject *args) 402 398 { 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 } 423 418 424 419 … … 427 422 pure_purify_new_messages(PyObject *self, PyObject *args) 428 423 { 429 424 return call_voidarg_function(purify_new_messages, self, args); 430 425 } 431 426 static PyObject* 432 427 pure_purify_all_messages(PyObject *self, PyObject *args) 433 428 { 434 429 return call_voidarg_function(purify_all_messages, self, args); 435 430 } 436 431 static PyObject* 437 432 pure_purify_clear_messages(PyObject *self, PyObject *args) 438 433 { 439 434 return call_voidarg_function(purify_clear_messages, self, args); 440 435 } 441 436 static PyObject* 442 437 pure_purify_clear_new_messages(PyObject *self, PyObject *args) 443 438 { 444 439 return call_voidarg_function(purify_clear_new_messages, self, args); 445 440 } 446 441 static PyObject* 447 442 pure_purify_start_batch(PyObject *self, PyObject *args) 448 443 { 449 444 return call_voidarg_function(purify_start_batch, self, args); 450 445 } 451 446 static PyObject* 452 447 pure_purify_start_batch_show_first(PyObject *self, PyObject *args) 453 448 { 454 455 449 return call_voidarg_function(purify_start_batch_show_first, 450 self, args); 456 451 } 457 452 static PyObject* 458 453 pure_purify_stop_batch(PyObject *self, PyObject *args) 459 454 { 460 455 return call_voidarg_function(purify_stop_batch, self, args); 461 456 } 462 457 static PyObject* 463 458 pure_purify_name_thread(PyObject *self, PyObject *args) 464 459 { 465 466 467 468 469 470 471 472 473 474 475 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); 476 471 } 477 472 static PyObject* 478 473 pure_purify_watch(PyObject *self, PyObject *args) 479 474 { 480 475 return call_intasaddr_function(purify_watch, self, args); 481 476 } 482 477 static PyObject* 483 478 pure_purify_watch_1(PyObject *self, PyObject *args) 484 479 { 485 480 return call_intasaddr_function(purify_watch_1, self, args); 486 481 } 487 482 static PyObject* 488 483 pure_purify_watch_2(PyObject *self, PyObject *args) 489 484 { 490 485 return call_intasaddr_function(purify_watch_2, self, args); 491 486 } 492 487 static PyObject* 493 488 pure_purify_watch_4(PyObject *self, PyObject *args) 494 489 { 495 490 return call_intasaddr_function(purify_watch_4, self, args); 496 491 } 497 492 static PyObject* 498 493 pure_purify_watch_8(PyObject *self, PyObject *args) 499 494 { 500 495 return call_intasaddr_function(purify_watch_8, self, args); 501 496 } 502 497 static PyObject* 503 498 pure_purify_watch_w_1(PyObject *self, PyObject *args) 504 499 { 505 500 return call_intasaddr_function(purify_watch_w_1, self, args); 506 501 } 507 502 static PyObject* 508 503 pure_purify_watch_w_2(PyObject *self, PyObject *args) 509 504 { 510 505 return call_intasaddr_function(purify_watch_w_2, self, args); 511 506 } 512 507 static PyObject* 513 508 pure_purify_watch_w_4(PyObject *self, PyObject *args) 514 509 { 515 510 return call_intasaddr_function(purify_watch_w_4, self, args); 516 511 } 517 512 static PyObject* 518 513 pure_purify_watch_w_8(PyObject *self, PyObject *args) 519 514 { 520 515 return call_intasaddr_function(purify_watch_w_8, self, args); 521 516 } 522 517 static PyObject* 523 518 pure_purify_watch_r_1(PyObject *self, PyObject *args) 524 519 { 525 520 return call_intasaddr_function(purify_watch_r_1, self, args); 526 521 } 527 522 static PyObject* 528 523 pure_purify_watch_r_2(PyObject *self, PyObject *args) 529 524 { 530 525 return call_intasaddr_function(purify_watch_r_2, self, args); 531 526 } 532 527 static PyObject* 533 528 pure_purify_watch_r_4(PyObject *self, PyObject *args) 534 529 { 535 530 return call_intasaddr_function(purify_watch_r_4, self, args); 536 531 } 537 532 static PyObject* 538 533 pure_purify_watch_r_8(PyObject *self, PyObject *args) 539 534 { 540 535 return call_intasaddr_function(purify_watch_r_8, self, args); 541 536 } 542 537 static PyObject* 543 538 pure_purify_watch_rw_1(PyObject *self, PyObject *args) 544 539 { 545 540 return call_intasaddr_function(purify_watch_rw_1, self, args); 546 541 } 547 542 static PyObject* 548 543 pure_purify_watch_rw_2(PyObject *self, PyObject *args) 549 544 { 550 545 return call_intasaddr_function(purify_watch_rw_2, self, args); 551 546 } 552 547 static PyObject* 553 548 pure_purify_watch_rw_4(PyObject *self, PyObject *args) 554 549 { 555 550 return call_intasaddr_function(purify_watch_rw_4, self, args); 556 551 } 557 552 static PyObject* 558 553 pure_purify_watch_rw_8(PyObject *self, PyObject *args) 559 554 { 560 555 return call_intasaddr_function(purify_watch_rw_8, self, args); 561 556 } 562 557 … … 564 559 pure_purify_watch_n(PyObject *self, PyObject *args) 565 560 { 566 567 568 569 570 571 572 573 574 575 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); 576 571 } 577 572 … … 579 574 pure_purify_watch_info(PyObject *self, PyObject *args) 580 575 { 581 576 return call_voidarg_function(purify_watch_info, self, args); 582 577 } 583 578 … … 585 580 pure_purify_watch_remove(PyObject *self, PyObject *args) 586 581 { 587 588 589 590 591 592 593 594 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); 595 590 } 596 591 … … 598 593 pure_purify_watch_remove_all(PyObject *self, PyObject *args) 599 594 { 600 595 return call_voidarg_function(purify_watch_remove_all, self, args); 601 596 } 602 597 static PyObject* 603 598 pure_purify_describe(PyObject *self, PyObject *args) 604 599 { 605 606 607 608 609 610 611 612 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); 613 608 } 614 609 … … 616 611 pure_purify_what_colors(PyObject *self, PyObject *args) 617 612 { 618 619 620 621 622 623 624 625 626 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); 627 622 } 628 623 … … 630 625 pure_purify_is_running(PyObject *self, PyObject *args) 631 626 { 632 627 return call_voidarg_function(purify_is_running, self, args); 633 628 } 634 629 … … 636 631 pure_purify_assert_is_readable(PyObject *self, PyObject *args) 637 632 { 638 639 633 return call_stringandint_function(purify_assert_is_readable, 634 self, args); 640 635 } 641 636 static PyObject* 642 637 pure_purify_assert_is_writable(PyObject *self, PyObject *args) 643 638 { 644 645 639 return call_stringandint_function(purify_assert_is_writable, 640 self, args); 646 641 } 647 642 … … 655 650 pure_purify_exit(PyObject *self, PyObject *args) 656 651 { 657 658 659 660 661 662 663 664 665 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; 666 661 } 667 662 #endif /* HAS_PURIFY_EXIT */ 668 663 669 664 #endif /* PURIFY_H */ 670 671 665 672 666 … … 687 681 pure_quantify_is_running(PyObject *self, PyObject *args) 688 682 { 689 683 return call_voidarg_function(quantify_is_running, self, args); 690 684 } 691 685 static PyObject* 692 686 pure_quantify_help(PyObject *self, PyObject *args) 693 687 { 694 688 return call_voidarg_function(quantify_help, self, args); 695 689 } 696 690 static PyObject* 697 691 pure_quantify_print_recording_state(PyObject *self, PyObject *args) 698 692 { 699 700 693 return call_voidarg_function(quantify_print_recording_state, 694 self, args); 701 695 } 702 696 static PyObject* 703 697 pure_quantify_start_recording_data(PyObject *self, PyObject *args) 704 698 { 705 706 699 return call_voidarg_function(quantify_start_recording_data, 700 self, args); 707 701 } 708 702 static PyObject* 709 703 pure_quantify_stop_recording_data(PyObject *self, PyObject *args) 710 704 { 711 705 return call_voidarg_function(quantify_stop_recording_data, self, args); 712 706 } 713 707 static PyObject* 714 708 pure_quantify_is_recording_data(PyObject *self, PyObject *args) 715 709 { 716 710 return call_voidarg_function(quantify_is_recording_data, self, args); 717 711 } 718 712 static PyObject* 719 713 pure_quantify_start_recording_system_calls(PyObject *self, PyObject *args) 720 714 { 721 722 715 return call_voidarg_function(quantify_start_recording_system_calls, 716 self, args); 723 717 } 724 718 static PyObject* 725 719 pure_quantify_stop_recording_system_calls(PyObject *self, PyObject *args) 726 720 { 727 728 721 return call_voidarg_function(quantify_stop_recording_system_calls, 722 self, args); 729 723 } 730 724 static PyObject* 731 725 pure_quantify_is_recording_system_calls(PyObject *self, PyObject *args) 732 726 { 733 734 727 return call_voidarg_function(quantify_is_recording_system_calls, 728 self, args); 735 729 } 736 730 static PyObject* 737 731 pure_quantify_start_recording_system_call(PyObject *self, PyObject *args) 738 732 { 739 740 733 return call_stringorint_function(quantify_start_recording_system_call, 734 self, args); 741 735 } 742 736 static PyObject* 743 737 pure_quantify_stop_recording_system_call(PyObject *self, PyObject *args) 744 738 { 745 746 739 return call_stringorint_function(quantify_stop_recording_system_call, 740 self, args); 747 741 } 748 742 static PyObject* 749 743 pure_quantify_is_recording_system_call(PyObject *self, PyObject *args) 750 744 { 751 752 745 return call_stringorint_function(quantify_is_recording_system_call, 746 self, args); 753 747 } 754 748 static PyObject* 755 749 pure_quantify_start_recording_dynamic_library_data(PyObject *self, PyObject *args) 756 750 { 757 758 759 751 return call_voidarg_function( 752 quantify_start_recording_dynamic_library_data, 753 self, args); 760 754 } 761 755 static PyObject* 762 756 pure_quantify_stop_recording_dynamic_library_data(PyObject *self, PyObject *args) 763 757 { 764 765 766 758 return call_voidarg_function( 759 quantify_stop_recording_dynamic_library_data, 760 self, args); 767 761 } 768 762 static PyObject* 769 763 pure_quantify_is_recording_dynamic_library_data(PyObject *self, PyObject *args) 770 764 { 771 772 773 765 return call_voidarg_function( 766 quantify_is_recording_dynamic_library_data, 767 self, args); 774 768 } 775 769 static PyObject* 776 770 pure_quantify_start_recording_register_window_traps(PyObject *self, PyObject *args) 777 771 { 778 779 780 772 return call_voidarg_function( 773 quantify_start_recording_register_window_traps, 774 self, args); 781 775 } 782 776 static PyObject* 783 777 pure_quantify_stop_recording_register_window_traps(PyObject *self, PyObject *args) 784 778 { 785 786 787 779 return call_voidarg_function( 780 quantify_stop_recording_register_window_traps, 781 self, args); 788 782 } 789 783 static PyObject* 790 784 pure_quantify_is_recording_register_window_traps(PyObject *self, PyObject *args) 791 785 { 792 793 794 786 return call_voidarg_function( 787 quantify_is_recording_register_window_traps, 788 self, args); 795 789 } 796 790 static PyObject* 797 791 pure_quantify_disable_recording_data(PyObject *self, PyObject *args) 798 792 { 799 800 793 return call_voidarg_function(quantify_disable_recording_data, 794 self, args); 801 795 } 802 796 static PyObject* 803 797 pure_quantify_clear_data(PyObject *self, PyObject *args) 804 798 { 805 799 return call_voidarg_function(quantify_clear_data, self, args); 806 800 } 807 801 static PyObject* 808 802 pure_quantify_save_data(PyObject *self, PyObject *args) 809 803 { 810 804 return call_voidarg_function(quantify_save_data, self, args); 811 805 } 812 806 static PyObject* 813 807 pure_quantify_save_data_to_file(PyObject *self, PyObject *args) 814 808 { 815 809 return call_stringarg_function(quantify_save_data_to_file, self, args); 816 810 } 817 811 static PyObject* 818 812 pure_quantify_add_annotation(PyObject *self, PyObject *args) 819 813 { 820 814 return call_stringarg_function(quantify_add_annotation, self, args); 821 815 } 822 816 823 817 #endif /* QUANTIFY_H */ 824 825 818 826 819 … … 935 928 {"quantify_add_annotation", pure_quantify_add_annotation, METH_VARARGS}, 936 929 #endif /* QUANTIFY_H */ 937 {NULL, NULL} 930 {NULL, NULL} /* sentinel */ 938 931 }; 939 940 932 941 933 … … 943 935 static void 944 936 ins(d, name, val) 945 946 947 948 { 949 950 951 952 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 } 954 946 } 955 947 … … 958 950 initpure() 959 951 { 960 961 962 963 964 return; 965 966 967 968 969 970 971 972 973 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 */ 975 967 #ifdef PURE_PURIFY_VERSION 976 968 ins(d, "PURIFY_VERSION", PURE_PURIFY_VERSION); 977 969 #else 978 970 PyDict_SetItemString(d, "PURIFY_VERSION", Py_None); 979 971 #endif 980 972 981 982 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 */ 984 976 #ifdef PURIFY_EXIT_ERRORS 985 977 ins(d, "PURIFY_EXIT_ERRORS", PURIFY_EXIT_ERRORS); 986 978 #endif 987 979 #ifdef PURIFY_EXIT_LEAKS 988 980 ins(d, "PURIFY_EXIT_LEAKS", PURIFY_EXIT_LEAKS); 989 981 #endif 990 982 #ifdef PURIFY_EXIT_PLEAKS 991 983 ins(d, "PURIFY_EXIT_PLEAKS", PURIFY_EXIT_PLEAKS); 992 984 #endif 993 985 994 986 995 987 #ifdef PURE_QUANTIFY_VERSION 996 988 ins(d, "QUANTIFY_VERSION", PURE_QUANTIFY_VERSION); 997 989 #else 998 990 PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None); 999 991 #endif 1000 992 }
Note:
See TracChangeset
for help on using the changeset viewer.