protected:
/// utility
Paper_def * paper_l() const;
- /**
- Invoke walker method to typeset element. Default: pass on to daddy.
- */
+
+ /*
+ Call this last thing.
+ */
virtual void typeset_element (Score_element*elem_p);
- /**
+ /*
take note of item/spanner
put item in spanner. Adjust local key; etc.
typedef SCM(*Scheme_function_unknown)();
#if __GNUC_MINOR__ >= 96
+typedef SCM(*Scheme_function_0)();
typedef SCM(*Scheme_function_1)(SCM);
typedef SCM(*Scheme_function_2)(SCM,SCM);
#else
+typedef SCM(*Scheme_function_0)(...);
typedef SCM(*Scheme_function_1)(...);
typedef SCM(*Scheme_function_2)(...);
#endif
*/
class Music_output_def
{
- Scope *translator_p_dict_p_;
public:
+ Scope *translator_p_dict_p_;
Scope *scope_p_;
VIRTUAL_COPY_CONS(Music_output_def);
#ifndef MY_LILY_PARSER_HH
#define MY_LILY_PARSER_HH
+
#include "lily-proto.hh"
#include "string.hh"
#include "parray.hh"
musical content here. We still have to remove default_duration_.
TODO: interface is too complicated
-
*/
class My_lily_parser
{
void parser_error (String);
void set_yydebug (bool);
+
+
+ DECLARE_SCHEME_CALLBACK(paper_description, ());
private:
-
+
Array<Input> define_spot_array_;
char const* here_ch_C() const;
- Simultaneous_music * get_chord (Musical_pitch tonic, Array<Musical_pitch>* add_arr_p, Array<Musical_pitch>* sub_arr_p, Musical_pitch* inversion_p, Musical_pitch* bass_p, Duration d);
-
+ Simultaneous_music * get_chord (Musical_pitch tonic, Array<Musical_pitch>* add_arr_p,
+ Array<Musical_pitch>* sub_arr_p, Musical_pitch* inversion_p,
+ Musical_pitch* bass_p, Duration d);
+
void set_chord_tremolo (int type_i);
void set_last_duration (Duration const *);
void set_last_pitch (Musical_pitch const *);
Link_array<Translator_def> path_to_acceptable_translator (SCM type_str, Music_output_def* odef) const;
Translator_group * instantiate (Music_output_def*);
+ SCM to_alist () const;
+
static SCM make_scm () ;
static void apply_pushpop_property (Translator_group*, SCM syms, SCM eprop, SCM val);
return lexer_p_->here_input ();
}
+// move me?
+#include "paper-def.hh"
+#include "identifier.hh"
+#include "translator-def.hh"
+My_lily_parser * current_parser;
+
+MAKE_SCHEME_CALLBACK(My_lily_parser,paper_description, 0);
+
+SCM
+My_lily_parser::paper_description ()
+{
+ My_lily_parser * me = current_parser;
+
+ Identifier *id = unsmob_identifier (me->lexer_p_->lookup_identifier ("$defaultpaper"));
+ Paper_def *p = dynamic_cast<Paper_def*> (id->access_content_Music_output_def (false));
+
+ SCM al = p->translator_p_dict_p_->to_alist ();
+ SCM l = SCM_EOL;
+ for (SCM s = al ; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Translator_def * td = unsmob_translator_def (gh_cdar (s));
+ l = gh_cons (td->to_alist (), l);
+ }
+ return l;
+}
+
yydebug = b;
#endif
}
+
+extern My_lily_parser * current_parser;
+
void
My_lily_parser::do_yyparse ()
{
+
+ current_parser = this;;
yyparse ((void*)this);
}
{
return id_dict_->try_retrieve (k, v);
}
+
Molecule
System_start_delimiter::staff_bracket (Score_element*me,Real height)
{
- Paper_def* p= me->paper_l ();
Real arc_height = gh_scm2double (me->get_elt_property("arch-height")) ;
SCM at = gh_list (ly_symbol2scm ("bracket"),
- me->get_elt_property ("arch-angle"),
- me->get_elt_property ("arch-width"),
+ me->get_elt_property ("arch-angle"),
+ me->get_elt_property ("arch-width"),
gh_double2scm (arc_height),
me->get_elt_property ("bracket-width"),
gh_double2scm (height),
return m.create_scheme ();
}
-/*
- Ugh. Suck me plenty.
- */
Molecule
System_start_delimiter::staff_brace (Score_element*me,Real y)
{
- int staff_size = 20; // URG.
-
- // URG
- Real step = 1.0;
- int minht = 2 * staff_size;
- int maxht = 7 * minht;
- int idx = int (((maxht - step) <? y - minht) / step);
- idx = idx >? 0;
-
+ int lo = 0;
+ int hi = 255;
Font_metric *fm = Font_interface::get_default_font (me);
-
- SCM at =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
+ Box b;
+
+ /* do a binary search for each Y, not very efficient, but passable? */
+ do
+ {
+ int cmp = (lo + hi) / 2;
+
+ b = fm->get_char (cmp);
+ if (b[Y_AXIS].empty_b () || b[Y_AXIS].length () > y )
+ hi = cmp;
+ else
+ lo = cmp;
+ }
+ while (hi - lo > 1);
+
+ SCM at = gh_list (ly_symbol2scm ("char"), gh_int2scm (lo), SCM_UNDEFINED);
at = fontify_atom (fm, at);
- Box b (Interval (0,0), Interval (-y/2, y/2));
+ b = fm->get_char (lo);
+ b[X_AXIS] = Interval (0,0);
return Molecule(b, at);
}
SCM d = accepts_name_list_;
return gh_pair_p (d) ? gh_car (scm_last_pair (d)) : SCM_EOL;
}
+
+SCM
+Translator_def::to_alist ()const
+{
+ SCM l = SCM_EOL;
+
+ l = gh_cons (gh_cons (ly_symbol2scm ("consists"), consists_name_list_), l);
+ l = gh_cons (gh_cons (ly_symbol2scm ("end-consists"), end_consists_name_list_), l);
+ l = gh_cons (gh_cons (ly_symbol2scm ("accepts"), accepts_name_list_), l);
+ l = gh_cons (gh_cons (ly_symbol2scm ("property-ops"), property_ops_), l);
+ l = gh_cons (gh_cons (ly_symbol2scm ("type-name"), type_name_), l);
+ l = gh_cons (gh_cons (ly_symbol2scm ("group-type"), translator_group_type_), l);
+
+ return l;
+}
--- /dev/null
+
+;;;;
+;
+; This file generates documentation for the backend of lilypond.
+;
+;;;;
+
+
+(define (uniqued-alist alist acc)
+ (if (null? alist) acc
+ (if (assoc (caar alist) acc)
+ (uniqued-alist (cdr alist) acc)
+ (uniqued-alist (cdr alist) (cons (car alist) acc)
+ ))))
+
+;;; TODO
+
+(define (wordwrap string)
+ ""
+ )
+
+(define (self-evaluating? x)
+ (or (number? x) (string? x) (procedure? x) (boolean? x))
+ )
+
+
+(define (htmlfy x)
+ (let*
+ ((x1 (regexp-substitute/global #f ">" x 'pre ">" 'post))
+ (x2 (regexp-substitute/global #f "<" x1 'pre "<" 'post))
+ )
+ x2))
+
+(define (scm->string val)
+ (string-append
+ (if (self-evaluating? val) "" "'")
+ (htmlfy
+ (call-with-output-string (lambda (port) (display val port))))
+ ))
+
+(define (document-property prop desc)
+ (let ((handle (assoc (car prop) desc)))
+ (string-append
+ "\n<li><code>" (symbol->string (car prop)) "</code> (" (type-name (cadr prop)) ") -- "
+ (caddr prop)
+ "<br>default value: <code>"
+ (if (pair? handle)
+ (scm->string (cdr handle))
+ "not set"
+ )
+ "</code>\n"
+ )
+ ))
+
+(define (document-interface interface elt-description)
+ (let* ((name (car interface))
+ (desc (cadr interface))
+ (props (caddr interface))
+ (docs (map (lambda (x) (document-property x elt-description))
+ props))
+ )
+
+ (string-append
+ "<hr>"
+ "<h2>Interface: " (symbol->string name) "</h2>\n"
+ desc
+ "<hr>\n<ul>"
+ (apply string-append docs)
+ "</ul>"
+ )
+ ))
+
+;
+; generate HTML, return filename.
+;
+(define (document-element iname description)
+ (display (string-append "Processing " iname " ... ") (current-error-port))
+ (let* ((metah (assoc 'meta description))
+
+ (meta (if (pair? metah)
+ (cdr metah)
+ '((properties . ()) (name . "huh?"))
+ ))
+
+ (name (cdr (assoc 'name meta)))
+ (ifaces (cdr (assoc 'interface-descriptions meta)))
+ (ifacedoc (map (lambda (x) (document-interface x description))
+ (reverse ifaces)))
+ (outname (string-append name ".html"))
+ (out (open-output-file outname))
+ )
+ (display (string-append "Writing " outname " ... \n") (current-error-port))
+ (display
+ (string-append "<title>LilyPond Element " name " </title>"
+ "<h1>" name "</h1>"
+ (apply string-append ifacedoc))
+ out)
+ outname
+ )
+ )
+
+(define (document-elements elts)
+ (let* ((files (map (lambda (x) (document-element (car x) (cdr x)))
+ elts))
+ (outname (string-append "backend.html"))
+ (out (open-output-file outname))
+ (l (map (lambda (x) (string-append
+ "<li><a href=" x ">" x "</a>\n"))
+ files))
+ )
+
+ (display
+ (string-append
+ "<title>LilyPond backend documentation</title>"
+ "<h1>LilyPond backend documentation</h1>"
+ "<ul>"
+ (apply string-append l)
+ "</ul>"
+ )
+ out
+ )
+ ))
+
+; (display (document-interface stem-interface '()))
+; (define b (cdr (assoc 'Dyna all-element-descriptions)))
+;(display b)
+
+;(document-element b)
+
+(document-elements all-element-descriptions)
+
(eval-string (ly-gulp-file "generic-property.scm"))
(eval-string (ly-gulp-file "basic-properties.scm"))
(eval-string (ly-gulp-file "chord-names.scm"))
- (eval-string (ly-gulp-file "element-descriptions.scm"))
+ (eval-string (ly-gulp-file "element-descriptions.scm"))
)