emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 431a3b325f 200/427: Toss "reap" and switch to new


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 431a3b325f 200/427: Toss "reap" and switch to new finalize with Cask.
Date: Tue, 13 Dec 2022 02:59:41 -0500 (EST)

branch: elpa/emacsql
commit 431a3b325fc74882829e25374873baabeb21e730
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Toss "reap" and switch to new finalize with Cask.
---
 .gitignore      |  2 ++
 Cask            |  8 +++++++
 Makefile        | 29 +++++++++++++++----------
 README.md       | 10 ++++++++-
 emacsql-pkg.el  |  3 ---
 emacsql-reap.el | 66 ---------------------------------------------------------
 emacsql.el      |  4 ++--
 7 files changed, 39 insertions(+), 83 deletions(-)

diff --git a/.gitignore b/.gitignore
index ef8cdbb022..97259b9f15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
 *.elc
 *.tar
+.cask
+emacsql-pkg.el
diff --git a/Cask b/Cask
new file mode 100644
index 0000000000..98657e356f
--- /dev/null
+++ b/Cask
@@ -0,0 +1,8 @@
+(source melpa)
+
+(package "emacsql" "0.9.0" "high-level SQL database front-end")
+
+(depends-on "emacs" "24.1")
+(depends-on "cl-lib" "0.3")
+(depends-on "eieio" "1.4")
+(depends-on "finalize" "1.0.0")
diff --git a/Makefile b/Makefile
index 7057a2cb80..8c0a9554ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,12 @@
-PACKAGE  = emacsql
-VERSION := $(word 1,$(subst -, ,$(shell git describe)))
-
 EMACS   ?= emacs
-BATCH   := $(EMACS) -batch -Q -L .
-COMPILE := $(BATCH) -f batch-byte-compile
+CASK    ?= cask
+VIRTUAL := $(CASK) exec $(EMACS)
+BATCH   := $(VIRTUAL) -batch -Q -L .
+
+PACKAGE := emacsql
+VERSION := $(shell $(CASK) version)
 
-EL = emacsql-reap.el emacsql-compiler.el emacsql.el emacsql-sqlite.el \
-     emacsql-psql.el emacsql-tests.el
+EL = emacsql-compiler.el emacsql.el emacsql-sqlite.el emacsql-psql.el
 ELC = $(EL:.el=.elc)
 EXTRA_DIST = README.md UNLICENSE
 
@@ -14,18 +14,25 @@ EXTRA_DIST = README.md UNLICENSE
 
 all : test
 
-compile: $(ELC)
+.cask : Cask
+       cask install
+       touch .cask
+
+compile: .cask $(ELC)
 
 package : $(PACKAGE)-$(VERSION).tar
 
+$(PACKAGE)-pkg.el : Cask
+       $(CASK) package
+
 $(PACKAGE)-$(VERSION).tar : $(EL) $(PACKAGE)-pkg.el $(EXTRA_DIST)
        tar -cf $@ --transform "s,^,$(PACKAGE)-$(VERSION)/," $^
 
-test: compile
+test: compile $(PACKAGE)-tests.elc
        $(BATCH) -l $(PACKAGE)-tests.elc -f ert-run-tests-batch
 
 clean:
-       $(RM) *.tar $(ELC)
+       $(RM) *.tar *.elc $(PACKAGE)-pkg.el
 
 %.elc: %.el
-       $(COMPILE) $<
+       $(BATCH) -f batch-byte-compile $<
diff --git a/README.md b/README.md
index 15c4db7b44..5dfd89765f 100644
--- a/README.md
+++ b/README.md
@@ -395,7 +395,14 @@ from the command line and allows for storage of Emacs 
richer data
 types. This is an efficient, ACID-compliant database specifically for
 Emacs.
 
-## Creating a New Front-end
+## Contributing and Extending
+
+You'll need to install [Cask][cask], which is required for compilation
+and unit testing.
+
+    make test
+
+### Creating a New Front-end
 
 Emacsql uses EIEIO so that interactions with a connection occur
 through generic functions. You need to define a new class that
