source file of the GNU LilyPond music typesetter
- (c) 1998--2003 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
source-file.hh includes cmath which undefines isinf and isnan
*/
-inline int my_isinf(Real r) { return isinf(r); }
-inline int my_isnan(Real r) { return isnan(r); }
+inline int my_isinf (Real r) { return isinf (r); }
+inline int my_isnan (Real r) { return isnan (r); }
return result;
}
-LY_DEFINE(ly_gulp_file, "ly:gulp-file", 1,0, 0,
- (SCM name),
- "Read the file named @var{name}, and return its contents in a string. The "
-" file is looked up using the lilypond search path.")
+LY_DEFINE (ly_gulp_file, "ly:gulp-file",
+ 1, 0, 0, (SCM name),
+ "Read the file @var{name}, and return its contents in a string. "
+ "The file is looked up using the search path.")
{
return scm_makfrom0str (gulp_file_to_string (ly_scm2string (name)).to_str0 ());
}
{
assert (gh_string_p (s));
- char *p = SCM_STRING_CHARS(s);
+ char *p = SCM_STRING_CHARS (s);
String r (p);
return r;
}
return s;
}
-LY_DEFINE(ly_warning,"ly:warn", 1, 0, 0,
- (SCM str),"Scheme callable function to issue the warning @code{msg}.")
+LY_DEFINE (ly_warning,"ly:warn", 1, 0, 0,
+ (SCM str), "Scheme callable function to issue the warning @code{msg}.")
{
SCM_ASSERT_TYPE (gh_string_p (str), str, SCM_ARG1, __FUNCTION__, "string");
+ progress_indication ("\n");
warning ("lily-guile: " + ly_scm2string (str));
return SCM_BOOL_T;
}
-LY_DEFINE(ly_dir_p, "ly:dir?", 1,0, 0, (SCM s),
- "type predicate. A direction is a -1, 0 or 1, where -1 represents "
- "left or down and 1 represents right or up. ")
+LY_DEFINE (ly_dir_p, "ly:dir?", 1,0, 0, (SCM s),
+ "type predicate. A direction is @code{-1}, @code{0} or "
+ "@code{1}, where @code{-1} represents "
+ "left or down and @code{1} represents right or up.")
{
if (gh_number_p (s))
{
}
-SCM lily_module ;
+SCM global_lily_module;
void
ly_init_guile ()
{
- lily_module = scm_c_define_module ("lily", ly_init_ly_module, 0);
+ global_lily_module = scm_c_define_module ("lily", ly_init_ly_module, 0);
scm_c_use_module ("lily");
}
gh_scm2double (ly_cdr (p)));
}
+Drul_array<Real>
+ly_scm2realdrul (SCM p)
+{
+ return Drul_array<Real> (gh_scm2double (ly_car (p)),
+ gh_scm2double (ly_cdr (p)));
+}
+
SCM
ly_interval2scm (Drul_array<Real> i)
{
}
-LY_DEFINE(ly_number2string, "ly:number->string", 1, 0,0,
- (SCM s),
- " converts @var{num} to a string without generating many decimals. It "
-"leaves a space at the end.")
+LY_DEFINE (ly_number2string, "ly:number->string",
+ 1, 0, 0, (SCM s),
+ "Convert @var{num} to a string without generating many decimals.")
{
SCM_ASSERT_TYPE (gh_number_p (s), s, SCM_ARG1, __FUNCTION__, "number");
r = 0.0;
}
- sprintf (str, "%8.4f ", r);
+ sprintf (str, "%08.4f", r);
}
else
- {
- sprintf (str, "%d ", gh_scm2int (s));
- }
+ sprintf (str, "%d", gh_scm2int (s));
return scm_makfrom0str (str);
}
#include "version.hh"
-LY_DEFINE(ly_version, "ly:version", 0, 0, 0, (),
+LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (),
"Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
{
char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
return gh_eval_str ((char*)vs);
}
-LY_DEFINE(ly_unit, "ly:unit", 0, 0, 0, (),
+LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (),
"Return the unit used for lengths as a string.")
{
return scm_makfrom0str (INTERNAL_UNIT);
-LY_DEFINE(ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
+LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
"Return @var{d} is a number. Used to distinguish length "
"variables from normal numbers.")
{
ly_assoc_cdr (SCM key, SCM alist)
{
if (gh_pair_p (alist)) {
- SCM trykey = ly_caar(alist);
- if(gh_pair_p(trykey) && to_boolean(scm_equal_p(key,ly_cdr(trykey))))
- return ly_car(alist);
+ SCM trykey = ly_caar (alist);
+ if (gh_pair_p (trykey) && to_boolean (scm_equal_p (key,ly_cdr (trykey))))
+ return ly_car (alist);
else
return ly_assoc_cdr (key, ly_cdr (alist));
}
{
SCM errport = scm_current_error_port ();
ok = false;
- SCM typefunc = scm_primitive_eval (ly_symbol2scm ("type-name"));
+ SCM typefunc = ly_scheme_function ("type-name");
SCM type_name = gh_call1 (typefunc, type);
SCM
display_list (SCM s)
{
- SCM p = scm_current_output_port();
+ SCM p = scm_current_output_port ();
scm_puts ("(", p);
- for (; gh_pair_p(s); s =gh_cdr(s))
+ for (; gh_pair_p (s); s =gh_cdr (s))
{
- scm_display (gh_car(s), p);
+ scm_display (gh_car (s), p);
scm_puts (" ", p);
}
scm_puts (")", p);
PRE: length (L) > 0
*/
SCM
-robust_list_ref(int i, SCM l)
+robust_list_ref (int i, SCM l)
{
- while (i-- > 0 && gh_pair_p (gh_cdr(l)))
+ while (i-- > 0 && gh_pair_p (gh_cdr (l)))
l = gh_cdr (l);
- return gh_car(l);
+ return gh_car (l);
+}
+
+
+
+Real
+robust_scm2double (SCM k, double x)
+{
+ if (gh_number_p (k))
+ x = gh_scm2double (k);
+ return x;
+}
+
+Interval
+robust_scm2interval (SCM k, Drul_array<Real> v)
+{
+ Interval i;
+ i[LEFT]= v[LEFT];
+ i[RIGHT]= v[RIGHT];
+ if (is_number_pair (k))
+ i = ly_scm2interval (k);
+ return i;
+}
+
+Drul_array<Real>
+robust_scm2drul (SCM k, Drul_array<Real> v)
+{
+ if (is_number_pair (k))
+ v = ly_scm2interval (k);
+ return v;
+}
+
+Offset
+robust_scm2offset (SCM k, Offset o)
+{
+ if (is_number_pair (k))
+ o = ly_scm2offset (k);
+
+ return o;
+}
+
+
+int
+robust_scm2int (SCM k, int o)
+{
+ if (scm_integer_p (k) == SCM_BOOL_T)
+ o = gh_scm2int (k);
+
+ return o;
}
+
+SCM
+alist_to_hashq (SCM alist)
+{
+ int i = scm_ilength (alist);
+ if (i < 0)
+ return scm_make_vector (gh_int2scm (0), SCM_EOL);
+
+ SCM tab = scm_make_vector (gh_int2scm (i), SCM_EOL);
+ for (SCM s = alist; gh_pair_p (s); s = ly_cdr (s))
+ {
+ SCM pt = ly_cdar (s);
+ scm_hashq_set_x (tab, ly_caar (s), pt);
+ }
+ return tab;
+}
+
+#if 1
+/*
+ Debugging mem leaks:
+ */
+LY_DEFINE (ly_protects, "ly:protects", 0, 0, 0, (),
+ "Return hash of protected objects.")
+{
+ return scm_protects;
+}
+#endif