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

import dstep.foundation.NSArray;
import dstep.foundation.NSCoder;
import dstep.foundation.NSDate;
import dstep.foundation.NSEnumerator;
import dstep.foundation.NSFileManager;
import dstep.foundation.NSValue;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSURL;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

const TNSDictionaryCreation = `

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

	static Object dictionaryWithObject (Object object, Object key)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObject:forKey:", Object, Object)(object, key);
	}

	static Object dictionaryWithObjects (id* objects, id* keys, NSUInteger cnt)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjects:forKeys:count:", id*, id*, NSUInteger)(objects, keys, cnt);
	}

	static Object dictionaryWithObjectsAndKeys (Object dictionaryWithObjectsAndKeys, ...)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjectsAndKeys:", Object)(dictionaryWithObjectsAndKeys);
	}

	static Object dictionaryWithDictionary (NSDictionary dict)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithDictionary:", NSDictionary)(dict);
	}

	static Object dictionaryWithObjects (NSArray objects, NSArray keys)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjects:forKeys:", NSArray, NSArray)(objects, keys);
	}

	Object initWithObjects (id* objects, id* keys, NSUInteger cnt)
	{
		return invokeObjcSelf!(Object, "initWithObjects:forKeys:count:", id*, id*, NSUInteger)(objects, keys, cnt);
	}

	this (id* objects, id* keys, NSUInteger cnt)
	{
		typeof(this).alloc.initWithObjects(objects, keys, cnt);
	}

	Object initWithObjectsAndKeys (Object initWithObjectsAndKeys, ...)
	{
		return invokeObjcSelf!(Object, "initWithObjectsAndKeys:", Object)(initWithObjectsAndKeys);
	}

	this (Object initWithObjectsAndKeys, ...)
	{
		typeof(this).alloc.initWithObjectsAndKeys(initWithObjectsAndKeys);
	}

	Object initWithDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(Object, "initWithDictionary:", NSDictionary)(otherDictionary);
	}

	this (NSDictionary otherDictionary)
	{
		typeof(this).alloc.initWithDictionary(otherDictionary);
	}

	Object initWithDictionary (NSDictionary otherDictionary, bool flag)
	{
		return invokeObjcSelf!(Object, "initWithDictionary:copyItems:", NSDictionary, bool)(otherDictionary, flag);
	}

	this (NSDictionary otherDictionary, bool flag)
	{
		typeof(this).alloc.initWithDictionary(otherDictionary, flag);
	}

	Object initWithObjects (NSArray objects, NSArray keys)
	{
		return invokeObjcSelf!(Object, "initWithObjects:forKeys:", NSArray, NSArray)(objects, keys);
	}

	this (NSArray objects, NSArray keys)
	{
		typeof(this).alloc.initWithObjects(objects, keys);
	}

	static Object dictionaryWithContentsOfFile (NSString path)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithContentsOfFile:", NSString)(path);
	}

	static Object dictionaryWithContentsOfURL (NSURL url)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithContentsOfURL:", NSURL)(url);
	}

	Object initWithContentsOfFile (NSString path)
	{
		return invokeObjcSelf!(Object, "initWithContentsOfFile:", NSString)(path);
	}

	this (NSString path)
	{
		typeof(this).alloc.initWithContentsOfFile(path);
	}

	Object initWithContentsOfURL (NSURL url)
	{
		return invokeObjcSelf!(Object, "initWithContentsOfURL:", NSURL)(url);
	}

	this (NSURL url)
	{
		typeof(this).alloc.initWithContentsOfURL(url);
	}
`;

const TNSMutableDictionaryCreation = `

	static Object dictionaryWithCapacity (NSUInteger numItems)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithCapacity:", NSUInteger)(numItems);
	}

	Object initWithCapacity (NSUInteger numItems)
	{
		return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems);
	}

	this (NSUInteger numItems)
	{
		typeof(this).alloc.initWithCapacity(numItems);
	}
`;

