public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem implementing faults in Objective-C
@ 2005-06-21 11:13 Frederic Stark
  2005-06-21 16:49 ` Timothy J. Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Stark @ 2005-06-21 11:13 UTC (permalink / raw)
  To: gnustep-dev, gcc

Hi all,

I am sending this to gnustep-dev crossposted to gcc. Maybe this isn't 
the right mailing list. See at the end of the post for a 40 line program 
that exhibit the bad behavior.

Problem:
If a is a fault (ie: changes its isa pointer during forwardInvocation), 
then:

[a method1:[a method2]]

fails (a does not recognize 'method1:'), while:

id o = [a method2];
[a method1:o];

works.

The code works correctly under Mac OS X.

Am I doing something horribly wrong ?
This is on gcc 3.2/mingw

Thanks for any help,

--fred

fred@FLEA /c/Dev/ObjcInvocations
$ shared_obj/invocation.exe
This one works:
method1
This one fails:
: Uncaught exception NSInvalidArgumentException, reason: B(instance) 
does not recognize method1:

fred@FLEA /c/Dev/ObjcInvocations


$ gcc -v
Reading specs from 
c:/GNUstepVersions/1.10.0/MinGW/bin/../lib/gcc-lib/mingw32/3.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as 
--host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads 
--disable-nls --enable-languages=f77,c++,objc,ada 
--disable-win32-registry --disable-shared
Thread model: win32
gcc version 3.2 (mingw special 20020817-1)

$ uname -a
MINGW32_NT-5.0 FLEA 1.0.10(0.46/3/2) 2004-03-15 07:17 i686 unknown

makefile:

---------------------

MAKEFILE_NAME = GNUstepMakefile

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = invocation

invocation_OBJC_FILES = Invocation.m

invocation_C_FILES =

invocation_CC_FILES =

invocation_HEADER_FILES =

invocation_OBJ_FILES =

ADDITIONAL_OBJCFLAGS =

ADDITIONAL_INCLUDE_DIRS = -I../SystemConfiguration

ADDITIONAL_LIB_DIRS = -L../SystemConfiguration

invocation_TOOL_LIBS = -lgnustep-base \
         -lobjc

-include GNUstepMakefile.preamble
-include GNUstepMakefile.local

include $(GNUSTEP_MAKEFILES)/tool.make

-include GNUstepMakefile.postamble

---------------------

//	Test for invocation problem
#import <Foundation/Foundation.h>

@interface A : NSProxy
@end

@interface B : NSObject
- (void)method1:(id)o;
- (id)method2;
@end

@implementation A
- init { return self; }
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSel { return [B 
instanceMethodSignatureForSelector:aSel]; }
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
	isa = [B class];
	[anInvocation invoke];
}
@end

@implementation B
- (id)method2 { return self; }
- (void)method1:(id)a { printf( "method1\n" ); }
@end

int main()
{
	[[NSAutoreleasePool alloc] init];
	B *theB0 = (B *)[[A alloc] init];
	B *theB1 = (B *)[[A alloc] init];

	printf( "This one works:\n" );

	id o = [theB0 method2];
	[theB0 method1:o];

	printf( "This one fails:\n" );
	fflush( stdout );

	[theB1 method1:[theB1 method2]];

	return 0;
}


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-06-21 17:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-21 11:13 Problem implementing faults in Objective-C Frederic Stark
2005-06-21 16:49 ` Timothy J. Wood
2005-06-21 17:20   ` Frederic Stark
2005-06-21 17:48     ` Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).