[MacRuby] #1485: Using MacRuby to invoke a Obj-C variadic method leads crash
MacRuby
ruby-noreply at macosforge.org
Tue Mar 20 08:30:02 PDT 2012
#1485: Using MacRuby to invoke a Obj-C variadic method leads crash
--------------------------------+-------------------------------------------
Reporter: xareelee@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords: variadic method
--------------------------------+-------------------------------------------
I got an Obj-C class like this:
============================
@interface Foo
/// this method would print the variables.
+ (void) log: (id) firstObj, ...; // Obj-C variadic method. Using nil
at the end of args.
@end
@implementation Foo
+ (void) log: (id) firstObj, ...{
va_list ap
va_start (ap, firstObj)
for (id obj = firstObj; obj != nil; obj = va_args(ap, id) ){
NSLog(@"%@", obj);
}
va_end (ap)
}
@end
============================
If I call the method using Obj-C like this:
[Foo log: @"1", @"2", @"3", nil];
The console would print:
=> 1
=> 2
=> 3
But if I call the method using MacRuby like this:
Foo.log ("1", "2", "3", nil)
The Console would print:
=> 1
=> 1 // Yes, it prints the first argument twice!!
then crash!
Did I do it wrong? Or it is a bug there?
--
Ticket URL: <http://www.macruby.org/trac/ticket/1485>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list