source file of the GNU LilyPond music typesetter
- (c) 2001--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2001--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "program-option.hh"
#include <cstring>
using namespace std;
+#include "profile.hh"
#include "international.hh"
#include "main.hh"
#include "parse-scm.hh"
#include "string-convert.hh"
#include "warn.hh"
-/* Write midi as formatted ascii stream? */
-bool do_midi_debugging_global;
-bool use_object_keys;
+bool debug_skylines;
/*
Backwards compatibility.
crash if internally the wrong type is used for a grob property.
*/
bool do_internal_type_checking_global;
+bool strict_infinity_checking = false;
static SCM option_hash;
profile_property_accesses = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
- else if (var == ly_symbol2scm ("midi-debug"))
- {
- do_midi_debugging_global = to_boolean (val);
- val = scm_from_bool (to_boolean (val));
- }
else if (var == ly_symbol2scm ("point-and-click"))
{
point_and_click_global = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
- else if (var == ly_symbol2scm ("parse-protect"))
+ else if (var == ly_symbol2scm ("protected-scheme-parsing"))
{
parse_protect_global = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
- else if (var == ly_symbol2scm ("internal-type-checking"))
+ else if (var == ly_symbol2scm ("check-internal-types"))
{
do_internal_type_checking_global = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
+ else if (var == ly_symbol2scm ("debug-gc-assert-parsed-dead"))
+ {
+ parsed_objects_should_be_dead = to_boolean (val);
+ val = scm_from_bool (parsed_objects_should_be_dead);
+ }
+ else if (var == ly_symbol2scm ("safe"))
+ {
+ be_safe_global = to_boolean (val);
+ val = scm_from_bool (be_safe_global);
+ }
else if (var == ly_symbol2scm ("old-relative"))
{
lily_1_8_relative = to_boolean (val);
lily_1_8_compatibility_used = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
- else if (var == ly_symbol2scm ("object-keys"))
+ else if (var == ly_symbol2scm ("strict-infinity-checking"))
{
- use_object_keys = to_boolean (val);
+ strict_infinity_checking = to_boolean (val);
+ val = scm_from_bool (to_boolean (val));
+ }
+ else if (var == ly_symbol2scm ("debug-skylines"))
+ {
+ debug_skylines = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
}
/*
Hmmm. should do in SCM / C++ ?
*/
-static std::string
+static string
get_help_string ()
{
SCM alist = ly_hash2alist (option_hash);
SCM convertor = ly_lily_module_constant ("scm->string");
- std::vector<std::string> opts;
+ vector<string> opts;
for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
{
SCM sym = scm_caar (s);
SCM val = scm_cdar (s);
- std::string opt_spec
+ string opt_spec
= String_convert::char_string (' ', INDENT)
+ ly_symbol2string (sym)
+ " ("
SCM opt_help_scm
= scm_object_property (sym, ly_symbol2scm ("program-option-documentation"));
- std::string opt_help = ly_scm2string (opt_help_scm);
+ string opt_help = ly_scm2string (opt_help_scm);
replace_all (opt_help,
- std::string ("\n"),
- std::string ("\n")
+ string ("\n"),
+ string ("\n")
+ String_convert::char_string (' ', HELP_INDENT));
opts.push_back (opt_spec + opt_help + "\n");
}
- std::string help ("Options supported by ly:set-option\n\n");
- opts.sort (string_compare);
+ string help ("Options supported by ly:set-option\n\n");
+ vector_sort (opts, less<string> ());
for (vsize i = 0; i < opts.size (); i++)
help += opts[i];
- help += std::string ("\n");
+ help += string ("\n");
return help;
}
LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (),
- "Print ly:set-option usage")
+ "Print @code{ly:set-option} usage")
{
- std::string help = get_help_string ();
- fputs (help.c_str (), stdout);
+ string help = get_help_string ();
+ progress_indication (help);
- exit (0);
return SCM_UNSPECIFIED;
}
__FUNCTION__, "symbol");
if (ly_symbol2scm ("help") == var)
- ly_option_usage ();
+ {
+ ly_option_usage ();
+ exit (0);
+ }
if (val == SCM_UNDEFINED)
val = SCM_BOOL_T;
- std::string varstr = ly_scm2string (scm_symbol_to_string (var));
- if (varstr.substr (0, 3) == std::string ("no-"))
+ string varstr = ly_scm2string (scm_symbol_to_string (var));
+ if (varstr.substr (0, 3) == string ("no-"))
{
var = ly_symbol2scm (varstr.substr (3, varstr.length () -3).c_str ());
val = scm_from_bool (!to_boolean (val));
return SCM_UNSPECIFIED;
}
+LY_DEFINE (ly_command_line_options, "ly:command-line-options", 0, 0, 0, (),
+ "The Scheme specified on command-line with @samp{-d}.")
+{
+ return ly_string2scm (init_scheme_variables_global);
+}
+
+LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (),
+ "The Scheme specified on command-line with @samp{-e}.")
+{
+ return ly_string2scm (init_scheme_code_global);
+}
+
LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
"Was be_verbose_global set?")
{
return scm_from_bool (be_verbose_global);
}
+
+
+LY_DEFINE (ly_all_option, "ly:all-options",
+ 0, 0, 0, (),
+ "Get all option settings in an alist.")
+{
+ return ly_hash2alist (option_hash);
+}
+
+
LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
"Get a global option setting.")
{
SCM_ARG1, __FUNCTION__, "symbol");
return scm_hashq_ref (option_hash, var, SCM_BOOL_F);
}
+
+
+
+bool
+get_program_option (const char *s)
+{
+ SCM sym = ly_symbol2scm (s);
+
+ return to_boolean (ly_get_option (sym));
+}