Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Dereferencing ProcPtr in LS Pascal Message-ID: <4771@helios.ee.lbl.gov> Date: 5 Feb 90 01:13:09 GMT References: <1268@diemen.cc.utas.oz> <1990Feb4.202759.16223@Neon.Stanford.EDU> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 38 X-Local-Date: 4 Feb 90 17:13:09 PST In article <1990Feb4.202759.16223@Neon.Stanford.EDU> philip@pescadero.stanford.edu writes: #In article <1268@diemen.cc.utas.oz> brian Harrold writes: #> #> I have a procedure in which one of the parameters is of type #> ProcPtr (pointer to another procedure). Is there any way in #> LS Pascal to dereference the pointer to the given procedure, #> and execute it ? #> # #The solution is along the following lines: # #procedure callProc(** parameters exactly as in proc ** ; theProc: #procPtr); #inline $205F $4ED0 ; {check the syntax for inline in LS manual} # By the way, MPW C++ will allow you to declare procedure pointer types and call them directly by pointer, even when declared as pascal! THINK C doesn't let you do that... For example: typedef pascal OSErr (**GMProcHandle)(type1 arg1, type2 arg2, ...); This type lets you call a code resource that has a funny calling convention. GMProcHandle myProcHandle = (GMProcHandle)GetResource(myId, 'ADgm'); ... HLock((Handle)myProcHandle); OSErr result = (**myProcHandle)(...); Sure looks nice to me, don't have to do any of that funny inline code. ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------