[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem calling scheme code from C++
From: |
Reinhold Kainhofer |
Subject: |
Re: Problem calling scheme code from C++ |
Date: |
Thu, 21 Aug 2008 16:51:22 +0200 |
User-agent: |
KMail/1.9.9 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Donnerstag, 21. August 2008 schrieb Han-Wen Nienhuys:
> On Wed, Aug 20, 2008 at 6:10 PM, Reinhold Kainhofer
>
> <address@hidden> wrote:
> >> > I'm having serious problems calling a scheme function from C++ code.
> >> > In particular:
> >> >
> >> > In Stem::flag (Grob *me), I have (stripped-down):
> >> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> > SCM flag_style_scm = me->get_property ("flag-style");
> >>
> >> This invokes the function you defined under the hood.
> >
> > Okay, so what's the solution? Setting flag-style to #'test-flag does not
> > work either, of course.
> >
> > Also, I don't understand the problem: Apparently the function body is NOT
> > evaluated when get_property is called, because the (display ...) shows
> > the grob argument passed in the scm_call_2, but not the number passed in
> > that same call...
> > Also, if I comment out the scm_call_2, I don't get any error at all.
> > And third, even if I set flag-style to (lambda (grob log) ....), I get
> > exactly the same errors, but the lambda is definitely not evaluated any
> > further when get_property is called, is it?
> >
> > I just fail to see how my situation is different from e.g. the
> > autoBeamCheck (lily/auto-beam-engraver.cc):
>
> get_property is overloaded; Grob::get_property works different from
> Context::get_property.
Ah, I didn't realize that the autoBeamCheck was from inside a context rather
than a grob. I was confused that the scheme function was called with a grob
as first parameter, but I failed to see that get_property passes the grob to
the function.
Anyway, since the duration-log is a property of the grob, I can easily do
everything in scheme with only the grob itself. That actually makes the code
even simpler. You can expect a patch in the next few days (the only thing
that's missing is the implementation of straight flags in scheme).
A current sample file highlighting the power of flags created with scheme
functions can be found at:
http://www.fam.tuwien.ac.at/~reinhold/temp/flags.pdf
http://www.fam.tuwien.ac.at/~reinhold/temp/flags.ly
The straight flags still use the glyphs that we designed a while ago, but the
test-flag style (the last one in the pdf) uses a custom scheme function to
create the stencils for the flags.
Cheers,
Reinhold
PS: I saw that Stem::flag() is called twice for each flag (one is in
Stem::width for determining the width). Thus each flag stencil is created
twice. Wouldn't it be better to store the flag in the first call (e.g. in a
propety of the stem) and only create it if that was not done already?
- --
- ------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: address@hidden, http://reinhold.kainhofer.com/
* Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
* K Desktop Environment, http://www.kde.org, KOrganizer maintainer
* Chorvereinigung "Jung-Wien", http://www.jung-wien.at/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIrYDqTqjEwhXvPN0RAiyBAJ9lCO9/3Ozvvbe9O6CwMi+OYTywYQCgtHOn
uRpCAc1oIwKBVfFM0JqozMg=
=hSHy
-----END PGP SIGNATURE-----