Compile fix.
[lilypond.git] / lily / function-documentation.cc
blob909eb1030b50a9ffe2a7f104f4ab40f1b2272cd2
1 /*
2 function-documentation.cc -- Scheme doc strings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include <cstring>
10 using namespace std;
12 #include "std-string.hh"
13 #include "lily-guile.hh"
14 #include "warn.hh"
17 static SCM doc_hash_table;
19 void
20 ly_check_name (string cxx, string scm_name)
22 string mangle = mangle_cxx_identifier (cxx);
23 if (mangle != scm_name)
25 programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name);
30 void
31 ly_add_function_documentation (SCM func,
32 string fname,
33 string varlist,
34 string doc)
36 if (doc == "")
37 return;
39 if (!doc_hash_table)
40 doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59));
42 string s = string (" - ") + "LilyPond procedure: " + fname + " " + varlist
43 + "\n" + doc;
45 scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
46 ly_string2scm (s));
47 SCM entry = scm_cons (ly_string2scm (varlist), ly_string2scm (doc));
48 scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname.c_str ()), entry);
51 LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
52 0, 0, 0, (),
53 "Get a hash table with all LilyPond Scheme extension functions.")
55 return doc_hash_table;
59 #include <map>
61 map<void *, string> type_names;
63 void
64 ly_add_type_predicate (void *ptr,
65 string name)
67 type_names[ptr] = name;
70 string
71 predicate_to_typename (void *ptr)
73 if (type_names.find (ptr) == type_names.end ())
75 programming_error ("Unknown type predicate");
76 return "unknown type";
78 else
79 return type_names[ptr];
82 /* type predicates. */
83 #include "spanner.hh"
84 #include "item.hh"
85 #include "music.hh"
86 #include "music-function.hh"
87 #include "performance.hh"
88 #include "paper-score.hh"
89 #include "global-context.hh"
90 #include "input.hh"
92 void
93 init_func_doc ()
95 ly_add_type_predicate ((void*) &is_direction, "direction");
96 ly_add_type_predicate ((void*) &is_music_function, "Music_function");
97 ly_add_type_predicate ((void*) &ly_is_port, "port");
98 ly_add_type_predicate ((void*) &ly_cheap_is_list, "list");
99 ly_add_type_predicate ((void*) &unsmob_global_context, "Global_context");
100 ly_add_type_predicate ((void*) &unsmob_input, "Input");
101 ly_add_type_predicate ((void*) &unsmob_moment, "Moment");
102 ly_add_type_predicate ((void*) &unsmob_paper_score, "Paper_score");
103 ly_add_type_predicate ((void*) &unsmob_performance, "Performance");
105 ly_add_type_predicate ((void*) &is_axis, "axis");
106 ly_add_type_predicate ((void*) &is_number_pair, "number pair");
107 ly_add_type_predicate ((void*) &ly_is_list, "list");
108 ly_add_type_predicate ((void*) &ly_is_procedure, "procedure");
109 ly_add_type_predicate ((void*) &ly_is_symbol, "symbol");
110 ly_add_type_predicate ((void*) &scm_is_bool, "boolean");
111 ly_add_type_predicate ((void*) &scm_is_integer, "integer");
112 ly_add_type_predicate ((void*) &scm_is_number, "number");
113 ly_add_type_predicate ((void*) &scm_is_pair, "pair");
114 ly_add_type_predicate ((void*) &scm_is_rational, "rational");
115 ly_add_type_predicate ((void*) &scm_is_string, "string");
116 ly_add_type_predicate ((void*) &scm_is_vector, "vector");
117 ly_add_type_predicate ((void*) &unsmob_item, "Item");
118 ly_add_type_predicate ((void*) &unsmob_music, "Music");
119 ly_add_type_predicate ((void*) &unsmob_spanner, "Spanner");
122 ADD_SCM_INIT_FUNC (func_doc, init_func_doc);