From 4a06364b3b10c714538221f8c8ec62606f806573 Mon Sep 17 00:00:00 2001 From: janneke Date: Sun, 18 Jul 2004 20:04:36 +0000 Subject: [PATCH] * lily/include/lily-guile.hh: Remove guile-1.4 compatibility. This greatly reduces the number of files that get recompiled after touching config.hh. * config.hh.in: Remove GUILE_*_VERSION. * lily/new-slur.cc: Resolve conflicts. * lily/stem-engraver.cc (make_stem): New method. * lily/new-slur.cc (get_base_attachments): Try at articulations. Lots of coding cleanups (Stom). --- ChangeLog | 9 +- SConstruct | 12 +-- config.hh.in | 19 ---- lily/include/lily-guile.hh | 146 ++++++++---------------------- lily/include/ly-smobs.icc | 176 +++++++++++++++++++------------------ lily/new-slur.cc | 14 --- lily/stem-engraver.cc | 16 ---- 7 files changed, 138 insertions(+), 254 deletions(-) diff --git a/ChangeLog b/ChangeLog index e565c3c5ed..75c3259108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,14 @@ 2004-07-18 Jan Nieuwenhuizen + * lily/include/lily-guile.hh: Remove guile-1.4 compatibility. + This greatly reduces the number of files that get recompiled + after touching config.hh. + + * config.hh.in: Remove GUILE_*_VERSION. + * lily/new-slur.cc: Resolve conflicts. - * lily/stem-engraver.cc (add_script): - (make_stem): New method. + * lily/stem-engraver.cc (make_stem): New method. * lily/include/script-interface.hh: * lily/script-interface.cc: New file. diff --git a/SConstruct b/SConstruct index 1b34dd33f3..40c634a6f2 100644 --- a/SConstruct +++ b/SConstruct @@ -60,19 +60,13 @@ prefix=os.path.join (os.environ['HOME'], 'usr', 'pkg', 'lilypond') # TODO: -# * install doc +# * usability # * more program configure tests (mfont, ...?) -# * split doc target: doc input examples mutopia? - -# * more fine-grained config.hh -- move lilypondprefix to version.hh? -# - config.hh: changes after system upgrades, affects all files -# - version.hh: prefix, version etc? affects few +# * install doc -# - what about GUILE_*_VERSION, seems to be the major culprit, -# for config.hh dependency escalation. Is the lily-guile.hh -# workaround necessary at all for GUILE > 1.5? +# * split doc target: doc input examples mutopia? # * grep FIXME $(find . -name 'S*t') diff --git a/config.hh.in b/config.hh.in index 2f8ec4b007..2219f84627 100644 --- a/config.hh.in +++ b/config.hh.in @@ -73,25 +73,6 @@ /* define if you have sstream */ #define HAVE_SSTREAM 0 -/* GUILE only includes version in headers (libguile/version.h) as of - 1.5.x. For some strange reason, they call it SCM.*VERSION. */ -#include - -#ifndef GUILE_MAJOR_VERSION -#ifdef SCM_MAJOR_VERSION -#define GUILE_MAJOR_VERSION SCM_MAJOR_VERSION -#define GUILE_MINOR_VERSION SCM_MINOR_VERSION -#define GUILE_PATCH_LEVEL SCM_MICRO_VERSION -#else -/* define GUILE major version */ -#define GUILE_MAJOR_VERSION 0 -/* define GUILE minor version */ -#define GUILE_MINOR_VERSION 0 -/* define GUILE patch level */ -#define GUILE_PATCH_LEVEL 0 -#endif -#endif - /* define if you have pango CVS */ #define HAVE_PANGO_CVS 0 diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 7c91a85a89..3042c980e1 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -9,123 +9,57 @@ #ifndef LILY_GUILE_HH #define LILY_GUILE_HH - -/* GUILE only includes version in headers (libguile/version.h) as of - 1.5.x. For some strange reason, they call it SCM.*VERSION. - - Not including config.hh here, saves a lot of unnecessary - recompiles. */ #include - -#ifndef GUILE_MAJOR_VERSION -#ifdef SCM_MAJOR_VERSION -#define GUILE_MAJOR_VERSION SCM_MAJOR_VERSION -#define GUILE_MINOR_VERSION SCM_MINOR_VERSION -#define GUILE_PATCH_LEVEL SCM_MICRO_VERSION -#else -#include "config.hh" -#endif -#endif +#include "flower-proto.hh" #include "drul-array.hh" +#include "direction.hh" - -/* Guile 1.4.x compatibility */ -#if GUILE_MINOR_VERSION < 5 - -#define scm_t_bits scm_bits_t - -#define fix_guile_1_4_scm_primitive_eval(form) scm_eval_3 (form, 1, SCM_EOL) -#define scm_primitive_eval(form) fix_guile_1_4_scm_primitive_eval (form) - -#define scm_int2num(x) scm_long2num (x) -#define scm_current_module() (SCM)0 -#define scm_set_current_module(x) (void)x -#define scm_c_resolve_module(x) (SCM)0 - -inline SCM scm_c_make_vector (int k, SCM val) { - return scm_make_vector (scm_from_int (k), val); -} -#define scm_c_define_gsubr scm_make_gsubr -#define scm_remember_upto_here_1(s) scm_remember (&s) -#define scm_gc_protect_object scm_protect_object -#define scm_gc_unprotect_object scm_unprotect_object -#define scm_list_n scm_listify -#define SCM_STRING_CHARS SCM_CHARS -#define SCM_STRING_LENGTH SCM_LENGTH -#define SCM_SYMBOL_CHARS SCM_CHARS -#define SCM_SYMBOL_LENGTH SCM_LENGTH -#define SCM_VECTOR_LENGTH SCM_LENGTH - -#define SMOB_FREE_RETURN_VAL(CL) sizeof(CL) -#define scm_done_free(x) -#endif +#if SCM_MINOR_VERSION < 7 +/* guile-1.6.x compatibility */ +#define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b) +#define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b) +#define SCM_VECTOR_REF(v,i) (SCM_VELTS ((v))[(i)]) +#define scm_from_int(x) SCM_MAKINUM (x) +#define scm_hash_table_p scm_vector_p +#endif /* SCM_MINOR_VERSION < 7 */ #ifndef SMOB_FREE_RETURN_VAL #define SMOB_FREE_RETURN_VAL(CL) 0 #endif - -#if GUILE_MINOR_VERSION < 7 -#define scm_gc_unregister_collectable_memory(a,b,c) scm_done_free(b) -#define scm_gc_register_collectable_memory(a,b,c) scm_done_malloc(b) -#define SCM_VECTOR_REF(v,i) (SCM_VELTS((v))[(i)]) -#define scm_from_int(x) SCM_MAKINUM(x) -#define scm_hash_table_p scm_vector_p - -#endif - -#include "direction.hh" -#include "flower-proto.hh" - #ifndef SCM_PACK #define SCM_PACK(x) ((SCM) x) - #endif + #ifndef SCM_UNPACK -#define SCM_UNPACK(x) ( x) +#define SCM_UNPACK(x) (x) #endif -/* - conversion functions follow the GUILE naming convention, i.e. - - A ly_B2A (B b); - */ +/** Conversion functions follow the GUILE naming convention, i.e. + A ly_B2A (B b); */ SCM ly_last (SCM list); SCM ly_write2scm (SCM s); SCM ly_deep_copy (SCM); -SCM ly_truncate_list (int k, SCM l ); - - -/* - Unreliable on gcc2 - */ -// #define CACHE_SYMBOLS - +SCM ly_truncate_list (int k, SCM lst); #if (__GNUC__ > 2) -/* - todo: should add check for x86 as well - */ +/* Unreliable with gcc-2.x + FIXME: should add check for x86 as well? */ #define CACHE_SYMBOLS #endif - #ifdef CACHE_SYMBOLS - -/* - Using this trick we cache the value of scm_str2symbol ("fooo") where +/* Using this trick we cache the value of scm_str2symbol ("fooo") where "fooo" is a constant string. This is done at the cost of one static variable per ly_symbol2scm() use, and one boolean evaluation for every call. - The overall speedup of lily is about 5% on a run of wtk1-fugue2 - -*/ -#define ly_symbol2scm(x) ({ static SCM cached; \ - SCM value = cached; /* We store this one locally, since G++ -O2 fucks up else */ \ + The overall speedup of lily is about 5% on a run of wtk1-fugue2. */ +#define ly_symbol2scm(x) ({ static SCM cached; \ + SCM value = cached; /* We store this one locally, since G++ -O2 fucks up else */ \ if ( __builtin_constant_p ((x)))\ { if (!cached)\ value = cached = scm_gc_protect_object (scm_str2symbol((x)));\ @@ -134,7 +68,7 @@ SCM ly_truncate_list (int k, SCM l ); value; }) #else inline SCM ly_symbol2scm(char const* x) { return scm_str2symbol((x)); } -#endif +#endif extern SCM global_lily_module; @@ -142,7 +76,7 @@ extern SCM global_lily_module; TODO: rename me to ly_c_lily_module_eval */ #define ly_scheme_function(x) ({static SCM cached; \ - SCM value = cached; /* We store this one locally, since G++ -O2 fucks up else */ \ + SCM value = cached; /* We store this one locally, since G++ -O2 fucks up else */ \ if ( __builtin_constant_p ((x)))\ { if (!cached)\ value = cached = scm_gc_protect_object (scm_eval(scm_str2symbol (x), global_lily_module));\ @@ -180,7 +114,7 @@ SCM robust_list_ref(int i, SCM l); SCM alist_to_hashq (SCM); inline SCM ly_cdr (SCM x) { return SCM_CDR (x); } -inline SCM ly_car (SCM x) { return SCM_CAR (x); } +inline SCM ly_car (SCM x) { return SCM_CAR (x); } inline SCM ly_caar (SCM x) { return SCM_CAAR (x); } inline SCM ly_cdar (SCM x) { return SCM_CDAR (x); } inline SCM ly_cadr (SCM x) { return SCM_CADR (x); } @@ -204,40 +138,38 @@ inline bool ly_c_vector_p (SCM x) { return SCM_VECTORP (x); } inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); } inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); } inline bool ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); } -inline bool ly_c_equal_p (SCM x, SCM y) { - return SCM_NFALSEP (scm_equal_p (x, y)); +inline bool ly_c_equal_p (SCM x, SCM y) { + return SCM_NFALSEP (scm_equal_p (x, y)); } inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); } inline char ly_scm2char (SCM x) { return SCM_CHAR(x); } inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); } inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); } -inline unsigned long ly_length (SCM x) { +inline unsigned long ly_length (SCM x) { return scm_num2ulong (scm_length (x), 0, "ly_length"); } inline unsigned long ly_vector_length (SCM x) { return SCM_VECTOR_LENGTH (x); } inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); } -inline SCM ly_append2 (SCM x1, SCM x2) { - return scm_append (scm_listify (x1, x2, SCM_UNDEFINED)); +inline SCM ly_append2 (SCM x1, SCM x2) { + return scm_append (scm_listify (x1, x2, SCM_UNDEFINED)); } -inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) { - return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED)); +inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) { + return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED)); } -inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) { - return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED)); +inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) { + return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED)); } /* display and print newline. */ -extern "C" { +extern "C" { void ly_display_scm (SCM s); } -#include "array.hh" - void read_lily_scm_file (String); void ly_c_init_guile (); @@ -278,8 +210,8 @@ typedef SCM (*Scheme_function_unknown) (); #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 typedef SCM (*Scheme_function_0) (); typedef SCM (*Scheme_function_1) (SCM); -typedef SCM (*Scheme_function_2) (SCM,SCM); -typedef SCM (*Scheme_function_3) (SCM,SCM, SCM); +typedef SCM (*Scheme_function_2) (SCM,SCM); +typedef SCM (*Scheme_function_3) (SCM,SCM, SCM); #else typedef SCM (*Scheme_function_0) (...); typedef SCM (*Scheme_function_1) (...); @@ -297,7 +229,7 @@ typedef SCM (*Scheme_function_3) (...); static SCM NAME ## _proc /* - Make TYPE::FUNC available as a Scheme function. + Make TYPE::FUNC available as a Scheme function. */ #define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \ SCM TYPE :: FUNC ## _proc;\ @@ -344,12 +276,12 @@ FNAME ARGLIST\ #define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ SCM FNAME ARGLIST ; \ -LY_DEFINE_WITHOUT_DECL(FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) +LY_DEFINE_WITHOUT_DECL(FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) #define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ SCM FNAME ARGLIST ; \ -LY_DEFINE_WITHOUT_DECL(CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) +LY_DEFINE_WITHOUT_DECL(CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) #define get_property(x) internal_get_property(ly_symbol2scm(x)) diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc index 3192056741..8fd9ff7aae 100644 --- a/lily/include/ly-smobs.icc +++ b/lily/include/ly-smobs.icc @@ -1,8 +1,8 @@ -/* - ly-smobs.icc -- implement smob glue. - +/* + ly-smobs.icc -- implement smob glue. + source file of the GNU LilyPond music typesetter - + (c) 1999--2004 Han-Wen Nienhuys */ @@ -11,16 +11,17 @@ #include "smobs.hh" - -#define IMPLEMENT_TYPE_P(CL, FUNCNAME)\ -SCM CL ## _type_p_proc;\ -void init_type_ ## CL ()\ -{\ - SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\ - CL ## _type_p_proc = subr;\ - ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Is @var{x} a @code{" #CL "} object?");\ - scm_c_export (FUNCNAME, NULL);\ -}\ +#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \ +SCM CL ## _type_p_proc; \ +void init_type_ ## CL () \ +{ \ + SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \ + (Scheme_function_unknown) CL::smob_p); \ + CL ## _type_p_proc = subr; \ + ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \ + "Is @var{x} a @code{" #CL "} object?"); \ + scm_c_export (FUNCNAME, NULL); \ +} \ ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) #ifndef SCM_CELL_TYPE @@ -31,84 +32,85 @@ ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) #define SCM_CELL_WORD_1(X) SCM_CDR (X) #endif - - -#define IMPLEMENT_BASE_SMOBS(CL) \ -scm_t_bits CL::smob_tag_; \ -SCM \ -CL::smob_p (SCM s) \ -{ \ - if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ - return SCM_BOOL_T; \ - else \ - return SCM_BOOL_F; \ - \ -} \ -void \ -CL::init_smobs () \ -{ \ - smob_tag_ = scm_make_smob_type (#CL, 0); \ - scm_set_smob_mark (smob_tag_, CL::mark_smob); \ - scm_set_smob_free (smob_tag_, CL::free_smob); \ - scm_set_smob_print (smob_tag_, CL::print_smob); \ - scm_set_smob_equalp (smob_tag_, CL::equal_p); \ -} \ -size_t \ -CL::free_smob (SCM ses) \ -{ \ - CL * s = (CL*) SCM_CDR (ses); \ - delete s; \ - scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \ - return SMOB_FREE_RETURN_VAL(CL);\ -}\ +#define IMPLEMENT_BASE_SMOBS(CL) \ +scm_t_bits CL::smob_tag_; \ +SCM \ +CL::smob_p (SCM s) \ +{ \ + if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ + return SCM_BOOL_T; \ + else \ + return SCM_BOOL_F; \ + \ +} \ + \ +void \ +CL::init_smobs () \ +{ \ + smob_tag_ = scm_make_smob_type (#CL, 0); \ + scm_set_smob_mark (smob_tag_, CL::mark_smob); \ + scm_set_smob_free (smob_tag_, CL::free_smob); \ + scm_set_smob_print (smob_tag_, CL::print_smob); \ + scm_set_smob_equalp (smob_tag_, CL::equal_p); \ +} \ + \ +size_t \ +CL::free_smob (SCM ses) \ +{ \ + CL *s = (CL*) SCM_CDR (ses); \ + delete s; \ + scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \ + return SMOB_FREE_RETURN_VAL(CL); \ +} \ + \ ADD_SCM_INIT_FUNC (CL, CL::init_smobs) - -#define IMPLEMENT_SIMPLE_SMOBS(CL) \ -IMPLEMENT_BASE_SMOBS(CL);\ -SCM CL::smobbed_copy () const \ -{ \ - CL * ptr = new CL (*this);\ - SCM s; \ - s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ +#define IMPLEMENT_SIMPLE_SMOBS(CL) \ +IMPLEMENT_BASE_SMOBS(CL); \ +SCM CL::smobbed_copy () const \ +{ \ + CL *ptr = new CL (*this); \ + SCM s; \ + s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob"); \ - \ - return s; \ -} \ - - -#define IMPLEMENT_SMOBS(CL) \ -IMPLEMENT_BASE_SMOBS (CL) \ -void \ -CL::smobify_self () \ -{ \ - SCM s = unprotected_smobify_self ();\ - scm_gc_protect_object (s);\ -}\ -SCM \ -CL::unprotected_smobify_self () \ -{ \ - /* \ - This is local. We don't assign to self_scm_ directly, to assure \ - that S isn't GC-ed from under us. \ - \ - We don't use smobbed_self () to ensure that mark_smob () doesn't have to \ - deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \ - the warning in smobs.hh is just to be doubleplus goodly sure \ - */ \ - SCM s;\ - SCM_NEWSMOB (s, CL::smob_tag_, this);\ - self_scm_ = s; \ - scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \ - return s; \ + \ + return s; \ +} \ + + +#define IMPLEMENT_SMOBS(CL) \ +IMPLEMENT_BASE_SMOBS (CL) \ +void \ +CL::smobify_self () \ +{ \ + SCM s = unprotected_smobify_self (); \ + scm_gc_protect_object (s); \ +} \ + \ +SCM \ +CL::unprotected_smobify_self () \ +{ \ + /* \ + This is local. We don't assign to self_scm_ directly, to assure \ + that S isn't GC-ed from under us. \ + \ + We don't use smobbed_self () to ensure that mark_smob () doesn't have to \ + deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \ + the warning in smobs.hh is just to be doubleplus goodly sure \ + */ \ + SCM s; \ + SCM_NEWSMOB (s, CL::smob_tag_, this); \ + self_scm_ = s; \ + scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \ + return s; \ } -#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ -SCM \ -CL::equal_p (SCM a , SCM b) \ -{ \ - return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ -} +#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ +SCM \ +CL::equal_p (SCM a , SCM b) \ +{ \ + return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ +} \ #endif /* LY_SMOBS_ICC */ diff --git a/lily/new-slur.cc b/lily/new-slur.cc index 01b93d4d33..6b9b8611e8 100644 --- a/lily/new-slur.cc +++ b/lily/new-slur.cc @@ -561,20 +561,6 @@ New_slur::get_base_attachments (Spanner *me, y = head->extent (common[Y_AXIS], Y_AXIS)[dir]; y += dir * 0.5 * staff_space; - if (stem) - { - SCM scripts = stem->get_property ((dir == UP - ? "script-up" - : "script-down")); - - /* FIXME: number of scripts, height, priority? - articulation scripts should be inside slur, other, - such as dynamics, pedals, fingering, should be - outside. */ - if (!SCM_NULLP (scripts)) - y += dir * staff_space; - } - Real pos = (y - extremes[d].staff_->relative_coordinate (common[Y_AXIS], Y_AXIS)) diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index 386447ab03..3483bab450 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -31,7 +31,6 @@ class Stem_engraver : public Engraver TRANSLATOR_DECLARATIONS (Stem_engraver); protected: - void add_script (Grob *); void make_stem (Grob_info); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); @@ -100,19 +99,6 @@ Stem_engraver::make_stem (Grob_info gi) } } -void -Stem_engraver::add_script (Grob *script) -{ - Direction d = get_grob_direction (script); - if (d == UP || d == DOWN) - { - char const *property = d == UP ? "script-up" : "script-down"; - stem_->set_property (property, - scm_cons (script->self_scm (), - stem_->get_property (property))); - } -} - void Stem_engraver::acknowledge_grob (Grob_info gi) { @@ -135,8 +121,6 @@ Stem_engraver::acknowledge_grob (Grob_info gi) Stem::add_head (stem_, gi.grob_); } - else if (Script_interface::has_interface (gi.grob_)) - add_script (gi.grob_); } void -- 2.39.5