diff dstep/foundation/NSObject.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/NSObject.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,387 @@
+/**
+ * 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.NSObject;
+
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSEnumerator;
+import dstep.foundation.NSInvocation;
+import dstep.foundation.NSMethodSignature;
+import dstep.foundation.NSObjCRuntime;
+import dstep.foundation.NSString;
+import dstep.foundation.NSZone;
+import dstep.foundation.Protocol;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+class NSObject : INSObject
+{
+	mixin ObjcWrap;
+	mixin TNSURLConnectionDelegate;
+	mixin TNSFileManagerFileOperationAdditions;
+	mixin TNSDeprecatedKeyValueCoding;
+	mixin TNSDistributedObjects;
+	mixin TNSArchiverCallback;
+	mixin TNSKeyValueObserverNotification;
+	mixin TNSMetadataQueryDelegate;
+	mixin TNSKeyValueObservingCustomization;
+	mixin TNSKeyedArchiverObjectSubstitution;
+	mixin TNSScriptClassDescription;
+	mixin TNSDelayedPerforming;
+	mixin TNSStreamDelegateEventExtensions;
+	mixin TNSCopyLinkMoveHandler;
+	mixin TNSMachPortDelegateMethods;
+	mixin TNSComparisonMethods;
+	mixin TNSSpellServerDelegate;
+	mixin TNSScriptKeyValueCoding;
+	mixin TNSDistantObjectRequestMethods;
+	mixin TNSClassDescriptionPrimitives;
+	mixin TNSKeyedUnarchiverObjectSubstitution;
+	mixin TNSScriptObjectSpecifiers;
+	mixin TNSNetServiceDelegateMethods;
+	mixin TNSConnectionDelegateMethods;
+	mixin TNSXMLParserDelegateEventAdditions;
+	mixin TNSErrorRecoveryAttempting;
+	mixin TNSDeprecatedMethods;
+	mixin TNSPortDelegateMethods;
+	mixin TNSURLClient;
+	mixin TNSScriptingComparisonMethods;
+	mixin TNSNetServiceBrowserDelegateMethods;
+	mixin TNSCoderMethods;
+	mixin TNSDeprecatedKeyValueObservingCustomization;
+	mixin TNSKeyedUnarchiverDelegate;
+	mixin TNSScripting;
+	mixin TNSURLDownloadDelegate;
+	mixin TNSKeyValueCoding;
+	mixin TNSKeyedArchiverDelegate;
+	mixin TNSThreadPerformAdditions;
+	mixin TNSKeyValueObserving;
+
+	static void load ()
+	{
+		return invokeObjcSelfClass!(void, "load");
+	}
+
+	static void initialize ()
+	{
+		return invokeObjcSelfClass!(void, "initialize");
+	}
+
+	Object init ()
+	{
+		return invokeObjcSelf!(Object, "init");
+	}
+
+	this ()
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "init")(objcObject);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	static Object new_ ()
+	{
+		return invokeObjcSelfClass!(Object, "new");
+	}
+
+	static Object allocWithZone (NSZone* zone)
+	{
+		return invokeObjcSelfClass!(Object, "allocWithZone:", NSZone*)(zone);
+	}
+
+	static Object alloc ()
+	{
+		return invokeObjcSelfClass!(Object, "alloc");
+	}
+
+	void dealloc ()
+	{
+		return invokeObjcSelf!(void, "dealloc");
+	}
+
+	void finalize ()
+	{
+		return invokeObjcSelf!(void, "finalize");
+	}
+
+	Object copy ()
+	{
+		return invokeObjcSelf!(Object, "copy");
+	}
+
+	Object mutableCopy ()
+	{
+		return invokeObjcSelf!(Object, "mutableCopy");
+	}
+
+	static Object copyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelfClass!(Object, "copyWithZone:", NSZone*)(zone);
+	}
+
+	static Object mutableCopyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelfClass!(Object, "mutableCopyWithZone:", NSZone*)(zone);
+	}
+
+	static Class superclass ()
+	{
+		return invokeObjcSelfClass!(Class, "superclass");
+	}
+
+	static Class class_ ()
+	{
+		return invokeObjcSelfClass!(Class, "class");
+	}
+
+	static bool instancesRespondToSelector (SEL aSelector)
+	{
+		return invokeObjcSelfClass!(bool, "instancesRespondToSelector:", SEL)(aSelector);
+	}
+
+	static bool conformsToProtocol (Protocol protocol)
+	{
+		return invokeObjcSelfClass!(bool, "conformsToProtocol:", Protocol)(protocol);
+	}
+
+	IMP methodForSelector (SEL aSelector)
+	{
+		return invokeObjcSelf!(IMP, "methodForSelector:", SEL)(aSelector);
+	}
+
+	static IMP instanceMethodForSelector (SEL aSelector)
+	{
+		return invokeObjcSelfClass!(IMP, "instanceMethodForSelector:", SEL)(aSelector);
+	}
+
+	void doesNotRecognizeSelector (SEL aSelector)
+	{
+		return invokeObjcSelf!(void, "doesNotRecognizeSelector:", SEL)(aSelector);
+	}
+
+	void forwardInvocation (NSInvocation anInvocation)
+	{
+		return invokeObjcSelf!(void, "forwardInvocation:", NSInvocation)(anInvocation);
+	}
+
+	NSMethodSignature methodSignatureForSelector (SEL aSelector)
+	{
+		return invokeObjcSelf!(NSMethodSignature, "methodSignatureForSelector:", SEL)(aSelector);
+	}
+
+	static NSMethodSignature instanceMethodSignatureForSelector (SEL aSelector)
+	{
+		return invokeObjcSelfClass!(NSMethodSignature, "instanceMethodSignatureForSelector:", SEL)(aSelector);
+	}
+
+	static NSString description ()
+	{
+		return invokeObjcSelfClass!(NSString, "description");
+	}
+
+	static bool isSubclassOfClass (Class aClass)
+	{
+		return invokeObjcSelfClass!(bool, "isSubclassOfClass:", Class)(aClass);
+	}
+
+	static bool resolveClassMethod (SEL sel)
+	{
+		return invokeObjcSelfClass!(bool, "resolveClassMethod:", SEL)(sel);
+	}
+
+	static bool resolveInstanceMethod (SEL sel)
+	{
+		return invokeObjcSelfClass!(bool, "resolveInstanceMethod:", SEL)(sel);
+	}
+
+	bool isEqual (Object object)
+	{
+		return invokeObjcSelf!(bool, "isEqual:", Object)(object);
+	}
+
+	NSUInteger hash ()
+	{
+		return invokeObjcSelf!(NSUInteger, "hash");
+	}
+
+	Class superclass ()
+	{
+		return invokeObjcSelf!(Class, "superclass");
+	}
+
+	Class class_ ()
+	{
+		return invokeObjcSelf!(Class, "class");
+	}
+
+	Object self ()
+	{
+		return invokeObjcSelf!(Object, "self");
+	}
+
+	NSZone* zone ()
+	{
+		return invokeObjcSelf!(NSZone*, "zone");
+	}
+
+	Object performSelector (SEL aSelector)
+	{
+		return invokeObjcSelf!(Object, "performSelector:", SEL)(aSelector);
+	}
+
+	Object performSelector (SEL aSelector, Object object)
+	{
+		return invokeObjcSelf!(Object, "performSelector:withObject:", SEL, Object)(aSelector, object);
+	}
+
+	Object performSelector (SEL aSelector, Object object1, Object object2)
+	{
+		return invokeObjcSelf!(Object, "performSelector:withObject:withObject:", SEL, Object, Object)(aSelector, object1, object2);
+	}
+
+	bool isProxy ()
+	{
+		return invokeObjcSelf!(bool, "isProxy");
+	}
+
+	bool isKindOfClass (Class aClass)
+	{
+		return invokeObjcSelf!(bool, "isKindOfClass:", Class)(aClass);
+	}
+
+	bool isMemberOfClass (Class aClass)
+	{
+		return invokeObjcSelf!(bool, "isMemberOfClass:", Class)(aClass);
+	}
+
+	bool conformsToProtocol (Protocol aProtocol)
+	{
+		return invokeObjcSelf!(bool, "conformsToProtocol:", Protocol)(aProtocol);
+	}
+
+	bool respondsToSelector (SEL aSelector)
+	{
+		return invokeObjcSelf!(bool, "respondsToSelector:", SEL)(aSelector);
+	}
+
+	Object retain ()
+	{
+		return invokeObjcSelf!(Object, "retain");
+	}
+
+	void release ()
+	{
+		return invokeObjcSelf!(void, "release");
+	}
+
+	Object autorelease ()
+	{
+		return invokeObjcSelf!(Object, "autorelease");
+	}
+
+	NSUInteger retainCount ()
+	{
+		return invokeObjcSelf!(NSUInteger, "retainCount");
+	}
+
+	NSString description ()
+	{
+		return invokeObjcSelf!(NSString, "description");
+	}
+}
+
+interface INSCopying
+{
+	Object copyWithZone (NSZone* zone);
+}
+
+interface INSObject
+{
+	bool isEqual (Object object);
+	NSUInteger hash ();
+	Class superclass ();
+	Class class_ ();
+	Object self ();
+	NSZone* zone ();
+	Object performSelector (SEL aSelector);
+	Object performSelector (SEL aSelector, Object object);
+	Object performSelector (SEL aSelector, Object object1, Object object2);
+	bool isProxy ();
+	bool isKindOfClass (Class aClass);
+	bool isMemberOfClass (Class aClass);
+	bool conformsToProtocol (Protocol aProtocol);
+	bool respondsToSelector (SEL aSelector);
+	Object retain ();
+	void release ();
+	Object autorelease ();
+	NSUInteger retainCount ();
+	NSString description ();
+}
+
+interface INSMutableCopying
+{
+	Object mutableCopyWithZone (NSZone* zone);
+}
+
+interface INSCoding
+{
+	void encodeWithCoder (NSCoder aCoder);
+	Object initWithCoder (NSCoder aDecoder);
+}
+
+template TNSDeprecatedMethods ()
+{
+	static void poseAsClass (Class aClass);
+}
+
+template TNSCoderMethods ()
+{
+	static NSInteger version_ ();
+	static void setVersion (NSInteger aVersion);
+	Class classForCoder ();
+	Object replacementObjectForCoder (NSCoder aCoder);
+	Object awakeAfterUsingCoder (NSCoder aDecoder);
+}
+
+Object NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone* zone)
+{
+	return Bridge.invokeObjcFunction!(Object, bindings.NSAllocateObject, Class, NSUInteger, NSZone*)(aClass, extraBytes, zone);
+}
+
+void NSDeallocateObject (Object object)
+{
+	return Bridge.invokeObjcFunction!(void, bindings.NSDeallocateObject, Object)(object);
+}
+
+Object NSCopyObject (Object object, NSUInteger extraBytes, NSZone* zone)
+{
+	return Bridge.invokeObjcFunction!(Object, bindings.NSCopyObject, Object, NSUInteger, NSZone*)(object, extraBytes, zone);
+}
+
+bool NSShouldRetainWithZone (Object anObject, NSZone* requestedZone)
+{
+	return Bridge.invokeObjcFunction!(bool, bindings.NSShouldRetainWithZone, Object, NSZone*)(anObject, requestedZone);
+}
+
+void NSIncrementExtraRefCount (Object object)
+{
+	return Bridge.invokeObjcFunction!(void, bindings.NSIncrementExtraRefCount, Object)(object);
+}
+
+bool NSDecrementExtraRefCountWasZero (Object object)
+{
+	return Bridge.invokeObjcFunction!(bool, bindings.NSDecrementExtraRefCountWasZero, Object)(object);
+}
+
+NSUInteger NSExtraRefCount (Object object)
+{
+	return Bridge.invokeObjcFunction!(NSUInteger, bindings.NSExtraRefCount, Object)(object);
+}
+