Re: [frogs] Changing subproperties with grob-set-property (working on bug #40)

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Neil Puttock schrieb:
2009/11/1 Marc Hohl <marc@xxxxxxxxxx>:

Staring at the code, I get a faint impression that it would be more
difficult than I expected.
But there is a file lily/nested-property.cc. Are there some functions that
would do the job or
at least something similar to it?

There's only one function in the file which will set a nested
property.  If you're still unsure, have a look at
new-dynamic-engraver.cc, which uses this function to set
'bound-details.
Ah, thanks.
At the moment, I think I understood the meaning of the arguments to
LY_DEFINE:
First comes the c++ name of the function, then the name used in scheme,
then the number of required arguments, the number of optional arguments,
then a zero (?? at least in every function I looked at), then a list of
arguments (...)
and the docstring.

You're on the right track. :)

The third number option sets a `rest' argument (see ly_format () for
an example).
Hm, I am not sure whether I understand that completely, but it seems
not to be important in this case.
So the header of the definition could be

LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!",
     3, 0, 0, (SCM grob, SCM symlist, SCM val),
     "Set nested property @var{symlist} in grob @var{grob} to value
@var{val}.")
{
 Grob *sc = unsmob_grob (grob);

 LY_ASSERT_SMOB (Grob, grob, 1);
 LY_ASSERT_TYPE (ly_is_list, symlist, 2);

But that's more or less a guess...

Looks OK, though it's preferable to use ly_cheap_is_list for
typechecking symlist, since has a lower overhead.
Ok, then:

LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!",
    3, 0, 0, (SCM grob, SCM symlist, SCM val),
    "Set nested property @var{symlist} in grob @var{grob} to value
@var{val}.")
{
Grob *sc = unsmob_grob (grob);

LY_ASSERT_SMOB (Grob, grob, 1);
LY_ASSERT_TYPE (ly_cheap_is_list, symlist, 2);

if (!ly_is_procedure (val)
&& !type_check_assignment (symlist, val, ly_symbol2scm ("backend-type?")))
  error ("typecheck failed");

set_nested_property (sc, scm_list_n (symlist, SCM_UNDEFINED), val);
return SCM_UNSPECIFIED;
}

(Hm, it still feels like the time beginning with scheme where I stirred
in the fog and put several pieces together in the hope they will work
somehow...).

Marc





---

----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/