emacs-diffs
[Top][All Lists]
Advanced

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

scratch/func-type-decls 55b617c57c7 1/2: Add optional arg to DEFUN to st


From: Andrea Corallo
Subject: scratch/func-type-decls 55b617c57c7 1/2: Add optional arg to DEFUN to store the declared function type
Date: Fri, 23 Feb 2024 04:27:12 -0500 (EST)

branch: scratch/func-type-decls
commit 55b617c57c76e634c1a85b6062b3c88389808519
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    Add optional arg to DEFUN to store the declared function type
---
 src/data.c    |  8 ++++++++
 src/lisp.h    | 18 ++++++++++--------
 src/pdumper.c |  1 +
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/data.c b/src/data.c
index f2f35fb355a..9e8c00a31e6 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1036,6 +1036,14 @@ DEFUN ("subr-type", Fsubr_type,
   (Lisp_Object subr)
 {
   CHECK_SUBR (subr);
+
+  const char *declared_type = XSUBR (subr)->declared_type;
+  if (declared_type && strcmp (declared_type, ""))
+    {
+      AUTO_STRING (str, declared_type);
+      return Fread (str);
+    }
+
 #ifdef HAVE_NATIVE_COMP
   return SUBR_TYPE (subr);
 #else
diff --git a/src/lisp.h b/src/lisp.h
index b02466390f1..5eca78542ac 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2190,6 +2190,7 @@ struct Lisp_Subr
       Lisp_Object native;
     } intspec;
     Lisp_Object command_modes;
+    const char *declared_type;
     EMACS_INT doc;
 #ifdef HAVE_NATIVE_COMP
     Lisp_Object native_comp_u;
@@ -3294,17 +3295,18 @@ CHECK_SUBR (Lisp_Object x)
     If it's a string that doesn't start with `(', the value should follow
     the one of the doc string for `interactive'.
     A null string means call interactively with no arguments.
- `doc' is documentation for the user.  */
+ `doc' is documentation for the user.
+ `type' is the optional argument for the declared type of the function.  */
 
 /* This version of DEFUN declares a function prototype with the right
    arguments, so we can catch errors with maxargs at compile-time.  */
-#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
-  SUBR_SECTION_ATTRIBUTE                                            \
-  static union Aligned_Lisp_Subr sname =                            \
-     {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                            \
-       { .a ## maxargs = fnname },                                 \
-       minargs, maxargs, lname, {intspec}, lisp_h_Qnil}};          \
-   Lisp_Object fnname
+#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc, ...)       
\
+  SUBR_SECTION_ATTRIBUTE                                                      \
+  static union Aligned_Lisp_Subr sname =                                      \
+    {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                                \
+      { .a ## maxargs = fnname },                                             \
+      minargs, maxargs, lname, {intspec}, lisp_h_Qnil, #__VA_ARGS__ }};        
       \
+  Lisp_Object fnname
 
 /* defsubr (Sname);
    is how we define the symbol for function `name' at start-up time.  */
diff --git a/src/pdumper.c b/src/pdumper.c
index 509fb079db7..3769df80740 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2936,6 +2936,7 @@ dump_subr (struct dump_context *ctx, const struct 
Lisp_Subr *subr)
       dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
       dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec.string);
       dump_field_emacs_ptr (ctx, &out, subr, &subr->command_modes);
+      dump_field_emacs_ptr (ctx, &out, subr, &subr->declared_type);
     }
   DUMP_FIELD_COPY (&out, subr, doc);
 #ifdef HAVE_NATIVE_COMP



reply via email to

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