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

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

[nongnu] elpa/sqlite3 77e719fb88 24/62: better comments


From: ELPA Syncer
Subject: [nongnu] elpa/sqlite3 77e719fb88 24/62: better comments
Date: Tue, 14 Mar 2023 11:01:46 -0400 (EDT)

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

    better comments
---
 README-in.md            |  4 +++-
 sqlite3-api.c           | 16 +++++++++-------
 tools/find-sqlite3-h.sh |  1 +
 tools/gen-consts.py     |  7 ++++---
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/README-in.md b/README-in.md
index fcca28c6ca..ffbf18cd9d 100644
--- a/README-in.md
+++ b/README-in.md
@@ -51,7 +51,7 @@ A tar archive called `sqlite3-api-X.Y.tar` will be created. 
Do a `M-x package-in
 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.)
+(`unload-feature` doesn't seem to work for dynamic modules.)
 If you are updating from an older version, you'll need to restart Emacs
 for the new module to take effect.
 
@@ -287,6 +287,8 @@ For integers > 61 bits you can retrieve them as text as a 
workaround.
 The code is licensed under the [GNU GPL 
v3](https://www.gnu.org/licenses/gpl-3.0.html).
 
 ## Changelog
+*2017-09-04*
+- Emacs Lisp code removed. The package is now pure C.
 *2017-08-29*
 - Fixed a memory leak in `sql_api_exec()`
 - Changed `sqlite3_close()` to `sqlite3_close_v2()` in `sqlite_api_close()`
diff --git a/sqlite3-api.c b/sqlite3-api.c
index 84d27319fd..27718e143a 100644
--- a/sqlite3-api.c
+++ b/sqlite3-api.c
@@ -120,7 +120,8 @@ static void message(emacs_env *env, int log_level, const 
char *fmt, ...) {
   fprintf(stderr, "\n");
 }
 
-/* Equivalent to (signal symbol '(msg code)) in elisp */
+/* Signal an error condition.
+   Equivalent to (signal symbol '(msg code)) in elisp */
 void signal_error(
     emacs_env *env,
     const char *symbol,
@@ -925,8 +926,11 @@ static void define_error(
   env->funcall(env, SYM(env, "define-error"), 2, argv);
 }
 
-/* Since defconst is a special form, we need to do:
-   (eval (list '(defconst sym val)))
+/* Since defconst is a special form, args are NOT evaluated. Hence
+   eval is needed:
+
+   (eval (list '(defconst sym val)) t)
+
    Reference: https://phst.github.io/emacs-modules#funcall
  */
 static void defconst(emacs_env *env, const char *sym, emacs_value val) {
@@ -938,9 +942,6 @@ static void defconst(emacs_env *env, const char *sym, 
emacs_value 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) {
@@ -1030,7 +1031,8 @@ int emacs_module_init(struct emacs_runtime *ert) {
     }
     sqlite3_api_log_level = SQLITE3_LOG_LEVEL_ERROR;
 
-
+    /* consts.c includes all the (defconst sqlite-xxx ....) function
+       calls which is generated by tools/gen-consts.py */
 #include "consts.c"
 
     define_error(env, "db-error", "Database Error");
diff --git a/tools/find-sqlite3-h.sh b/tools/find-sqlite3-h.sh
index 082a454f95..ff13bbc6ff 100755
--- a/tools/find-sqlite3-h.sh
+++ b/tools/find-sqlite3-h.sh
@@ -1,2 +1,3 @@
 #!/bin/bash
+# locate the path of sqlite3.h
 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 0a80786cc8..863b0a6e9d 100755
--- a/tools/gen-consts.py
+++ b/tools/gen-consts.py
@@ -6,10 +6,11 @@ import re
 
 for line in sys.stdin.readlines():
   line.rstrip()
+  # fields = [ "#define", "SQLITE_XXXX" "YYYY" ];
   fields = re.split("\s+", line, 3)
-  name = re.sub("_", "-", fields[1].lower())
+  sym = re.sub("_", "-", fields[1].lower())
   if len(fields) > 2 and fields[2] != "":
     if fields[2].startswith('"'):
-      print('defconst(env, "{0}", env->make_string(env, {1}, 
strlen({1})));'.format(name, fields[1]))
+      print('defconst(env, "{0}", env->make_string(env, {1}, 
strlen({1})));'.format(sym, fields[1]))
     else:
-      print('defconst(env, "{0}", env->make_integer(env, {1}));'.format(name, 
fields[1]))
+      print('defconst(env, "{0}", env->make_integer(env, {1}));'.format(sym, 
fields[1]))



reply via email to

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