]> git.eshelyaron.com Git - emacs.git/commit
Bindat: new macro-expansion based data layout language
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 6 Mar 2021 00:56:31 +0000 (19:56 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 6 Mar 2021 00:56:31 +0000 (19:56 -0500)
commit533c659b6c73fd381231f25d0644c69729dd0aed
tree612bf257c9bf5805bf10d4b129a4180e6c7a2326
parent1362a9fec4dff341a84c881ac17dbf1ee2cf82fd
Bindat: new macro-expansion based data layout language

Thorough redesign of the Bindat system, which makes it possible
to define new Bindat type forms, define recursive types, control
the values returned when unpacking, freely mix arbitrary computations
with type definitions, as well as support for arbitrary sized
integers.

This also reverts the recent addition of the `bindat-spec` macro and
the support for 64bit integers in the old Bindat language since that
is now considered obsolete anyway.

* doc/lispref/processes.texi (Bindat Types): Rename from `Bindat Spec`
and rewrite for the new sublanguage.
(Bindat Functions): Adjust to the new terminology.
(Bindat Computed Types): New node.

* lisp/emacs-lisp/bindat.el (bindat--type): New type.
(bindat--unpack-u64, bindat--unpack-u64r): Delete functions.
(bindat--unpack-item, bindat--pack-item, bindat--fixed-length-alist):
Revert addition of support for 64bit integers.
(bindat--unpack-group, bindat--length-group, bindat--pack-group):
Handle the new `bindat--type` values.
(bindat-spec): Revert addition of this macro.
(bindat--unpack-uint, bindat--unpack-uintr, bindat--pack-uint)
(bindat--pack-uintr): New functions.
(bindat-type, bindat-defmacro, bindat--pcase): New macros.
(bindat-type): New Edebug elem.
(bindat--type): New generic function.
(bindat--primitives): New constant.
(bindat--macroenv, bindat--op): New vars.
(bindat--make-docstring, bindat--fun, bindat--makefun, bindat--toplevel):
New functions.

* test/lisp/emacs-lisp/bindat-tests.el: Use `bindat-type`.
(ip): New Bindat type.
(header-bindat-spec, data-bindat-spec, packet-bindat-spec): Adjust to
new `bindat-type` macro.
(bindat-test-unpack): Simplify now that the order of fields is preserved.
(bindat-test--int-websocket-type, bindat-test--LEB128): New consts.
(bindat-test--pack-val, bindat-test--sint, bindat-test--recursive):
New tests.
doc/lispref/elisp.texi
doc/lispref/processes.texi
etc/NEWS
lisp/emacs-lisp/bindat.el
test/lisp/emacs-lisp/bindat-tests.el