~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_chk_map_pyx.pyx

  • Committer: Parth Malwankar
  • Date: 2010-05-19 02:58:05 UTC
  • mfrom: (5240 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5241.
  • Revision ID: parth.malwankar@gmail.com-20100519025805-3gy1anwga6497y4s
merged in changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    PyObject *PyString_FromStringAndSize_ptr "PyString_FromStringAndSize" (char *, Py_ssize_t)
39
39
    Py_ssize_t PyString_GET_SIZE(object)
40
40
    void PyString_InternInPlace(PyObject **)
41
 
    unsigned long PyInt_AsUnsignedLongMask(object) except? -1
 
41
    long PyInt_AS_LONG(object)
42
42
 
43
43
    int PyDict_SetItem(object d, object k, object v) except -1
44
44
 
45
 
    object PyTuple_New(Py_ssize_t count)
46
 
    void PyTuple_SET_ITEM(object t, Py_ssize_t offset, object)
47
 
 
48
45
    void Py_INCREF(object)
49
46
    void Py_DECREF_ptr "Py_DECREF" (PyObject *)
50
47
 
51
 
    PyObject * PyTuple_GET_ITEM_ptr "PyTuple_GET_ITEM" (object t,
52
 
                                                        Py_ssize_t offset)
53
 
    int PyString_CheckExact_ptr "PyString_CheckExact" (PyObject *p)
54
 
    Py_ssize_t PyString_GET_SIZE_ptr "PyString_GET_SIZE" (PyObject *s)
55
 
    char *PyString_AS_STRING_ptr "PyString_AS_STRING" (PyObject *s)
56
48
    object PyString_FromStringAndSize(char*, Py_ssize_t)
57
49
 
58
50
# cimport all of the definitions we will need to access
61
53
    StaticTuple_Intern, StaticTuple_SET_ITEM, StaticTuple_CheckExact, \
62
54
    StaticTuple_GET_SIZE
63
55
 
64
 
cdef extern from "_static_tuple_c.h":
65
 
    # Defined explicitly rather than cimport-ing. Trying to use cimport, the
66
 
    # type for PyObject is a different class that happens to have the same
67
 
    # name...
68
 
    PyObject * StaticTuple_GET_ITEM_ptr "StaticTuple_GET_ITEM" (StaticTuple,
69
 
                                                                Py_ssize_t)
70
 
 
71
56
cdef object crc32
72
57
from zlib import crc32
73
58
 
130
115
        if i > 0:
131
116
            c_out[0] = c'\x00'
132
117
            c_out = c_out + 1
133
 
        crc_val = PyInt_AsUnsignedLongMask(crc32(key[i]))
 
118
        crc_val = PyInt_AS_LONG(crc32(key[i]))
134
119
        # Hex(val) order
135
120
        sprintf(c_out, '%08X', crc_val)
136
121
        c_out = c_out + 8
155
140
        if i > 0:
156
141
            c_out[0] = c'\x00'
157
142
            c_out = c_out + 1
158
 
        crc_val = PyInt_AsUnsignedLongMask(crc32(key[i]))
 
143
        crc_val = PyInt_AS_LONG(crc32(key[i]))
159
144
        # MSB order
160
145
        c_out[0] = (crc_val >> 24) & 0xFF
161
146
        c_out[1] = (crc_val >> 16) & 0xFF