[Top][All Lists]

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

NSInvocation does not seem to always assign return value (suite)

From: Sebastien Pierre
Subject: NSInvocation does not seem to always assign return value (suite)
Date: Tue, 22 Apr 2003 17:24:15 +0200

[sorry, I hit the wrong key in my mua]

Hi all,

I am trying to port a scripting language named Io Objective-C bridge from Cocoa 
to GNUstep. I have experienced some issues in this process, and most notably 
when using NSInvocation objects.

Here is the code snippet that executes an NSInvocation object (the 
Io2Objc_perform function, which translates a Io message to an Objc message) and 
gets the result:

  if (*cType == '@')
    id obj;
    [invocation getReturnValue:&obj];
    [pool release];
    return IoObjcBridge_ioValueForCValue_ofType_(self->bridge, obj, cType);
    [invocation getReturnValue:&(self->returnBuffer)];
    [pool release];
    return IoObjcBridge_ioValueForCValue_ofType_(self->bridge, 
self->returnBuffer, cType);

When the "assert" are commented, as shown in the example, Io does not get the 
return value:

2003-04-22 15:07:45.599 DebugTest[3173] [NSMutableArray<1075777504> alloc]
2003-04-22 15:07:45.649 DebugTest[3173] Pisces:Io       > Io -> Objc 'alloc'
2003-04-22 15:07:45.696 DebugTest[3173] Pisces:Io       > ERROR 
'Io.Primitive.doesNotRespond':Nil does not respond to message 'init'

This can be interpreted as "NSMutableArray alloc" did not return the right 
thing (and this thing is unable to respond to "init"), but did not return nil 

But when I uncomment the assertions, "NSMutableArray alloc init" works fine:

2003-04-22 15:07:02.475 DebugTest[3081] [NSMutableArray<1075777504> alloc]
2003-04-22 15:07:02.523 DebugTest[3081] Pisces:Io       > Io -> Objc 'alloc'
2003-04-22 15:07:02.572 DebugTest[3081] [GSMutableArray<135113432> init]
2003-04-22 15:07:02.620 DebugTest[3081] Pisces:Io       > Io -> Objc 'init'

Which means that "NSMutableArray" alloc created a "GSMutableArray" that was 
properly wrapped by Io. I would also add that this works *most of the time*, 
which means that sometimes we fallback to the first situation.

The only reason for the different behaviour generated by the addition of 
assertions is that [NSInvocation getReturnValue:] is executed *asynchronously*, 
and that sometimes the return value is not completely assigned or not assigned 
at all when the "IoObjcBridge_ioValueForCValue_ofType_" is executed.

So my question is : how can we ask NSInvocation to synchronously (blocking) 
call the getReturnValue method ?


 -- Sebastien

reply via email to

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