CVSROOT: /cvsroot/lilypond
Module name: lilypond
Branch:
Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/05/30 23:38:46
Modified files:
. : ChangeLog
lily : stencil-scheme.cc stencil.cc
lily/include : stencil.hh
scm : lily.scm
Added files:
lily : stencil-expression.cc stencil-interpret.cc
scm : define-stencil-commands.scm
Log message:
* scm/define-stencil-commands.scm (Module): new file. Register all
allowed stencil expression heads in a central place.
* lily/stencil-scheme.cc (LY_DEFINE): check is_stencil_head in
ly:make-stencil
* lily/stencil-expression.cc (all_stencil_heads): registering
stencil expressions.
* lily/stencil-interpret.cc: new file. Stencil expression
interpreting.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3684&tr2=1.3685&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/stencil-expression.cc?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/stencil-interpret.cc?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/stencil-scheme.cc.diff?tr1=1.44&tr2=1.45&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/stencil.cc.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/stencil.hh.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/define-stencil-commands.scm?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/lily.scm.diff?tr1=1.349&tr2=1.350&r1=text&r2=text
Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3684 lilypond/ChangeLog:1.3685
--- lilypond/ChangeLog:1.3684 Mon May 30 22:34:51 2005
+++ lilypond/ChangeLog Mon May 30 23:38:45 2005
@@ -1,5 +1,17 @@
2005-05-31 Han-Wen Nienhuys <[EMAIL PROTECTED]>
+ * scm/define-stencil-commands.scm (Module): new file. Register all
+ allowed stencil expression heads in a central place.
+
+ * lily/stencil-scheme.cc (LY_DEFINE): check is_stencil_head in
+ ly:make-stencil
+
+ * lily/stencil-expression.cc (all_stencil_heads): registering
+ stencil expressions.
+
+ * lily/stencil-interpret.cc: new file. Stencil expression
+ interpreting.
+
* input/xiao-haizi-guai-guai.ly: move file back.
2005-05-30 Graham Percival <[EMAIL PROTECTED]>
Index: lilypond/lily/include/stencil.hh
diff -u lilypond/lily/include/stencil.hh:1.18
lilypond/lily/include/stencil.hh:1.19
--- lilypond/lily/include/stencil.hh:1.18 Sat May 28 13:43:24 2005
+++ lilypond/lily/include/stencil.hh Mon May 30 23:38:46 2005
@@ -88,15 +88,15 @@
};
DECLARE_UNSMOB (Stencil, stencil);
-SCM fontify_atom (Font_metric const *, SCM atom);
void interpret_stencil_expression (SCM expr,
void (*func) (void *, SCM),
void *func_arg,
Offset o);
-
-Stencil create_stencil (SCM print);
SCM find_expression_fonts (SCM expr);
+void register_stencil_head (SCM symbol);
+bool is_stencil_head (SCM symbol);
+SCM all_stencil_heads ();
#endif /* STENCIL_HH */
Index: lilypond/lily/stencil-scheme.cc
diff -u lilypond/lily/stencil-scheme.cc:1.44
lilypond/lily/stencil-scheme.cc:1.45
--- lilypond/lily/stencil-scheme.cc:1.44 Sat May 28 13:43:24 2005
+++ lilypond/lily/stencil-scheme.cc Mon May 30 23:38:46 2005
@@ -221,12 +221,17 @@
"They carry two pieces of information: \n\n"
"1: a specification of how to print this object. "
"This specification is processed by the output backends, "
- " for example @file{scm/output-tex.scm}.\n\n"
+ " for example @file{scm/output-ps.scm}.\n\n"
"2: the vertical and horizontal extents of the object.\n\n")
{
+ SCM_ASSERT_TYPE (!scm_is_pair (expr)
+ || is_stencil_head (scm_car (expr)),
+ expr, SCM_ARG1, __FUNCTION__, "registered stencil
expression");
+
SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__,
"number pair");
SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__,
"number pair");
-
+
+
Box b (ly_scm2interval (xext), ly_scm2interval (yext));
Stencil s (b, expr);
return s.smobbed_copy ();
@@ -334,3 +339,23 @@
scm_to_double (blot)).smobbed_copy ();
}
+
+
+LY_DEFINE (ly_register_stencil_expression, "ly:register-stencil-expression",
+ 1, 0, 0,
+ (SCM symbol),
+ "Add @var{symbol} as head of a stencil expression")
+{
+ SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol,
+ SCM_ARG1, __FUNCTION__, "Symbol");
+ register_stencil_head (symbol);
+ return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_all_stencil_expressions, "ly:all-stencil-expressions",
+ 0, 0, 0,
+ (),
+ "Return all symbols recognized as stencil expressions.")
+{
+ return all_stencil_heads ();
+}
Index: lilypond/lily/stencil.cc
diff -u lilypond/lily/stencil.cc:1.41 lilypond/lily/stencil.cc:1.42
--- lilypond/lily/stencil.cc:1.41 Sat May 28 13:43:24 2005
+++ lilypond/lily/stencil.cc Mon May 30 23:38:46 2005
@@ -203,103 +203,3 @@
expr ()));
return new_stencil;
}
-
-/****************************************************************/
-
-void
-interpret_stencil_expression (SCM expr,
- void (*func) (void *, SCM),
- void *func_arg,
- Offset o)
-{
- while (1)
- {
- if (!scm_is_pair (expr))
- return;
-
- SCM head = scm_car (expr);
-
- if (head == ly_symbol2scm ("translate-stencil"))
- {
- o += ly_scm2offset (scm_cadr (expr));
- expr = scm_caddr (expr);
- }
- else if (head == ly_symbol2scm ("combine-stencil"))
- {
- for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x))
- interpret_stencil_expression (scm_car (x), func, func_arg, o);
- return;
- }
- else if (head == ly_symbol2scm ("grob-cause"))
- {
- SCM grob = scm_cadr (expr);
-
- (*func) (func_arg, scm_list_3 (head,
- ly_quote_scm (ly_offset2scm (o)),
grob));
- interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
- (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin")));
- return;
- }
- else if (head == ly_symbol2scm ("color"))
- {
- SCM color = scm_cadr (expr);
- SCM r = scm_car (color);
- SCM g = scm_cadr (color);
- SCM b = scm_caddr (color);
-
- (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b));
- interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
- (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor")));
-
- return;
- }
- else
- {
- (*func) (func_arg,
- scm_list_4 (ly_symbol2scm ("placebox"),
- scm_make_real (o[X_AXIS]),
- scm_make_real (o[Y_AXIS]),
- expr));
- return;
- }
- }
-}
-
-struct Font_list
-{
- SCM fonts_;
-};
-
-static void
-find_font_function (void *fs, SCM x)
-{
- Font_list *me = (Font_list *) fs;
-
- if (scm_car (x) == ly_symbol2scm ("placebox"))
- {
- SCM args = scm_cdr (x);
- SCM what = scm_caddr (args);
-
- if (scm_is_pair (what))
- {
- SCM head = scm_car (what);
- if (ly_symbol2scm ("text") == head)
- me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
- else if (head == ly_symbol2scm ("char"))
- me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
- }
- }
-}
-
-SCM
-find_expression_fonts (SCM expr)
-{
- Font_list fl;
-
- fl.fonts_ = SCM_EOL;
-
- interpret_stencil_expression (expr, &find_font_function,
- (void *) & fl, Offset (0, 0));
-
- return fl.fonts_;
-}
Index: lilypond/scm/lily.scm
diff -u lilypond/scm/lily.scm:1.349 lilypond/scm/lily.scm:1.350
--- lilypond/scm/lily.scm:1.349 Mon May 30 09:45:14 2005
+++ lilypond/scm/lily.scm Mon May 30 23:38:46 2005
@@ -151,46 +151,6 @@
(define-public (ps-output-expression expr port)
(display (eval expr output-ps-module) port))
-;; TODO: generate this list by registering the stencil expressions
-;; stencil expressions should have docstrings.
-(define-public (ly:all-stencil-expressions)
- "Return list of stencil expressions."
- '(beam
- bezier-sandwich
- blank
- bracket
- char
- circle
- dashed-line
- dashed-slur
- dot
- draw-line
- filledbox
- glyph-string
- named-glyph
- polygon
- repeat-slash
- round-filled-box
- text
- url-link
- utf8-string
- white-dot
- white-text
- embedded-ps
- zigzag-line))
-
-;; TODO:
-;; - generate this list by registering the output-backend-commands
-;; output-backend-commands should have docstrings.
-;; - remove hard copies in output-ps output-tex
-(define-public (ly:all-output-backend-commands)
- "Return list of output backend commands."
- '(
- grob-cause
- no-origin
- placebox
- unknown))
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Safe definitions utility
(define safe-objects (list))
@@ -250,6 +210,7 @@
"define-grob-properties.scm"
"define-grobs.scm"
"define-grob-interfaces.scm"
+ "define-stencil-commands.scm"
"page-layout.scm"
"titling.scm"
_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs