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

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

[nongnu] elpa/sqlite3 639ffb711e 20/62: all .el files removed.


From: ELPA Syncer
Subject: [nongnu] elpa/sqlite3 639ffb711e 20/62: all .el files removed.
Date: Tue, 14 Mar 2023 11:01:45 -0400 (EDT)

branch: elpa/sqlite3
commit 639ffb711ee956d102399c504a978c19d2a92ac4
Author: Y. N. Lo <gordonynlo@yahoo.com>
Commit: Y. N. Lo <gordonynlo@yahoo.com>

    all .el files removed.
---
 .gitignore                            |  6 +--
 Makefile                              | 33 +++++++-------
 README-in.md                          | 34 +++++++--------
 README.md                             | 40 ++++++++---------
 sqlite3-api-module.c => sqlite3-api.c | 39 ++++++++++++++++-
 sqlite3-api.el                        | 82 -----------------------------------
 {test => tests}/regression.el         |  0
 tools/find-sqlite3-h.sh               |  2 +
 tools/gen-consts.py                   | 14 +-----
 tools/run.sh                          | 45 -------------------
 10 files changed, 96 insertions(+), 199 deletions(-)

diff --git a/.gitignore b/.gitignore
index 86b005a01c..239bfd03e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,6 @@
 *.so
 **/.DS_Store
 sqlite3-napi-module-with-create-function.c
+consts.c
 xxx.el
-tools/def.c
-tools/def
-MODULE
-**/sqlite3-api-module-*
\ No newline at end of file
+**/sqlite3-api-*
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 5a28256e85..d0de5f92f0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,34 +2,33 @@ CC = gcc
 CFLAGS = -g3 -Wall -std=c99
 EMACS252=$(HOME)/test-emacs/bin/emacs
 EMACS251=$(HOME)/test-emacs-251/bin/emacs
+SQLITE3_H=$(shell tools/find-sqlite3-h.sh)
 
 # Melpa package
 PKG=sqlite3-api
 
 # dynamic module package
-MODULE=$(PKG)-module
-MODULE_VERSION=0.0.1
+MODULE=$(PKG)
+MODULE_VERSION=0.1
 MODULE_BASENAME=$(MODULE)-$(MODULE_VERSION)
 MODULE_PKG_EL=$(MODULE_BASENAME)/$(MODULE)-pkg.el
 MODULE_TAR=$(MODULE_BASENAME).tar
 
-all: consts $(MODULE).so 
+all: consts.c $(MODULE).so 
 
 clean:
