swarm-support
[Top][All Lists]
Advanced

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

Re: replacing objc method with c function; ivars inside function no good


From: Marcus G. Daniels
Subject: Re: replacing objc method with c function; ivars inside function no good...
Date: 02 Apr 2001 17:03:19 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "PJ" == Paul E Johnson <address@hidden> writes:

PJ> But I ran into a little trouble. I know there was a way around it.

PJ> Suppose I declare

PJ> unsigned getMyUnsignedFunction ()
PJ> {
PJ>    ---want to use IVARS in here
PJ> }

PJ> The compiler goes crazy because it can't find any of the
PJ> IVARS. Know what I mean? It says all the ivars are undeclared.

You can pass the whole object just as efficiently..   You might also want
to consider a macro, so that there isn't the need for a "->" to get the
the ivars..

#import <simtools.h>
#import <defobj/Create.h>

@interface Foo: CreateDrop
{
  int a;
}
- (int)getA;
@end

@implementation Foo

static void
bar (Foo *foo)
{
  foo->a = 1;
}

- (void)bar
{
  bar (self);
}

- (int)getA
{
  return a;
}
@end

int
main (int argc, const char **argv)
{
  initSwarm (argc, argv);

  {
    id foo = [Foo create: globalZone];


    [foo bar];
    printf ("a: %u\n", [foo getA]);
  }
}

/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -D_GNU_SOURCE -o 
Foo -g -Wno-import -I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm Foo.m 
-lswarm -lobjc"
End:
*/

                  ==================================
   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]