home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
- From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
- Subject: Re: Calling external code resources - how?
- Message-ID: <1993Jan25.005216.12749@kth.se>
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: dront.nada.kth.se
- Organization: Royal Institute of Technology, Stockholm, Sweden
- References: <01050014.odph61@blanc.north.de>
- Date: Mon, 25 Jan 1993 00:52:16 GMT
- Lines: 36
-
- In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
-
- >Where can I find information on how to do this? The Segment Manager
- >chapter of IM gives no clues on this. Anyone has got some sample code
- >on this?
-
- Your extensions can't get at your globals, however,
- you're not lost.
-
- Define an interface for the extensions, consisting of ONE
- function that takes a lot of interesting parameters,
- like a handle to some data and a command, and a handle to
- put retusn data in, and returns an err code.
-
- The just load in the resource, lock it, and call the dereferenced
- resource as a function pointers with the right arguments.
-
- Something like:
-
- typedef short ( * myFuncType ) ( short code , Handle dataIn , Handle dataOut ) ;
-
- Code resources have a main with the same arguments, and
- you call 'em like:
-
- Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
- HLockHi ( h ) ;
- result = ( * h ) ( theCode , theInData , theOutData ) ;
- ReleaseResource ( h ) ;
-
- Cheers,
-
- / h+
- --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
-
- There's no sex act that can't be made better with Yell-O.
-