Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!brutus.cs.uiuc.edu!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: Have you had problems with SetClikLoop? Message-ID: <37528@apple.Apple.COM> Date: 1 Jan 90 06:22:34 GMT References: <921@excelan.COM> <3429@hub.UUCP> <3509@husc6.harvard.edu> <4@bootsie.UUCP> Organization: Apple Computer Inc, Cupertino, CA Lines: 54 In article <4@bootsie.UUCP> olson@bootsie.UUCP (Eric Olson) writes: >In article <3509@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes: >>>From article <921@excelan.COM>, by mahboud@kinetics.com (Mahboud Zabetian): >>>> Hi. Anybody out there ever try calling SetClikLoop twice consecutively for >>>> different TEHandles? I am doing so and it seems that the second call also >>>> changes the value of the clikLoop field of the first TE! Sound strange? > >> SetClikLoop saves away the old clickLoop in a place relative to >>A5, so that it can restore it. When and why, I don't know. Because TE >>doesn't maintain a stack of saved clikLoops, it will smash old ones, >>as you're finding out. >> > >When I bumped into this problem, I thought it was a misfeature of Think C. >It seemed to me that the Think C routine for SetClikLoop would always set the >clikLoop field in the TERec to a Think C glue routine, after saving the >actual (pascal) function pointer away in a global. The glue routine then >translates registers to pascal stack and calls the routine you specified. > >Since only one global existed and all TERecs got a pointer to the glue routine, >only the last installed glue routine would ever get executed. > >Is this _not_ the case?!?!? I was pretty sure... Just got back from vacation, and caught up to the bottom of this thread. Yes, Eric, you are correct. SetClikLoop is a glue routine that actually saves off the pointer you pass to it in the Application parameters section, and then points to one of its own routines. This routine is used to translate from the register based routine TE uses to the stack based convention documented in Inside Mac. And, yes, this seems like a pretty bad design decision, but it's what we're stuck with. By the way, this is in no way a Think C (or even Think Pascal) problem. The fault is all ours. Think gets their Toolbox interface glue from us. This means that you'll have the same problem in MPW C or Pascal. >-Eric > >P.S. Of course, the workaround is to set the field directly and use one's >own glue routine, one per ClikLoop function, as amply described by others >who responded. > >-- >Eric K. Olson olson@endor.harvard.edu harvard!endor!olson -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions