[MacRuby-devel] mangled range param in NSString#getLineStart:end:contentsEnd:forRange:

Laurent Sansonetti lsansonetti at apple.com
Wed Dec 9 14:33:11 PST 2009


Hi Michael,

This could be another ABI calling problem. What architecture are you  
running?

Laurent

On Dec 9, 2009, at 2:25 PM, Michael Johnston wrote:

> I'm having trouble with the NSString method  
> getLineStart:end:contentsEnd:forRange:.  The range param at the end  
> gets mangled.
>
> First of all, the ordinary syntax can't be used because "end" is a  
> keyword, so I'm using the hash syntax.
>
> I added cover methods to NSString to see what was happening. I made  
> two cover methods, one with the same signature as  
> getLineStart:end:contentsEnd:forRange: and one with the range param  
> first:
>
> - (void)getLineStart2:(NSUInteger *)startIndex end:(NSUInteger *) 
> lineEndIndex contentsEnd:(NSUInteger *)contentsEndIndex forRange: 
> (NSRange)aRange
> {
> 	NSLog( @"getLineStartForRange startIndex: %d lineEndIndex: %d  
> contentsEndIndex: %d range: %@", *startIndex, *lineEndIndex,  
> *contentsEndIndex, NSStringFromRange(aRange));
> 	[self getLineStart: startIndex end: lineEndIndex contentsEnd:  
> contentsEndIndex forRange: aRange];
> }
>
> - (void)getLineStart3:(NSRange)aRange end:(NSUInteger *)lineEndIndex  
> contentsEnd:(NSUInteger *)contentsEndIndex forIndex:(NSUInteger *) 
> startIndex
> {
> 	NSLog( @"getLineStartForRange startIndex: %d lineEndIndex: %d  
> contentsEndIndex: %d range: %@", *startIndex, *lineEndIndex,  
> *contentsEndIndex, NSStringFromRange(aRange));
> 	[self getLineStart: startIndex end: lineEndIndex contentsEnd:  
> contentsEndIndex forRange: aRange];
> }
>
> When calling them,  getLineStart3 with the range param as the first  
> param works fine, but getLineStart2 mangles the range:
>
>
>    endix = Pointer.new(:ulong_long)
>    conix = Pointer.new(:ulong_long)
>    ix = Pointer.new(:ulong_long)
>    ix[0] = 5
>    conix[0] = 6
>    endix[0] = 7
>
>    puts "selectedRange: #{selectedRange.inspect}"
>    @diagramCode.getLineStart3(selectedRange, :end =>  
> endix, :contentsEnd => conix, :forIndex => ix)
>    puts "try old way"
>    ix[0] = 5
>    conix[0] = 6
>    endix[0] = 7
>    @diagramCode.getLineStart2(ix, :end => endix, :contentsEnd =>  
> conix, :forRange => selectedRange)
>    puts "ix: #{ix} endix: #{endix.inspect} conix: #{conix.inspect}"
>
>
> selectedRange: #<NSRange location=3 length=0>
> 2009-12-09 14:22:11.487 seeqr[11372:10b] getLineStart3 startIndex: 5  
> lineEndIndex: 7 contentsEndIndex: 6 range: {3, 0}
> try old way
> 2009-12-09 14:22:11.489 seeqr[11372:10b] getLineStart2 startIndex: 5  
> lineEndIndex: 7 contentsEndIndex: 6 range: {0, 4294995796}
> 2009-12-09 14:22:11.490 seeqr[11372:10b] *** -[NSBigMutableString  
> _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]:  
> Range or index out of bounds
>
>
> Am I missing something obvious?
>
> Thanks,
>
> Michael Johnston
> lastobelus at mac.com
>
>
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list