[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Re: Passing Scheme callbacks to Swig wraps.

From: Tony Sidaway
Subject: [Chicken-users] Re: Passing Scheme callbacks to Swig wraps.
Date: Wed, 28 Feb 2007 10:37:34 +0000

On 2/28/07, Tony Sidaway <address@hidden> wrote:
 As a concrete example, I want to enable the Scheme programmer to be
able override the menubar method with a method written as a Chicken
Scheme callback (define-external) procedure, by passing a pointer to
that callback to the setter for the C++ class's menubar function
pointer member.

To illustrate, here's how I do it at present, by subclassing in C++ in
my Swig interface file:

class TAppScm : public TApplication
   TAppScm( TStatusLine *(*cStatusLine)( TRect ) = &TAppScm::initStatusLine,
              TMenuBar *(*cMenuBar)( TRect ) = &TAppScm::initMenuBar,
              TDeskTop *(*cDeskTop )( TRect ) = &TAppScm::initDeskTop
             ):     TProgInit (cStatusLine, cMenuBar, cDeskTop) {};

The derived class uses a constructor with default values so I can
instantiate it in Scheme with just (make <TAppScm>), which creates the
tinyclos proxy and thereby the C++ class with the default Status bar,
MenuBar and Desktop.  When I use the run method for this proxy my C++
object (a use interface window) appears on the screen and behaves as
expected. Hurray!

The problem I'm trying to solve here is how I substantiate the class
with a menubar coded as a C++ callback.

The class hierarchy in question, by the way, is Borland's rather good
Turbo Vision text-based user interface library, which I recently
discovered is now part of a pretty good open source project.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]