swarm-support
[Top][All Lists]
Advanced

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

Re: Casting an id type to a specific object type?


From: Ken Cline
Subject: Re: Casting an id type to a specific object type?
Date: Sat, 15 Mar 1997 18:53:16 -0500 (EST)

Jae,

Hmmm...

Maybe tgt doesn't point at an object that is a subclass of
DefObject. Although there is also the same method defined in
Object I believe.

> tgt is not nil as far as I know.

Are you testing this? For example: if ( tgt == nil ) ...
I guess your are in you getObjectAtX: Y: call right?

Maybe try just:
         if ( [tgt isMemberOfClassNamed: "Person"] )
                 fprintf(stderr,"tgt is a 'Person'!\n");
         else
                 fprintf(stderr,"tgt is a nobody!\n");

To see if indeed tgt is a person. Or more simply:
         if ( [tgt isMemberOf: Person] )
                 fprintf(stderr,"tgt is a 'Person'!\n");
         else
                 fprintf(stderr,"tgt is a nobody!\n");

However, "isMemberOfClassNamed:" and "isMemberOf:" are both
methods defined in Object as well.

It just seems to me that tgt is pointing at something
other than an object or the object it is pointing at is
screwed up somehow.  Maybe its pointing at an int or float
or something?  You could try printing the address of tgt to
stderr as well as the address each pointer as you create
each person (in ModelSwarm)?  (As you can tell my debugging
skills are rather crude!)

I'm sort of grasping for ideas... 

Can you send me more of the code?  

BTW, what type of space is "world"? 

What does Person subclass? 

Is there anyway x1 and y1 are outside of the world?

Well, that's it for me and ideas, maybe someone else will
see the solution... If you want to send me anything, I'll be
available for an hour or two more; possibly tomorrow as
well.

Sorry I couldn't help more,

Ken.


On Sat, 15 Mar 1997, Jae Chan Oh wrote:

> Ken, Thanks for the kind replies.
> I have tried your suggestions on trapping core dump using respondTo: etc.
> My program gives core dump on even that call as well.. sigh..
> 
> i.e.
>       if ([tgt respondsTo: M(print)] )        <--- bombs right here.
>         [tgt print];
>     else
>         {
>         if ( [tgt isMemberOfClassNamed: "Person"] )
>                 fprintf(stderr,"tgt is a 'Person'!\n");
>         else
>                 fprintf(stderr,"tgt is a nobody!\n");
>         exit(1);
>         }
> tgt is not nil as far as I know. 
> tgt is declard as id.
> gdb command "where" gives the following:
> 
> Program received signal SIGSEGV, Segmentation fault.
> objc_msg_lookup (receiver=0x18, op=0x14c100) at sendmsg.c:115
> sendmsg.c:115: No such file or directory.
> (gdb) where
> #0  objc_msg_lookup (receiver=0x18, op=0x14c100) at sendmsg.c:115
> #1  0x2329c in _i_Person__look (self=0x22b850, _cmd=0x14bec0) at Person.m:335
> #2  0x21b10 in _i_Person__step (self=0x22b850, _cmd=0x14c9cc) at Person.m:49
> #3  0x5e990 in _i_Object_s__perform_ (self=0x22b850, _cmd=0x154fd0, 
>     aSel=0x14c9cc) at DefObject.m:241
> #4  0x47110 in _i_ActionTo_0___performAction__ (self=0x244478, _cmd=0x155410, 
>     anActivity=0x244408) at Action.m:161
> #5  0x48d78 in _i_Activity_c___run_ (self=0x244408, _cmd=0x1553f8)
>     at Activity.m:482
> #6  0x1172f0 in __objc_init_install_dtable (receiver=0x1532e0, op=0x1553f8)
>     at sendmsg.c:208
> #7  0x48bb4 in _i_Activity_c___run_ (self=0x243f40, _cmd=0x1553f8)
>     at Activity.m:454
> #8  0x48bb4 in _i_Activity_c___run_ (self=0x243958, _cmd=0x1553f8)
>     at Activity.m:454
> #9  0x48bb4 in _i_Activity_c___run_ (self=0x243668, _cmd=0x1553f8)
>     at Activity.m:454
> #10 0x48bb4 in _i_Activity_c___run_ (self=0x243c88, _cmd=0x1553f8)
>     at Activity.m:454
> #11 0x48bb4 in _i_Activity_c___run_ (self=0x242c28, _cmd=0x1553e0)
>     at Activity.m:454
> #12 0x4897c in _i_Activity_c__run (self=0x242c28, _cmd=0x1553b8)
>     at Activity.m:411
> #13 0x48664 in _i_Activity_c__next (self=0x242c28, _cmd=0x1553d0)
>     at Activity.m:350
> #14 0x48888 in _i_Activity_c__stepUntil_ (self=0x242c28, _cmd=0x14e820, 
> tVal=1)
>     at Activity.m:399
> #15 0x2f714 in _i_GUISwarm__go (self=0x1f41e8, _cmd=0x14bab4) at GUISwarm.m:56
> #16 0x21a24 in main (argc=1, argv=0xeffffbe4) at main.m:25
> (gdb) 
> 
> I'm stuck here any suggestions? Sorry for the too much detailed question.
> 
> -Jae
> 

_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427






reply via email to

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