@@ -424,3 +431,4 @@ the emacsql-simple-parser mixin class to do most of the 
work.
 [exe]: http://skeeto.s3.amazonaws.com/emacs/sqlite3-3.8.2-fixed.exe
 [asc]: http://skeeto.s3.amazonaws.com/emacs/sqlite3-3.8.2-fixed.exe.asc
 [batch]: 
http://lists.gnu.org/archive/html/emacs-pretest-bug/2005-11/msg00320.html
+[cask]: http://cask.github.io/
diff --git a/emacsql-pkg.el b/emacsql-pkg.el
deleted file mode 100644
index b1cc2d175f..0000000000
--- a/emacsql-pkg.el
+++ /dev/null
@@ -1,3 +0,0 @@
-(define-package "emacsql" "0.9.0"
-  "high-level SQL database front-end"
-  '((emacs "24.1") (cl-lib "0.3")))
diff --git a/emacsql-reap.el b/emacsql-reap.el
deleted file mode 100644
index b076081f28..0000000000
--- a/emacsql-reap.el
+++ /dev/null
@@ -1,66 +0,0 @@
-;;; emacsql-reap.el --- callbacks for garbage-collected objects -*- 
lexical-binding: t; -*-
-
-;; This is free and unencumbered software released into the public domain.
-
-;; Commentary:
-
-;; This package is for immediately running a callback after a lisp
-;; object is garbage collected. An optional token can be passed to the
-;; callback to provide a hint as to what was collected, since the
-;; original object obviously can't be passed.
-
-;; It works by exploiting Emacs Lisp's weak hash tables and hooking
-;; the `post-gc-hook'.
-
-;;; Code:
-
-(require 'cl-lib)
-
-(defvar emacsql-reap-objects ()
-  "Collection of all objects being watched by the reaper.")
-
-(defun emacsql-reap--ref (thing)
-  "Create a weak reference to THING."
-  (let ((ref (make-hash-table :test 'eq :size 1 :weakness 'value)))
-    (prog1 ref
-      (setf (gethash t ref) thing))))
-
-(defun emacsql-reap--deref (ref)
-  "Retrieve value from REF."
-  (gethash t ref))
-
-(defun emacsql-reap--empty-p (ref)
-  "Return non-nil if value behind REF is still there."
-  (zerop (hash-table-count ref)))
-
-(cl-defun emacsql-reap-register (object callback &optional (token nil token-p))
-  "Run CALLBACK with TOKEN when OBJECT is garbage collected.
-Do *not* use OBJECT for TOKEN because it will not get collected."
-  (let ((ref (emacsql-reap--ref object))
-        (rich-token (and token-p (vector token))))
-    ;; Rich-token could be instead captured in a closure, but
-    ;; establishing a closure here would require this package to be
-    ;; byte-compiled in order to operate properly. Interpreted
-    ;; closures capture the entire environment.
-    (push (list callback rich-token ref) emacsql-reap-objects)))
-
-(defun emacsql-reap-single (entry)
-  "Cleanup ENTRY and return non-nil if ENTRY has been garbage collected."
-  (cl-destructuring-bind (callback token ref) entry
-    (when (emacsql-reap--empty-p ref)
-      (prog1 t
-        (ignore-errors
-          (if token
-              (funcall callback (elt token 0))
-            (funcall callback)))))))
-
-(defun emacsql-reap ()
-  "Run callbacks for garbage collected objects."
-  (setf emacsql-reap-objects
-        (cl-delete-if #'emacsql-reap-single emacsql-reap-objects)))
-
-(add-hook 'post-gc-hook #'emacsql-reap)
-
-(provide 'emacsql-reap)
-
-;;; emacsql-reap.el ends here
diff --git a/emacsql.el b/emacsql.el
index 1b5b1910ac..5e8562be48 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -58,7 +58,7 @@
 
 (require 'cl-lib)
 (require 'eieio)
-(require 'emacsql-reap)
+(require 'finalize)
 (require 'emacsql-compiler)
 
 (defclass emacsql-connection ()
@@ -196,7 +196,7 @@ specific error conditions."
 
 (defun emacsql-register (connection)
   "Register CONNECTION for automatic cleanup and return CONNECTION."
-  (emacsql-reap-register connection #'emacsql-close (copy-sequence connection))
+  (finalize-register connection #'emacsql-close (copy-sequence connection))
   connection)
 
 ;; Useful macros:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]