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

import dstep.foundation.NSArray;
import dstep.foundation.NSCoder;
import dstep.foundation.NSEnumerator;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSPointerFunctions;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

const TNSArrayConveniences = `

	static Object pointerArrayWithStrongObjects ()
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects");
	}

	static Object pointerArrayWithWeakObjects ()
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects");
	}

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

class NSPointerArray : NSObject, INSFastEnumeration, INSCopying, INSCoding
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	Object initWithOptions (uint options)
	{
		return invokeObjcSelf!(Object, "initWithOptions:", uint)(options);
	}

	this (uint options)
	{
		typeof(this).alloc.initWithOptions(options);
	}

	Object initWithPointerFunctions (NSPointerFunctions functions)
	{
		return invokeObjcSelf!(Object, "initWithPointerFunctions:", NSPointerFunctions)(functions);
	}

	this (NSPointerFunctions functions)
	{
		typeof(this).alloc.initWithPointerFunctions(functions);
	}

	static Object pointerArrayWithOptions (uint options)
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithOptions:", uint)(options);
	}

	static Object pointerArrayWithPointerFunctions (NSPointerFunctions functions)
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithPointerFunctions:", NSPointerFunctions)(functions);
	}

	NSPointerFunctions pointerFunctions ()
	{
		return invokeObjcSelf!(NSPointerFunctions, "pointerFunctions");
	}

	void* pointerAtIndex (NSUInteger index)
	{
		return invokeObjcSelf!(void*, "pointerAtIndex:", NSUInteger)(index);
	}

	void addPointer (void* pointer)
	{
		return invokeObjcSelf!(void, "addPointer:", void*)(pointer);
	}

	void removePointerAtIndex (NSUInteger index)
	{
		return invokeObjcSelf!(void, "removePointerAtIndex:", NSUInteger)(index);
	}

	void insertPointer (void* item, NSUInteger index)
	{
		return invokeObjcSelf!(void, "insertPointer:atIndex:", void*, NSUInteger)(item, index);
	}

	void replacePointerAtIndex (NSUInteger index, void* item)
	{
		return invokeObjcSelf!(void, "replacePointerAtIndex:withPointer:", NSUInteger, void*)(index, item);
	}

	void compact ()
	{
		return invokeObjcSelf!(void, "compact");
	}

	NSUInteger count ()
	{
		return invokeObjcSelf!(NSUInteger, "count");
	}

	void setCount (NSUInteger count)
	{
		return invokeObjcSelf!(void, "setCount:", NSUInteger)(count);
	}

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

	Object copyWithZone (NSZone* zone)
	{
		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
	}

	void encodeWithCoder (NSCoder aCoder)
	{
		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
	}

	Object initWithCoder (NSCoder aDecoder)
	{
		return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
	}

	this (NSCoder aDecoder)
	{
		typeof(this).alloc.initWithCoder(aDecoder);
	}
	
	// TNSArrayConveniences
	static Object pointerArrayWithStrongObjects ()
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithStrongObjects");
	}
	
	static Object pointerArrayWithWeakObjects ()
	{
		return invokeObjcSuperClass!(Object, "pointerArrayWithWeakObjects");
	}
	
	NSArray allObjects ()
	{
		return invokeObjcSelf!(NSArray, "allObjects");
	}
}