guile-user
[Top][All Lists]
Advanced

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

Re: Any fix for define-public/export failure in dynamic modules (1.3)?


From: Rob Browning
Subject: Re: Any fix for define-public/export failure in dynamic modules (1.3)?
Date: 17 Jan 2001 16:53:52 -0600
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Rob Browning <address@hidden> writes:

> In 1.3.4 and in 1.4, if you put a 
> 
>   gh_eval_str("(define-public foo bar)");
> 
> into the initialization function for a dynamically loaded .so module,
> you get the right effect, presuming you've also already done this:
> 
>     /* guile currently gives dlopened modules an empty environment
>        so here we add in the default one so things you think should work
>        will. */
>     gh_call2(gh_lookup("set-module-uses!"),
>              gh_call0(gh_lookup("current-module")),
>              gh_list(gh_lookup("the-scm-module"),
>                      SCM_UNDEFINED));
> 
> However, in 1.3, any call to define-public or export fails because the
> public interface for the current module is still #f (i.e. public-i,
> which is set from (module-public-interface (current-module)), is #f.

OK, continuing my tradition of following myself up :> Here's the fix I
found (and it corresponds roughly to the code changes in guile
1.3->1.4).

Here's the new code g-wrap inserts in the initialization segment of a
module:

    if(gw_file_being_loaded_as_a_guile_module_p) {
      /* guile currently gives dlopened modules an empty environment
         so here we add in the default one so things you think should work
         will. */
      gh_call2(gh_lookup("set-module-uses!"),
               gh_call0(gh_lookup("current-module")),
               gh_list(gh_lookup("the-scm-module"),
                       SCM_UNDEFINED));
      
      /* guile 1.3 doesn't initialize the module's public interface.
         This was fixed in later versions. */
      if(gh_string_equal_p(gh_str02scm("1.3"), gh_eval_str("(version)"))) {
        char *cmd =
          "(set-module-public-interface! (current-module) (current-module))";
        gh_eval_str(cmd);
      }
    }

Thanks, and please let me know if this is BAD(TM).

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

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