]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.102
authorfred <fred>
Wed, 27 Mar 2002 00:01:56 +0000 (00:01 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:01:56 +0000 (00:01 +0000)
12 files changed:
lily/include/engraver.hh
lily/include/lily-guile.hh
lily/include/music-output-def.hh
lily/include/my-lily-parser.hh
lily/include/translator-def.hh
lily/my-lily-parser.cc
lily/parser.yy
lily/scope.cc
lily/system-start-delimiter.cc
lily/translator-def.cc
scm/generate-backend-documentation.scm [new file with mode: 0644]
scm/lily.scm

index 3c20037f7e357140c0436f0301fa30de00f79871..3e768cdbf1678e23288b4c7baf8232fe1c1ea426 100644 (file)
@@ -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.
 
index 623e8526924fee7540c0116a5cbd4461acc5ac26..d69322d91b62958bd31f6388f3054117b08b1433 100644 (file)
@@ -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
index e60743cb2561c8fd79d87427bf7de48b294314ae..6d77fbebdcde45ff2b29eab43939f718c6141f13 100644 (file)
@@ -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);
index 3ea7db50a78a2c6b1923e045a6926203bfb159de..7832bb3c07ccf1385ad0a1df713f9d2e52c0cf46 100644 (file)
@@ -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<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 *);
index 1fcfc37ab5f28cdb9c31744fc0144a119e85477a..634f70db3027904d8792db170264ffdd1883c3c5 100644 (file)
@@ -47,6 +47,8 @@ public:
   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);
 
index 7fe85f3dab2ccb6370caf7be6db0580fff4c8f6d..d4fa575511aa36e8573b97730b99b539e0e65fc3 100644 (file)
@@ -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<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;  
+}
+  
 
index ebc0f0759a0d6cedb15d27fea48615f62267076f..10242bfdfe0e4c877306016be28ed9e4a8ccf855 100644 (file)
@@ -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);
 }
 
index ba18c1f44c707362c82048ec295597da4f4e5be4..5fd04e4257c5e02f36ae54fd6d21f79dfeceb385 100644 (file)
@@ -86,3 +86,4 @@ Scope::try_retrieve (SCM k , SCM *v)const
 {
   return id_dict_->try_retrieve (k, v);
 }
+
index 1ad12f6d0cbf92240f280998445bb92eee8e6fd0..544492852a2034bf69fde9e6ffea0f3e86da3994 100644 (file)
 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) <? 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);
 }
index 83ae6ac0452a5dbb865ec0c65962638094772288..3a9cc88de92ccd7c02de3cb7258375d854f62432 100644 (file)
@@ -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 (file)
index 0000000..a2f445a
--- /dev/null
@@ -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 "&gt;" 'post))
+       (x2 (regexp-substitute/global #f "<" x1 'pre "&lt;" '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)
+
index a2834f250ec0ec2bc415daf3b4c3358f7a4b6b4e..8dad0147d05c99ea509c9da7babf8d7fc8c656c3 100644 (file)
   (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"))
  )