-       rm -rf *.so *.o *.tar MODULE $(MODULE_BASENAME) tools/*.el
-
-# create sqlite3-api-constants.el
-consts:
-       (cd tools; ./run.sh $(MODULE_VERSION))
+       rm -rf *.so *.o *.tar consts.c
 
 # File "MODULE" is read by (sqlite3-api-install-dynamic-module)
 # during installation
-module: clean consts $(MODULE).so 
-       mkdir $(MODULE_BASENAME)
-       echo "(define-package \"$(MODULE)\" \"$(MODULE_VERSION)\" \"SQLite3 API 
dynamic module\" '((sqlite3-api \"0.0.1\")))" > $(MODULE_PKG_EL)
-       cp $(MODULE).so tools/$(PKG)-constants.el $(MODULE_BASENAME)
+module: consts.c $(MODULE).so 
+       mkdir -p $(MODULE_BASENAME)
+       cp $(MODULE).so $(MODULE_BASENAME)
+       echo "(define-package \"$(MODULE)\" \"$(MODULE_VERSION)\" \"SQLite3 API 
dynamic module\")" > $(MODULE_PKG_EL)
        tar cvf $(MODULE_TAR) $(MODULE_BASENAME)
-       echo $(MODULE_TAR) > MODULE
+
+consts.c: $(SQLITE_H)
+       grep "^#define SQLITE" $(SQLITE3_H) | tools/gen-consts.py > $@
 
 %.so: %.o
        $(CC) -shared -o $@ $< -lsqlite3
@@ -38,9 +37,9 @@ module: clean consts $(MODULE).so
        $(CC) $(CFLAGS) -fPIC -c $<
 
 # Emacs 25.2
-test: $(MODULE)
-       $(EMACS252) -batch -Q -l test/regression.el
+test:
+       $(EMACS252) -batch -Q -l tests/regression.el
 
 # Emacs 25.1
-test251: $(MODULE)
-       $(EMACS251) -batch -Q -l test/regression.el
+t251:
+       $(EMACS251) -batch -Q -l tests/regression.el
diff --git a/README-in.md b/README-in.md
index 3fccb0c9e4..663f0b9c00 100644
--- a/README-in.md
+++ b/README-in.md
@@ -30,31 +30,31 @@ This is an alpha release so it might crash your Emacs. Save 
your work before you
 <<TOC>>
 ## Requirements
 - Emacs 25.1 or above, compiled with module support (`./configure 
--with-modules`)
-- sqlite3 library and header file
+- SQLite3 v3.16.0 or above
 - A C99 compiler
 
 It's been tested on macOS (Sierra) and CentOS 7.
 ## Installation
-### ELPA
-<!--
-Install `sqlite3-api` from the MELPA Repository. To enable installation of 
packages from MELPA, follow the instructions 
[here](https://github.com/melpa/melpa#usage).
-
-After you install and `(require 'sqlite3-api)`, do a 
-`M-x sqlite3-api-install-dynamic-module`. This command will:
-1. Clone this repo to your local machine,
-1. Compile the source code to produce the dynamic module
-1. Create and install a package called sqlite3-api-module-x.y.z
--->
-Coming Soon
 ### Manual
 ~~~sh
 $ git co https://github.com/pekingduck/emacs-sqlite3-api
 $ cd emacs-sqlite3-api
 $ make
-$ cp sqlite3-api.el tools/sqlite3-api-constants.el sqlite3-api-module.so 
/your/elisp/load-path/
+$ cp sqlite3-api.so /your/elisp/load-path/
 ~~~
-A copy of `emacs-module.h` is included in this repo so Emacs source tree
-is not needed to build the module.
+### ELPA
+~~~sh
+$ git co https://github.com/pekingduck/emacs-sqlite3-api
+$ cd emacs-sqlite3-api
+$ make module
+~~~
+A tar archive called `sqlite3-api-X.Y.tar` will be created. Do a `M-x 
package-install-file` in Emacs to install that tar archive and 
+you'll all set.
+
+Currently there's no way to reload a dynamic module in Emacs
+(`unload-feature` doesn't seem to work for dynamic module.)
+If you are updating from an older version, you'll need to restart Emacs
+for the new module to take effect.
 
 ## API
 To load the package, put the following in your `.emacs`:
@@ -216,7 +216,7 @@ Return number of columns in a result set.
 ~~~e1
 (sqlite3-column-type statement-handle column-no)
 ~~~
-Return the type (`sqlite-integer`, `sqlite-float`, `sqlite-text` or
+Return the type (`sqlite-integer`, `sqlite-float`, `sqlite3-text` or
 `sqlite-null`) of the specified column. 
 
 Note: Column number starts from 0.
@@ -282,7 +282,7 @@ to manually free database/statement handles once they are 
not needed.
 ## Known Problems
 - SQLite3 supports 64 bit integers but Emacs integers are only 61 bits.
 For integers > 61 bits you can retrieve them as text as a workaround.
-- BLOB/TEXT columns with embedded NULLs are not supported.
+- BLOB and TEXT columns with embedded NULLs are not supported.
 
 ## License
 The code is licensed under the [GNU GPL 
v3](https://www.gnu.org/licenses/gpl-3.0.html).
diff --git a/README.md b/README.md
index 1de4aeab23..ad979ee11b 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,8 @@ This is an alpha release so it might crash your Emacs. Save 
your work before you
 ## Table of Contents
 * [Requirements](#1)
 * [Installation](#2)
-    * [ELPA](#2-1)
-    * [Manual](#2-2)
+    * [Manual](#2-1)
+    * [ELPA](#2-2)
 * [API](#3)
     * [sqlite3-open](#3-1)
     * [sqlite3-close](#3-2)
@@ -57,31 +57,31 @@ This is an alpha release so it might crash your Emacs. Save 
your work before you
 
 ## <a name="1"/> Requirements
 - Emacs 25.1 or above, compiled with module support (`./configure 
--with-modules`)
-- sqlite3 library and header file
+- SQLite3 v3.16.0 or above
 - A C99 compiler
 
 It's been tested on macOS (Sierra) and CentOS 7.
 ## <a name="2"/> Installation
-### <A NAME="2-1"/> ELPA
-<!--
-Install `sqlite3-api` from the MELPA Repository. To enable installation of 
packages from MELPA, follow the instructions 
[here](https://github.com/melpa/melpa#usage).
-
-After you install and `(require 'sqlite3-api)`, do a 
-`M-x sqlite3-api-install-dynamic-module`. This command will:
-1. Clone this repo to your local machine,
-1. Compile the source code to produce the dynamic module
-1. Create and install a package called sqlite3-api-module-x.y.z
--->
-Coming Soon
-### <a name="2-2"/> Manual
+### <a name="2-1"/> Manual
 ~~~sh
 $ git co https://github.com/pekingduck/emacs-sqlite3-api
 $ cd emacs-sqlite3-api
 $ make
-$ cp sqlite3-api.el tools/sqlite3-api-constants.el sqlite3-api-module.so 
/your/elisp/load-path/
+$ cp sqlite3-api.so /your/elisp/load-path/
 ~~~
-A copy of `emacs-module.h` is included in this repo so Emacs source tree
-is not needed to build the module.
+### <A NAME="2-2"/> ELPA
+~~~sh
+$ git co https://github.com/pekingduck/emacs-sqlite3-api
+$ cd emacs-sqlite3-api
+$ make module
+~~~
+A tar archive called `sqlite3-api-X.Y.tar` will be created. Do a `M-x 
package-install-file` in Emacs to install that tar archive and 
+you'll all set.
+
+Currently there's no way to reload a dynamic module in Emacs
+(`unload-feature` doesn't seem to work for dynamic module.)
+If you are updating from an older version, you'll need to restart Emacs
+for the new module to take effect.
 
 ## <A NAME="3"/> API
 To load the package, put the following in your `.emacs`:
@@ -243,7 +243,7 @@ Return number of columns in a result set.
 ~~~e1
 (sqlite3-column-type statement-handle column-no)
 ~~~
-Return the type (`sqlite-integer`, `sqlite-float`, `sqlite-text` or
+Return the type (`sqlite-integer`, `sqlite-float`, `sqlite3-text` or
 `sqlite-null`) of the specified column. 
 
 Note: Column number starts from 0.
@@ -309,7 +309,7 @@ to manually free database/statement handles once they are 
not needed.
 ## <a name="7"/> Known Problems
 - SQLite3 supports 64 bit integers but Emacs integers are only 61 bits.
 For integers > 61 bits you can retrieve them as text as a workaround.
-- BLOB/TEXT columns with embedded NULLs are not supported.
+- BLOB and TEXT columns with embedded NULLs are not supported.
 
 ## <a name="8"/> License
 The code is licensed under the [GNU GPL 
v3](https://www.gnu.org/licenses/gpl-3.0.html).
diff --git a/sqlite3-api-module.c b/sqlite3-api.c
similarity index 96%
rename from sqlite3-api-module.c
rename to sqlite3-api.c
index 28ec06320d..84d27319fd 100644
--- a/sqlite3-api-module.c
+++ b/sqlite3-api.c
@@ -20,7 +20,6 @@
 #include <float.h>
 #include "emacs-module.h"
 
-
 int plugin_is_GPL_compatible;
 
 #define NON_LOCAL_EXIT_CHECK(env) \
@@ -914,6 +913,36 @@ static emacs_value sqlite3_api_open(
   return env->make_user_ptr(env, sqlite3_dbh_gc, dbh);
 }
 
+/* (define-error err_sym err_desc) */
+static void define_error(
+    emacs_env *env,
+    const char *err_sym,
+    const char *err_desc) {
+  emacs_value argv[] = {
+    SYM(env, err_sym),
+    env->make_string(env, err_desc, strlen(err_desc))
+  };
+  env->funcall(env, SYM(env, "define-error"), 2, argv);
+}
+
+/* Since defconst is a special form, we need to do:
+   (eval (list '(defconst sym val)))
+   Reference: https://phst.github.io/emacs-modules#funcall
+ */
+static void defconst(emacs_env *env, const char *sym, emacs_value val) {
+  emacs_value list_argv[] = {
+    SYM(env, "defconst"),
+    SYM(env, sym),
+    val
+  };
+  emacs_value form = make_list(env, 3, list_argv);
+  emacs_value eval_argv[] = { form, SYM(env, "t") };
+  env->funcall(env, SYM(env, "eval"), 2, eval_argv);
+  /* if (env->non_local_exit_check (env) == emacs_funcall_exit_return) { */
+  /*   fprintf(stderr, "SCREWED: %s\n", sym); */
+  /* } */
+}
+
 int emacs_module_init(struct emacs_runtime *ert) {
     emacs_env *env = ert->get_environment(ert);
 
@@ -1001,9 +1030,15 @@ int emacs_module_init(struct emacs_runtime *ert) {
     }
     sqlite3_api_log_level = SQLITE3_LOG_LEVEL_ERROR;
 
+
+#include "consts.c"
+
+    define_error(env, "db-error", "Database Error");
+    define_error(env, "sql-error", "SQL Error");
+
     /* (provide 'sqlite3-module ) */
     emacs_value provide = SYM(env, "provide");
-    emacs_value mod = SYM(env, "sqlite3-api-module");
+    emacs_value mod = SYM(env, "sqlite3-api");
     env->funcall(env, provide, 1, &mod);
     return 0;
 }
