Mercurial > genshi > mirror
comparison genshi/_speedups.c @ 724:919809e55d16 experimental-match-fastpaths
update to trunk to track r847, fixing python 2.4 compatibility issues in speedup (and fixing copyrights, apparently :))
author | aflett |
---|---|
date | Mon, 21 Apr 2008 19:36:53 +0000 |
parents | d143dd73789b |
children | ea46fb523485 |
comparison
equal
deleted
inserted
replaced
718:d143dd73789b | 724:919809e55d16 |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006 Edgewall Software | 2 * Copyright (C) 2006-2008 Edgewall Software |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This software is licensed as described in the file COPYING, which | 5 * This software is licensed as described in the file COPYING, which |
6 * you should have received as part of this distribution. The terms | 6 * you should have received as part of this distribution. The terms |
7 * are also available at http://genshi.edgewall.org/wiki/License. | 7 * are also available at http://genshi.edgewall.org/wiki/License. |
11 * history and logs, available at http://genshi.edgewall.org/log/. | 11 * history and logs, available at http://genshi.edgewall.org/log/. |
12 */ | 12 */ |
13 | 13 |
14 #include <Python.h> | 14 #include <Python.h> |
15 #include <structmember.h> | 15 #include <structmember.h> |
16 | |
17 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) | |
18 typedef int Py_ssize_t; | |
19 #define PY_SSIZE_T_MAX INT_MAX | |
20 #define PY_SSIZE_T_MIN INT_MIN | |
21 #endif | |
16 | 22 |
17 static PyObject *amp1, *amp2, *lt1, *lt2, *gt1, *gt2, *qt1, *qt2; | 23 static PyObject *amp1, *amp2, *lt1, *lt2, *gt1, *gt2, *qt1, *qt2; |
18 static PyObject *stripentities, *striptags; | 24 static PyObject *stripentities, *striptags; |
19 | 25 |
20 static void | 26 static void |
291 if (PyDict_Check(args)) { | 297 if (PyDict_Check(args)) { |
292 kwds = args; | 298 kwds = args; |
293 } | 299 } |
294 if (kwds && PyDict_Size(kwds)) { | 300 if (kwds && PyDict_Size(kwds)) { |
295 PyObject *kwcopy, *key, *value; | 301 PyObject *kwcopy, *key, *value; |
302 #if PY_VERSION_HEX >= 0x02050000 | |
296 Py_ssize_t pos = 0; | 303 Py_ssize_t pos = 0; |
304 #else | |
305 int pos = 0; | |
306 #endif | |
297 | 307 |
298 kwcopy = PyDict_Copy( kwds ); | 308 kwcopy = PyDict_Copy( kwds ); |
299 if (kwcopy == NULL) { | 309 if (kwcopy == NULL) { |
300 return NULL; | 310 return NULL; |
301 } | 311 } |
534 0, | 544 0, |
535 "genshi._speedups.Markup", | 545 "genshi._speedups.Markup", |
536 sizeof(MarkupObject), | 546 sizeof(MarkupObject), |
537 0, | 547 0, |
538 0, /*tp_dealloc*/ | 548 0, /*tp_dealloc*/ |
539 0, /*tp_print*/ | 549 0, /*tp_print*/ |
540 0, /*tp_getattr*/ | 550 0, /*tp_getattr*/ |
541 0, /*tp_setattr*/ | 551 0, /*tp_setattr*/ |
542 0, /*tp_compare*/ | 552 0, /*tp_compare*/ |
543 Markup_repr, /*tp_repr*/ | 553 Markup_repr, /*tp_repr*/ |
544 &Markup_as_number, /*tp_as_number*/ | 554 &Markup_as_number, /*tp_as_number*/ |
552 0, /*tp_setattro*/ | 562 0, /*tp_setattro*/ |
553 0, /*tp_as_buffer*/ | 563 0, /*tp_as_buffer*/ |
554 | 564 |
555 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ | 565 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ |
556 Markup__doc__,/*tp_doc*/ | 566 Markup__doc__,/*tp_doc*/ |
557 | 567 |
558 0, /*tp_traverse*/ | 568 0, /*tp_traverse*/ |
559 0, /*tp_clear*/ | 569 0, /*tp_clear*/ |
560 | 570 |
561 0, /*tp_richcompare*/ | 571 0, /*tp_richcompare*/ |
562 0, /*tp_weaklistoffset*/ | 572 0, /*tp_weaklistoffset*/ |
569 Markup_methods,/*tp_methods*/ | 579 Markup_methods,/*tp_methods*/ |
570 0, /*tp_members*/ | 580 0, /*tp_members*/ |
571 0, /*tp_getset*/ | 581 0, /*tp_getset*/ |
572 0, /*tp_base*/ | 582 0, /*tp_base*/ |
573 0, /*tp_dict*/ | 583 0, /*tp_dict*/ |
574 | 584 |
575 0, /*tp_descr_get*/ | 585 0, /*tp_descr_get*/ |
576 0, /*tp_descr_set*/ | 586 0, /*tp_descr_set*/ |
577 0, /*tp_dictoffset*/ | 587 0, /*tp_dictoffset*/ |
578 | 588 |
579 0, /*tp_init*/ | 589 0, /*tp_init*/ |
580 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ | 590 0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/ |
581 0, /*tp_new*/ | 591 0, /*tp_new*/ |
582 0, /*tp_free Low-level free-memory routine */ | 592 0, /*tp_free Low-level free-memory routine */ |
583 0, /*tp_is_gc For PyObject_IS_GC */ | 593 0, /*tp_is_gc For PyObject_IS_GC */ |