*/
#include "lily-guile.hh"
+#include "protected-scm.hh"
+#include "string.hh"
Protected_scm all_ifaces;
--- /dev/null
+/*
+ kpath-private.hh -- declare
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef KPATH_PRIVATE_HH
+#define KPATH_PRIVATE_HH
+
+kpse_file_format_type kpathsea_find_format (String name);
+
+#endif /* KPATH_PRIVATE_HH */
+
+
+
--- /dev/null
+/*
+ input-scheme.cc -- implement Input bindings.
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "string.hh"
+#include "input-smob.hh"
+
+/* We don't use IMPLEMENT_TYPE_P, since the smobification part is
+ implemented separately from the class. */
+LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
+ (SCM x),
+ "Return #t if @var{x} is an input location.")
+{
+ return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
+}
+
+LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg),
+ "Print @var{msg} as a GNU compliant error message, pointing to the"
+ "location in @var{sip}.\n")
+{
+ Input *ip = unsmob_input (sip);
+ SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
+ SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
+
+ String m = ly_scm2string (msg);
+ ip->message (m);
+
+ return SCM_UNSPECIFIED;
+}
+
+/*
+ TODO: rename this function. ly:input-location? vs ly:input-location
+ */
+LY_DEFINE (ly_input_location, "ly:input-location", 1, 0, 0, (SCM sip),
+ "Return input location in @var{sip} as (file-name line column).")
+{
+ Input *ip = unsmob_input (sip);
+ SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
+ return scm_list_3 (scm_makfrom0str (ip->file_string ().to_str0 ()),
+ scm_int2num (ip->line_number ()),
+ scm_int2num (ip->column_number ()));
+}
return 0;
}
-/* We don't use IMPLEMENT_TYPE_P, since the smobification part is
- implemented separately from the class. */
-LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
- (SCM x),
- "Return #t if @var{x} is an input location.")
-{
- return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
-}
-
-LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg),
- "Print @var{msg} as a GNU compliant error message, pointing to the"
- "location in @var{sip}.\n")
-{
- Input *ip = unsmob_input (sip);
- SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
- SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
-
- String m = ly_scm2string (msg);
- ip->message (m);
-
- return SCM_UNSPECIFIED;
-}
-
-/*
- TODO: rename this function. ly:input-location? vs ly:input-location
- */
-LY_DEFINE (ly_input_location, "ly:input-location", 1, 0, 0, (SCM sip),
- "Return input location in @var{sip} as (file-name line column).")
-{
- Input *ip = unsmob_input (sip);
- SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
- return scm_list_3 (scm_makfrom0str (ip->file_string ().to_str0 ()),
- scm_int2num (ip->line_number ()),
- scm_int2num (ip->column_number ()));
-}
ADD_SCM_INIT_FUNC (input, start_input_smobs);
--- /dev/null
+/*
+ kpath-scheme.cc -- implement kpathsea bindings
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "kpath.hh"
+
+#include <cstdio>
+#include <cstring>
+
+/*
+
+The problem, as far as I can tell, is that MacOS X has its getopt
+prototype in <unistd.h>, while I think other operating systems have it
+in other places. <unistd.h> is included by kpathsea.h, so you end up
+renaming both conflicting prototypes to YAKLUDGE.
+
+I found a somewhat more elegant patch for this: Just #include
+<unistd.h> before defining YAKLUDGE.
+
+*/
+
+#include <unistd.h>
+
+#include "config.hh"
+
+#define popen REALLYUGLYKLUDGE
+#define pclose ANOTHERREALLYUGLYKLUDGE
+#define getopt YAKLUDGE
+
+#if HAVE_KPATHSEA_KPATHSEA_H
+extern "C" {
+#include <kpathsea/kpathsea.h>
+#include <kpathsea/tex-file.h>
+}
+#endif
+
+#include "file-path.hh"
+#include "main.hh"
+#include "source-file.hh"
+#include "warn.hh"
+#include "kpath-private.hh"
+
+LY_DEFINE (ly_find_file, "ly:find-file",
+ 1, 0, 0, (SCM name),
+ "Return the absolute file name of @var{name},"
+ "or @code{#f} if not found.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+ String nm = ly_scm2string (name);
+ String file_name = global_path.find (nm);
+ if (file_name.is_empty ())
+ return SCM_BOOL_F;
+
+ return scm_makfrom0str (file_name.to_str0 ());
+}
+
+LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
+ 1, 0, 0, (SCM name),
+ "Return the absolute file name of @var{name},"
+ "or @code{#f} if not found.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+ String nm = ly_scm2string (name);
+ String file_name = global_path.find (nm);
+ if (file_name.is_empty ())
+ {
+ if (char *p = kpse_find_file (nm.to_str0 (), kpathsea_find_format (nm),
+ true))
+ return scm_makfrom0str (p);
+ return SCM_BOOL_F;
+ }
+ return scm_makfrom0str (file_name.to_str0 ());
+}
+
+LY_DEFINE (ly_kpathsea_expand_variable, "ly:kpathsea-expand-variable",
+ 1, 0, 0, (SCM var),
+ "Return the expanded version @var{var}.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string");
+
+ String nm = ly_scm2string (var);
+ char *result = kpse_var_expand (nm.to_str0 ());
+ SCM ret = scm_makfrom0str (result);
+ delete[] result;
+
+ return ret;
+}
#include "main.hh"
#include "source-file.hh"
#include "warn.hh"
+#include "kpath-private.hh"
String
kpathsea_find_afm (char const *name)
#if KPATHSEA
/* FIXME: this should be part of kpathsea */
-static kpse_file_format_type
+kpse_file_format_type
kpathsea_find_format (String name)
{
for (int i = 0; i < kpse_last_format; i++)
}
-LY_DEFINE (ly_find_file, "ly:find-file",
- 1, 0, 0, (SCM name),
- "Return the absolute file name of @var{name},"
- "or @code{#f} if not found.")
-{
- SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
-
- String nm = ly_scm2string (name);
- String file_name = global_path.find (nm);
- if (file_name.is_empty ())
- return SCM_BOOL_F;
-
- return scm_makfrom0str (file_name.to_str0 ());
-}
-
-LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
- 1, 0, 0, (SCM name),
- "Return the absolute file name of @var{name},"
- "or @code{#f} if not found.")
-{
- SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
-
- String nm = ly_scm2string (name);
- String file_name = global_path.find (nm);
- if (file_name.is_empty ())
- {
- if (char *p = kpse_find_file (nm.to_str0 (), kpathsea_find_format (nm),
- true))
- return scm_makfrom0str (p);
- return SCM_BOOL_F;
- }
- return scm_makfrom0str (file_name.to_str0 ());
-}
-
-LY_DEFINE (ly_kpathsea_expand_variable, "ly:kpathsea-expand-variable",
- 1, 0, 0, (SCM var),
- "Return the expanded version @var{var}.")
-{
- SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string");
-
- String nm = ly_scm2string (var);
- char *result = kpse_var_expand (nm.to_str0 ());
- SCM ret = scm_makfrom0str (result);
- delete[] result;
-
- return ret;
-}
void
initialize_kpathsea (char *av0)
/*
- score-scheme.cc -- implement
+ score-scheme.cc -- implement Score bindings.
source file of the GNU LilyPond music typesetter
#include "score.hh"
#include "music.hh"
+#include "output-def.hh"
+#include "global-context.hh"
LY_DEFINE (ly_music_scorify, "ly:music-scorify",
2, 0, 0,
scm_gc_unprotect_object (score->self_scm ());
return score->self_scm ();
}
+
+LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
+ 2, 1, 0, (SCM score, SCM layout, SCM key),
+ "Run @var{score} through @var{layout}, an output definition, "
+ "scaled to correct outputscale already, "
+ "return a list of layout-lines. "
+ "\nTake optional Object_key argument."
+ )
+{
+ Score * sc = unsmob_score (score);
+ Output_def *od = unsmob_output_def (layout);
+
+ if (sc->error_found_)
+ {
+ return SCM_EOL;
+ }
+
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
+ SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
+
+ Output_def * score_def = 0;
+
+ /* UGR, FIXME, these are default \layout blocks once again. They
+ suck. */
+ for (int i = 0; !score_def && i < sc->defs_.size (); i++)
+ if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
+ score_def = sc->defs_[i];
+
+ if (!score_def)
+ return scm_c_make_vector (0, SCM_EOL);
+
+ score_def = score_def->clone ();
+ SCM prot = score_def->self_scm ();
+ scm_gc_unprotect_object (prot);
+
+ /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
+ itself. */
+ score_def->parent_ = od;
+
+ SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
+ key);
+ SCM lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
+
+ scm_remember_upto_here_1 (prot);
+ return lines;
+}
-LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
- 2, 1, 0, (SCM score, SCM layout, SCM key),
- "Run @var{score} through @var{layout}, an output definition, "
- "scaled to correct outputscale already, "
- "return a list of layout-lines. "
- "\nTake optional Object_key argument."
- )
-{
- Score * sc = unsmob_score (score);
- Output_def *od = unsmob_output_def (layout);
-
- if (sc->error_found_)
- {
- return SCM_EOL;
- }
-
- SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
- SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
-
- Output_def * score_def = 0;
-
- /* UGR, FIXME, these are default \layout blocks once again. They
- suck. */
- for (int i = 0; !score_def && i < sc->defs_.size (); i++)
- if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
- score_def = sc->defs_[i];
-
- if (!score_def)
- return scm_c_make_vector (0, SCM_EOL);
-
- score_def = score_def->clone ();
- SCM prot = score_def->self_scm ();
- scm_gc_unprotect_object (prot);
-
- /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
- itself. */
- score_def->parent_ = od;
-
- SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
- key);
- SCM lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
-
- scm_remember_upto_here_1 (prot);
- return lines;
-}
void
Score::set_music (SCM music, SCM parser)