From a92c8cdbe16880c655c05c31a6141324c41406b2 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 00:01:56 +0000 Subject: [PATCH] lilypond-1.3.102 --- lily/include/engraver.hh | 9 +- lily/include/lily-guile.hh | 2 + lily/include/music-output-def.hh | 2 +- lily/include/my-lily-parser.hh | 13 ++- lily/include/translator-def.hh | 2 + lily/my-lily-parser.cc | 26 +++++ lily/parser.yy | 5 + lily/scope.cc | 1 + lily/system-start-delimiter.cc | 40 ++++---- lily/translator-def.cc | 15 +++ scm/generate-backend-documentation.scm | 131 +++++++++++++++++++++++++ scm/lily.scm | 2 +- 12 files changed, 220 insertions(+), 28 deletions(-) create mode 100644 scm/generate-backend-documentation.scm diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 3c20037f7e..3e768cdbf1 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -27,11 +27,12 @@ class Engraver : public virtual Translator { 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. diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 623e852692..d69322d91b 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -84,9 +84,11 @@ void add_scm_init_func (void (*)()); 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 diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index e60743cb25..6d77fbebdc 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -20,8 +20,8 @@ */ class Music_output_def { - Scope *translator_p_dict_p_; public: + Scope *translator_p_dict_p_; Scope *scope_p_; VIRTUAL_COPY_CONS(Music_output_def); diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 3ea7db50a7..7832bb3c07 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -9,6 +9,7 @@ #ifndef MY_LILY_PARSER_HH #define MY_LILY_PARSER_HH + #include "lily-proto.hh" #include "string.hh" #include "parray.hh" @@ -25,7 +26,6 @@ musical content here. We still have to remove default_duration_. TODO: interface is too complicated - */ class My_lily_parser { @@ -57,14 +57,19 @@ public: void parser_error (String); void set_yydebug (bool); + + + DECLARE_SCHEME_CALLBACK(paper_description, ()); private: - + Array define_spot_array_; char const* here_ch_C() const; - Simultaneous_music * get_chord (Musical_pitch tonic, Array* add_arr_p, Array* sub_arr_p, Musical_pitch* inversion_p, Musical_pitch* bass_p, Duration d); - + Simultaneous_music * get_chord (Musical_pitch tonic, Array* add_arr_p, + Array* 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 *); diff --git a/lily/include/translator-def.hh b/lily/include/translator-def.hh index 1fcfc37ab5..634f70db30 100644 --- a/lily/include/translator-def.hh +++ b/lily/include/translator-def.hh @@ -47,6 +47,8 @@ public: Link_array 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); diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 7fe85f3dab..d4fa575511 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -102,5 +102,31 @@ My_lily_parser::here_input() const 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 (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; +} + diff --git a/lily/parser.yy b/lily/parser.yy index ebc0f0759a..10242bfdfe 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1679,9 +1679,14 @@ My_lily_parser::set_yydebug (bool b) yydebug = b; #endif } + +extern My_lily_parser * current_parser; + void My_lily_parser::do_yyparse () { + + current_parser = this;; yyparse ((void*)this); } diff --git a/lily/scope.cc b/lily/scope.cc index ba18c1f44c..5fd04e4257 100644 --- a/lily/scope.cc +++ b/lily/scope.cc @@ -86,3 +86,4 @@ Scope::try_retrieve (SCM k , SCM *v)const { return id_dict_->try_retrieve (k, v); } + diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 1ad12f6d0c..544492852a 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -20,12 +20,11 @@ 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), @@ -115,27 +114,32 @@ System_start_delimiter::brew_molecule (SCM smob) 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) ? 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); } diff --git a/lily/translator-def.cc b/lily/translator-def.cc index 83ae6ac045..3a9cc88de9 100644 --- a/lily/translator-def.cc +++ b/lily/translator-def.cc @@ -304,3 +304,18 @@ Translator_def::default_child_context_name () 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; +} diff --git a/scm/generate-backend-documentation.scm b/scm/generate-backend-documentation.scm new file mode 100644 index 0000000000..a2f445ac78 --- /dev/null +++ b/scm/generate-backend-documentation.scm @@ -0,0 +1,131 @@ + +;;;; +; +; 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
  • " (symbol->string (car prop)) " (" (type-name (cadr prop)) ") -- " + (caddr prop) + "
    default value: " + (if (pair? handle) + (scm->string (cdr handle)) + "not set" + ) + "\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 + "
    " + "

    Interface: " (symbol->string name) "

    \n" + desc + "
    \n
      " + (apply string-append docs) + "
    " + ) + )) + +; +; 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 "LilyPond Element " name " " + "

    " name "

    " + (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 + "
  • " x "\n")) + files)) + ) + + (display + (string-append + "LilyPond backend documentation" + "

    LilyPond backend documentation

    " + "
      " + (apply string-append l) + "
    " + ) + out + ) + )) + +; (display (document-interface stem-interface '())) +; (define b (cdr (assoc 'Dyna all-element-descriptions))) +;(display b) + +;(document-element b) + +(document-elements all-element-descriptions) + diff --git a/scm/lily.scm b/scm/lily.scm index a2834f250e..8dad0147d0 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -766,5 +766,5 @@ (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")) ) -- 2.39.5