]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.0.15.jcn3: guilig atoom
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 13 Oct 1998 22:52:55 +0000 (01:52 +0300)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 13 Oct 1998 22:52:55 +0000 (01:52 +0300)
pl 15.jcn3
- try at scheme in Atom

17 files changed:
NEWS
VERSION
init/declarations.ly
init/scm.ly [new file with mode: 0644]
lily/atom.cc
lily/include/atom.hh
lily/include/lookup.hh
lily/include/ps-lookup.hh
lily/include/tex-lookup.hh
lily/lookup.cc
lily/main.cc
lily/my-lily-lexer.cc
lily/parser.yy
lily/ps-lookup.cc
lily/ps-outputter.cc
lily/tex-lookup.cc
make/STATE-VECTOR

diff --git a/NEWS b/NEWS
index 11fe12c20663e527272fa95826629e0e2d7ed9e6..12dcd9281f46eccd1cf99cb88ecfd3cf6d839a12 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+pl 15.jcn3
+       - try at scheme in Atom
+
 pl 15.jcn2
        - autoconf on guile
        - graphical-lisp-element + silly half hook-up with autuplet
diff --git a/VERSION b/VERSION
index bddde17e0092518d9bde904cb764c9a82f744cfc..9970bc70be380177ee46bab69b19e2930ef12bca 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=0
 PATCH_LEVEL=15
-MY_PATCH_LEVEL=jcn2
+MY_PATCH_LEVEL=jcn3
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index ec6a60a127dca2d318a32467b0f2b852466c219d..462671530bafba90a79891dbe1eb5f8c08563e4b 100644 (file)
@@ -33,5 +33,7 @@ nobreak = { \penalty = -10000; }
 
 \include "property.ly"
 
+\include "scm.ly"
+
 % music = "\melodic\relative c"
 
