swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: return type for a method parameter & assigning probe buttons


From: Marcus G. Daniels
Subject: Re: return type for a method parameter & assigning probe buttons
Date: 07 Sep 1999 12:11:19 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "WS" == William S Shu <address@hidden> writes:

WS> Problem 1: Objective-C) How can one pass a method as an argument
WS> as well as the type of its return value? 

In Swarm, the way selectors are called is via the `perform' method.
Since this method is typed to return an object, selectors should all be for
methods that return objects.

Generic return typing is hairy problem.  If you really want to be
able to return generic types you need to use GCC builtins and the
performv: method.  Something like this:

- (double)call: (SEL)sel
{
  __builtin_return ([self performv: sel : __builtin_apply_args ()]);
}

Unfortunately the __builtin_{return/apply_args} are deprecated in GCC
and actually fail on some platforms (e.g. Sparc).  (For Java things,
we take care of argument frame packing and unpacking by hand, using platform
specific code.)

WS> // valueOf takes *no* argument
WS> - (Real)getValueBL: (Point)bL TR: (Point)tR
WS>       class: (id)aClass  order: (int)type value: (SEL)valueOf {
WS>  id obj;
WS>  int i, j;
WS>  Real val;
WS> ...
WS>      obj = [self getWorldObjectAtX: i Y: j];
WS>      if ([obj isKindOf: aClass]) {
WS>        ....
WS>        val += [obj valueOf]    <====== **** return type assumed to be id

This is actually invalid syntax.  You'd have to say [obj perform: valueOf].

WS>     How do I get to probe both objects (in fact any object) on the
WS> raster by using the same mouse button.

WS>  [worldRaster setButton: ButtonRight   // use Right button
WS>               Client: personDisplay
WS>               Message: M(makeProbeAtX:Y:)];

Send a different message, one that has the effect of calling
makeProbeAtX:Y: twice.


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]