Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / function-documentation.cc
blob8d7c14b99900f40e42d823cc0f91c8a31becf215
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include <cstring>
21 using namespace std;
23 #include "std-string.hh"
24 #include "lily-guile.hh"
25 #include "warn.hh"
28 static SCM doc_hash_table;
30 void
31 ly_check_name (string cxx, string scm_name)
33 string mangle = mangle_cxx_identifier (cxx);
34 if (mangle != scm_name)
36 programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name);
41 void
42 ly_add_function_documentation (SCM func,
43 string fname,
44 string varlist,
45 string doc)
47 if (doc == "")
48 return;
50 if (!doc_hash_table)
51 doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59));
53 string s = string (" - ") + "LilyPond procedure: " + fname + " " + varlist
54 + "\n" + doc;
56 scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
57 ly_string2scm (s));
58 SCM entry = scm_cons (ly_string2scm (varlist), ly_string2scm (doc));
59 scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname.c_str ()), entry);
62 LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
63 0, 0, 0, (),
64 "Get a hash table with all LilyPond Scheme extension functions.")
66 return doc_hash_table;
70 #include <map>
72 map<void *, string> type_names;
74 void
75 ly_add_type_predicate (void *ptr,
76 string name)
78 type_names[ptr] = name;
81 string
82 predicate_to_typename (void *ptr)
84 if (type_names.find (ptr) == type_names.end ())
86 programming_error ("Unknown type predicate");
87 return "unknown type";
89 else
90 return type_names[ptr];
93 /* type predicates. */
94 #include "global-context.hh"
95 #include "input.hh"
96 #include "item.hh"
97 #include "music.hh"
98 #include "music-function.hh"
99 #include "paper-score.hh"
100 #include "performance.hh"
101 #include "spanner.hh"
102 #include "stream-event.hh"
104 void
105 init_func_doc ()
107 ly_add_type_predicate ((void*) &is_direction, "direction");
108 ly_add_type_predicate ((void*) &is_music_function, "Music_function");
109 ly_add_type_predicate ((void*) &ly_is_port, "port");
110 ly_add_type_predicate ((void*) &ly_cheap_is_list, "list");
111 ly_add_type_predicate ((void*) &unsmob_global_context, "Global_context");
112 ly_add_type_predicate ((void*) &unsmob_input, "Input");
113 ly_add_type_predicate ((void*) &unsmob_moment, "Moment");
114 ly_add_type_predicate ((void*) &unsmob_paper_score, "Paper_score");
115 ly_add_type_predicate ((void*) &unsmob_performance, "Performance");
117 ly_add_type_predicate ((void*) &is_axis, "axis");
118 ly_add_type_predicate ((void*) &is_number_pair, "number pair");
119 ly_add_type_predicate ((void*) &ly_is_list, "list");
120 ly_add_type_predicate ((void*) &ly_is_procedure, "procedure");
121 ly_add_type_predicate ((void*) &ly_is_symbol, "symbol");
122 ly_add_type_predicate ((void*) &scm_is_bool, "boolean");
123 ly_add_type_predicate ((void*) &scm_is_integer, "integer");
124 ly_add_type_predicate ((void*) &scm_is_number, "number");
125 ly_add_type_predicate ((void*) &scm_is_pair, "pair");
126 ly_add_type_predicate ((void*) &scm_is_rational, "rational");
127 ly_add_type_predicate ((void*) &scm_is_string, "string");
128 ly_add_type_predicate ((void*) &scm_is_vector, "vector");
129 ly_add_type_predicate ((void*) &unsmob_item, "Item");
130 ly_add_type_predicate ((void*) &unsmob_music, "Music");
131 ly_add_type_predicate ((void*) &unsmob_spanner, "Spanner");
132 ly_add_type_predicate ((void*) &unsmob_stream_event, "Stream_event");
135 ADD_SCM_INIT_FUNC (func_doc, init_func_doc);