diff dstep/foundation/NSRange.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSRange.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,50 @@
+/**
+ * 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 : id;
+
+alias NSRange* NSRangePointer;
+
+struct NSRange
+{
+	NSUInteger location;
+	NSUInteger length;
+}
+
+template TNSValueRangeExtensions ()
+{
+	static NSValue valueWithRange (NSRange range)
+	{
+		return invokeObjcSelfClass!(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);
+}
\ No newline at end of file