/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_annotator_pyx.pyx

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
cdef extern from "python-compat.h":
23
23
    pass
24
24
 
25
 
from cpython.dict cimport (
26
 
    PyDict_GetItem,
27
 
    PyDict_SetItem,
28
 
    )
29
 
from cpython.list cimport (
30
 
    PyList_Append,
31
 
    PyList_CheckExact,
32
 
    PyList_GET_ITEM,
33
 
    PyList_GET_SIZE,
34
 
    PyList_SetItem,
35
 
    PyList_Sort,
36
 
    )
37
 
from cpython.object cimport (
38
 
    Py_EQ,
39
 
    Py_LT,
40
 
    PyObject,
41
 
    PyObject_RichCompareBool,
42
 
    )
43
 
from cpython.ref cimport (
44
 
    Py_INCREF,
45
 
    )
46
 
from cpython.tuple cimport (
47
 
    PyTuple_CheckExact,
48
 
    PyTuple_GET_ITEM,
49
 
    PyTuple_GET_SIZE,
50
 
    PyTuple_New,
51
 
    PyTuple_SET_ITEM,
52
 
    )
53
 
 
54
25
cdef extern from "Python.h":
 
26
    ctypedef int Py_ssize_t
 
27
    ctypedef struct PyObject:
 
28
        pass
55
29
    ctypedef struct PyListObject:
56
30
        PyObject **ob_item
 
31
    int PyList_CheckExact(object)
 
32
    PyObject *PyList_GET_ITEM(object, Py_ssize_t o)
 
33
    Py_ssize_t PyList_GET_SIZE(object)
 
34
    int PyList_Append(object, object) except -1
 
35
    int PyList_SetItem(object, Py_ssize_t o, object) except -1
 
36
    int PyList_Sort(object) except -1
57
37
 
 
38
    int PyTuple_CheckExact(object)
 
39
    object PyTuple_New(Py_ssize_t len)
 
40
    void PyTuple_SET_ITEM(object, Py_ssize_t pos, object)
58
41
    void PyTuple_SET_ITEM_ptr "PyTuple_SET_ITEM" (object, Py_ssize_t,
59
42
                                                  PyObject *)
60
 
 
 
43
    int PyTuple_Resize(PyObject **, Py_ssize_t newlen)
 
44
    PyObject *PyTuple_GET_ITEM(object, Py_ssize_t o)
 
45
    Py_ssize_t PyTuple_GET_SIZE(object)
 
46
 
 
47
    PyObject *PyDict_GetItem(object d, object k)
 
48
    int PyDict_SetItem(object d, object k, object v) except -1
 
49
 
 
50
    void Py_INCREF(object)
61
51
    void Py_INCREF_ptr "Py_INCREF" (PyObject *)
62
52
    void Py_DECREF_ptr "Py_DECREF" (PyObject *)
63
53
 
 
54
    int Py_EQ
 
55
    int Py_LT
 
56
    int PyObject_RichCompareBool(object, object, int opid) except -1
64
57
    int PyObject_RichCompareBool_ptr "PyObject_RichCompareBool" (
65
58
        PyObject *, PyObject *, int opid)
66
59
 
98
91
 
99
92
    :param tpl: The tuple we are investigating, *must* be a PyTuple
100
93
    :param pos: The last item we found. Will be updated to the new position.
101
 
 
 
94
    
102
95
    This cannot raise an exception, as it does no error checking.
103
96
    """
104
97
    pos[0] = pos[0] + 1
111
104
    """Combine the annotations from both sides."""
112
105
    cdef Py_ssize_t pos_one, pos_two, len_one, len_two
113
106
    cdef Py_ssize_t out_pos
114
 
    cdef PyObject *temp
115
 
    cdef PyObject *left
116
 
    cdef PyObject *right
 
107
    cdef PyObject *temp, *left, *right
117
108
 
118
109
    if (PyObject_RichCompareBool(ann_one, ann_two, Py_LT)):
119
110
        cache_key = (ann_one, ann_two)
180
171
    matching_blocks defines the ranges that match.
181
172
    """
182
173
    cdef Py_ssize_t parent_idx, lines_idx, match_len, idx
183
 
    cdef PyListObject *par_list
184
 
    cdef PyListObject *ann_list
185
 
    cdef PyObject **par_temp
186
 
    cdef PyObject **ann_temp
 
174
    cdef PyListObject *par_list, *ann_list
 
175
    cdef PyObject **par_temp, **ann_temp
187
176
 
188
177
    _check_annotations_are_lists(annotations, parent_annotations)
189
178
    par_list = <PyListObject *>parent_annotations
208
197
                            matching_blocks, ann_cache) except -1:
209
198
    cdef Py_ssize_t parent_idx, ann_idx, lines_idx, match_len, idx
210
199
    cdef Py_ssize_t pos
211
 
    cdef PyObject *ann_temp
212
 
    cdef PyObject *par_temp
 
200
    cdef PyObject *ann_temp, *par_temp
213
201
 
214
202
    _check_annotations_are_lists(annotations, parent_annotations)
215
203
    last_ann = None