[frogs] Re: %module-public-interface

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Hi Andy,

On 27/04/10 21:34, Andy Wingo wrote:
Hi Ian,

On Fri 02 Apr 2010 02:11, Ian Hulin<ian@xxxxxxxxxxxx>  writes:

On 30/03/10 22:52, Ludovic � wrote:

Lilypond does:

--8<---------------cut here---------------start------------->8---
        mod = scm_call_0 (maker);
        scm_module_define (mod, ly_symbol2scm ("%module-public-interface"),
                           mod);
--8<---------------cut here---------------end--------------->8---

Solution: do something like:

--8<---------------cut here---------------start------------->8---
#ifdef HAVE_SCM_SET_MODULE_PUBLIC_INTERFACE_X
    scm_set_module_public_interface_x (mod, mod);
#else
    scm_module_define (mod, ly_symbol2scm ("%module-public-interface"),
                       mod);
#endif
--8<---------------cut here---------------end--------------->8---

(We just need to add that function.)

As it appears here that you are trying to export everything from that
module (in a somewhat incorrect formulation -- I can explain if you
like), and that seems to be a sort of pattern, I'd suggest that instead
we offer a module-export-all! function. Here is some code to provide
such a function for pre-2.0 guile:

     (cond-expand
       ((not guile-2)
        (define (module-export-all! mod)
          (define (fresh-interface!)
            (let ((iface (make-module)))
              (set-module-name! iface (module-name mod))
              ;; for guile 2: (set-module-version! iface (module-version mod))
              (set-module-kind! iface 'interface)
              (set-module-public-interface! mod iface)
              iface))
          (let ((iface (or (module-public-interface mod)
                           (fresh-interface!))))
            (set-module-obarray! iface (module-obarray mod))))))

Use that to export all bindings instead. As it is, there are some shims
for %module-public-interface hackery to keep on working if deprecated
code is compiled in, but you should migrate to calling
module-export-all!, I think.

Then your C code would unconditionally:

    scm_call_1 (scm_variable_ref (module_export_all_var), mod);

Regards,

Andy

Lilypond currently has a patch submitted to use your suggested guile code to avoid using the reference to %module-public-interface in Lilypond C++ code.

Please can you confirm that module-export-all! will be supplied in Guile V2.0.

Cheers,
Ian Hulin


---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/