/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 bzrlib/_simple_set_pyx.pyx

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-14 07:53:41 UTC
  • mfrom: (4739.3.1 fix-diff-docstring)
  • Revision ID: pqm@pqm.ubuntu.com-20091014075341-xjtgl5ji20autac6
(jml) Bring docstring of bzrlib.diff.get_trees_and_branches_to_diff
        up to date with recent changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
 
22
22
cdef extern from "Python.h":
23
23
    ctypedef unsigned long size_t
24
 
    ctypedef long (*hashfunc)(PyObject*) except -1
25
 
    ctypedef object (*richcmpfunc)(PyObject *, PyObject *, int)
 
24
    ctypedef long (*hashfunc)(PyObject*)
 
25
    ctypedef PyObject *(*richcmpfunc)(PyObject *, PyObject *, int)
26
26
    ctypedef int (*visitproc)(PyObject *, void *)
27
27
    ctypedef int (*traverseproc)(PyObject *, visitproc, void *)
28
28
    int Py_EQ
 
29
    PyObject *Py_True
 
30
    PyObject *Py_NotImplemented
29
31
    void Py_INCREF(PyObject *)
30
32
    void Py_DECREF(PyObject *)
31
33
    ctypedef struct PyTypeObject:
34
36
        traverseproc tp_traverse
35
37
 
36
38
    PyTypeObject *Py_TYPE(PyObject *)
 
39
    int PyObject_IsTrue(PyObject *)
37
40
    # Note: *Don't* use hash(), Pyrex 0.9.8.5 thinks it returns an 'int', and
38
41
    #       thus silently truncates to 32-bits on 64-bit machines.
39
42
    long PyObject_Hash(PyObject *) except -1
55
58
_dummy = <PyObject *>_dummy_obj
56
59
 
57
60
 
58
 
cdef object _NotImplemented
59
 
_NotImplemented = NotImplemented
60
 
 
61
 
 
62
61
cdef int _is_equal(PyObject *this, long this_hash, PyObject *other) except -1:
63
62
    cdef long other_hash
 
63
    cdef PyObject *res
64
64
 
65
65
    if this == other:
66
66
        return 1
76
76
    #      equal. (It doesn't try to cast them both to some intermediate form
77
77
    #      that would compare equal.)
78
78
    res = Py_TYPE(this).tp_richcompare(this, other, Py_EQ)
79
 
    if res is _NotImplemented:
 
79
    if res == NULL: # Exception
 
80
        return -1
 
81
    if PyObject_IsTrue(res):
 
82
        Py_DECREF(res)
 
83
        return 1
 
84
    if res == Py_NotImplemented:
 
85
        Py_DECREF(res)
80
86
        res = Py_TYPE(other).tp_richcompare(other, this, Py_EQ)
81
 
        if res is _NotImplemented:
82
 
            return 0
83
 
    if res:
 
87
    if res == NULL:
 
88
        return -1
 
89
    if PyObject_IsTrue(res):
 
90
        Py_DECREF(res)
84
91
        return 1
 
92
    Py_DECREF(res)
85
93
    return 0
86
94
 
87
95
 
540
548
    return _check_self(self)._used
541
549
 
542
550
 
543
 
cdef api int SimpleSet_Next(object self, Py_ssize_t *pos,
544
 
                            PyObject **key) except -1:
 
551
cdef api int SimpleSet_Next(object self, Py_ssize_t *pos, PyObject **key):
545
552
    """Walk over items in a SimpleSet.
546
553
 
547
554
    :param pos: should be initialized to 0 by the caller, and will be updated
568
575
    return 1
569
576
 
570
577
 
571
 
cdef int SimpleSet_traverse(SimpleSet self, visitproc visit,
572
 
                            void *arg) except -1:
 
578
cdef int SimpleSet_traverse(SimpleSet self, visitproc visit, void *arg):
573
579
    """This is an implementation of 'tp_traverse' that hits the whole table.
574
580
 
575
581
    Cython/Pyrex don't seem to let you define a tp_traverse, and they only