jdm@ut-ngp.UUCP (Jim Meiss) (05/12/87)
According to IM I-446 when the csCode parameter is set to accEvent, csParam contains a pointer to the eventRecord . Thus one might expect that one could use this pointer to call DialogSelect, for example. This does not work, however, and apparently one needs to do a complicated casting of csParam as shown in this code fragment from AsciiDA by W. S. Blomgren, who quotes the DA ZoomIdle by P. Dubois: ----------------- main (p,d,n) cntrlParam *p; DCtlPtr d; int n; { ........ switch(n) { ........ case 2: /* action in the DA */ switch(p->csCode) { case accEvent: DAevent(((EventRecord *) * (long *) &p->csParam)); /* casting the *address of* p->csParam as an pointer to a long, and the */ /* long is cast as a pointer to a pointer to an eventRecord (I think?) */ /* (from ZoomIdle 1.1 by Paul DuBois) */ /* the pointer is passed as the parameter to DAevent */ ------------------ Can someone explain this to me? Wouldn't you think that (EventRecord *) p->csParam would be sufficient? My first try was just to pass p->csParam itself, since its supposed to be the pointer to the eventRecord....but this definitely doesn't work. Jim Meiss jdm@ut-ngp.UTEXAS.EDU jdm@uta.MFENET.ARPA
guido@mcvax.cwi.nl (Guido van Rossum) (05/13/87)
p->csParam is an array of shorts. The first two elements together contain the EventRecord pointer. The given example is about the shortest way to extract the EventRecord pointer from it. -- Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@cwi.nl or mcvax!guido or (from ARPAnet) guido%cwi.nl@seismo.css.gov
mark@hyper.UUCP (Mark Mendel) (05/14/87)
Apparently, p->csParam is declared as an array of shorts. There is, however, a clearer way to get an EventRecord pointer out of this: *(EventRecord **)&p->csParam is slightly clearer than (EventRecord *) * (long *) &p->csParam and should do the same thing. You have to use the '&' operator, since otherwise p->csParam will extract a 16 bit quantity. -- Mark G. Mendel, ihnp4!umn-cs!hyper!mark, Network Systems Corporation All opinions expressed herein, even the most arbitrary, are defended by my employer with religious fervor.
olson@endor.harvard.edu (Eric Olson) (05/15/87)
In article <259@hyper.UUCP> mark@hyper.UUCP (Mark Mendel) writes: >Apparently, p->csParam is declared as an array of shorts. There is, however, >a clearer way to get an EventRecord pointer out of this: > > *(EventRecord **)&p->csParam > >...You have to use the '&' operator, since otherwise >p->csParam will extract a 16 bit quantity. csParam is declared as int csParam[]. Doesn't this mean that p->csParam is the pointer to the base of the array, and p->csParam[0] and p->csParam[1] are shorts? It seems to me that &p->csParam is the same as p->csParam and also the same as &p->csParam[0] Am I missing something? -Eric