[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #29226] GSFFCallInvocation and structs
From: |
Manuel Guesdon |
Subject: |
[bug #29226] GSFFCallInvocation and structs |
Date: |
Sun, 14 Mar 2010 14:45:49 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 |
URL:
<http://savannah.gnu.org/bugs/?29226>
Summary: GSFFCallInvocation and structs
Project: GNUstep
Submitted by: mguesdon
Submitted on: dim 14 mar 2010 15:45:49 CET
Category: Base/Foundation
Severity: 4 - Important
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
GSFFCallInvocation has a bug handling structs as parameters.
The following code:
typedef struct _PassingStructStruct
{
long long int _value;
} PassingStructStruct;
@interface PassingStructObject: NSObject
-(PassingStructStruct)testPassingStruct:(PassingStructStruct)aStruct;
-(PassingStructStruct)testPassingStructReal:(PassingStructStruct)aStruct;
@end
@implementation PassingStructObject
-(PassingStructStruct)testPassingStructReal:(PassingStructStruct)aStruct
{
NSLog(@"aStruct value=%lld",aStruct._value);
aStruct._value+=456;
return aStruct;
}
- (NSMethodSignature *)methodSignatureForSelector: (SEL)selector
{
NSLog(@"methodSignatureForSelector: %@",NSStringFromSelector(selector));
if (sel_eq(selector,@selector(testPassingStruct:)))
return [super
methodSignatureForSelector:@selector(testPassingStructReal:)];
else
return [super methodSignatureForSelector:selector];
}
- (void)forwardInvocation: (NSInvocation *)invocation
{
NSLog(@"forward: %@",NSStringFromSelector([invocation selector]));
if (sel_eq([invocation selector],@selector(testPassingStruct:)))
[invocation setSelector:@selector(testPassingStructReal:)];
[invocation invoke];
}
@end
void TestPassingStruct()
{
PassingStructObject* o=AUTORELEASE([[PassingStructObject alloc]init]);
PassingStructStruct inStruct;
inStruct._value=123456789;
NSLog(@"inStruct value=%lld",inStruct._value);
PassingStructStruct retStruct=[o testPassingStruct:inStruct];
NSLog(@"retStruct value=%lld",retStruct._value);
}
produce:
inStruct value=123456789
aStruct value=0
retStruct value=456
instead of
inStruct value=123456789
aStruct value=123456789
retStruct value=123457245
The problem seems to come from GSFFCallInvocation GSInvocationCallback
dunction which handle struct as struct pointer but
handle struct as struct in GSFFCallInvokeWithTargetAndImp so the parameter of
the called method is wrong
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?29226>
_______________________________________________
Message posté via/par Savannah
http://savannah.gnu.org/
- [bug #29226] GSFFCallInvocation and structs,
Manuel Guesdon <=