const TNSExtendedMutableDictionary = `

	void addEntriesFromDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(void, "addEntriesFromDictionary:", NSDictionary)(otherDictionary);
	}

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

	void removeObjectsForKeys (NSArray keyArray)
	{
		return invokeObjcSelf!(void, "removeObjectsForKeys:", NSArray)(keyArray);
	}

	void setDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(void, "setDictionary:", NSDictionary)(otherDictionary);
	}
`;

const TNSExtendedDictionary = `

	NSArray allKeys ()
	{
		return invokeObjcSelf!(NSArray, "allKeys");
	}

	NSArray allKeysForObject (Object anObject)
	{
		return invokeObjcSelf!(NSArray, "allKeysForObject:", Object)(anObject);
	}

	NSArray allValues ()
	{
		return invokeObjcSelf!(NSArray, "allValues");
	}

	NSString description ()
	{
		return invokeObjcSelf!(NSString, "description");
	}

	NSString descriptionInStringsFileFormat ()
	{
		return invokeObjcSelf!(NSString, "descriptionInStringsFileFormat");
	}

	NSString descriptionWithLocale (Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale);
	}

	NSString descriptionWithLocale (Object locale, NSUInteger level)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:indent:", Object, NSUInteger)(locale, level);
	}

	bool isEqualToDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(bool, "isEqualToDictionary:", NSDictionary)(otherDictionary);
	}

	NSEnumerator objectEnumerator ()
	{
		return invokeObjcSelf!(NSEnumerator, "objectEnumerator");
	}

	NSArray objectsForKeys (NSArray keys, Object marker)
	{
		return invokeObjcSelf!(NSArray, "objectsForKeys:notFoundMarker:", NSArray, Object)(keys, marker);
	}

	bool writeToFile (NSString path, bool useAuxiliaryFile)
	{
		return invokeObjcSelf!(bool, "writeToFile:atomically:", NSString, bool)(path, useAuxiliaryFile);
	}

	bool writeToURL (NSURL url, bool atomically)
	{
		return invokeObjcSelf!(bool, "writeToURL:atomically:", NSURL, bool)(url, atomically);
	}

	NSArray keysSortedByValueUsingSelector (SEL comparator)
	{
		return invokeObjcSelf!(NSArray, "keysSortedByValueUsingSelector:", SEL)(comparator);
	}

	void getObjects (id* objects, id* keys)
	{
		return invokeObjcSelf!(void, "getObjects:andKeys:", id*, id*)(objects, keys);
	}
`;

