~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_pyx.pyx

messy but working.

Start exposing the C API using a nice python dict, rather than offsets into an array.
This is much more convenient and allows a small amount of api skew without
serious problems. It also allows some safety checks to be performed during
import.


Mostly we just need to clean up the code a bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
# It seems we need to import the definitions so that the pyrex compiler has
61
61
# local names to access them.
62
 
from _static_tuple_c cimport StaticTuple, StaticTuple_API,\
63
 
    import_static_tuple, STATIC_TUPLE_ALL_STRING, StaticTuple_New, \
 
62
from _static_tuple_c cimport StaticTuple, \
 
63
    import_static_tuple_c, STATIC_TUPLE_ALL_STRING, StaticTuple_New, \
64
64
    StaticTuple_intern, StaticTuple_SET_ITEM, StaticTuple_CheckExact
65
65
 
66
66
 
106
106
cdef object _ST
107
107
_ST = _static_tuple_c.StaticTuple
108
108
# This sets up the StaticTuple C_API functionality
109
 
if import_static_tuple() == -1:
110
 
    raise ImportError('failed to import_static_tuple()')
111
 
if StaticTuple_API == NULL:
112
 
    raise ImportError('StaticTuple_API failed to be initialized.')
 
109
import_static_tuple_c()
113
110
 
114
111
 
115
112
cdef class BTreeLeafParser:
151
148
        self._end_str = NULL
152
149
        self._header_found = 0
153
150
        # keys are tuples
154
 
        if StaticTuple_API == NULL:
155
 
            raise ImportError('failed to import_static_tuple()')
156
151
 
157
152
    cdef extract_key(self, char * last):
158
153
        """Extract a key.