Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth Mac > Re: how do crea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 8 Topic 144 of 161
Post > Topic >>

Re: how do create a shared library from macforth app

by Roelf Toxopeus <these3rt0only@[EMAIL PROTECTED] > May 21, 2007 at 01:49 PM

In article <these3rt0only-6E010C.09090221052007@[EMAIL PROTECTED]
>,
 Roelf Toxopeus <these3rt0only@[EMAIL PROTECTED]
> wrote:

> In article <1179455096.142444.86820@[EMAIL PROTECTED]
>,
>  chris@[EMAIL PROTECTED]
 wrote:
> 
> > On Mac I would like to be able to call the existing Mac application as
> > a shared library.  And this is where I need help.
> > 
> > Is it possible to create a MacForth turnkey that is a shared library?
> > Can anyone help me with this?
> 
> Not much, but:
> 
> MacForth shared library, not that I know of (wish list).

Mmm, some rethinking.
If I'm right in assuming you want to access functions from your
turnkeyed  MacForth from the outside.
I can think of 3 possible alternatives, all three needing a running
MacForth, not necessarily in the foreground.

1. Set up MacForth as a background server listening to a predefined
    ****t. The outside app connects to this ****t and makes requests.

The MacForth topword part could be:
    begin   listen connect  receive evaluate   again

Your 'ex****ted' functions could be inside a sealed vocabulary.

The outside app connects to your ****t and sends its request in the form
of the name of the function.

For MacForth you can use sockets, somewhere on:
    http://home.uni-one.nl/bmbcon2/toolshed/mac/pmf/

An application like Supercollider works this way. It has two parts:
 a server and a gui interface connected via sockets.

2. Use Unix communication stuff like a fifo/pipes/shared memory.
    Not really looked in to it.

3. Use an intermediate framework.
    Again you have your MF running, doing nothing, just be there.
    Outside app and MF include the intermediate framework, which has
    one or more functions which call your MF functions as callbacks.
    No idea if this will work: sharing the same bundle!

Example, download from Apple:
    http://developer.apple.com/samplecode/CFM_MachO_CFM/index.html
put the build Test.bundle found in:
         CFM_MachO_CFM/MachO\ Bundle/build/ 
somewhere like
        /User/you/Library/Frameworks

In MF:
\ include the shared framework or bundle
globalbundle /Users/you/Library/Frameworks/Test.bundle

\ select it
test.bundle

\ im****t needed function
2 machofunc _GetFooWithCallBack

\ our word to execute
: beeps 0 ?do 5 _SysBeep 100 ms loop ;

\ prepare as callback
1 ' beeps MakeMachCallback *beeps

\ run it as callback
5 *beeps _GetFooWithCallBack drop

--------
This gives the idea.
You need to change the setting: Mf and the bundle.
Of course your outside app doesn't know the MF callback pointers,
so MF on boot loads the bundle, stores the appropriate pointers in
some global variables inside the bundle. The public bundle function(s)
will run a modified GetFooWithCallBack which uses the needed callback
pointer to run the requested action. Or whatever.

A lot of variations possible. It wouldn't surprise me if there's a much
simpler solution. Love to learn about it.

regards
-Roelf
 




 8 Posts in Topic:
how do create a shared library from macforth app
chris@[EMAIL PROTECTED]   2007-05-17 19:24:56 
Re: how do create a shared library from macforth app
Roelf Toxopeus <these3  2007-05-21 09:09:02 
Re: how do create a shared library from macforth app
Roelf Toxopeus <these3  2007-05-21 13:49:01 
Re: how do create a shared library from macforth app
chris@[EMAIL PROTECTED]   2007-05-21 23:58:48 
Re: how do create a shared library from macforth app
chris@[EMAIL PROTECTED]   2007-05-22 00:23:15 
Re: how do create a shared library from macforth app
Roelf Toxopeus <these3  2007-05-22 21:49:21 
Re: how do create a shared library from macforth app
chris@[EMAIL PROTECTED]   2007-05-27 17:21:24 
Re: how do create a shared library from macforth app
Roelf Toxopeus <these3  2007-05-28 12:37:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 13:58:54 CST 2008.