When ly:make-unpure-pure-container is called with a single procedure
argument, this procedure is used for both unpure and pure calls. It
turns out that the calling convention in call_pure_function places the
start/end arguments always in position 2/3 of the call.
Unpure_pure_call::call previously always dropped the last 2 arguments of
a pure call before passing the rest on. Most calls take exactly 3
arguments (grob start end) where this does not make a difference, but
there may be use cases with a different number of arguments.
*/
#include "unpure-pure-container.hh"
*/
#include "unpure-pure-container.hh"
-// Reroutes a call to the contained function after dropping last two
-// arguments. Used for applying an "unpure" function in a "pure"
+// Reroutes a call to the contained function after dropping second and
+// third argument. Used for applying an "unpure" function in a "pure"
// context.
class Unpure_pure_call : public Smob1<Unpure_pure_call>
{
public:
// context.
class Unpure_pure_call : public Smob1<Unpure_pure_call>
{
public:
+ // Smob procedures unfortunately can only take at most 3 SCM
+ // arguments. Otherwise we could use a "3, 0, 1" call signature and
+ // not require an argument count check of our own.
LY_DECLARE_SMOB_PROC (&Unpure_pure_call::call, 2, 0, 1)
LY_DECLARE_SMOB_PROC (&Unpure_pure_call::call, 2, 0, 1)
- SCM call (SCM arg1, SCM arg2, SCM rest)
+ SCM call (SCM arg1, SCM, SCM rest)
- return scm_apply_0 (scm1 (),
- scm_list_head (scm_cons2 (arg1, arg2, rest),
- scm_length (rest)));
+ if (!scm_is_pair (rest))
+ scm_wrong_num_args (scm1 ());
+ return scm_apply_1 (scm1 (), arg1, scm_cdr (rest));