emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master d2e1bac 1/2: Move definition of Lisp_Module_Functio


From: Philipp Stephani
Subject: [Emacs-diffs] master d2e1bac 1/2: Move definition of Lisp_Module_Function to emacs-module.c.
Date: Wed, 24 Apr 2019 17:14:41 -0400 (EDT)

branch: master
commit d2e1bac47816fa1f48482faeebf7fa562a5b0e40
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Move definition of Lisp_Module_Function to emacs-module.c.
    
    * src/lisp.h: Remove include of emacs-module.h.  Remove definition
    of Lisp_Module_Function structure.
    
    * src/emacs-module.c (module_function_documentation)
    (module_function_address): New accessor functions for module function
    fields.
    (emacs_subr, struct Lisp_Module_Function): Move from lisp.h.
    
    * src/print.c (print_vectorlike):
    * src/doc.c (Fdocumentation): Use the new accessor functions.
---
 src/doc.c          |  4 +++-
 src/emacs-module.c | 36 ++++++++++++++++++++++++++++++++++++
 src/lisp.h         | 30 ++++--------------------------
 src/print.c        |  4 ++--
 4 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/src/doc.c b/src/doc.c
index 372e376..3fa0eaa 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -337,8 +337,10 @@ string is passed through `substitute-command-keys'.  */)
     fun = XCDR (fun);
   if (SUBRP (fun))
     doc = make_fixnum (XSUBR (fun)->doc);
+#ifdef HAVE_MODULES
   else if (MODULE_FUNCTIONP (fun))
-    doc = XMODULE_FUNCTION (fun)->documentation;
+    doc = module_function_documentation (XMODULE_FUNCTION (fun));
+#endif
   else if (COMPILEDP (fun))
     {
       if (PVSIZE (fun) <= COMPILED_DOC_STRING)
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 41ce9ef..b6a1238 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -471,6 +471,30 @@ module_non_local_exit_throw (emacs_env *env, emacs_value 
tag, emacs_value value)
                                   value_to_lisp (value));
 }
 
+/* Function prototype for the module Lisp functions.  */
+typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
+                                  emacs_value [], void *);
+
+/* Module function.  */
+
+/* A function environment is an auxiliary structure returned by
+   `module_make_function' to store information about a module
+   function.  It is stored in a pseudovector.  Its members correspond
+   to the arguments given to `module_make_function'.  */
+
+struct Lisp_Module_Function
+{
+  union vectorlike_header header;
+
+  /* Fields traced by GC; these must come first.  */
+  Lisp_Object documentation;
+
+  /* Fields ignored by GC.  */
+  ptrdiff_t min_arity, max_arity;
+  emacs_subr subr;
+  void *data;
+} GCALIGNED_STRUCT;
+
 static struct Lisp_Module_Function *
 allocate_module_function (void)
 {
@@ -901,6 +925,18 @@ module_function_arity (const struct Lisp_Module_Function 
*const function)
                maxargs == MANY ? Qmany : make_fixnum (maxargs));
 }
 
+Lisp_Object
+module_function_documentation (const struct Lisp_Module_Function *function)
+{
+  return function->documentation;
+}
+
+void *
+module_function_address (const struct Lisp_Module_Function *function)
+{
+  return function->subr;
+}
+
 
 /* Helper functions.  */
 
diff --git a/src/lisp.h b/src/lisp.h
index 70b2aa2..8dc4429 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4151,32 +4151,8 @@ extern void *unexec_realloc (void *, size_t);
 extern void unexec_free (void *);
 #endif
 
-#define EMACS_MODULE_GMP
-#include "emacs-module.h"
-
-/* Function prototype for the module Lisp functions.  */
-typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
-                                  emacs_value [], void *);
-
-/* Module function.  */
-
-/* A function environment is an auxiliary structure returned by
-   `module_make_function' to store information about a module
-   function.  It is stored in a pseudovector.  Its members correspond
-   to the arguments given to `module_make_function'.  */
-
-struct Lisp_Module_Function
-{
-  union vectorlike_header header;
-
-  /* Fields traced by GC; these must come first.  */
-  Lisp_Object documentation;
-
-  /* Fields ignored by GC.  */
-  ptrdiff_t min_arity, max_arity;
-  emacs_subr subr;
-  void *data;
-} GCALIGNED_STRUCT;
+/* The definition of Lisp_Module_Function depends on emacs-module.h,
+   so we don't define it here.  It's defined in emacs-module.c.  */
 
 INLINE bool
 MODULE_FUNCTIONP (Lisp_Object o)
@@ -4198,6 +4174,8 @@ extern Lisp_Object make_user_ptr (void (*finalizer) (void 
*), void *p);
 /* Defined in emacs-module.c.  */
 extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
 extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
+extern Lisp_Object module_function_documentation (const struct 
Lisp_Module_Function *);
+extern void *module_function_address (const struct Lisp_Module_Function *);
 extern void mark_modules (void);
 extern void init_module_assertions (bool);
 extern void syms_of_module (void);
diff --git a/src/print.c b/src/print.c
index 081e557..8b163e3 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1787,8 +1787,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
     case PVEC_MODULE_FUNCTION:
       {
        print_c_string ("#<module function ", printcharfun);
-       void *ptr = XMODULE_FUNCTION (obj)->subr;
-       const char *file = NULL;
+        void *ptr = module_function_address (XMODULE_FUNCTION (obj));
+        const char *file = NULL;
        const char *symbol = NULL;
        dynlib_addr (ptr, &file, &symbol);
 



reply via email to

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