Re: %module-public-interface

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: %module-public-interface

Ian Hulin
Hi Andy,

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

> Hi Ian,
>
> On Fri 02 Apr 2010 02:11, Ian Hulin<[hidden email]>  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!

Reply | Threaded
Open this post in threaded view
|

Re: %module-public-interface

Valentin Villenave
Administrator
On Sat, May 15, 2010 at 10:32 PM, Ian Hulin <[hidden email]> wrote:
> 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.

By the way (sorry for having missed this thread earlier): the
appropriate tracker page is
http://code.google.com/p/lilypond/issues/detail?id=1055

(Just for the list's archive sake :)

Cheers,
Valentin

---
----
Join the Frogs!