From: Han-Wen Nienhuys Date: Fri, 26 Jan 2007 16:25:58 +0000 (+0100) Subject: uniformize C++ <-> scheme name mappings. X-Git-Tag: release/2.11.15-1~32 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=11164b5cb08da70748b1e431adbe907f4314e75b;p=lilypond.git uniformize C++ <-> scheme name mappings. --- diff --git a/lily/book-scheme.cc b/lily/book-scheme.cc index 23237dbb0d..3a162ac392 100644 --- a/lily/book-scheme.cc +++ b/lily/book-scheme.cc @@ -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, diff --git a/lily/context-scheme.cc b/lily/context-scheme.cc index a6ee973a1c..f4a2f6191c 100644 --- a/lily/context-scheme.cc +++ b/lily/context-scheme.cc @@ -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}.") { diff --git a/lily/dispatcher-scheme.cc b/lily/dispatcher-scheme.cc index 9e491e0a9a..06da9c1602 100644 --- a/lily/dispatcher-scheme.cc +++ b/lily/dispatcher-scheme.cc @@ -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}." ) { diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 4b8c4605c0..e2dfeec744 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -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.") { diff --git a/lily/function-documentation.cc b/lily/function-documentation.cc index b700fad320..e59df62192 100644 --- a/lily/function-documentation.cc +++ b/lily/function-documentation.cc @@ -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) diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index cbc3b605ed..868d2d11fb 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -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.") { diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index 476cae950c..7cb4afab87 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -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-pqget_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}") diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 85c30ffb47..400ead26ea 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -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); \ diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index 17595408a7..abb4b20040 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -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); diff --git a/lily/include/music.hh b/lily/include/music.hh index ec6f98766c..4ed048fda0 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -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; diff --git a/lily/input-scheme.cc b/lily/input-scheme.cc index 2ff7bf5007..3f14236759 100644 --- a/lily/input-scheme.cc +++ b/lily/input-scheme.cc @@ -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).") diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 976b19e47c..bdfcae1648 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -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, "__", "::"); cxx_id = replace_all (cxx_id, '_', '-'); + + return cxx_id; } diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index ca1d224bd6..cb84471b9c 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -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.") { diff --git a/lily/ly-module.cc b/lily/ly-module.cc index c2e96a4a1c..581984dfe9 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -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.") { diff --git a/lily/moment-scheme.cc b/lily/moment-scheme.cc index b19259e6b2..9bad172300 100644 --- a/lily/moment-scheme.cc +++ b/lily/moment-scheme.cc @@ -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.") { diff --git a/lily/music-scheme.cc b/lily/music-scheme.cc index 711df4d1a1..ce4268d9c8 100644 --- a/lily/music-scheme.cc +++ b/lily/music-scheme.cc @@ -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}.") { diff --git a/lily/music.cc b/lily/music.cc index b22e243139..77c8f34335 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -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)) diff --git a/lily/output-def-scheme.cc b/lily/output-def-scheme.cc index a806781015..13c4d7456f 100644 --- a/lily/output-def-scheme.cc +++ b/lily/output-def-scheme.cc @@ -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)) { diff --git a/lily/pfb.cc b/lily/pfb.cc index f062c986db..8eee6647a7 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -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.") diff --git a/lily/program-option.cc b/lily/program-option.cc index 5ae59f9569..139a47f304 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -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.") { diff --git a/lily/spanner-scheme.cc b/lily/spanner-scheme.cc index e5a33e0c4b..728dbd1e4a 100644 --- a/lily/spanner-scheme.cc +++ b/lily/spanner-scheme.cc @@ -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.") diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 6ef0e191fd..cef3c8a353 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -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} " diff --git a/lily/stream-event-scheme.cc b/lily/stream-event-scheme.cc index e6e4fb7dc6..c44d24a577 100644 --- a/lily/stream-event-scheme.cc +++ b/lily/stream-event-scheme.cc @@ -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); diff --git a/lily/ttf.cc b/lily/ttf.cc index 26deb0841b..092284edba 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -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.") diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index 49636a8b90..2e3f2afe65 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -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!