]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-guile.cc
2003 -> 2004
[lilypond.git] / lily / lily-guile.cc
index fe940add8056026f07e327e95ae2dec08bbde758..4cd7a34554bb2beaa56cbd95e4c34010d31d9d2c 100644 (file)
@@ -3,7 +3,7 @@
 
   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>
 */
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <math.h>   /* isinf */
 #include <string.h> /* strdup, strchr */
-
+#include <ctype.h>
 
 #include "lily-proto.hh"
 
@@ -188,7 +188,7 @@ void add_scm_init_func (void (*f) ())
 
 
 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)) ();
@@ -253,6 +253,13 @@ ly_scm2interval (SCM p)
                    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)
 {
@@ -699,8 +706,6 @@ int_list_to_slice (SCM l)
 }
 
 
-
-
 /*
   Return I-th element, or last elt L. If I < 0, then we take the first
   element.
@@ -716,3 +721,67 @@ robust_list_ref(int i, SCM 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; 
+}