home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22087 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.6 KB  |  49 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
  3. From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
  4. Subject: Re: Calling external code resources - how?
  5. Message-ID: <1993Jan25.005216.12749@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: dront.nada.kth.se
  8. Organization: Royal Institute of Technology, Stockholm, Sweden
  9. References: <01050014.odph61@blanc.north.de>
  10. Date: Mon, 25 Jan 1993 00:52:16 GMT
  11. Lines: 36
  12.  
  13. In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
  14.  
  15. >Where can I find information on how to do this? The Segment Manager
  16. >chapter of IM gives no clues on this. Anyone has got some sample code
  17. >on this?
  18.  
  19. Your extensions can't get at your globals, however,
  20. you're not lost.
  21.  
  22. Define an interface for the extensions, consisting of ONE
  23. function that takes a lot of interesting parameters,
  24. like a handle to some data and a command, and a handle to
  25. put retusn data in, and returns an err code.
  26.  
  27. The just load in the resource, lock it, and call the dereferenced
  28. resource as a function pointers with the right arguments.
  29.  
  30. Something like:
  31.  
  32. typedef short ( * myFuncType ) ( short code , Handle dataIn , Handle dataOut ) ;
  33.  
  34. Code resources have a main with the same arguments, and
  35. you call 'em like:
  36.  
  37.     Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
  38.     HLockHi ( h ) ;
  39.     result = ( * h ) ( theCode , theInData , theOutData ) ;
  40.     ReleaseResource ( h ) ;
  41.  
  42. Cheers,
  43.  
  44.                         / h+
  45. -- 
  46.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  47.  
  48.    There's no sex act that can't be made better with Yell-O.
  49.