[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pq 5fcaa751f2 13/63: Cleanup prototype definitions.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pq 5fcaa751f2 13/63: Cleanup prototype definitions. |
Date: |
Mon, 14 Feb 2022 23:24:19 -0500 (EST) |
branch: externals/pq
commit 5fcaa751f2ffccda3de2470339a41f35c07619da
Author: Andreas Seltenreich <andreas+git@ansel.ydns.eu>
Commit: Andreas Seltenreich <andreas+git@ansel.ydns.eu>
Cleanup prototype definitions.
- Do it like the romans do in emacs/modules/mod-test.c.
- Fix Fpq_escape maximum argument number.
- Get rid of more global vars.
---
pq.c | 71 ++++++++++++++++++++++++--------------------------------------------
1 file changed, 25 insertions(+), 46 deletions(-)
diff --git a/pq.c b/pq.c
index 3a62ee4b61..6e68ad6357 100644
--- a/pq.c
+++ b/pq.c
@@ -6,13 +6,10 @@
#include <stdlib.h>
#include <assert.h>
-#define MAX_PARAMS 12
+#define MAX_PQ_PARAMS 12
void *plugin_is_GPL_compatible;
-static struct emacs_runtime *ert;
-static emacs_env *env;
-
static emacs_value Qnil;
static emacs_value Qt;
@@ -188,7 +185,7 @@ Fpq_escape (emacs_env *env, int nargs, emacs_value args[],
void *data)
/* Bind NAME to FUN. */
static void
-bind_function (const char *name, emacs_value Sfun)
+bind_function (emacs_env *env, const char *name, emacs_value Sfun)
{
/* Set the function cell of the symbol named NAME to SFUN using
the 'fset' function. */
@@ -206,7 +203,7 @@ bind_function (const char *name, emacs_value Sfun)
/* Provide FEATURE to Emacs. */
static void
-provide (const char *feature)
+provide (emacs_env *env, const char *feature)
{
/* call 'provide' with FEATURE converted to a symbol */
@@ -218,51 +215,33 @@ provide (const char *feature)
}
int
-emacs_module_init (struct emacs_runtime *init_ert)
+emacs_module_init (struct emacs_runtime *ert)
{
- ert = init_ert;
- env = ert->get_environment(ert);
-
- emacs_value fun1 = env->make_function (env,
- 0, /* min. number of arguments */
- 1, /* max. number of arguments */
- Fpq_connectdb, /* actual function pointer */
- "Connect to PostgreSQL database described by CONNSTR.",
/* docstring */
- NULL /* user pointer of your choice (data param in
Fmymod_test) */
- );
- bind_function("pq:connectdb", fun1);
-
- emacs_value fun7 = env->make_function (env,
- 2, /* min. number of arguments */
- 2+MAX_PARAMS, /* max. number of arguments */
- Fpq_query, /* actual function pointer */
- "Execute QUERY on CONNECTION.", /* docstring */
- NULL /* user pointer of your choice (data param in
Fmymod_test) */
- );
- bind_function("pq:query", fun7);
-
- emacs_value fun10 = env->make_function (env,
- 2, /* min. number of arguments */
- 2+MAX_PARAMS, /* max. number of arguments */
- Fpq_escape, /* actual function pointer */
- "Perform literal value quoting on STRING for CONN.", /*
docstring */
- PQescapeLiteral /* user pointer of your choice (data param in
Fmymod_test) */
- );
- bind_function("pq:escapeLiteral", fun10);
-
- emacs_value fun11 = env->make_function (env,
- 2, /* min. number of arguments */
- 2+MAX_PARAMS, /* max. number of arguments */
- Fpq_escape, /* actual function pointer */
- "Perform identifier quoting on STRING for CONN.", /*
docstring */
- PQescapeIdentifier /* user pointer of your choice (data param
in Fmymod_test) */
- );
- bind_function("pq:escapeIdentifier", fun11);
+ emacs_env *env = ert->get_environment(ert);
+
+#define DEFUN(lsym, csym, amin, amax, doc, data) \
+ bind_function (env, lsym, \
+ env->make_function (env, amin, amax, csym, doc, data))
+ DEFUN("pq:connectdb", Fpq_connectdb, 0, 1,
+ "Connect to PostgreSQL database described by CONNSTR.",
+ NULL);
+
+ DEFUN("pq:query", Fpq_query, 2, 2+MAX_PQ_PARAMS,
+ "Execute QUERY on CONNECTION with optional PARAMETERS",
+ NULL);
+
+ DEFUN("pq:escapeLiteral", Fpq_escape, 2, 2,
+ "Perform literal value quoting on STRING for CONN.",
+ PQescapeLiteral);
+
+ DEFUN("pq:escapeIdentifier", Fpq_escape, 2, 2,
+ "Perform identifier value quoting on STRING for CONN.",
+ PQescapeIdentifier);
Qnil = env->intern (env, "nil");
Qt = env->intern (env, "t");
- provide("pq");
+ provide(env, "pq");
/* loaded successfully */
return 0;
- [elpa] branch externals/pq created (now 04c91e8374), ELPA Syncer, 2022/02/14
- [elpa] externals/pq 03c4dbf3f9 04/63: Add pq:getrow., ELPA Syncer, 2022/02/14
- [elpa] externals/pq f743c450ac 09/63: Set application_name., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8cbe2e24fc 36/63: Make test notice-receiver more robust., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 5fcaa751f2 13/63: Cleanup prototype definitions.,
ELPA Syncer <=
- [elpa] externals/pq d6e3746c80 40/63: Skip encoding test unless supported by server., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 69d6fba048 06/63: Make argument to pq:connectdb optional., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 37e21db4c2 41/63: Shuffle tests, make gc test emit more info on failure., ELPA Syncer, 2022/02/14
- [elpa] externals/pq cdc04b0b61 27/63: Add missing PQclear calls, ELPA Syncer, 2022/02/14
- [elpa] externals/pq 6f6d8728e5 38/63: Test expected error on invalid encoding., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 527e544165 46/63: Improve error handling on connection failure., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 7a15153e8d 58/63: Protect against NULL SQLSTATE., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 966a05ef25 07/63: Initialize client_encoding to utf8., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 2f63308225 24/63: Use PQexec instead of PQexecParams when no parameters are specified., ELPA Syncer, 2022/02/14
- [elpa] externals/pq a70d1fe40d 37/63: Test encoding by using some high unicode codepoints., ELPA Syncer, 2022/02/14