Re: Passing XTs to DLLs

From: Robert Dickow <dickow_at_uidaho.edu>
Date: Mon, 15 Sep 2003 10:52:30 -0700

Would one general approach to this problem be:

(1) Write a machine language glue routine within
the SwiftForth environment that could act as an
entry point for such DLL non-Windows 'callbacks'.

(2) Make the glue routine do the initializations
needed and pass any parameters around etc?

(3) Send the external routine the absolute address
of the glue code.

(4) Find out that the first three steps don't work and
merely crash the computer?

(Just kidding about step 4)

Bob Dickow

----------
> From: Rick VanNorman <rvn_at_forth.com>
>
> SwiftForth is subroutine threaded native code, but depends on an
execution
> context that includes at a minimum a data stack in addition to the
> processor
> supplied return stack. The principle that you are trying to implement is
> that of a callback -- but you have to be careful of how the dll's
interface
> expects the stack to be treated. All of the callback examples in
swiftforth
> are windows callbacks, and do not map onto the "extern C" . Check the
> definition
> of CB: and its various uses for examples.
>
> On Mon, 15 Sep 2003 10:25:47 -0600, Jeff Massung <jma_at_mfire.com> wrote:
>
> > Okay, hopefully a simple question. I have a DLL that =
> > expects a pointer to a function as a parameter. =
> > As an example:
> >
> > /* C DLL */
> > typedef (*fnptr)(void);
> > extern "C" EXPORT test(fnptr p)
> > {
> > p();
> > }
> >
> > Now in SwiftForth, I would like to:
> >
> > { SF code }
> > LIBRARY test.dll
> > 1 cimport: test
> > : go 10 0 do i . loop cr ;
> > ' go test
> >
> > This does not work, of course, giving an ACCESS_VIOLATION. =
> > I was hoping (since SF is STC) this would be possible to =
> > do. If there is sample code out there to "wrap" my Forth =
> > routine, I can't seem to find it.
>

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Sep 15 2003 - 11:10:34 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 06-Feb-2012. Archive updated nightly.