DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Dia Structure

Info Catalog (guile.info.gz) Dia Hook (guile.info.gz) Extending Dia (guile.info.gz) Dia Advanced
 
 17.1.6 Top-level Structure of Guile-enabled Dia
 -----------------------------------------------
 
 Let's assume that the pre-Guile Dia code looks structurally like this:
 
    * `main ()'
 
         * do lots of initialization and setup stuff
 
         * enter Gtk main loop
 
    When you add Guile to a program, one (rather technical) requirement
 is that Guile's garbage collector needs to know where the bottom of the
 C stack is.  The easiest way to ensure this is to use `scm_boot_guile'
 like this:
 
    * `main ()'
 
         * do lots of initialization and setup stuff
 
         * `scm_boot_guile (argc, argv, inner_main, NULL)'
 
    * `inner_main ()'
 
         * define all SMOB types
 
         * export primitives to Scheme using `scm_c_define_gsubr'
 
         * enter Gtk main loop
 
    In other words, you move the guts of what was previously in your
 `main' function into a new function called `inner_main', and then add a
 `scm_boot_guile' call, with `inner_main' as a parameter, to the end of
 `main'.
 
    Assuming that you are using SMOBs and have written primitive code as
 described in the preceding subsections, you also need to insert calls to
 declare your new SMOBs and export the primitives to Scheme.  These
 declarations must happen _inside_ the dynamic scope of the
 `scm_boot_guile' call, but also _before_ any code is run that could
 possibly use them -- the beginning of `inner_main' is an ideal place
 for this.
 
Info Catalog (guile.info.gz) Dia Hook (guile.info.gz) Extending Dia (guile.info.gz) Dia Advanced
automatically generated byinfo2html