comparison mercurial/cext/revlog.c @ 44502:166349510398

revlog: using two new functions in C capsule from Rust code We expose `index_length` and `index_node` in the C capsule, so that the Rust representation of the C index can implement the `RevlogIndex` trait. Because our `Node` is actually a one-field struct, we have to decorate it for direct FFI exchange with the C `char*` It would be a good thing to get a length from the C layer, but doing so right now would probably interfere with the upcoming changes that will happen there for the hash length. Differential Revision: https://phab.mercurial-scm.org/D8152
author Georges Racinet <georges.racinet@octobus.net>
date Mon, 13 Jan 2020 19:31:33 +0100
parents b55bec1ea972
children f8427841c8fc
comparison
equal deleted inserted replaced
44501:87b327de772c 44502:166349510398
37 int children[16]; 37 int children[16];
38 } nodetreenode; 38 } nodetreenode;
39 39
40 typedef struct { 40 typedef struct {
41 int abi_version; 41 int abi_version;
42 Py_ssize_t (*index_length)(const indexObject *);
43 const char *(*index_node)(indexObject *, Py_ssize_t);
42 int (*index_parents)(PyObject *, int, int *); 44 int (*index_parents)(PyObject *, int, int *);
43 } Revlog_CAPI; 45 } Revlog_CAPI;
44 46
45 /* 47 /*
46 * A base-16 trie for fast node->rev mapping. 48 * A base-16 trie for fast node->rev mapping.
2875 } 2877 }
2876 2878
2877 static Revlog_CAPI CAPI = { 2879 static Revlog_CAPI CAPI = {
2878 /* increment the abi_version field upon each change in the Revlog_CAPI 2880 /* increment the abi_version field upon each change in the Revlog_CAPI
2879 struct or in the ABI of the listed functions */ 2881 struct or in the ABI of the listed functions */
2880 1, 2882 2,
2883 index_length,
2884 index_node,
2881 HgRevlogIndex_GetParents, 2885 HgRevlogIndex_GetParents,
2882 }; 2886 };
2883 2887
2884 void revlog_module_init(PyObject *mod) 2888 void revlog_module_init(PyObject *mod)
2885 { 2889 {