~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_simple_set_pyx.pxd

  • Committer: John Arbash Meinel
  • Date: 2009-10-07 19:31:39 UTC
  • mto: (4679.6.1 2.1-export-c-api)
  • mto: This revision was merged to the branch mainline in revision 4735.
  • Revision ID: john@arbash-meinel.com-20091007193139-5etl1h2f1jad4j13
Fix up _simple_set_pyx.pyx to be compatible with pyrex again.

Surprisingly not as easy as I expected, but things seem to be working.
Found an actual bug in the dealloc code...

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
     eg. SimpleSet.add(key) => saved_key and SimpleSet[key] => saved_key
24
24
"""
25
25
 
26
 
cdef extern from "python-compat.h":
27
 
    ctypedef long Py_ssize_t
28
 
 
29
26
cdef extern from "Python.h":
30
27
    ctypedef struct PyObject:
31
28
        pass
43
40
    operations (difference, intersection, etc).
44
41
    """
45
42
 
46
 
    cdef readonly Py_ssize_t used    # active
47
 
    cdef readonly Py_ssize_t fill    # active + dummy
48
 
    cdef readonly Py_ssize_t mask    # Table contains (mask+1) slots, a power
 
43
    cdef Py_ssize_t _used   # active
 
44
    cdef Py_ssize_t _fill   # active + dummy
 
45
    cdef Py_ssize_t _mask   # Table contains (mask+1) slots, a power
49
46
                                     # of 2
50
 
    cdef PyObject **table   # Pyrex/Cython doesn't support arrays to 'object'
 
47
    cdef PyObject **_table  # Pyrex/Cython doesn't support arrays to 'object'
51
48
                            # so we manage it manually
52
49
 
53
50
    cdef PyObject *_get(self, object key) except? NULL
54
 
    cpdef object add(self, key)
55
 
    cpdef int discard(self, key) except -1
 
51
    cdef object _add(self, key)
 
52
    cdef int _discard(self, key) except -1
56
53
    cdef int _insert_clean(self, PyObject *key) except -1
57
 
    cpdef Py_ssize_t _resize(self, Py_ssize_t min_unused) except -1
 
54
    cdef Py_ssize_t _resize(self, Py_ssize_t min_unused) except -1
58
55
 
59
56
# TODO: might want to export the C api here, though it is all available from
60
57
#       the class object...
61
58
cdef api object SimpleSet_Add(object self, object key)
 
59
cdef api SimpleSet SimpleSet_New()