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

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSBundle.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,247 @@
+/**
+ * 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.NSBundle;
+
+import dstep.foundation.NSArray;
+import dstep.foundation.NSDictionary;
+import dstep.foundation.NSError;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSString;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+import bindings = dstep.foundation.NSBundle_bindings;
+
+const NSString NSBundleDidLoadNotification;
+const NSString NSLoadedClasses;
+
+enum
+{
+	NSBundleExecutableArchitectureI386 = 0x00000007,
+	NSBundleExecutableArchitecturePPC = 0x00000012,
+	NSBundleExecutableArchitectureX86_64 = 0x01000007,
+	NSBundleExecutableArchitecturePPC64 = 0x01000012
+}
+
+static this ()
+{
+	NSBundleDidLoadNotification = new NSString(bindings.NSBundleDidLoadNotification);
+	NSLoadedClasses = new NSString(bindings.NSLoadedClasses);
+}
+
+class NSBundle : NSObject
+{
+	mixin ObjcWrap;
+
+	static NSBundle mainBundle ()
+	{
+		return invokeObjcSelfClass!(NSBundle, "mainBundle"return result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null);	}
+
+	static NSBundle bundleWithPath (NSString path)
+	{
+		return invokeObjcSelfClass!(NSBundle, "bundleWithPath:", NSString)(pathreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null);	}
+
+	Object initWithPath (NSString path)
+	{
+		return invokeObjcSelf!(Object, "initWithPath:", NSString)(path);
+	}
+
+	this (NSString path)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithPath:", NSString)(objcObject, path);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	static NSBundle bundleForClass (Class aClass)
+	{
+		return invokeObjcSelfClass!(NSBundle, "bundleForClass:", Class)(aClassreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null);	}
+
+	static NSBundle bundleWithIdentifier (NSString identifier)
+	{
+		return invokeObjcSelfClass!(NSBundle, "bundleWithIdentifier:", NSString)(identifierreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null);	}
+
+	static NSArray allBundles ()
+	{
+		return invokeObjcSelfClass!(NSArray, "allBundles");
+	}
+
+	static NSArray allFrameworks ()
+	{
+		return invokeObjcSelfClass!(NSArray, "allFrameworks");
+	}
+
+	bool load ()
+	{
+		return invokeObjcSelf!(bool, "load");
+	}
+
+	bool isLoaded ()
+	{
+		return invokeObjcSelf!(bool, "isLoaded");
+	}
+
+	bool unload ()
+	{
+		return invokeObjcSelf!(bool, "unload");
+	}
+
+	bool preflightAndReturnError (NSError** error)
+	{
+		return invokeObjcSelf!(bool, "preflightAndReturnError:", NSError**)(error);
+	}
+
+	bool loadAndReturnError (NSError** error)
+	{
+		return invokeObjcSelf!(bool, "loadAndReturnError:", NSError**)(error);
+	}
+
+	NSString bundlePath ()
+	{
+		return invokeObjcSelf!(NSString, "bundlePath");
+	}
+
+	NSString resourcePath ()
+	{
+		return invokeObjcSelf!(NSString, "resourcePath");
+	}
+
+	NSString executablePath ()
+	{
+		return invokeObjcSelf!(NSString, "executablePath");
+	}
+
+	NSString pathForAuxiliaryExecutable (NSString executableName)
+	{
+		return invokeObjcSelf!(NSString, "pathForAuxiliaryExecutable:", NSString)(executableName);
+	}
+
+	NSString privateFrameworksPath ()
+	{
+		return invokeObjcSelf!(NSString, "privateFrameworksPath");
+	}
+
+	NSString sharedFrameworksPath ()
+	{
+		return invokeObjcSelf!(NSString, "sharedFrameworksPath");
+	}
+
+	NSString sharedSupportPath ()
+	{
+		return invokeObjcSelf!(NSString, "sharedSupportPath");
+	}
+
+	NSString builtInPlugInsPath ()
+	{
+		return invokeObjcSelf!(NSString, "builtInPlugInsPath");
+	}
+
+	NSString bundleIdentifier ()
+	{
+		return invokeObjcSelf!(NSString, "bundleIdentifier");
+	}
+
+	Class classNamed (NSString className)
+	{
+		return invokeObjcSelf!(Class, "classNamed:", NSString)(className);
+	}
+
+	Class principalClass ()
+	{
+		return invokeObjcSelf!(Class, "principalClass");
+	}
+
+	static NSString pathForResource (NSString name, NSString ext, NSString bundlePath)
+	{
+		return invokeObjcSelfClass!(NSString, "pathForResource:ofType:inDirectory:", NSString, NSString, NSString)(name, ext, bundlePath);
+	}
+
+	NSString pathForResource (NSString name, NSString ext)
+	{
+		return invokeObjcSelf!(NSString, "pathForResource:ofType:", NSString, NSString)(name, ext);
+	}
+
+	NSString pathForResource (NSString name, NSString ext, NSString subpath)
+	{
+		return invokeObjcSelf!(NSString, "pathForResource:ofType:inDirectory:", NSString, NSString, NSString)(name, ext, subpath);
+	}
+
+	NSString pathForResource (NSString name, NSString ext, NSString subpath, NSString localizationName)
+	{
+		return invokeObjcSelf!(NSString, "pathForResource:ofType:inDirectory:forLocalization:", NSString, NSString, NSString, NSString)(name, ext, subpath, localizationName);
+	}
+
+	static NSArray pathsForResourcesOfType (NSString ext, NSString bundlePath)
+	{
+		return invokeObjcSelfClass!(NSArray, "pathsForResourcesOfType:inDirectory:", NSString, NSString)(ext, bundlePath);
+	}
+
+	NSArray pathsForResourcesOfType (NSString ext, NSString subpath)
+	{
+		return invokeObjcSelf!(NSArray, "pathsForResourcesOfType:inDirectory:", NSString, NSString)(ext, subpath);
+	}
+
+	NSArray pathsForResourcesOfType (NSString ext, NSString subpath, NSString localizationName)
+	{
+		return invokeObjcSelf!(NSArray, "pathsForResourcesOfType:inDirectory:forLocalization:", NSString, NSString, NSString)(ext, subpath, localizationName);
+	}
+
+	NSString localizedStringForKey (NSString key, NSString value, NSString tableName)
+	{
+		return invokeObjcSelf!(NSString, "localizedStringForKey:value:table:", NSString, NSString, NSString)(key, value, tableName);
+	}
+
+	NSDictionary infoDictionary ()
+	{
+		return invokeObjcSelf!(NSDictionary, "infoDictionary");
+	}
+
+	NSDictionary localizedInfoDictionary ()
+	{
+		return invokeObjcSelf!(NSDictionary, "localizedInfoDictionary");
+	}
+
+	Object objectForInfoDictionaryKey (NSString key)
+	{
+		return invokeObjcSelf!(Object, "objectForInfoDictionaryKey:", NSString)(key);
+	}
+
+	NSArray localizations ()
+	{
+		return invokeObjcSelf!(NSArray, "localizations");
+	}
+
+	NSArray preferredLocalizations ()
+	{
+		return invokeObjcSelf!(NSArray, "preferredLocalizations");
+	}
+
+	NSString developmentLocalization ()
+	{
+		return invokeObjcSelf!(NSString, "developmentLocalization");
+	}
+
+	static NSArray preferredLocalizationsFromArray (NSArray localizationsArray)
+	{
+		return invokeObjcSelfClass!(NSArray, "preferredLocalizationsFromArray:", NSArray)(localizationsArray);
+	}
+
+	static NSArray preferredLocalizationsFromArray (NSArray localizationsArray, NSArray preferencesArray)
+	{
+		return invokeObjcSelfClass!(NSArray, "preferredLocalizationsFromArray:forPreferences:", NSArray, NSArray)(localizationsArray, preferencesArray);
+	}
+
+	NSArray executableArchitectures ()
+	{
+		return invokeObjcSelf!(NSArray, "executableArchitectures");
+	}
+}
+