X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsimple-closure.cc;fp=lily%2Fsimple-closure.cc;h=0c5dca8e95873af67d1d0433b50d8ae6950abfbb;hb=32a34dcef0c0041c6d62677487a380b5c8b85712;hp=7c46c0198b728fbbdd83c7cd226f43885def37e7;hpb=f41973ff763d5972a85995b6d40c864281ec6714;p=lilypond.git diff --git a/lily/simple-closure.cc b/lily/simple-closure.cc index 7c46c0198b..0c5dca8e95 100644 --- a/lily/simple-closure.cc +++ b/lily/simple-closure.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2011 Han-Wen Nienhuys + Copyright (C) 2005--2012 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ SCM simple_closure_expression (SCM smob) { assert (is_simple_closure (smob)); - return (SCM) SCM_CELL_WORD_1(smob); + return (SCM) SCM_CELL_WORD_1 (smob); } SCM @@ -44,33 +44,33 @@ evaluate_args (SCM delayed_argument, SCM args, bool pure, int start, int end) for (SCM s = args; scm_is_pair (s); s = scm_cdr (s)) { *tail = scm_cons (evaluate_with_simple_closure (delayed_argument, scm_car (s), - pure, start, end), - SCM_EOL); + pure, start, end), + SCM_EOL); if (scm_car (*tail) == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; tail = SCM_CDRLOC (*tail); } - + return new_args; } SCM evaluate_with_simple_closure (SCM delayed_argument, - SCM expr, - bool pure, - int start, - int end) + SCM expr, + bool pure, + int start, + int end) { if (is_simple_closure (expr)) { SCM inside = simple_closure_expression (expr); SCM args = scm_cons (delayed_argument, - evaluate_args (delayed_argument, scm_cdr (inside), - pure, start, end)); + evaluate_args (delayed_argument, scm_cdr (inside), + pure, start, end)); if (scm_cdr (args) == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; if (pure) - return call_pure_function (scm_car (inside), args, start, end); + return call_pure_function (scm_car (inside), args, start, end); return scm_apply_0 (scm_car (inside), args); } else if (!scm_is_pair (expr)) @@ -81,32 +81,32 @@ evaluate_with_simple_closure (SCM delayed_argument, { SCM args = evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); if (args == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; if (pure) - return call_pure_function (scm_car (expr), args, start, end); + return call_pure_function (scm_car (expr), args, start, end); return scm_apply_0 (scm_car (expr), args); } else - // ugh. deviation from standard. Should print error? - return evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); - + // ugh. deviation from standard. Should print error? + return evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); + assert (false); return SCM_EOL; } LY_DEFINE (ly_simple_closure_p, "ly:simple-closure?", - 1, 0, 0, (SCM clos), - "Is @var{clos} a simple closure?") + 1, 0, 0, (SCM clos), + "Is @var{clos} a simple closure?") { return scm_from_bool (is_simple_closure (clos)); } LY_DEFINE (ly_make_simple_closure, "ly:make-simple-closure", - 1, 0, 0, (SCM expr), - "Make a simple closure. @var{expr} should be form of" - " @code{(@var{func} @var{a1} @var{a2} @dots{})}, and will be" - " invoked as @code{(@var{func} @var{delayed-arg} @var{a1}" - " @var{a2} @dots{})}.") + 1, 0, 0, (SCM expr), + "Make a simple closure. @var{expr} should be form of" + " @code{(@var{func} @var{a1} @var{a2} @dots{})}, and will be" + " invoked as @code{(@var{func} @var{delayed-arg} @var{a1}" + " @var{a2} @dots{})}.") { SCM z; @@ -115,10 +115,10 @@ LY_DEFINE (ly_make_simple_closure, "ly:make-simple-closure", } LY_DEFINE (ly_eval_simple_closure, "ly:eval-simple-closure", - 2, 2, 0, (SCM delayed, SCM closure, SCM scm_start, SCM scm_end), - "Evaluate a simple @var{closure} with the given @var{delayed}" - " argument. If @var{scm-start} and @var{scm-end} are defined," - " evaluate it purely with those start and end points.") + 2, 2, 0, (SCM delayed, SCM closure, SCM scm_start, SCM scm_end), + "Evaluate a simple @var{closure} with the given @var{delayed}" + " argument. If @var{scm-start} and @var{scm-end} are defined," + " evaluate it purely with those start and end points.") { bool pure = (scm_is_number (scm_start) && scm_is_number (scm_end)); int start = robust_scm2int (scm_start, 0); @@ -126,7 +126,7 @@ LY_DEFINE (ly_eval_simple_closure, "ly:eval-simple-closure", SCM expr = simple_closure_expression (closure); return evaluate_with_simple_closure (delayed, expr, pure, start, end); } - + int print_simple_closure (SCM s, SCM port, scm_print_state *) { @@ -136,7 +136,6 @@ print_simple_closure (SCM s, SCM port, scm_print_state *) return 1; } - void init_simple_closure () { simple_closure_tag = scm_make_smob_type ("simple-closure", 0); @@ -144,6 +143,4 @@ void init_simple_closure () scm_set_smob_print (simple_closure_tag, print_simple_closure); }; - - ADD_SCM_INIT_FUNC (simple_closure, init_simple_closure);