This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: call a C-routine as a Scheme function?


jostobfe@linux.zrz.TU-Berlin.DE writes:
> But I think it's better to modularize your project, i.e.  use the
> snarfer instead of explicit calls to gh_new_procedure() and such.

One of the (few) advantages of C++ is the existence of global
constructors. I never use snarfing, because I think that the scripts
are an additional point of failure.

    #define ADD_SCM_INIT_FUNC(name, func)\
    class name ## _scm_initter {		\
    public:\
      name ## _scm_initter ()			\
        {							\
	    add_scm_init_func (func);
    \
      }						\
      } _ ## name ## _scm_initter;				\
      /* end define */

      #define GLOBAL_SYMBOL(cname, name)  \
      SCM cname ;						\
      void \
      cname ## _init_func ()				\
      {
      \
        cname = ly_symbol2scm (name);			\
	  scm_permanent_object (cname);
      \
      }						\
      ADD_SCM_INIT_FUNC(cname,cname ## _init_func);\

      GLOBAL_SYMBOL( offset_sym , "translate-molecule");

 

-- 

Han-Wen Nienhuys   |   hanwen@cs.uu.nl    | http://www.cs.uu.nl/~hanwen/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]