m4-patches
[Top][All Lists]
Advanced

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

Re: module cleanup [2/n]


From: Eric Blake
Subject: Re: module cleanup [2/n]
Date: Fri, 07 Sep 2007 14:58:14 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 9/6/2007 4:56 PM:
> - We currently expose the libltdl interface to all clients of m4module.h.  
> That 
> is poor interface design
> 
> I'm starting a patch series to try to improve several points; the series may 
> be 
> a bit open-ended based on what else I discover.

> split this particular patch into smaller chunks.  I'm applying this:

Oops - I forgot to paste yesterday's changelog entry.

2007-09-06  Eric Blake  <address@hidden>

        Wrap lt_dlhandle in struct m4_module.
        * m4/m4module.h (includes): No longer require clients to know
        about lt_dlhandle.
        (m4_module): New opaque declaration.
        (m4_export): Delete unused type.
        (M4INIT_HANDLER, M4FINISH_HANDLER, m4_module_init_func)
        (m4_module_finish_func, m4_module_load, m4_get_module_name)
        (m4_builtin_find_by_name, m4_builtin_find_by_func): Use new
        wrapper.
        (m4_module_makeresident, m4_module_refcount): New declarations.
        * m4/m4private.h (includes): Move <ltdl.h> here.
        (m4_module): New declaration.  Simple for now, but intended for
        growth.
        (m4__module_open, m4__module_next, m4__module_find)
        (m4__symtab_remove_module_references): Use new wrapper.
        * m4/builtin.c (m4_builtin_find_by_name, m4_builtin_find_by_func):
        Likewise.
        * m4/module.c (m4_get_module_name, m4_module_import)
        (m4_module_load): Likewise.
        (install_builtin_table, install_macro_table): Likewise.  Also,
        change return type since these always returned NULL and no one
        used the result.
        (m4_module_makeresident, m4_module_refcount): New functions.
        (m4_module_unload, m4__module_next, m4__module_find): Use new
        wrapper.
        (m4__module_open): Populate new wrapper, and associate it with the
        lt_dlhandle.
        (m4__module_exit): Use new wrapper.
        (module_remove): Likewise.  Reclaim storage on last use.
        (module_close): Delete, and inline into module_remove.
        * m4/symtab.c (m4__symtab_remove_module_references): Use new
        wrapper.
        * modules/load.c (load_init): Use new API.
        * modules/m4.c (m4_export_table): Kill unused declaration.
        (m4_init): Use new API.
        * modules/shadow.c (shadow_init): Use new API.
        * src/main.c (main): Adjust callers.
        * src/freeze.c (reload_frozen_state): Likewise.
        * tests/modules.at (unload load module): New test.

Also, I missed some spots, hence this part 2:

2007-09-07  Eric Blake  <address@hidden>

        More conversion to m4_module*.
        * src/freeze.c (produce_module_dump, dump_symbol_CB)
        (reload_frozen_state): Use correct type.
        * m4/input.c (struct m4_input_block): Likewise.
        * m4/symtab.c (dump_symbol_CB): Likewise.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4btm84KuGfSFAYARAj0QAJ9zTaHLnrJyf/CR47IQHTGor7JEQQCeNeJt
