view dstep/foundation/NSRange.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 89f3c3ef1fd2
children
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Aug 3, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.foundation.NSRange;

import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSString;
import dstep.foundation.NSValue;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;
import bindings = dstep.foundation.NSRange_bindings;

alias NSRange* NSRangePointer;

struct NSRange
{
	NSUInteger location;
	NSUInteger length;
}

const TNSValueRangeExtensions = `

	static NSValue valueWithRange (NSRange range)
	{
		return invokeObjcSuperClass!(NSValue, "valueWithRange:", NSRange)(range);
	}

	NSRange rangeValue ()
	{
		return invokeObjcSelf!(NSRange, "rangeValue");
	}
`;

NSString NSStringFromRange (NSRange range)
{
	return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromRange, NSRange)(range);
}

NSRange NSRangeFromString (NSString aString)
{
	return Bridge.invokeObjcFunction!(NSRange, bindings.NSRangeFromString, NSString)(aString);
}

extern (C)
{
	NSRange NSUnionRange (NSRange range1, NSRange range2);
	NSRange NSIntersectionRange (NSRange range1, NSRange range2);
}