diff --git a/init/scm.ly b/init/scm.ly
new file mode 100644 (file)
index 0000000..24883e0
--- /dev/null
@@ -0,0 +1,8 @@
+\scm "
+(define (add-column p) (display \"adding column (in guile): \") (display p) (newline))
+(define (dashed-slur o l) (newline) (display \"output type: \") (display o) (newline) (display \"controls: \") (map display l) (newline))
+";
+
+% deze is blond
+% ((lambda (o) (dashed-slur o '((0.0 0.0) (17.2124966172942 -16.8303258151405) (161.324688856776 -15.2124966172942) (178.155014671916 2.0)))) 'ps)
+
index 76b59197d39219634b934a0f5761588a76705558..3f79970b7154d1ad8f369db4c40ec088a7e7cfd8 100644 (file)
@@ -76,12 +76,14 @@ Atom::Atom ()
     But Atom is used as a simple type *everywhere*,
     and we don't have virtual contructors.
    */
+  lambda_ = 0;
   str_ = global_lookup_l->unknown_str ();
 }
 
 Atom::Atom (String s, Box b)
   :  dim_ (b)
 {
+  lambda_ = 0;
   str_ = s;
 }
 
index 0d88e7ce315cbba217a753c552fdc4c15f32e6f1..fcd434f0ab4f3e0226c2a375edf394f80001f17f 100644 (file)
@@ -9,17 +9,18 @@
 #ifndef ATOM_HH
 #define ATOM_HH
 
+#include "lily-guile.hh"
 #include "string.hh"
 #include "box.hh"
 #include "lily-proto.hh"
 
-
 /// a symbol which can be translated, and freely copied
 class Atom {
   Offset off_;
 public:
   String str_;
   String font_;
+  SCM lambda_;
   Box dim_;
 
   Offset offset () const;
index 7efe60bb7e5c03fa4d4d06e7a2c32455c0a887ba..4d2325ae82d01a6f069acea2ee7989cb667a476d 100644 (file)
@@ -40,7 +40,8 @@ public:
   Atom beam (Real,Real, Real) const;
   virtual String character_str (int i) const;
   Atom clef (String) const;
-  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const = 0;
+//  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const = 0;
+  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
   Atom dots () const;
   Atom dynamic (String) const;
   Atom fill (Box b) const;
index 2eb9ed025a934d6b8a8e58ffcac6ceaf3a6fad84..9b8ef622e5ef43bd63930d2cb8ec20a1938a3a3c 100644 (file)
@@ -22,7 +22,7 @@ public:
   virtual Atom afm_find (String s) const;
   virtual Atom* atom_p (String, int, Box) const;
   virtual String character_str (int i) const;
-  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
+//  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
   virtual Atom hairpin (Real width, bool decresc, bool continued) const;
   virtual Lookup* lookup_p (Lookup const&) const;
   virtual Lookup* lookup_p (Symtables const&) const;
index cdb9839fcc5f3c685b0b4648be8a2e42e0892816..4b9d598e08d12d9cc872b57c762d6baab651f38e 100644 (file)
@@ -22,7 +22,7 @@ public:
 
   virtual Atom afm_find (String s) const;
   virtual String character_str (int i) const;
-  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
+//  virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
   virtual Atom* atom_p (String, int, Box) const;
   Atom embed (Atom a) const;
   virtual Atom hairpin (Real width, bool decresc, bool continued) const;
index 8ba88483f5f080c3bf4fdf17d0a2274863318bf8..faed69f1aab93226e29ea479fd17fce81f024a69 100644 (file)
@@ -150,6 +150,81 @@ Lookup::clef (String st) const
   return afm_find (String ("clefs") + String ("-") + st);
 }
 
+Atom
+Lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
+{
+  assert (controls.size () == 8);
+
+  Real dx = controls[3].x () - controls[0].x ();
+  Real dy = controls[3].y () - controls[0].y ();
+
+  Atom a;
+  a.font_ = font_;
+  a.dim_[X_AXIS] = Interval (0, dx);
+  a.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
+
+#if 0
+
+  for (int i = 1; i < 4; i++)
+    ps += String_convert::double_str (controls[i].x ()) + " "
+      + String_convert::double_str (controls[i].y ()) + " ";
+
+  ps += String_convert::double_str (controls[0].x ()) + " "
+    + String_convert::double_str (controls[0].y ()) + " ";
+
+  ps += String_convert::double_str (thick) + " ";
+  Real on = dash > 1? thick * dash - thick : 0;
+  Real off = 2 * thick;
+  ps += "[" + String_convert::double_str (on) + " ";
+  ps += String_convert::double_str (off) + "] ";
+  ps += String_convert::int_str (0) + " ";
+  ps += "draw_dashed_slur ";
+
+  Atom a;
+  a.str_ = ps;
+  a.font_ = font_;
+  a.dim_[X_AXIS] = Interval (0, dx);
+  a.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
+
+  a.str_ = ps;
+
+#else
+
+  SCM list_scm = gh_eval_str ("list");
+  // ((0.1 0.2) (1.1 1.2) (2.1 2.2) (3.1 3.2))
+  SCM controls_scm = 
+    gh_cons (gh_call2 (list_scm, gh_double2scm (controls[0].x ()), gh_double2scm (controls[0].y ())),
+    gh_cons (gh_call2 (list_scm, gh_double2scm (controls[1].x ()), gh_double2scm (controls[1].y ())),
+    gh_cons (gh_call2 (list_scm, gh_double2scm (controls[2].x ()), gh_double2scm (controls[2].y ())),
+    gh_cons (gh_call2 (list_scm, gh_double2scm (controls[3].x ()), gh_double2scm (controls[3].y ())),
+    SCM_EOL))));
+
+  gh_newline ();
+  gh_display (controls_scm);
+  gh_newline ();
+
+  SCM append_scm = gh_eval_str ("append");
+
+  // (dashed-slur o ((0.1 0.2) (1.1 1.2) (2.1 2.2) (3.1 3.2)))
+  SCM dashed_slur_scm = 
+    gh_call1 (gh_eval_str ("list"),
+    gh_call2 (append_scm, 
+             gh_eval_str ("cons '(dashed-slur o)"), 
+             gh_call1 (gh_eval_str ("list"), controls_scm)));
+  gh_display (dashed_slur_scm); 
+  gh_newline ();
+
+  // (lambda (o) dashed-slur o ((0.1 0.2) (1.1 1.2) (2.1 2.2) (3.1 3.2)))
+  a.lambda_ =
+    gh_call2 (append_scm, gh_eval_str ("'(lambda (o))"), dashed_slur_scm);
+  gh_display (a.lambda_);
+  gh_newline ();
+
+#endif
+
+  return a;
+}
+
 Atom
 Lookup::dots () const
 {
index d6b90e1359a642fce662a98469abc1ca333f2bb6..767e106f235ae296e07c54947743dc4c238addcb 100644 (file)
@@ -188,16 +188,18 @@ identify ()
   *mlog << get_version_str () << endl;
 }
 
+#if 0
 void
 guile_init ()
 {
    gh_eval_str ("(define (add-column p) (display \"adding column (in guile): \") (display p) (newline))");
 }
+#endif
 
 void
 main_prog (int argc, char **argv)
 {
-  guile_init ();
+  //guile_init ();
 
   // facilitate binary distributions
   char const *env_lily = getenv ("LILYPONDPREFIX");
index 82948a3067447e6fe31c043f95d8257895575015..4c7d05a9a22ca8b6b561a2eb8965319592e72f29 100644 (file)
@@ -55,6 +55,7 @@ static Keyword_ent the_key_tab[]={
   {"pt", PT_T},
   {"relative", RELATIVE},
   {"remove", REMOVE},
+  {"scm", SCHEME},
   {"score", SCORE},
   {"script", SCRIPT},
   {"shape", SHAPE},
index 428fff3c373f0611941608fd4249e2dd61eb881e..55655080a320dfe6ab0d95f6c9698751ea96d806 100644 (file)
@@ -10,6 +10,7 @@
 */
 
 #include <iostream.h>
+#include "lily-guile.hh"
 #include "notename-table.hh"
 #include "scalar.hh"
 #include "translation-property.hh"
@@ -195,6 +196,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token PT_T
 %token RELATIVE
 %token REMOVE
+%token SCHEME /* token vs typedef;  can't be named SCM */
 %token SCORE
 %token SCRIPT
 %token SHAPE
@@ -321,8 +323,16 @@ toplevel_expression:
                        Midi_def_identifier ($1, MIDI_IDENTIFIER);
                THIS->lexer_p_->set_identifier ("$defaultmidi", id)
        }
+       | embedded_scm { 
+       }
        ;
 
+embedded_scm:
+       SCHEME STRING ';' {
+               gh_eval_str ($2->ch_C ());
+               delete $2;
+       };
+
 check_version:
        VERSION STRING ';'              {
                Mudela_version ver (*$2);
index 8d160b1f88a50e98a77d873d832413bc73d9b61b..3d4333c098dc6bb2da1ed2cd46eb52495a518a26 100644 (file)
@@ -62,6 +62,7 @@ Ps_lookup::character_str (int i) const
   return to_str (i, "(\\%03o)");
 }
 
+#if 0
 Atom
 Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
 {
@@ -95,6 +96,7 @@ Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
   a.font_ = font_;
   return a;
 }
+#endif
 
 Atom
 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
index d0ad70ef39045c954d357af0b5a73dc3328238b2..06597cda87e7adcdf7304b3251834d7ef988e885 100644 (file)
@@ -14,6 +14,8 @@
 #include "array.hh"
 #include "string-convert.hh"
 #include "debug.hh"
+#include "lookup.hh"
+#include "main.hh"
 
 Ps_outputter::Ps_outputter (Paper_stream *s)
   :Paper_outputter (s)
@@ -62,7 +64,39 @@ Ps_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
   if (check_debug)
     *outstream_l_ << String ("\n%start: ") << nm << "\n";
 
+#if 0
   Paper_outputter::output_molecule (m, o, nm, "% % {%}placebox \n");
+#else
+  String s = "% % {%}placebox \n";
+
+  if (check_debug)
+    *outstream_l_ << String ("\n%start: ") << nm << "\n";
+
+  for (PCursor <Atom*> i (m->atoms_); i.ok (); i++)
+    {
+      Offset a_off = i->offset ();
+      a_off += o;
+
+      switch_to_font (i->font_);
+
+      Array<String> a;
+      String r;
+  
+      a.push (global_lookup_l->print_dimen (a_off.y()));
+      a.push (global_lookup_l->print_dimen (a_off.x()));
+      if (i->lambda_)
+        {
+         gh_call1 (i->lambda_, gh_eval_str ("'ps"));
+         // char* c = gh_scm2newstr (gh_call1 (i->lambda_, gh_eval_str ("'ps")), NULL);
+         // a.push (String (c));
+         // free (c);
+       }
+      else
+       a.push (i->str_);
+      r += global_lookup_l->substitute_args (s, a);
+      *outstream_l_ << r;
+    }
+#endif
 }
 
 void
index c50b233904f8ae4533629d532da55b56750e0e9c..7ca6b43ac730ffe01a2173de223b1760d792f7ac 100644 (file)
@@ -63,11 +63,13 @@ Tex_lookup::character_str (int i) const
   return Lookup::character_str (i);
 }
 
+#if 0
 Atom
 Tex_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
 {
   return embed (Ps_lookup::dashed_slur (controls, thick, dash));
 }
+#endif
 
 Atom
 Tex_lookup::embed (Atom a) const
index 26f86d5cafadd87d667e98c34941bbe0692f01ff..abf88bfd169f1b609f228571b9ddc1329531614f 100644 (file)
 1.0.15
 1.0.15.jcn1
 1.0.15.jcn2
+1.0.15.jcn3