]> git.donarmstrong.com Git - lilypond.git/commitdiff
(LY_DEFINE): new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 1 Aug 2005 20:15:09 +0000 (20:15 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 1 Aug 2005 20:15:09 +0000 (20:15 +0000)
ChangeLog
lily/GNUmakefile
lily/include/ly-module.hh
lily/ly-module.cc
lily/module-scheme.cc [new file with mode: 0644]
lily/spacing-spanner.cc

index fb3f719678057c4b70c8ff66564efd5ca4c0d348..52cd078d3fba4b9f9feceff99ccba5b2b5d0e569 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2005-08-01  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/module-scheme.cc (LY_DEFINE): new file. 
+
        * Documentation/user/advanced-notation.itely (Font selection): add
        doco for make-pango-font-tree.
 
index 0dadf1f71fb70710a390d3fb654db6d6e59c7885..04ad56acf4a2dfa80adad517e569933d2576eb2c 100644 (file)
@@ -54,7 +54,8 @@ ETAGS_FLAGS += --regex='{c++}/^LY_DEFINE *([^"]*"\([^"]+\)"/\1/'
 default:
 
 
-$(outdir)/libstdc++.a: 
+$(outdir)/libstdc++.a:
+       rm -f $@
        ln -s `$(CXX) -print-file-name=libstdc++.a` $(outdir)/
 
 ifeq ($(LINK_GXX_STATICALLY),yes)
index a45fad64c8631731123087018f3ccde4d194b227..bc1ba2125a6efb7d61f99444a81ba8582d321244 100644 (file)
@@ -21,5 +21,8 @@ inline bool ly_is_module (SCM x) { return SCM_MODULEP (x); }
 SCM ly_clear_anonymous_modules ();
 SCM ly_use_module (SCM mod, SCM used);
 
+/* Ugh signature of scm_internal_hash_fold () is inaccurate.  */
+typedef SCM (*Hash_closure_function) ();
+
 #endif /* LY_MODULE_HH */
 
index b14a222b492da232cbd6057c2dfca5d1d7ab5f34..ba99e64f7470fe15352577fdb0b8baea60994ced 100644 (file)
 Protected_scm anonymous_modules = SCM_EOL;
 #endif
 
-#define FUNC_NAME __FUNCTION__
-
 
-LY_DEFINE(ly_clear_anonymous_modules, "ly:clear-anonymous-modules",
-         0, 0, 0, (),
-         "Plug a GUILE 1.6 and 1.7 memory leak by breaking a weak reference "
-         "pointer cycle explicitly."
-         )
+void
+clear_anonymous_modules ()
 {
-#ifdef MODULE_GC_KLUDGE
   for (SCM s = anonymous_modules;
        scm_is_pair (s);
        s = scm_cdr (s))
@@ -44,9 +38,6 @@ LY_DEFINE(ly_clear_anonymous_modules, "ly:clear-anonymous-modules",
     }
 
   anonymous_modules = SCM_EOL;
-#endif
-
-  return SCM_UNSPECIFIED;
 }
 
 SCM
@@ -93,33 +84,7 @@ ly_use_module (SCM mod, SCM used)
 
 #define FUNC_NAME __FUNCTION__
 
-static SCM
-module_define_closure_func (void *closure, SCM key, SCM val, SCM result)
-{
-  (void) result;
-  SCM module = (SCM) closure;
-  if (scm_variable_bound_p (val) == SCM_BOOL_T)
-    scm_module_define (module, key, scm_variable_ref (val));
-  return SCM_EOL;
-}
-
-/* Ugh signature of scm_internal_hash_fold () is inaccurate.  */
-typedef SCM (*Hash_cl_func) ();
 
-/*
-  If a variable in changed in SRC, we DEST doesn't see the
-  definitions.
-*/
-LY_DEFINE (ly_module_copy, "ly:module-copy",
-          2, 0, 0, (SCM dest, SCM src),
-          "Copy all bindings from module SRC into DEST.")
-{
-  SCM_VALIDATE_MODULE (1, src);
-  scm_internal_hash_fold ((Hash_cl_func) & module_define_closure_func,
-                         (void *) dest,
-                         SCM_EOL, SCM_MODULE_OBARRAY (src));
-  return SCM_UNSPECIFIED;
-}
 
 static SCM
 accumulate_symbol (void *closure, SCM key, SCM val, SCM result)
@@ -135,7 +100,7 @@ ly_module_symbols (SCM mod)
   SCM_VALIDATE_MODULE (1, mod);
 
   SCM obarr = SCM_MODULE_OBARRAY (mod);
-  return scm_internal_hash_fold ((Hash_cl_func) & accumulate_symbol,
+  return scm_internal_hash_fold ((Hash_closure_function) & accumulate_symbol,
                                 NULL, SCM_EOL, obarr);
 }
 
@@ -156,40 +121,7 @@ LY_DEFINE (ly_module2alist, "ly:module->alist",
   SCM_VALIDATE_MODULE (1, mod);
   SCM obarr = SCM_MODULE_OBARRAY (mod);
 
-  return scm_internal_hash_fold ((Hash_cl_func) & entry_to_alist, NULL, SCM_EOL, obarr);
-}
-
-/* Lookup SYM, but don't give error when it is not defined.  */
-SCM
-ly_module_lookup (SCM module, SCM sym)
-{
-#define FUNC_NAME __FUNCTION__
-  SCM_VALIDATE_MODULE (1, module);
-
-  return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
-#undef FUNC_NAME
-}
-
-/* Lookup SYM in a list of modules, which do not have to be related.
-   Return the first instance. */
-LY_DEFINE (ly_modules_lookup, "ly:modules-lookup",
-          2, 1, 0,
-          (SCM modules, SCM sym, SCM def),
-          "Lookup @var{sym} in the list @var{modules}, "
-          "returning the first occurence.  "
-          "If not found, return @var{default}, or @code{#f}.")
-{
-  for (SCM s = modules; scm_is_pair (s); s = scm_cdr (s))
-    {
-      SCM mod = scm_car (s);
-      SCM v = ly_module_lookup (mod, sym);
-      if (SCM_VARIABLEP (v) && SCM_VARIABLE_REF (v) != SCM_UNDEFINED)
-       return scm_variable_ref (v);
-    }
-
-  if (def != SCM_UNDEFINED)
-    return def;
-  return SCM_BOOL_F;
+  return scm_internal_hash_fold ((Hash_closure_function) & entry_to_alist, NULL, SCM_EOL, obarr);
 }
 
 void
@@ -207,3 +139,35 @@ ly_reexport_module (SCM mod)
 {
   ly_export (mod, ly_module_symbols (mod));
 }
+
+
+
+#ifdef MODULE_GC_KLUDGE
+static SCM
+redefine_keyval (void *closure, SCM key, SCM val, SCM result)
+{
+  (void)closure;
+  SCM new_tab = result;
+  scm_hashq_set_x (new_tab, key, val);
+  return new_tab;
+}
+
+/*
+  UGH UGH.
+  Kludge for older GUILE 1.6 versions.
+ */
+void
+make_stand_in_procs_weak ()
+{
+  SCM old_tab = scm_stand_in_procs;
+  SCM new_tab = scm_make_weak_key_hash_table (scm_from_int (257));
+  
+  new_tab = scm_internal_hash_fold ((Hash_closure_function) & redefine_keyval,
+                                   NULL,
+                                   new_tab, old_tab);
+
+  scm_stand_in_procs = new_tab;
+}
+
+ADD_SCM_INIT_FUNC(make_stand_in_procs_weak, make_stand_in_procs_weak);
+#endif
diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc
new file mode 100644 (file)
index 0000000..0e3d98c
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+  lily/module-scheme.cc -- implement module bindings
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "lily-guile.hh"
+#include "warn.hh"
+#include "main.hh"
+#include "string.hh"
+
+/*
+  If a variable in changed in SRC, we DEST doesn't see the
+  definitions.
+*/
+
+static SCM
+module_define_closure_func (void *closure, SCM key, SCM val, SCM result)
+{
+  (void) result;
+  SCM module = (SCM) closure;
+  if (scm_variable_bound_p (val) == SCM_BOOL_T)
+    scm_module_define (module, key, scm_variable_ref (val));
+  return SCM_EOL;
+}
+
+LY_DEFINE (ly_module_copy, "ly:module-copy",
+          2, 0, 0, (SCM dest, SCM src),
+          "Copy all bindings from module SRC into DEST.")
+{
+#define FUNC_NAME __FUNCTION__
+  SCM_VALIDATE_MODULE (1, src);
+  scm_internal_hash_fold ((Hash_closure_function) & module_define_closure_func,
+                         (void *) dest,
+                         SCM_EOL, SCM_MODULE_OBARRAY (src));
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE(ly_clear_anonymous_modules, "ly:clear-anonymous-modules",
+         0, 0, 0, (),
+         "Plug a GUILE 1.6 and 1.7 memory leak by breaking a weak reference "
+         "pointer cycle explicitly."
+         )
+{
+#ifdef MODULE_GC_KLUDGE
+  clear_anonymous_modules();
+#endif
+
+  return SCM_UNSPECIFIED;
+}
+
+
+/* Lookup SYM, but don't give error when it is not defined.  */
+SCM
+ly_module_lookup (SCM module, SCM sym)
+{
+#define FUNC_NAME __FUNCTION__
+  SCM_VALIDATE_MODULE (1, module);
+
+  return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
+#undef FUNC_NAME
+}
+
+/* Lookup SYM in a list of modules, which do not have to be related.
+   Return the first instance. */
+LY_DEFINE (ly_modules_lookup, "ly:modules-lookup",
+          2, 1, 0,
+          (SCM modules, SCM sym, SCM def),
+          "Lookup @var{sym} in the list @var{modules}, "
+          "returning the first occurence.  "
+          "If not found, return @var{default}, or @code{#f}.")
+{
+  for (SCM s = modules; scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM mod = scm_car (s);
+      SCM v = ly_module_lookup (mod, sym);
+      if (SCM_VARIABLEP (v) && SCM_VARIABLE_REF (v) != SCM_UNDEFINED)
+       return scm_variable_ref (v);
+    }
+
+  if (def != SCM_UNDEFINED)
+    return def;
+  return SCM_BOOL_F;
+}
index b8513cec0a9c633cca9fb23602fa4cb6b2b0f0e4..64eecf07586d1a419a2853739e4432c3a3200ab0 100644 (file)
@@ -895,8 +895,9 @@ Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc,
   shortest_playing_len = max (shortest_playing_len, delta_t);
   if (delta_t.main_part_ && !lwhen.grace_part_)
     {
-      dist = get_duration_space (me, shortest_playing_len, shortest.main_part_, expand_only);
-      dist *= (double) (delta_t.main_part_ / shortest_playing_len.main_part_);
+      dist = get_duration_space (me, shortest_playing_len,
+                                shortest.main_part_, expand_only);
+      dist *= double (delta_t.main_part_ / shortest_playing_len.main_part_);
     }
   else if (delta_t.grace_part_)
     {
@@ -925,9 +926,14 @@ ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface",
               "gets 2 note heads width (i.e. the space following a note is 1 note\n"
               "head width) A 16th note is followed by 0.5 note head width. The\n"
               "quarter note is followed by  3 NHW, the half by 4 NHW, etc.\n",
-              "grace-space-factor spacing-increment base-shortest-duration shortest-duration-space common-shortest-duration");
+              
+              "grace-space-factor spacing-increment base-shortest-duration "
+              "shortest-duration-space common-shortest-duration"
+
+              );
 
 ADD_INTERFACE (Spacing_interface, "spacing-interface",
-              "Something to do with line breaking and spacing. Kill this one after determining line breaks.",
+              "Something to do with line breaking and spacing. "
+              "Kill this one after determining line breaks.",
               "");