diff --git a/sqlite3-api.el b/sqlite3-api.el
deleted file mode 100644
index 89dac49558..0000000000
--- a/sqlite3-api.el
+++ /dev/null
@@ -1,82 +0,0 @@
-;;; sqlite3-api.el --- Provides access to SQLite3 C API
-;;
-;; Author: Peking Duck <github.com/pekingduck>
-;; Version: 0.0.1
-;; Package-Requires: ((emacs "25.1"))
-;; Keywords: data, extensions
-;; URL: https://github.com/pekingduck/emacs-sqlite3-api
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;; This package provides access to SQLite3 C API via dynamic module.
-;; After installing this package, you should do a
-;; M-x sqlite3-api-install-dynamic-module to install the actual
-;; dynamic module.
-;;
-;; Visit https://github.com/pekingduck/emacs-sqlite3-api for
-;; documentation.
-
-;;; Code:
-
-;; sqlite-* constants
-(require 'sqlite3-api-constants nil t)
-
-;; Dynamic module
-(require 'sqlite3-api-module nil t)
-
-;; Error signals raised by the dynamic module
-(define-error 'db-error "Database Error")
-(define-error 'sql-error "SQL Error")
-
-;; Install dynamic module
-(defun sqlite3-api-install-dynamic-module ()
-  "Install sqlite3-api-module from github."
-  (interactive)
-  (let ((log-buffer "*sqlite3-api-install-log*")
-       (err-buffer "*sqlite3-api-install-error*")
-       (tmp-dir (make-temp-file "sqlite3-api" t))
-       (cur-dir default-directory)
-       (repo-url "https://github.com/pekingduck/emacs-sqlite3-api";)
-       (tar))
-    (unwind-protect
-       (condition-case err
-           (progn
-             (when (get-buffer log-buffer)
-               (kill-buffer log-buffer))
-             (when (get-buffer err-buffer)
-               (kill-buffer err-buffer))
-             (cd tmp-dir)
-             (shell-command (format "git clone %s" repo-url)
-                            log-buffer err-buffer)
-             (cd "emacs-sqlite3-api")
-             ;; compile the module and create a tar archive
-             (shell-command "make module" log-buffer err-buffer)
-             ;; A file called "MODULE" is created in the previous step
-             ;; and it contains the name of the tar file
-             (setq tar (with-temp-buffer
-                         (insert-file-contents "MODULE")
-                         (buffer-substring-no-properties
-                          (point-min)
-                          (1- (point-max)))))
-             (package-install-file tar)
-             (require 'sqlite3-api-module)
-             (message "%s successfully installed" (file-name-base tar)))
-         (error
-          (message "Installation aborted: %S" err)))
-      (delete-directory tmp-dir t)
-      (cd cur-dir))))
-
-(provide 'sqlite3-api)
-;;; sqlite3-api.el ends here
diff --git a/test/regression.el b/tests/regression.el
similarity index 100%
rename from test/regression.el
rename to tests/regression.el
diff --git a/tools/find-sqlite3-h.sh b/tools/find-sqlite3-h.sh
new file mode 100755
index 0000000000..082a454f95
--- /dev/null
+++ b/tools/find-sqlite3-h.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo '#include <sqlite3.h>' | gcc -x c -H -fsyntax-only - 2>&1 | grep '^\. ' | 
cut -f2 -d' '
diff --git a/tools/gen-consts.py b/tools/gen-consts.py
index 74f57a84f9..0a80786cc8 100755
--- a/tools/gen-consts.py
+++ b/tools/gen-consts.py
@@ -4,22 +4,12 @@ import sys
 import os
 import re
 
-c_src="""
-#include <stdio.h>
-#include <sqlite3.h>
-
-int main(int argc, char *argv[]) {
-"""
-print(c_src)
 for line in sys.stdin.readlines():
   line.rstrip()
   fields = re.split("\s+", line, 3)
   name = re.sub("_", "-", fields[1].lower())
   if len(fields) > 2 and fields[2] != "":
-    #print("<{0}>-<{1}>".format(fields[1], fields[2]), file=sys.stderr)
     if fields[2].startswith('"'):
-      print('  printf("(defconst {1} \\"%s\\")\\n", {0});'.format(fields[1], 
name))
+      print('defconst(env, "{0}", env->make_string(env, {1}, 
strlen({1})));'.format(name, fields[1]))
     else:
-      print('  printf("(defconst {1} %d)\\n", {0});'.format(fields[1], name))
-print('  printf("(provide \'sqlite3-api-constants)\\n");')
-print("}")
+      print('defconst(env, "{0}", env->make_integer(env, {1}));'.format(name, 
fields[1]))
diff --git a/tools/run.sh b/tools/run.sh
deleted file mode 100755
index ab77bb2e18..0000000000
--- a/tools/run.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-
-# This script generates sqlite3-api-constants.el.
-#
-# First all '#define SQLITE...' lines are extracted from sqlite3.h
-# Then gen-consts.py takes these lines and produces a .c that in turn
-# prints out a .el file.
-
-# locate the path to sqlite3.h
-SQLITE3_H=$(echo '#include <sqlite3.h>' | gcc -x c -H -fsyntax-only - 2>&1 | 
grep '^\. ' | cut -f2 -d' ')
-DEST=sqlite3-api-constants.el
-cat <<EOF > $DEST
-;;; sqlite3-api-constants.el --- Constants for SQLite3 API
-;;; Commentary:
-;; This package provides sqlite-* constants for sqlite3-api.
-;; The file is auto-generated. Do not edit.
-
-;; Author: Peking Duck <github.com/pekingduck>
-;; Version: $1
-;; Package-Requires: ((emacs "25.1"))
-;; Keywords: data, extensions
-;; URL: https://github.com/pekingduck/emacs-sqlite3-api
-
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-;;
-EOF
-
-EXE=./def
-
-rm -f $EXE ${EXE}.c
-grep "^#define SQLITE" $SQLITE3_H | ./gen-consts.py > ${EXE}.c
-gcc -o $EXE ${EXE}.c -lsqlite3
-${EXE} >> $DEST
-echo ";;; sqlite3-api-constants.el ends here" >> $DEST



reply via email to

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