view dstep/foundation/NSEnumerator.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 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.NSEnumerator;

import dstep.foundation.NSArray;
import dstep.foundation.NSObject;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc : id;

struct NSFastEnumerationState
{
	uint state;
	id* itemsPtr;
	unsigned long* mutationsPtr;
	unsigned long* extra;
}

class NSEnumerator : NSObject, INSFastEnumeration
{
	mixin ObjcWrap;
	mixin TNSExtendedEnumerator;

	Object nextObject ()
	{
		return invokeObjcSelf!(Object, "nextObject");
	}

	NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len)
	{
		return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len);
	}
}

interface INSFastEnumeration
{
	NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len);
}

template TNSExtendedEnumerator ()
{
	NSArray allObjects ()
	{
		return invokeObjcSelf!(NSArray, "allObjects");
	}
}