29
29
# GetItem returns a borrowed reference
30
30
void *PyDict_GetItem(object p, object key)
31
31
int PyDict_SetItem(object p, object key, object val) except -1
33
int PyList_Append(object lst, object item) except -1
32
34
void *PyList_GetItem_object_void "PyList_GET_ITEM" (object lst, int index)
33
void *PyTuple_GetItem_void_void "PyTuple_GET_ITEM" (void* tpl, int index)
34
object PyUnicode_Split_void_object "PyUnicode_Split" (void* str, )
35
object PyList_GET_ITEM (object lst, int index)
35
36
int PyList_CheckExact(object)
36
38
int PyTuple_CheckExact(object)
39
void *PyTuple_GetItem_void_void "PyTuple_GET_ITEM" (void* tpl, int index)
40
object PyTuple_New(int)
41
int PyTuple_SetItem(object tpl, int offset, object val)
42
void PyTuple_SET_ITEM(object tpl, int offset, object val)
43
object PyTuple_Pack(int n, ...)
38
45
char *PyString_AsString(object p)
39
46
char *PyString_AS_STRING_void "PyString_AS_STRING" (void *p)
44
51
void Py_INCREF(object)
45
52
void Py_DECREF(object)
55
cdef extern from "stdlib.h":
56
unsigned long int strtoul(char *nptr, char **endptr, int base)
47
58
cdef extern from "string.h":
48
int strncmp(char *s1, char *s2, size_t len)
49
int strcmp(char *s1, char *s2)
50
59
char *strchr(char *s1, char c)
194
cdef object _List_GetItem_Incref(object lst, int offset):
195
"""Get an item, and increment a reference to it.
197
The caller must have checked that the object really is a list.
200
cur = PyList_GET_ITEM(lst, offset)
205
cdef object _fields_to_entry_0_parents(object fields):
206
cdef object path_name_file_id_key
208
cdef unsigned long int size
209
cdef char* executable_str
210
cdef object is_executable
211
if not PyList_CheckExact(fields):
212
raise TypeError('fields must be a list')
213
path_name_file_id_key = (_List_GetItem_Incref(fields, 0),
214
_List_GetItem_Incref(fields, 1),
215
_List_GetItem_Incref(fields, 2),
218
size_str = PyString_AS_STRING_void(
219
PyList_GetItem_object_void(fields, 5))
220
size = strtoul(size_str, NULL, 10)
221
executable_str = PyString_AS_STRING_void(
222
PyList_GetItem_object_void(fields, 6))
223
if executable_str[0] == c'y':
226
is_executable = False
227
return (path_name_file_id_key, [
229
_List_GetItem_Incref(fields, 3),# minikind
230
_List_GetItem_Incref(fields, 4),# fingerprint
232
is_executable, # executable
233
_List_GetItem_Incref(fields, 7),# packed_stat or revision_id
185
237
def _c_read_dirblocks(state):
186
238
"""Read in the dirblocks for the given DirState object.
276
330
# append the entry to the current block
277
331
append_entry(entry)
278
332
state._split_root_dirblock_into_contents()
333
elif num_present_parents == 0:
336
while pos < field_count:
337
PyList_Append(entries,
338
_fields_to_entry_0_parents(fields[pos:pos+entry_size]))
339
pos = pos + entry_size
340
state._entries_to_current_state(entries)
281
342
fields_to_entry = state._get_fields_to_entry()
283
344
entries_append = entries.append
285
entry_size = entry_size
286
346
while pos < field_count:
287
347
entries_append(fields_to_entry(fields[pos:pos+entry_size]))
288
348
pos = pos + entry_size