X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ffunction-documentation.cc;h=99fbdfe6c8ce17838c2f58a90f1eba3517995a4d;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=f190f0e2b8eb1bf0b08c9901b1ef152ec33216f8;hpb=235de94b7408e9badc7b82c8e0dae8f05009adc3;p=lilypond.git diff --git a/lily/function-documentation.cc b/lily/function-documentation.cc index f190f0e2b8..99fbdfe6c8 100644 --- a/lily/function-documentation.cc +++ b/lily/function-documentation.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2004--2010 Han-Wen Nienhuys + Copyright (C) 2004--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,64 +18,73 @@ */ #include +#include using namespace std; #include "std-string.hh" #include "lily-guile.hh" #include "warn.hh" +/* type predicates. */ +#include "global-context.hh" +#include "input.hh" +#include "item.hh" +#include "music.hh" +#include "music-function.hh" +#include "paper-score.hh" +#include "performance.hh" +#include "protected-scm.hh" +#include "spanner.hh" +#include "stream-event.hh" +#include "unpure-pure-container.hh" -static SCM doc_hash_table; +static Protected_scm doc_hash_table; void -ly_check_name (string cxx, string scm_name) +ly_check_name (const string &cxx, const string &scm_name) { string mangle = mangle_cxx_identifier (cxx); if (mangle != scm_name) { - programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name); + programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name); } } - void ly_add_function_documentation (SCM func, - string fname, - string varlist, - string doc) + const string &fname, + const string &varlist, + const string &doc) { if (doc == "") return; - if (!doc_hash_table) - doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59)); + if (!doc_hash_table.is_bound ()) + doc_hash_table = scm_c_make_hash_table (59); string s = string (" - ") + "LilyPond procedure: " + fname + " " + varlist - + "\n" + doc; + + "\n" + doc; scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"), - ly_string2scm (s)); + ly_string2scm (s)); 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.") + 0, 0, 0, (), + "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) + const string &name) { - type_names[ptr] = name; + type_names[ptr] = name; } string @@ -90,46 +99,31 @@ predicate_to_typename (void *ptr) return type_names[ptr]; } -/* type predicates. */ -#include "global-context.hh" -#include "input.hh" -#include "item.hh" -#include "music.hh" -#include "music-function.hh" -#include "paper-score.hh" -#include "performance.hh" -#include "spanner.hh" -#include "stream-event.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"); - ly_add_type_predicate ((void*) &unsmob_stream_event, "Stream_event"); + ly_add_type_predicate ((void *) &is_direction, "direction"); + 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"); + ly_add_type_predicate ((void *) &unsmob, "Paper_score"); + ly_add_type_predicate ((void *) &unsmob, "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"); + ly_add_type_predicate ((void *) &unsmob, "Music"); + ly_add_type_predicate ((void *) &unsmob, "Spanner"); + ly_add_type_predicate ((void *) &unsmob, "Stream_event"); } ADD_SCM_INIT_FUNC (func_doc, init_func_doc);