[PATCH] mpatch: add setup_mpatch_cffi.py

Augie Fackler raf at durin42.com
Mon Aug 29 10:16:06 EDT 2016


On Sun, Aug 28, 2016 at 05:53:01PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Maciej Fijalkowski <fijall at gmail.com>
> # Date 1472431892 25200
> #      Sun Aug 28 17:51:32 2016 -0700
> # Node ID cfabba249769ddefcf23fdb491b75865ab5adf49
> # Parent  318e2b600b80e4ed3c6f37df46ec7544f60d4c0b
> mpatch: add setup_mpatch_cffi.py

queued, thanks

>
> This file got dropped when the corresponding setup.py changes were
> made.
>
> diff --git a/setup_mpatch_cffi.py b/setup_mpatch_cffi.py
> new file mode 100644
> --- /dev/null
> +++ b/setup_mpatch_cffi.py
> @@ -0,0 +1,35 @@
> +from __future__ import absolute_import
> +
> +import os
> +import cffi
> +
> +ffi = cffi.FFI()
> +mpatch_c = os.path.join(os.path.join(os.path.dirname(__file__), 'mercurial',
> +                                     'mpatch.c'))
> +ffi.set_source("_mpatch_cffi", open(mpatch_c).read(),
> +               include_dirs=["mercurial"])
> +ffi.cdef("""
> +
> +struct mpatch_frag {
> +       int start, end, len;
> +       const char *data;
> +};
> +
> +struct mpatch_flist {
> +       struct mpatch_frag *base, *head, *tail;
> +};
> +
> +extern "Python" struct mpatch_flist* cffi_get_next_item(void*, ssize_t);
> +
> +int mpatch_decode(const char *bin, ssize_t len, struct mpatch_flist** res);
> +ssize_t mpatch_calcsize(size_t len, struct mpatch_flist *l);
> +void mpatch_lfree(struct mpatch_flist *a);
> +static int mpatch_apply(char *buf, const char *orig, size_t len,
> +                        struct mpatch_flist *l);
> +struct mpatch_flist *mpatch_fold(void *bins,
> +                       struct mpatch_flist* (*get_next_item)(void*, ssize_t),
> +                       ssize_t start, ssize_t end);
> +""")
> +
> +if __name__ == '__main__':
> +    ffi.compile()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list