On Sat, 2006-09-16 at 16:29 +0200, Han-Wen Nienhuys wrote: > Some comments: > > * can you add another macro layer, so __LINE__ and __FILE__ aren't > sprinkled around in the code? For good measure, you could also add > __FUNCTION__ . How about something like the attached patch? I "overload" get_property so that it can take a SCM directly. Then I can replace every internal_get_property with get_property.
> > * similarly, can you add macro layering, so that passing around line > numbers/file names is entirely optional, and doesn't happen for a > -DNDEBUG build? Sure. > > * It might be possible to get some sort of causality in the diagram, by > recursively tracing 'cause properties. Dunno if that helps understanding > things, though. Probably. There are a bunch more hooks I want to add too... this was just the start :) > > + protect (); > > + if (ly_is_procedure (modification_callback)) > > + scm_apply_0 (modification_callback, > > + scm_list_n (self_scm (), scm_makfrom0str (file), > > scm_from_int (line), > > + sym, v, SCM_UNDEFINED)); > > + unprotect (); > > this protection should not be necessary: as self_scm is passed as Stack > variable it will be GC protected. I was getting segfaults in scm_gc_mark and this magically solved it. Being in dirty hack mode, I didn't investigate further. But you're right.
diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 7002c0f..dcb0a13 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -29,6 +29,14 @@ #endif #ifdef CACHE_SYMBOLS +/* this lets us "overload" macros such as get_property to take + symbols as well as strings */ +inline SCM +scm_or_str2symbol (char const *c) { return scm_str2symbol (c); } + +inline SCM +scm_or_str2symbol (SCM s) { return s; } + /* 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 @@ -43,10 +51,10 @@ #define ly_symbol2scm(x) \ if (__builtin_constant_p ((x))) \ { \ if (!cached) \ - value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \ + value = cached = scm_gc_protect_object (scm_or_str2symbol (x)); \ } \ else \ - value = scm_str2symbol ((char *) (x)); \ + value = scm_or_str2symbol (x); \ value; \ }) #else diff --git a/lily/tweak-engraver.cc b/lily/tweak-engraver.cc index a479935..1749228 100644 --- a/lily/tweak-engraver.cc +++ b/lily/tweak-engraver.cc @@ -33,7 +33,7 @@ Tweak_engraver::acknowledge_grob (Grob_i for (SCM s = music->get_property ("tweaks"); scm_is_pair (s); s = scm_cdr (s)) { - info.grob ()->internal_set_property (scm_caar (s), scm_cdar (s), __FILE__, __LINE__); + info.grob ()->set_property (scm_caar (s), scm_cdar (s)); } } }
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel