~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_groupcompress_pyx.pyx

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-10 16:25:28 UTC
  • mfrom: (5020.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100210162528-00g29u0ex6vzv914
(gerard) Update performs two merges in a more logical order but stop
        on conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 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
22
22
 
23
23
 
24
24
cdef extern from "Python.h":
25
 
    ctypedef struct PyObject:
26
 
        pass
27
25
    ctypedef int Py_ssize_t # Required for older pyrex versions
28
26
    int PyString_CheckExact(object)
29
27
    char * PyString_AS_STRING(object)
55
53
             unsigned long *delta_size, unsigned long max_delta_size) nogil
56
54
    unsigned long get_delta_hdr_size(unsigned char **datap,
57
55
                                     unsigned char *top) nogil
58
 
    unsigned long sizeof_delta_index(delta_index *index)
59
56
    Py_ssize_t DELTA_SIZE_MIN
60
57
 
61
58
 
94
91
    cdef readonly object _sources
95
92
    cdef source_info *_source_infos
96
93
    cdef delta_index *_index
 
94
    cdef readonly unsigned int _max_num_sources
97
95
    cdef public unsigned long _source_offset
98
 
    cdef readonly unsigned int _max_num_sources
99
96
 
100
97
    def __init__(self, source=None):
101
98
        self._sources = []
108
105
        if source is not None:
109
106
            self.add_source(source, 0)
110
107
 
111
 
    def __sizeof__(self):
112
 
        # We want to track the _source_infos allocations, but the referenced
113
 
        # void* are actually tracked in _sources itself.
114
 
        # XXX: Cython is capable of doing sizeof(class) and returning the size
115
 
        #      of the underlying struct. Pyrex (<= 0.9.9) refuses, so we need
116
 
        #      to do it manually. *sigh* Note that we might get it wrong
117
 
        #      because of alignment issues.
118
 
        cdef Py_ssize_t size
119
 
        # PyObject start, vtable *, 3 object pointers, 2 C ints
120
 
        size = ((sizeof(PyObject) + sizeof(void*) + 3*sizeof(PyObject*)
121
 
                 + sizeof(unsigned long)
122
 
                 + sizeof(unsigned int))
123
 
                + (sizeof(source_info) * self._max_num_sources)
124
 
                + sizeof_delta_index(self._index))
125
 
        return size
126
 
 
127
108
    def __repr__(self):
128
109
        return '%s(%d, %d)' % (self.__class__.__name__,
129
110
            len(self._sources), self._source_offset)