Patchwork mpatch: add setup_mpatch_cffi.py

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 29, 2016, 12:53 a.m.
Message ID <cfabba249769ddefcf23.1472431981@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16472/
State Accepted
Headers show

Comments

Gregory Szorc - Aug. 29, 2016, 12:53 a.m.
# HG changeset patch
# User Maciej Fijalkowski <fijall@gmail.com>
# Date 1472431892 25200
#      Sun Aug 28 17:51:32 2016 -0700
# Node ID cfabba249769ddefcf23fdb491b75865ab5adf49
# Parent  318e2b600b80e4ed3c6f37df46ec7544f60d4c0b
mpatch: add setup_mpatch_cffi.py

This file got dropped when the corresponding setup.py changes were
made.
Augie Fackler - Aug. 29, 2016, 2:16 p.m.
On Sun, Aug 28, 2016 at 05:53:01PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Maciej Fijalkowski <fijall@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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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()