ctkae2WcC20YMtgrswgbW7M=
=SqDC
-----END PGP SIGNATURE-----
Index: m4/input.c
===================================================================
RCS file: /sources/m4/m4/m4/input.c,v
retrieving revision 1.68
diff -u -p -r1.68 input.c
--- m4/input.c  7 Aug 2007 03:15:26 -0000       1.68
+++ m4/input.c  7 Sep 2007 20:48:06 -0000
@@ -163,7 +163,7 @@ struct m4_input_block
       struct
        {
          const m4_builtin *builtin;  /* pointer to builtin's function. */
-         lt_dlhandle handle;     /* originating module. */
+         m4_module *handle;      /* originating module. */
          int flags;              /* flags associated with the builtin. */
          m4_hash *arg_signature; /* argument signature for builtin.  */
          unsigned int min_args;  /* argv minima for the builtin. */
Index: m4/symtab.c
===================================================================
RCS file: /sources/m4/m4/m4/symtab.c,v
retrieving revision 1.75
diff -u -p -r1.75 symtab.c
--- m4/symtab.c 6 Sep 2007 22:58:26 -0000       1.75
+++ m4/symtab.c 7 Sep 2007 20:48:06 -0000
@@ -709,7 +709,7 @@ dump_symbol_CB (m4_symbol_table *symtab,
 {
   m4_symbol_value *value       = m4_get_symbol_value (symbol);
   int             flags        = value ? SYMBOL_FLAGS (symbol) : 0;
-  lt_dlhandle      handle      = value ? SYMBOL_HANDLE (symbol) : 0;
+  m4_module *      handle      = value ? SYMBOL_HANDLE (symbol) : NULL;
   const char *     module_name = handle ? m4_get_module_name (handle) : "NONE";
 
   fprintf (stderr, "%10s: (%d%s) %s=", module_name, flags,
Index: src/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.69
diff -u -p -r1.69 freeze.c
--- src/freeze.c        6 Sep 2007 22:58:26 -0000       1.69
+++ src/freeze.c        7 Sep 2007 20:48:06 -0000
@@ -29,7 +29,7 @@
 static void  produce_mem_dump          (FILE *, const char *, size_t);
 static void  produce_resyntax_dump     (m4 *, FILE *);
 static void  produce_syntax_dump       (FILE *, m4_syntax_table *, char);
-static void  produce_module_dump       (FILE *, lt_dlhandle);
+static void  produce_module_dump       (FILE *, m4_module *);
 static void  produce_symbol_dump       (m4 *, FILE *, m4_symbol_table *);
 static void *dump_symbol_CB            (m4_symbol_table *, const char *,
                                         m4_symbol *, void *);
@@ -131,7 +131,7 @@ produce_syntax_dump (FILE *file, m4_synt
    reloaded from the frozen file.  libltdl stores handles in a push
    down stack, so we need to dump them in the reverse order to that.  */
 static void
-produce_module_dump (FILE *file, lt_dlhandle handle)
+produce_module_dump (FILE *file, m4_module *handle)
 {
   const char *name = m4_get_module_name (handle);
   size_t len = strlen (name);
@@ -159,7 +159,7 @@ static void *
 dump_symbol_CB (m4_symbol_table *symtab, const char *symbol_name,
                m4_symbol *symbol, void *userdata)
 {
-  lt_dlhandle   handle         = SYMBOL_HANDLE (symbol);
+  m4_module *   handle         = SYMBOL_HANDLE (symbol);
   const char   *module_name    = handle ? m4_get_module_name (handle) : NULL;
   FILE *       file            = (FILE *) userdata;
   size_t       symbol_len      = strlen (symbol_name);
@@ -549,7 +549,7 @@ ill-formed frozen file, version 2 direct
 
          /* Enter a macro having a builtin function as a definition.  */
          {
-           lt_dlhandle handle   = 0;
+           m4_module *handle = NULL;
            m4_symbol_value *token;
 
            if (number[2] > 0)
@@ -750,14 +750,14 @@ ill-formed frozen file, version 2 direct
          /* Enter a macro having an expansion text as a definition.  */
          {
            m4_symbol_value *token = xzalloc (sizeof *token);
-           lt_dlhandle handle = 0;
+           m4_module *handle = NULL;
 
            if (number[2] > 0)
              handle = m4__module_find (string[2]);
 
            m4_set_symbol_value_text (token, xstrdup (string[1]));
-           VALUE_HANDLE (token)                = handle;
-           VALUE_MAX_ARGS (token)      = -1;
+           VALUE_HANDLE (token) = handle;
+           VALUE_MAX_ARGS (token) = -1;
 
            m4_symbol_pushdef (M4SYMTAB, string[0], token);
          }

reply via email to

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