]> git.donarmstrong.com Git - lilypond.git/commitdiff
offsets <-> scm conversion routines
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Nov 2006 20:31:28 +0000 (21:31 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Nov 2006 20:31:28 +0000 (21:31 +0100)
lily/include/lily-guile.hh
lily/lily-guile.cc

index 3422089e9c50e043b884093d37600de8d42e14e3..621849edc6a01344922a1f270e858581d7419df2 100644 (file)
@@ -66,6 +66,7 @@ Interval robust_scm2interval (SCM, Drul_array<Real>);
 Offset robust_scm2offset (SCM, Offset);
 string robust_scm2string (SCM, string);
 
+  
 SCM ly_quote_scm (SCM s);
 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol);
 string print_scm_val (SCM val);
@@ -195,4 +196,7 @@ ly_cxx_vector_to_list  (vector<T> const &src)
 }
 
 
+SCM ly_offsets2scm (vector<Offset> os);
+vector<Offset> ly_scm2offsets (SCM s);
+
 #endif /* LILY_GUILE_HH */
index 4c23b2ad409c9bf4de6bffb8879bd9b47919a61f..d57a9f5730e7e936fdd7b2307aa49dc9359e20ea 100644 (file)
@@ -303,6 +303,28 @@ ly_scm2offset (SCM s)
                 scm_to_double (scm_cdr (s)));
 }
 
+SCM
+ly_offsets2scm (vector<Offset> os)
+{
+  SCM l = SCM_EOL;
+  SCM *tail = &l;
+  for (vsize i = 0; i < os.size (); i++)
+    {
+      *tail = scm_cons (ly_offset2scm (os[i]), SCM_EOL);
+      tail = SCM_CDRLOC(*tail);
+    }
+  return l;
+}
+
+vector<Offset>
+ly_scm2offsets (SCM s)
+{
+  vector<Offset> os;
+  for (; scm_is_pair (s); s = scm_cdr (s))
+    os.push_back (ly_scm2offset (scm_car (s)));
+  return os;
+}
+
 SCM
 ly_deep_copy (SCM src)
 {