/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-07-02 20:37:44 UTC
  • mfrom: (7025 work)
  • mto: This revision was merged to the branch mainline in revision 7027.
  • Revision ID: jelmer@jelmer.uk-20180702203744-3i0bimk0r5pfzjzl
merge trunk

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