From 5bfcde359e5e76a9cfb0ab357ed34a308eedba84 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 14 Oct 1998 01:52:55 +0300 Subject: [PATCH] patch::: 1.0.15.jcn3: guilig atoom pl 15.jcn3 - try at scheme in Atom --- NEWS | 3 ++ VERSION | 2 +- init/declarations.ly | 2 + init/scm.ly | 8 ++++ lily/atom.cc | 2 + lily/include/atom.hh | 3 +- lily/include/lookup.hh | 3 +- lily/include/ps-lookup.hh | 2 +- lily/include/tex-lookup.hh | 2 +- lily/lookup.cc | 75 ++++++++++++++++++++++++++++++++++++++ lily/main.cc | 4 +- lily/my-lily-lexer.cc | 1 + lily/parser.yy | 10 +++++ lily/ps-lookup.cc | 2 + lily/ps-outputter.cc | 34 +++++++++++++++++ lily/tex-lookup.cc | 2 + make/STATE-VECTOR | 1 + 17 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 init/scm.ly diff --git a/NEWS b/NEWS index 11fe12c206..12dcd9281f 100644 --- 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 bddde17e00..9970bc70be 100644 --- 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. diff --git a/init/declarations.ly b/init/declarations.ly index ec6a60a127..462671530b 100644 --- a/init/declarations.ly +++ b/init/declarations.ly @@ -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 index 0000000000..24883e035e --- /dev/null +++ b/init/scm.ly @@ -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) + diff --git a/lily/atom.cc b/lily/atom.cc index 76b59197d3..3f79970b71 100644 --- a/lily/atom.cc +++ b/lily/atom.cc @@ -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; } diff --git a/lily/include/atom.hh b/lily/include/atom.hh index 0d88e7ce31..fcd434f0ab 100644 --- a/lily/include/atom.hh +++ b/lily/include/atom.hh @@ -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; diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 7efe60bb7e..4d2325ae82 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -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 controls, Real thick, Real dash) const = 0; +// virtual Atom dashed_slur (Array controls, Real thick, Real dash) const = 0; + virtual Atom dashed_slur (Array controls, Real thick, Real dash) const; Atom dots () const; Atom dynamic (String) const; Atom fill (Box b) const; diff --git a/lily/include/ps-lookup.hh b/lily/include/ps-lookup.hh index 2eb9ed025a..9b8ef622e5 100644 --- a/lily/include/ps-lookup.hh +++ b/lily/include/ps-lookup.hh @@ -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 controls, Real thick, Real dash) const; +// virtual Atom dashed_slur (Array 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; diff --git a/lily/include/tex-lookup.hh b/lily/include/tex-lookup.hh index cdb9839fcc..4b9d598e08 100644 --- a/lily/include/tex-lookup.hh +++ b/lily/include/tex-lookup.hh @@ -22,7 +22,7 @@ public: virtual Atom afm_find (String s) const; virtual String character_str (int i) const; - virtual Atom dashed_slur (Array controls, Real thick, Real dash) const; +// virtual Atom dashed_slur (Array 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; diff --git a/lily/lookup.cc b/lily/lookup.cc index 8ba88483f5..faed69f1aa 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -150,6 +150,81 @@ Lookup::clef (String st) const return afm_find (String ("clefs") + String ("-") + st); } +Atom +Lookup::dashed_slur (Array 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); + +#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); + + 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 { diff --git a/lily/main.cc b/lily/main.cc index d6b90e1359..767e106f23 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -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"); diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 82948a3067..4c7d05a9a2 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -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}, diff --git a/lily/parser.yy b/lily/parser.yy index 428fff3c37..55655080a3 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -10,6 +10,7 @@ */ #include +#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); diff --git a/lily/ps-lookup.cc b/lily/ps-lookup.cc index 8d160b1f88..3d4333c098 100644 --- a/lily/ps-lookup.cc +++ b/lily/ps-lookup.cc @@ -62,6 +62,7 @@ Ps_lookup::character_str (int i) const return to_str (i, "(\\%03o)"); } +#if 0 Atom Ps_lookup::dashed_slur (Array controls, Real thick, Real dash) const { @@ -95,6 +96,7 @@ Ps_lookup::dashed_slur (Array controls, Real thick, Real dash) const a.font_ = font_; return a; } +#endif Atom Ps_lookup::hairpin (Real width, bool decresc, bool continued) const diff --git a/lily/ps-outputter.cc b/lily/ps-outputter.cc index d0ad70ef39..06597cda87 100644 --- a/lily/ps-outputter.cc +++ b/lily/ps-outputter.cc @@ -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 i (m->atoms_); i.ok (); i++) + { + Offset a_off = i->offset (); + a_off += o; + + switch_to_font (i->font_); + + Array 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 diff --git a/lily/tex-lookup.cc b/lily/tex-lookup.cc index c50b233904..7ca6b43ac7 100644 --- a/lily/tex-lookup.cc +++ b/lily/tex-lookup.cc @@ -63,11 +63,13 @@ Tex_lookup::character_str (int i) const return Lookup::character_str (i); } +#if 0 Atom Tex_lookup::dashed_slur (Array controls, Real thick, Real dash) const { return embed (Ps_lookup::dashed_slur (controls, thick, dash)); } +#endif Atom Tex_lookup::embed (Atom a) const diff --git a/make/STATE-VECTOR b/make/STATE-VECTOR index 26f86d5caf..abf88bfd16 100644 --- a/make/STATE-VECTOR +++ b/make/STATE-VECTOR @@ -102,3 +102,4 @@ 1.0.15 1.0.15.jcn1 1.0.15.jcn2 +1.0.15.jcn3 -- 2.39.5