[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Problems with pointers to c++ objects
From: |
Felix Winkelmann |
Subject: |
Re: [Chicken-users] Problems with pointers to c++ objects |
Date: |
Fri, 30 Jul 2004 09:33:01 +0200 |
User-agent: |
Opera M2/7.52 (Win32, build 3834) |
On Thu, 29 Jul 2004 22:42:15 +0000, Petter Egesund <address@hidden>
wrote:
But I have problems with functions defined like this;
QFont (const QString &, int pointSize, int weight, bool italic);
They need the pointer to a created object, rather than the object itself.
I have looked through the mailing list, but my failed attempt to create
a pointer to a font-object does not seem to work.
Any clues on this one?
Yes, the problem here is that the FFI parser understands "Foo *",
where Foo is the name of a registered class and transforms it into
a foreign type specifier of the form (instance "Foo" <Foo>), which
is basically a specially handled type of pointer.
So the TinyCLOS wrapper for the QFont constructor wants a pointer (i.e.
a reference, because that's how Chicken passed references into Scheme)
but gets an instance.
So: "Foo &" is not properly recognized (even though the FFI handles
references). The solution is to have another foreign type
(instance-ref ...) that is treated as a specially handled reference
type.
I have cobbled something together that should work, but I have to do
some testing before I release it. I have only a rather old version
of Chicken here, so diffs will probably be not overly useful.
Anyway, that problem can be solved and I will provide a fix at
the start of next week.
BTW, this:
(define the_font_name
(let ([a (make <QString> 'this a "Times")])
a))
should probably be
(define the_font_name
(let ([a (make <QString> "Times")])
a)
cheers,
felix