]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-guile.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / lily-guile.cc
index e44e47f4be27f6f30b64817b760191a678e4441f..d57a9f5730e7e936fdd7b2307aa49dc9359e20ea 100644 (file)
@@ -16,8 +16,6 @@
 
 using namespace std;
 
-#include "config.hh"
-
 #include "dimensions.hh"
 #include "direction.hh"
 #include "file-path.hh"
@@ -105,10 +103,8 @@ gulp_file_to_string (string fn, bool must_exist, int size)
   if (be_verbose_global)
     progress_indication ("[" + s);
 
-  int n = size;
-  char *str = gulp_file (s, &n);
-  string result (str, n);
-  delete[] str;
+  vector<char> chars = gulp_file (s, size);
+  string result (&chars[0], chars.size ());
 
   if (be_verbose_global)
     progress_indication ("]");
@@ -131,7 +127,7 @@ ly_scm2string (SCM str)
 {
   assert (scm_is_string (str));
   return string (scm_i_string_chars (str),
-                    (int) scm_i_string_length (str));
+                (int) scm_i_string_length (str));
 }
 
 char *
@@ -307,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)
 {
@@ -655,6 +673,14 @@ robust_scm2offset (SCM k, Offset o)
   return o;
 }
 
+string
+robust_scm2string (SCM k, string s)
+{
+  if (scm_is_string (k))
+    s = ly_scm2string (k);
+  return s;
+}
+
 int
 robust_scm2int (SCM k, int o)
 {
@@ -742,3 +768,4 @@ mangle_cxx_identifier (string cxx_id)
   cxx_id = replace_all (cxx_id, '_', '-');
   return cxx_id;
 }
+