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.
default:
-$(outdir)/libstdc++.a:
+$(outdir)/libstdc++.a:
+ rm -f $@
ln -s `$(CXX) -print-file-name=libstdc++.a` $(outdir)/
ifeq ($(LINK_GXX_STATICALLY),yes)
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 */
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))
}
anonymous_modules = SCM_EOL;
-#endif
-
- return SCM_UNSPECIFIED;
}
SCM
#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)
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);
}
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
{
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
--- /dev/null
+/*
+ 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;
+}
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_)
{
"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.",
"");