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>
*/
#include <stdlib.h>
#include <math.h> /* isinf */
#include <string.h> /* strdup, strchr */
-
+#include <ctype.h>
#include "lily-proto.hh"
return SCM_BOOL_T;
}
-LY_DEFINE(ly_isdir, "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 a -1, 0 or 1, where -1 represents "
+ "left or down and 1 represents right or up. ")
{
if (gh_number_p (s))
{
}
bool
-ly_number_pair_p (SCM p)
+is_number_pair (SCM p)
{
return gh_pair_p (p) && gh_number_p (ly_car (p)) && gh_number_p (ly_cdr (p));
}
void
-ly_init_ly_module (void *data)
+ly_init_ly_module (void *)
{
for (int i=scm_init_funcs_->size () ; i--;)
(scm_init_funcs_->elem (i)) ();
bool
-ly_dir_p (SCM s)
+is_direction (SCM s)
{
if (gh_number_p (s))
{
bool
-ly_axis_p (SCM s)
+is_axis (SCM s)
{
if (gh_number_p (s))
{
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_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 ")" ;
+ char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
return gh_eval_str ((char*)vs);
}
return scm_makfrom0str (INTERNAL_UNIT);
}
-LY_DEFINE(ly_verbose, "ly:verbose", 0, 0, 0, (),
- "Return whether lilypond is being run in verbose mode.")
-{
- return gh_bool2scm (verbose_global_b);
-}
+
LY_DEFINE(ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
"Return @var{d} is a number. Used to distinguish length "
char *orig = s;
SCM create_list = SCM_EOL;
+ char * e = s + strlen (s) - 1;
+ while (e >= s && isspace (*e))
+ *e -- = 0;
+
for (char * p = s; *p; p++)
{
if (*p == '\n')
if (val == SCM_EOL || val == SCM_BOOL_F)
return ok;
-
- SCM type = SCM_EOL;
+ if (!gh_symbol_p (sym))
+#if 0
+ return false;
+#else
+ /*
+ This is used for autoBeamSettings.
+
+ TODO: deprecate the use of \override and \revert for
+ autoBeamSettings?
- if (gh_symbol_p (sym))
- type = scm_object_property (sym, type_symbol);
+ or use a symbol autoBeamSettingS?
+ */
+ return true;
+#endif
+
+ SCM type = scm_object_property (sym, type_symbol);
if (type != SCM_EOL && !gh_procedure_p (type))
{
}
-
-
/*
Return I-th element, or last elt L. If I < 0, then we take the first
element.
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;
+}