commit: db67dcecd4a6e48a1e074061c6f8b42d2f4dabd7
parent 81698ccb285eea2cb5516b68349b217320cd87fc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 3 Dec 2022 04:11:17 +0100
Add support for Emacs Lisp Bytecode
Diffstat:
6 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/.reuse/dep5 b/.reuse/dep5
@@ -3,6 +3,6 @@ Upstream-Name: deblob
Upstream-Contact: deblob Authors <https://hacktivis.me/projects/deblob>
Source: https://hacktivis.me/projects/deblob
-Files: test/fixtures/pyc/*.pyc test/fixtures/pickle/*.pickle test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam test/fixtures/empty.dtb test/fixtures/hello-chez.so test/fixtures/hello.n test/fixtures/hello-ocaml.* test/fixtures/compiled/hello-racket_rkt.zo
+Files: test/fixtures/pyc/*.pyc test/fixtures/pickle/*.pickle test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam test/fixtures/empty.dtb test/fixtures/hello-chez.so test/fixtures/hello.n test/fixtures/hello-ocaml.* test/fixtures/compiled/hello-racket_rkt.zo test/fixtures/hello.elc
Copyright: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
License: BSD-3-Clause
diff --git a/deblob.1 b/deblob.1
@@ -79,6 +79,8 @@ NekoVM bytecode
OCaml bytecode and native binaries
.It
Racket bytecode
+.It
+Emacs Lisp Bytecode
.El
.Sh EXAMPLES
The following code block shows how it can be used in Gentoo's
diff --git a/main.ha b/main.ha
@@ -46,8 +46,9 @@ const magic: [_][]u8 = [
['p', 's', 't', '0'], // Perl Storable(v0.7)
[0x00, 0x00, 0x00, 0x00, 'c', 'h', 'e', 'z'], // Chez Scheme bytecode
['N', 'E', 'K', 'O'], // NekoVM Bytecode
+ [';', 'E', 'L', 'C'], // Emacs lisp bytecode, if there is known false positives next 4 bytes is the version
- ['C', 'a', 'm', 'l', '1', '9', '9', '9'] // OCaml
+ ['C', 'a', 'm', 'l', '1', '9', '9', '9'], // OCaml
];
const dos_magic: []u8 = ['M', 'Z'];
const pe_magic: []u8 = ['P', 'E', 0x00, 0x00];
@@ -112,6 +113,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
(false, "test/fixtures/hello.1"),
(false, "test/fixtures/hello.c"),
(false, "test/fixtures/hello.cs"),
+ (false, "test/fixtures/hello.el"),
(false, "test/fixtures/hello.erl"),
(false, "test/fixtures/hello.java"),
(false, "test/fixtures/hello.lua"),
@@ -134,6 +136,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
(true, "test/fixtures/hello.a"),
(true, "test/fixtures/hello.beam"),
(true, "test/fixtures/hello.class"),
+ (true, "test/fixtures/hello.elc"),
(true, "test/fixtures/hello.exe"),
(true, "test/fixtures/hello.luac53"),
(true, "test/fixtures/hello.luac54"),
@@ -248,7 +251,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_before) == 52);
+ assert(len(files_before) == 54);
const ret = check_dir(dirname);
assert(ret is void);
@@ -259,7 +262,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_after) == 28);
+ assert(len(files_after) == 29);
};
export fn main() void = {
diff --git a/test/fixtures/Makefile b/test/fixtures/Makefile
@@ -14,9 +14,10 @@ DTC ?= dtc
CHEZ ?= chezscheme
OCAMLC ?= ocamlc
OCAMLOPT ?= ocamlopt
+EMACS ?= emacs
NONBUNDLED_BLOBS = hello hello.a hello.o
-TEST_BLOBS = $(NONBUNDLED_BLOBS) hello.exe hello.luac53 hello.luac54 hello.wasm hello.class hello.nqp.moarvm hello.pir.pbc perl_storage.pst hello.beam empty.dtb hello-chez.so hello.n hello-ocaml.cmo hello-ocaml.cma hello-ocaml.cmx hello-ocaml.cmxa compiled/hello-racket_rkt.zo
+TEST_BLOBS = $(NONBUNDLED_BLOBS) hello.exe hello.luac53 hello.luac54 hello.wasm hello.class hello.nqp.moarvm hello.pir.pbc perl_storage.pst hello.beam empty.dtb hello-chez.so hello.n hello-ocaml.cmo hello-ocaml.cma hello-ocaml.cmx hello-ocaml.cmxa compiled/hello-racket_rkt.zo hello.elc
base: $(NONBUNDLED_BLOBS)
@@ -89,3 +90,6 @@ hello-ocaml.cmxa: hello-ocaml.cmx
compiled/hello-racket_rkt.zo: hello-racket.rkt
racket -e '(require compiler/cm)(managed-compile-zo "hello-racket.rkt")'
+
+hello.elc: hello.el
+ $(EMACS) --eval '(byte-compile-file "hello.el")' --batch
diff --git a/test/fixtures/hello.el b/test/fixtures/hello.el
@@ -0,0 +1,6 @@
+; SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
+; SPDX-License-Identifier: BSD-3-Clause
+(defun hello()
+ (princ "Hello, World!\n")
+)
+(hello)
diff --git a/test/fixtures/hello.elc b/test/fixtures/hello.elc
Binary files differ.