]> git.donarmstrong.com Git - lilypond.git/commitdiff
uniformize C++ <-> scheme name mappings.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 26 Jan 2007 16:25:58 +0000 (17:25 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 26 Jan 2007 16:25:58 +0000 (17:25 +0100)
26 files changed:
lily/book-scheme.cc
lily/context-scheme.cc
lily/dispatcher-scheme.cc
lily/duration-scheme.cc
lily/function-documentation.cc
lily/general-scheme.cc
lily/grob-pq-engraver.cc
lily/grob-scheme.cc
lily/include/lily-guile-macros.hh
lily/include/ly-module.hh
lily/include/music.hh
lily/input-scheme.cc
lily/lily-guile.cc
lily/lily-parser-scheme.cc
lily/ly-module.cc
lily/moment-scheme.cc
lily/music-scheme.cc
lily/music.cc
lily/output-def-scheme.cc
lily/pfb.cc
lily/program-option.cc
lily/spanner-scheme.cc
lily/stencil-scheme.cc
lily/stream-event-scheme.cc
lily/ttf.cc
scm/safe-lily.scm

index 23237dbb0d7559e9cfa877d85f7a28596835a3d8..3a162ac392d914ca65faaede6021a38ae27101b0 100644 (file)
@@ -35,7 +35,7 @@ LY_DEFINE (ly_make_book, "ly:make-book",
   return x;
 }
 
-LY_DEFINE (ly_parser_print_book, "ly:book-process",
+LY_DEFINE (ly_book_process, "ly:book-process",
           4, 0, 0, (SCM book_smob,
                     SCM default_paper,
                     SCM default_layout,
@@ -65,7 +65,7 @@ LY_DEFINE (ly_parser_print_book, "ly:book-process",
 }
 
 
-LY_DEFINE (ly_parser_print_book_to_systems, "ly:book-process-to-systems",
+LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
           4, 0, 0, (SCM book_smob,
                     SCM default_paper,
                     SCM default_layout,
index a6ee973a1c3adc37164f4157ea54ba07c7b628c5..f4a2f6191cc5ce12583092239ad49bdaf6434ee0 100644 (file)
@@ -75,7 +75,7 @@ LY_DEFINE (ly_context_property, "ly:context-property",
   return tr->internal_get_property (name);
 }
 
-LY_DEFINE (ly_context_set_property, "ly:context-set-property!",
+LY_DEFINE (ly_context_set_property_x, "ly:context-set-property!",
           3, 0, 0, (SCM context, SCM name, SCM val),
           "Set value of property @var{name} in context @var{context} "
           "to @var{val}.")
@@ -106,7 +106,7 @@ LY_DEFINE (ly_context_property_where_defined, "ly:context-property-where-defined
   return SCM_EOL;
 }
 
-LY_DEFINE (ly_unset_context_property, "ly:context-unset-property", 2, 0, 0,
+LY_DEFINE (ly_context_unset_property, "ly:context-unset-property", 2, 0, 0,
           (SCM context, SCM name),
           "Unset value of property @var{name} in context @var{context}.")
 {
index 9e491e0a9abc185795c01e1c1be5091dd32998da..06da9c1602cd0ba2c3129d5c8de5979512bb16eb 100644 (file)
@@ -15,7 +15,7 @@ LY_DEFINE (ly_make_dispatcher, "ly:make-dispatcher",
   return (new Dispatcher ())->unprotect ();
 }
 
-LY_DEFINE (ly_register_dispatcher, "ly:connect-dispatchers",
+LY_DEFINE (ly_connect_dispatchers, "ly:connect-dispatchers",
           2, 0, 0, (SCM to, SCM from),
           "Makes the dispatcher @var{to} listen to events from @var{from}." )
 {
index 4b8c4605c0e19e40c984c4b1e4fe424a7b112d0c..e2dfeec744cc68ec4d73bec4183ac96c866ce416 100644 (file)
@@ -121,7 +121,7 @@ LY_DEFINE (ly_duration_length, "ly:duration-length",
   return Moment (unsmob_duration (dur)->get_length ()).smobbed_copy ();
 }
 
-LY_DEFINE (ly_duration2string, "ly:duration->string",
+LY_DEFINE (ly_duration_2_string, "ly:duration->string",
           1, 0, 0, (SCM dur),
           "Convert @var{dur} to string.")
 {
index b700fad3202ca744e961881c8d7090c77b9f4a0b..e59df6219272ab45ec88ab364464c453d93f3828 100644 (file)
@@ -11,10 +11,23 @@ using namespace std;
 
 #include "std-string.hh"
 #include "lily-guile.hh"
+#include "warn.hh"
 
 static SCM doc_hash_table;
 
-void ly_add_function_documentation (SCM func,
+void
+ly_check_name (string cxx, string scm_name)
+{
+  string mangle = mangle_cxx_identifier (cxx);
+  if (mangle != scm_name)
+    {
+      programming_error ("wrong cxx name: " + mangle + ", " + cxx +  ", " + scm_name);
+    }
+}
+
+
+void
+ly_add_function_documentation (SCM func,
                                    string fname,
                                    string varlist,
                                    string doc)
index cbc3b605ed13c9be41229f04db1119f952b772f4..868d2d11fb1f2620aaad23fa5f0117b76d70b5e0 100644 (file)
@@ -162,7 +162,7 @@ LY_DEFINE (ly_string_substitute, "ly:string-substitute",
   return ly_string2scm (ss);
 }
   
-LY_DEFINE (ly_number2string, "ly:number->string",
+LY_DEFINE (ly_number_2_string, "ly:number->string",
           1, 0, 0, (SCM s),
           "Convert @var{num} to a string without generating many decimals.")
 {
@@ -251,7 +251,7 @@ LY_DEFINE (ly_output_formats, "ly:output-formats",
   return lst;
 }
 
-LY_DEFINE (ly_wchar_to_utf_8, "ly:wide-char->utf-8",
+LY_DEFINE (ly_wide_char_2_utf_8, "ly:wide-char->utf-8",
           1, 0, 0, (SCM wc),
           "Encode the Unicode codepoint @var{wc}, an integer, as UTF-8")
 {
@@ -344,7 +344,7 @@ LY_DEFINE(ly_hash_table_keys, "ly:hash-table-keys",
                                 NULL, SCM_EOL, tab);
 }
 
-LY_DEFINE (ly_camel_case_to_lisp_identifier, "ly:camel-case->lisp-identifier",
+LY_DEFINE (ly_camel_case_2_lisp_identifier, "ly:camel-case->lisp-identifier",
           1, 0, 0, (SCM name_sym),
           "Convert FooBar_Bla to foo-bar-bla style symbol.")
 {
index 476cae950ca61cece500a96b27fd0f510742ca77..7cb4afab87900821d25ee4f39df5e28a8cec35ea 100644 (file)
@@ -47,7 +47,7 @@ Grob_pq_engraver::initialize ()
   context ()->set_property ("busyGrobs", SCM_EOL);
 }
 
-LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?",
+LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq<?",
           2, 0, 0, (SCM a, SCM b),
           "Compare 2 grob priority queue entries. Internal")
 {
index 8d3cc0b4a454ed8faf4ae9dbe8ecf315c16db2cf..6938ee25a1ecb14c8134bd6d27b46fb23d08bfbc 100644 (file)
@@ -120,7 +120,7 @@ LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain",
   return sc->get_property_alist_chain (global);
 }
 
-LY_DEFINE (ly_get_extent, "ly:grob-extent",
+LY_DEFINE (ly_grob_extent, "ly:grob-extent",
           3, 0, 0, (SCM grob, SCM refp, SCM axis),
           "Get the extent in @var{axis} direction of @var{grob} relative to "
           "the grob @var{refp}")
index 85c30ffb4772bf20c89ee44ea20ff794c6669950..400ead26ea857b299895fc3ee72b69106ddc9870 100644 (file)
@@ -104,7 +104,8 @@ string mangle_cxx_identifier (string);
   void                                                                 \
   TYPE ## _ ## FUNC ## _init_functions ()                              \
   {                                                                    \
-    string id = mangle_cxx_identifier (string (#TYPE) + "::" + string (#FUNC)); \
+    string cxx = string (#TYPE) + "::" + string (#FUNC); \
+    string id = mangle_cxx_identifier (cxx); \
     TYPE ::FUNC ## _proc = scm_c_define_gsubr (id.c_str(),                     \
                                               (ARGCOUNT-OPTIONAL_COUNT), OPTIONAL_COUNT, 0,    \
                                               (Scheme_function_unknown) TYPE::FUNC); \
@@ -122,8 +123,8 @@ string mangle_cxx_identifier (string);
 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT)                     \
   MAKE_SCHEME_CALLBACK_WITH_OPTARGS(TYPE,FUNC,ARGCOUNT, 0, "");
 
-void
-ly_add_function_documentation (SCM proc, string fname, string varlist, string doc);
+void ly_add_function_documentation (SCM proc, string fname, string varlist, string doc);
+void ly_check_name (string cxx, string fname);
 
 #define ADD_SCM_INIT_FUNC(name, func)          \
   class name ## _scm_initter                   \
@@ -146,6 +147,7 @@ ly_add_function_documentation (SCM proc, string fname, string varlist, string do
   {                                                                    \
     FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR,      \
                                         (Scheme_function_unknown) FNAME); \
+    ly_check_name (#FNAME, PRIMNAME);\
     ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \
                                   DOCSTRING);                          \
     scm_c_export (PRIMNAME, NULL);                                     \
index 17595408a71965ab102578136fa83c63d10a600c..abb4b200405cee65221ea27a28fd949eb2139674 100644 (file)
@@ -12,7 +12,7 @@
 
 SCM ly_make_anonymous_module (bool safe);
 SCM ly_module_copy (SCM dest, SCM src);
-SCM ly_module2alist (SCM mod);
+SCM ly_module_2_alist (SCM mod);
 SCM ly_module_lookup (SCM module, SCM sym);
 SCM ly_modules_lookup (SCM modules, SCM sym, SCM);
 SCM ly_module_symbols (SCM mod);
index ec6f98766cdc3d912f6f87ee74dbcc3c33a3f0eb..4ed048fda01448255239261c76830f940b91c318 100644 (file)
@@ -61,7 +61,7 @@ protected:
 Music *unsmob_music (SCM);
 Music *make_music_by_name (SCM sym);
 SCM ly_music_deep_copy (SCM);
-SCM ly_camel_case_to_lisp_identifier (SCM name_sym);
+SCM ly_camel_case_2_lisp_identifier (SCM name_sym);
 
 extern SCM ly_music_p_proc;
 
index 2ff7bf500762d7496efe533ed80bf1a728e701b4..3f1423675940f30e42aebce21da2f4d7f8260116 100644 (file)
@@ -11,7 +11,7 @@
 
 /* We don't use IMPLEMENT_TYPE_P, since the smobification part is
    implemented separately from the class.  */
-LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
+LY_DEFINE (ly_input_location_p, "ly:input-location?", 1, 0, 0,
           (SCM x),
           "Is @var{x} an @code{input-location}?")
 {
@@ -35,7 +35,7 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM
 }
 
 
-LY_DEFINE (ly_input_file_line_column,
+LY_DEFINE (ly_input_file_line_char_column,
           "ly:input-file-line-char-column",
           1, 0, 0, (SCM sip),
           "Return input location in @var{sip} as (file-name line char column).")
index 976b19e47c0819a32111fea6f28d5261d24ee2ae..bdfcae16486aac79287377dec4e3fac0794f3e48 100644 (file)
@@ -630,11 +630,16 @@ mangle_cxx_identifier (string 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, "?");
+    cxx_id = cxx_id.replace (cxx_id.length () - 2, 2, "?");
   else if (cxx_id.substr (cxx_id.length () - 2) == "_x")
-    cxx_id = cxx_id.replace (cxx_id.length () - 2, 1, "!");
+    cxx_id = cxx_id.replace (cxx_id.length () - 2, 2, "!");
 
+  cxx_id = replace_all (cxx_id, "_less?", "<?");
+  cxx_id = replace_all (cxx_id, "_2_", "->");
+  cxx_id = replace_all (cxx_id, "__", "::");
   cxx_id = replace_all (cxx_id, '_', '-');
+
+
   return cxx_id;
 }
 
index ca1d224bd6ac7703f7d8f54b64434fe4102965ee..cb84471b9cc535cb77e5f2a971768ea5b61f5adf 100644 (file)
@@ -166,7 +166,7 @@ LY_DEFINE (ly_parser_clone, "ly:parser-clone",
   return clone->unprotect ();
 }
 
-LY_DEFINE (ly_parser_define, "ly:parser-define!",
+LY_DEFINE (ly_parser_define_x, "ly:parser-define!",
           3, 0, 0, (SCM parser_smob, SCM symbol, SCM val),
           "Bind @var{symbol} to @var{val} in @var{parser-smob}'s module.")
 {
index c2e96a4a1cf800c62197c085424f6a8460f457ed..581984dfe9951495bd4320684d8d1f562784ae94 100644 (file)
@@ -106,7 +106,7 @@ entry_to_alist (void *closure, SCM key, SCM val, SCM result)
   return result;
 }
 
-LY_DEFINE (ly_module2alist, "ly:module->alist",
+LY_DEFINE (ly_module_2_alist, "ly:module->alist",
           1, 0, 0, (SCM mod),
           "Dump the contents of  module @var{mod} as an alist.")
 {
index b19259e6b2505d36c30034282cc3caf55abfcdb9..9bad172300cac7651ff78666587f1d57d6e137fe 100644 (file)
@@ -42,7 +42,7 @@ LY_DEFINE (ly_make_moment, "ly:make-moment",
                 Rational (grace_num, grace_den)).smobbed_copy ();
 }
 
-LY_DEFINE (ly_sub_moment, "ly:moment-sub",
+LY_DEFINE (ly_moment_sub, "ly:moment-sub",
           2, 0, 0, (SCM a, SCM b),
           "Subtract two moments.")
 {
index 711df4d1a194352790df0dc839e8ce142316408d..ce4268d9c8b9ea0e47c53e19dc79a9e5bd525664 100644 (file)
@@ -30,7 +30,7 @@ LY_DEFINE (ly_music_property,
   return ly_prob_property (mus,sym,dfault);
 }
 
-LY_DEFINE (ly_music_set_property, "ly:music-set-property!",
+LY_DEFINE (ly_music_set_property_x, "ly:music-set-property!",
           3, 0, 0, (SCM mus, SCM sym, SCM val),
           "Set property @var{sym} in music expression @var{mus} to @var{val}.")
 {
index b22e243139690aa239ea475d7a6bff176675afe0..77c8f34335629a5c75c4d2e7e9614976e95e259e 100644 (file)
@@ -250,7 +250,7 @@ Music::origin () const
 Stream_event *
 Music::to_event () const
 {
-  SCM class_name = ly_camel_case_to_lisp_identifier (get_property ("name"));
+  SCM class_name = ly_camel_case_2_lisp_identifier (get_property ("name"));
 
   // catch programming mistakes.
   if (!internal_is_music_type (class_name))
index a806781015b6d3ae2cfee5a0d4c1ff01278e2170..13c4d7456fdc69ae98b3b94979022e09d86892b4 100644 (file)
@@ -14,7 +14,7 @@
 #include "context-def.hh"
 #include "lily-parser.hh"
 
-LY_DEFINE (ly_layout_lookup, "ly:output-def-lookup",
+LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup",
           2, 1, 0, (SCM pap, SCM sym, SCM def),
           "Lookup @var{sym} in the Output_def @var{pap}. "
           "Return the value or @var{def} (which defaults to  @code{'()}) if undefined.")
@@ -70,7 +70,7 @@ LY_DEFINE (ly_output_description, "ly:output-description",
 {
   Output_def *id = unsmob_output_def (output_def);
 
-  SCM al = ly_module2alist (id->scope_);
+  SCM al = ly_module_2_alist (id->scope_);
   SCM ell = SCM_EOL;
   for (SCM s = al; scm_is_pair (s); s = scm_cdr (s))
     {
index f062c986dbcb75a30c7f5947634ede72ba54452c..8eee6647a7b1a04cc290ae8f76a6371587d0c0eb 100644 (file)
@@ -70,7 +70,7 @@ pfb2pfa (Byte const *pfb, int length)
   return out;
 }
 
-LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa",
+LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
           1, 0, 0, (SCM pfb_file_name),
           "Convert the contents of a PFB file to PFA.")
 {
@@ -94,7 +94,7 @@ LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa",
   return pfa_scm;
 }
 
-LY_DEFINE (ly_otf_to_cff, "ly:otf->cff",
+LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
           1, 0, 0, (SCM otf_file_name),
           "Convert the contents of a OTF file to CFF file, returning it as "
           " a string.")
index 5ae59f9569b0a4c1d6a92c2b9837076b5ec1274d..139a47f304b361d990de7248f2518ad4ec387821 100644 (file)
@@ -217,7 +217,7 @@ LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
 
 
 
-LY_DEFINE (ly_all_option, "ly:all-options",
+LY_DEFINE (ly_all_options, "ly:all-options",
           0, 0, 0, (),
           "Get all option settings in an alist.")
 {
index e5a33e0c4b45976ffc7f50907c5a592b25872931..728dbd1e4ad94877e744e545697e9b11e83d5761 100644 (file)
@@ -10,7 +10,7 @@
 #include "spanner.hh"
 #include "item.hh"
 
-LY_DEFINE (ly_spanner_get_bound, "ly:spanner-bound",
+LY_DEFINE (ly_spanner_bound, "ly:spanner-bound",
           2, 0, 0, (SCM slur, SCM dir),
           "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} "
           "for left, and @code{1} for right.")
index 6ef0e191fd4394bad150cf94dfc7aa45151f3e23..cef3c8a353ec7b73715e6e59fe7375aae90d1a3c 100644 (file)
@@ -16,7 +16,7 @@
   TODO: naming add/combine.
 */
 
-LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis",
+LY_DEFINE (ly_stencil_translate_axis, "ly:stencil-translate-axis",
           3, 0, 0, (SCM stil, SCM amount, SCM axis),
           "Return a copy of @var{stil} but translated by @var{amount} in @var{axis} direction.")
 {
@@ -39,7 +39,7 @@ LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis",
   return new_s;
 }
 
-LY_DEFINE (ly_translate_stencil, "ly:stencil-translate",
+LY_DEFINE (ly_stencil_translate, "ly:stencil-translate",
           2, 0, 0, (SCM stil, SCM offset),
           "Return a @var{stil}, "
           "but translated by @var{offset} (a pair of numbers).")
@@ -281,7 +281,7 @@ LY_DEFINE (ly_bracket, "ly:bracket",
                          0.95 * scm_to_double (t)).smobbed_copy ();
 }
 
-LY_DEFINE (ly_rotate_stencil, "ly:stencil-rotate",
+LY_DEFINE (ly_stencil_rotate, "ly:stencil-rotate",
           4, 0, 0, (SCM stil, SCM angle, SCM x, SCM y),
           "Return a @var{stil} rotated @var{angle} degrees around point (@var{x}, @var{y}).")
 {
@@ -300,7 +300,7 @@ LY_DEFINE (ly_rotate_stencil, "ly:stencil-rotate",
   return new_s;
 }
 
-LY_DEFINE (ly_filled_box, "ly:round-filled-box",
+LY_DEFINE (ly_round_filled_box, "ly:round-filled-box",
           3, 0, 0,
           (SCM xext, SCM yext, SCM blot),
           "Make a @code{Stencil} "
index e6e4fb7dc60faaac59ae85c6354dd8d43a340aa2..c44d24a5779a52344d3da65e53ad176d1124655b 100644 (file)
@@ -36,7 +36,7 @@ LY_DEFINE (ly_event_property, "ly:event-property",
   return e->internal_get_property (sym);
 }
 
-LY_DEFINE (ly_event_set_property, "ly:event-set-property!",
+LY_DEFINE (ly_event_set_property_x, "ly:event-set-property!",
            3, 0, 0, (SCM ev, SCM sym, SCM val),
            "Set property @var{sym} in event @var{ev} to @var{val}."){
   Stream_event *sc = unsmob_stream_event (ev);
index 26deb0841b9db4696abd4ac8a8960aae5d9d2155..092284edba0f6f5fac16726b17c5d215c5323a69 100644 (file)
@@ -243,7 +243,7 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name",
 
 
 
-LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
+LY_DEFINE (ly_ttf_2_pfa, "ly:ttf->pfa",
           1, 0, 0, (SCM ttf_file_name),
           "Convert the contents of a TTF file to Type42 PFA, returning it as "
           " a string.")
index 49636a8b90f6e739c00fab3c6daefdb43d11e8f7..2e3f2afe654fb0bb4d3ba8101483b6b7ce0da995 100644 (file)
@@ -51,7 +51,6 @@
    ly:grob-original
    ly:grob-layout
    ly:grob-parent
-   ly:grob-pq-less?
    ly:grob-property
    ly:grob-script-priority-less
    ly:grob-set-property!