class NSMutableDictionary : NSDictionary
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	void removeObjectForKey (Object aKey)
	{
		return invokeObjcSelf!(void, "removeObjectForKey:", Object)(aKey);
	}

	void setObject (Object anObject, Object aKey)
	{
		return invokeObjcSelf!(void, "setObject:forKey:", Object, Object)(anObject, aKey);
	}
	
	// TNSMutableDictionaryCreation
	static Object dictionaryWithCapacity (NSUInteger numItems)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithCapacity:", NSUInteger)(numItems);
	}
	
	Object initWithCapacity (NSUInteger numItems)
	{
		return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems);
	}
	
	this (NSUInteger numItems)
	{
		typeof(this).alloc.initWithCapacity(numItems);
	}
	
	// TNSExtendedMutableDictionary
	void addEntriesFromDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(void, "addEntriesFromDictionary:", NSDictionary)(otherDictionary);
	}
	
	void removeAllObjects ()
	{
		return invokeObjcSelf!(void, "removeAllObjects");
	}
	
	void removeObjectsForKeys (NSArray keyArray)
	{
		return invokeObjcSelf!(void, "removeObjectsForKeys:", NSArray)(keyArray);
	}
	
	void setDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(void, "setDictionary:", NSDictionary)(otherDictionary);
	}
}

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

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

	Object objectForKey (Object aKey)
	{
		return invokeObjcSelf!(Object, "objectForKey:", Object)(aKey);
	}

	NSEnumerator keyEnumerator ()
	{
		return invokeObjcSelf!(NSEnumerator, "keyEnumerator");
	}

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

	Object mutableCopyWithZone (NSZone* zone)
	{
		return invokeObjcSelf!(Object, "mutableCopyWithZone:", 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);
	}

	NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len)
	{
		return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len);
	}
	
	// TNSDictionaryCreation
	static Object dictionary ()
	{
		return invokeObjcSuperClass!(Object, "dictionary");
	}
	
	static Object dictionaryWithObject (Object object, Object key)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObject:forKey:", Object, Object)(object, key);
	}
	
	static Object dictionaryWithObjects (id* objects, id* keys, NSUInteger cnt)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjects:forKeys:count:", id*, id*, NSUInteger)(objects, keys, cnt);
	}
	
	static Object dictionaryWithObjectsAndKeys (Object dictionaryWithObjectsAndKeys, ...)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjectsAndKeys:", Object)(dictionaryWithObjectsAndKeys);
	}
	
	static Object dictionaryWithDictionary (NSDictionary dict)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithDictionary:", NSDictionary)(dict);
	}
	
	static Object dictionaryWithObjects (NSArray objects, NSArray keys)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithObjects:forKeys:", NSArray, NSArray)(objects, keys);
	}
	
	Object initWithObjects (id* objects, id* keys, NSUInteger cnt)
	{
		return invokeObjcSelf!(Object, "initWithObjects:forKeys:count:", id*, id*, NSUInteger)(objects, keys, cnt);
	}
	
	this (id* objects, id* keys, NSUInteger cnt)
	{
		typeof(this).alloc.initWithObjects(objects, keys, cnt);
	}
	
	Object initWithObjectsAndKeys (Object initWithObjectsAndKeys, ...)
	{
		return invokeObjcSelf!(Object, "initWithObjectsAndKeys:", Object)(initWithObjectsAndKeys);
	}
	
	this (Object initWithObjectsAndKeys, ...)
	{
		typeof(this).alloc.initWithObjectsAndKeys(initWithObjectsAndKeys);
	}
	
	Object initWithDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(Object, "initWithDictionary:", NSDictionary)(otherDictionary);
	}
	
	this (NSDictionary otherDictionary)
	{
		typeof(this).alloc.initWithDictionary(otherDictionary);
	}
	
	Object initWithDictionary (NSDictionary otherDictionary, bool flag)
	{
		return invokeObjcSelf!(Object, "initWithDictionary:copyItems:", NSDictionary, bool)(otherDictionary, flag);
	}
	
	this (NSDictionary otherDictionary, bool flag)
	{
		typeof(this).alloc.initWithDictionary(otherDictionary, flag);
	}
	
	Object initWithObjects (NSArray objects, NSArray keys)
	{
		return invokeObjcSelf!(Object, "initWithObjects:forKeys:", NSArray, NSArray)(objects, keys);
	}
	
	this (NSArray objects, NSArray keys)
	{
		typeof(this).alloc.initWithObjects(objects, keys);
	}
	
	static Object dictionaryWithContentsOfFile (NSString path)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithContentsOfFile:", NSString)(path);
	}
	
	static Object dictionaryWithContentsOfURL (NSURL url)
	{
		return invokeObjcSuperClass!(Object, "dictionaryWithContentsOfURL:", NSURL)(url);
	}
	
	Object initWithContentsOfFile (NSString path)
	{
		return invokeObjcSelf!(Object, "initWithContentsOfFile:", NSString)(path);
	}
	
	this (NSString path)
	{
		typeof(this).alloc.initWithContentsOfFile(path);
	}
	
	Object initWithContentsOfURL (NSURL url)
	{
		return invokeObjcSelf!(Object, "initWithContentsOfURL:", NSURL)(url);
	}
	
	this (NSURL url)
	{
		typeof(this).alloc.initWithContentsOfURL(url);
	}
	
	// TNSFileAttributes
	ulong fileSize ()
	{
		return invokeObjcSelf!(ulong, "fileSize");
	}
	
	NSDate fileModificationDate ()
	{
		return invokeObjcSelf!(NSDate, "fileModificationDate");
	}
	
	NSString fileType ()
	{
		return invokeObjcSelf!(NSString, "fileType");
	}
	
	NSUInteger filePosixPermissions ()
	{
		return invokeObjcSelf!(NSUInteger, "filePosixPermissions");
	}
	
	NSString fileOwnerAccountName ()
	{
		return invokeObjcSelf!(NSString, "fileOwnerAccountName");
	}
	
	NSString fileGroupOwnerAccountName ()
	{
		return invokeObjcSelf!(NSString, "fileGroupOwnerAccountName");
	}
	
	NSInteger fileSystemNumber ()
	{
		return invokeObjcSelf!(NSInteger, "fileSystemNumber");
	}
	
	NSUInteger fileSystemFileNumber ()
	{
		return invokeObjcSelf!(NSUInteger, "fileSystemFileNumber");
	}
	
	bool fileExtensionHidden ()
	{
		return invokeObjcSelf!(bool, "fileExtensionHidden");
	}
	
	uint fileHFSCreatorCode ()
	{
		return invokeObjcSelf!(uint, "fileHFSCreatorCode");
	}
	
	uint fileHFSTypeCode ()
	{
		return invokeObjcSelf!(uint, "fileHFSTypeCode");
	}
	
	bool fileIsImmutable ()
	{
		return invokeObjcSelf!(bool, "fileIsImmutable");
	}
	
	bool fileIsAppendOnly ()
	{
		return invokeObjcSelf!(bool, "fileIsAppendOnly");
	}
	
	NSDate fileCreationDate ()
	{
		return invokeObjcSelf!(NSDate, "fileCreationDate");
	}
	
	NSNumber fileOwnerAccountID ()
	{
		return invokeObjcSelf!(NSNumber, "fileOwnerAccountID");
	}
	
	NSNumber fileGroupOwnerAccountID ()
	{
		return invokeObjcSelf!(NSNumber, "fileGroupOwnerAccountID");
	}
	
	// TNSExtendedDictionary
	NSArray allKeys ()
	{
		return invokeObjcSelf!(NSArray, "allKeys");
	}
	
	NSArray allKeysForObject (Object anObject)
	{
		return invokeObjcSelf!(NSArray, "allKeysForObject:", Object)(anObject);
	}
	
	NSArray allValues ()
	{
		return invokeObjcSelf!(NSArray, "allValues");
	}
	
	NSString description ()
	{
		return invokeObjcSelf!(NSString, "description");
	}
	
	NSString descriptionInStringsFileFormat ()
	{
		return invokeObjcSelf!(NSString, "descriptionInStringsFileFormat");
	}
	
	NSString descriptionWithLocale (Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale);
	}
	
	NSString descriptionWithLocale (Object locale, NSUInteger level)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:indent:", Object, NSUInteger)(locale, level);
	}
	
	bool isEqualToDictionary (NSDictionary otherDictionary)
	{
		return invokeObjcSelf!(bool, "isEqualToDictionary:", NSDictionary)(otherDictionary);
	}
	
	NSEnumerator objectEnumerator ()
	{
		return invokeObjcSelf!(NSEnumerator, "objectEnumerator");
	}
	
	NSArray objectsForKeys (NSArray keys, Object marker)
	{
		return invokeObjcSelf!(NSArray, "objectsForKeys:notFoundMarker:", NSArray, Object)(keys, marker);
	}
	
	bool writeToFile (NSString path, bool useAuxiliaryFile)
	{
		return invokeObjcSelf!(bool, "writeToFile:atomically:", NSString, bool)(path, useAuxiliaryFile);
	}
	
	bool writeToURL (NSURL url, bool atomically)
	{
		return invokeObjcSelf!(bool, "writeToURL:atomically:", NSURL, bool)(url, atomically);
	}
	
	NSArray keysSortedByValueUsingSelector (SEL comparator)
	{
		return invokeObjcSelf!(NSArray, "keysSortedByValueUsingSelector:", SEL)(comparator);
	}
	
	void getObjects (id* objects, id* keys)
	{
		return invokeObjcSelf!(void, "getObjects:andKeys:", id*, id*)(objects, keys);
	}
}