X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ffunction-documentation.cc;h=77b6133518374991fdbed8ff6b298ad5d304f2d8;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=7e450528ae13e65813f26cbbd6baeba9fa61a6ef;hpb=87eedcd59f4082cb0841528ad5bc82cb1d1191e3;p=lilypond.git diff --git a/lily/function-documentation.cc b/lily/function-documentation.cc index 7e450528ae..77b6133518 100644 --- a/lily/function-documentation.cc +++ b/lily/function-documentation.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2004--2007 Han-Wen Nienhuys + (c) 2004--2008 Han-Wen Nienhuys */ #include @@ -11,15 +11,29 @@ 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, - char const *fname, - char const *varlist, - char const *doc) +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) { - if (!strlen (doc)) + if (doc == "") return; if (!doc_hash_table) @@ -30,13 +44,79 @@ void ly_add_function_documentation (SCM func, scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"), ly_string2scm (s)); - SCM entry = scm_cons (scm_from_locale_string (varlist), scm_from_locale_string (doc)); - scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry); + SCM entry = scm_cons (ly_string2scm (varlist), ly_string2scm (doc)); + scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname.c_str ()), entry); } LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation", 0, 0, 0, (), - "Get a hash table with all lilypond Scheme extension functions.") + "Get a hash table with all LilyPond Scheme extension functions.") { return doc_hash_table; } + + +#include + +map type_names; + +void +ly_add_type_predicate (void *ptr, + string name) +{ + type_names[ptr] = name; +} + +string +predicate_to_typename (void *ptr) +{ + if (type_names.find (ptr) == type_names.end ()) + { + programming_error ("Unknown type predicate"); + return "unknown type"; + } + else + return type_names[ptr]; +} + +/* type predicates. */ +#include "spanner.hh" +#include "item.hh" +#include "music.hh" +#include "music-function.hh" +#include "performance.hh" +#include "paper-score.hh" +#include "global-context.hh" +#include "input.hh" + +void +init_func_doc () +{ + ly_add_type_predicate ((void*) &is_direction, "direction"); + ly_add_type_predicate ((void*) &is_music_function, "Music_function"); + ly_add_type_predicate ((void*) &ly_is_port, "port"); + ly_add_type_predicate ((void*) &ly_cheap_is_list, "list"); + ly_add_type_predicate ((void*) &unsmob_global_context, "Global_context"); + ly_add_type_predicate ((void*) &unsmob_input, "Input"); + ly_add_type_predicate ((void*) &unsmob_moment, "Moment"); + ly_add_type_predicate ((void*) &unsmob_paper_score, "Paper_score"); + ly_add_type_predicate ((void*) &unsmob_performance, "Performance"); + + ly_add_type_predicate ((void*) &is_axis, "axis"); + ly_add_type_predicate ((void*) &is_number_pair, "number pair"); + ly_add_type_predicate ((void*) &ly_is_list, "list"); + ly_add_type_predicate ((void*) &ly_is_procedure, "procedure"); + ly_add_type_predicate ((void*) &ly_is_symbol, "symbol"); + ly_add_type_predicate ((void*) &scm_is_bool, "boolean"); + ly_add_type_predicate ((void*) &scm_is_integer, "integer"); + ly_add_type_predicate ((void*) &scm_is_number, "number"); + ly_add_type_predicate ((void*) &scm_is_pair, "pair"); + ly_add_type_predicate ((void*) &scm_is_rational, "rational"); + ly_add_type_predicate ((void*) &scm_is_string, "string"); + ly_add_type_predicate ((void*) &scm_is_vector, "vector"); + ly_add_type_predicate ((void*) &unsmob_item, "Item"); + ly_add_type_predicate ((void*) &unsmob_music, "Music"); + ly_add_type_predicate ((void*) &unsmob_spanner, "Spanner"); +} + +ADD_SCM_INIT_FUNC (func_doc, init_func_doc);