X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flily-guile.cc;h=e44e47f4be27f6f30b64817b760191a678e4441f;hb=2d807340ff4a9b9d8f82b7d99f557ece8534582c;hp=4a237d7440a655118516012ebbe4440cac5516a2;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 4a237d7440..e44e47f4be 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -75,7 +75,7 @@ ly_quote_scm (SCM s) return scm_list_n (ly_symbol2scm ("quote"), s, SCM_UNDEFINED); } -String +string ly_symbol2string (SCM s) { /* @@ -85,15 +85,15 @@ ly_symbol2string (SCM s) return ly_scm2string (str); } -String -gulp_file_to_string (String fn, bool must_exist, int size) +string +gulp_file_to_string (string fn, bool must_exist, int size) { - String s = global_path.find (fn); + string s = global_path.find (fn); if (s == "") { if (must_exist) { - String e = _f ("can't find file: `%s'", fn); + string e = _f ("can't find file: `%s'", fn); e += " "; e += _f ("(load path: `%s')", global_path.to_string ()); error (e); @@ -107,7 +107,7 @@ gulp_file_to_string (String fn, bool must_exist, int size) int n = size; char *str = gulp_file (s, &n); - String result ((Byte *) str, n); + string result (str, n); delete[] str; if (be_verbose_global) @@ -126,12 +126,12 @@ extern "C" { } }; -String +string ly_scm2string (SCM str) { assert (scm_is_string (str)); - return String ((Byte *)scm_i_string_chars (str), - (int) scm_i_string_length (str)); + return string (scm_i_string_chars (str), + (int) scm_i_string_length (str)); } char * @@ -179,21 +179,21 @@ is_number_pair (SCM p) } typedef void (*Void_fptr) (); -Array *scm_init_funcs_; +vector *scm_init_funcs_; void add_scm_init_func (void (*f) ()) { if (!scm_init_funcs_) - scm_init_funcs_ = new Array; + scm_init_funcs_ = new vector; - scm_init_funcs_->push (f); + scm_init_funcs_->push_back (f); } void ly_init_ly_module (void *) { - for (int i = scm_init_funcs_->size (); i--;) - (scm_init_funcs_->elem (i)) (); + for (vsize i = scm_init_funcs_->size (); i--;) + (scm_init_funcs_->at (i)) (); if (be_verbose_global) { @@ -356,11 +356,11 @@ ly_assoc_cdr (SCM key, SCM alist) } SCM -ly_string_array_to_scm (Array a) +ly_string_array_to_scm (vector a) { SCM s = SCM_EOL; - for (int i = a.size () - 1; i >= 0; i--) - s = scm_cons (ly_symbol2scm (a[i].to_str0 ()), s); + for (vsize i = a.size (); i ; i--) + s = scm_cons (ly_symbol2scm (a[i - 1].c_str ()), s); return s; } @@ -370,10 +370,10 @@ parse_symbol_list (char const *symbols) { while (isspace (*symbols)) *symbols++; - String s = symbols; - s.substitute ('\n', ' '); - s.substitute ('\t', ' '); - return ly_string_array_to_scm (String_convert::split (s, ' ')); + string s = symbols; + replace_all (s, '\n', ' '); + replace_all (s, '\t', ' '); + return ly_string_array_to_scm (string_split (s, ' ')); } SCM @@ -394,14 +394,14 @@ ly_truncate_list (int k, SCM lst) return lst; } -String +string print_scm_val (SCM val) { - String realval = ly_scm2string (ly_write2scm (val)); + string realval = ly_scm2string (ly_write2scm (val)); if (realval.length () > 200) - realval = realval.left_string (100) + realval = realval.substr (0, 100) + "\n :\n :\n" - + realval.right_string (100); + + realval.substr (realval.length () - 100); return realval; } @@ -439,8 +439,8 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) if (type != SCM_EOL && !ly_is_procedure (type)) { warning (_f ("can't find property type-check for `%s' (%s).", - ly_symbol2string (sym).to_str0 (), - ly_symbol2string (type_symbol).to_str0 ()) + ly_symbol2string (sym).c_str (), + ly_symbol2string (type_symbol).c_str ()) + " " + _ ("perhaps a typing error?")); /* Be strict when being anal :) */ @@ -460,9 +460,9 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) SCM type_name = scm_call_1 (typefunc, type); warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", - ly_symbol2string (sym).to_str0 (), + ly_symbol2string (sym).c_str (), print_scm_val (val), - ly_scm2string (type_name).to_str0 ())); + ly_scm2string (type_name).c_str ())); progress_indication ("\n"); } } @@ -498,7 +498,9 @@ scm_default_compare (void const *a, void const *b) return pa < pb ? -1 : 1; } -/* Modify LST in place: qsort it. */ +/* Modify LST in place: qsort it. + +FIXME: unused, junk? */ SCM ly_list_qsort_uniq_x (SCM lst) { @@ -721,3 +723,22 @@ procedure_arity (SCM proc) SCM fixed = scm_car (arity); return scm_to_int (fixed); } + +string +mangle_cxx_identifier (string cxx_id) +{ + if (cxx_id.substr (0, 3) == "ly_") + cxx_id = cxx_id.replace (0, 3, "ly:"); + else + { + cxx_id = String_convert::to_lower (cxx_id); + cxx_id = "ly:" + cxx_id; + } + if (cxx_id.substr (cxx_id.length () - 2) == "_p") + cxx_id = cxx_id.replace (cxx_id.length () - 2, 1, "?"); + else if (cxx_id.substr (cxx_id.length () - 2) == "_x") + cxx_id = cxx_id.replace (cxx_id.length () - 2, 1, "!"); + + cxx_id = replace_all (cxx_id, '_', '-'); + return cxx_id; +}