diff dwt/internal/cocoa/NSBundle.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBundle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBundle;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSBundle : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSArray allBundles ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allBundles);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray allFrameworks ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allFrameworks);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString builtInPlugInsPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_builtInPlugInsPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle bundleForClass (objc.Class aClass)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleForClass_1, aClass);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public NSString bundleIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString bundlePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bundlePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle bundleWithIdentifier (NSString identifier)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public static NSBundle bundleWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public objc.Class classNamed (NSString className)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_classNamed_1, className !is null ? className.id : null);
+    }
+
+    public NSString developmentLocalization ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_developmentLocalization);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray executableArchitectures ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executableArchitectures);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString executablePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executablePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary infoDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_infoDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSBundle initWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPath_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isLoaded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLoaded) !is null;
+    }
+
+    //public bool load() {
+    //  return OS.objc_msgSend(this.id, OS.sel_load) !is null;
+    //}
+
+    public bool loadAndReturnError (objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loadAndReturnError_1, error) !is null;
+    }
+
+    public NSArray localizations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary localizedInfoDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedInfoDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString localizedStringForKey (NSString key, NSString value, NSString tableName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedStringForKey_1value_1table_1, key !is null ? key.id : null,
+                value !is null ? value.id : null, tableName !is null ? tableName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle mainBundle ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_mainBundle);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public id objectForInfoDictionaryKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForInfoDictionaryKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString pathForAuxiliaryExecutable (NSString executableName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForAuxiliaryExecutable_1, executableName !is null ? executableName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_ (NSString name, NSString ext)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1, name !is null ? name.id : null, ext !is null ? ext.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString subpath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, subpath !is null ? subpath.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString static_pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString bundlePath)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, bundlePath !is null ? bundlePath.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_inDirectory_forLocalization_ (NSString name, NSString ext, NSString subpath, NSString localizationName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1forLocalization_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSArray static_pathsForResourcesOfType_inDirectory_ (NSString ext, NSString bundlePath)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null,
+                bundlePath !is null ? bundlePath.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray pathsForResourcesOfType_inDirectory_ (NSString ext, NSString subpath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null,
+                subpath !is null ? subpath.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray pathsForResourcesOfType_inDirectory_forLocalization_ (NSString ext, NSString subpath, NSString localizationName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1forLocalization_1, ext !is null ? ext.id : null,
+                subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray preferredLocalizations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredLocalizations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray static_preferredLocalizationsFromArray_ (NSArray localizationsArray)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1,
+                localizationsArray !is null ? localizationsArray.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray static_preferredLocalizationsFromArray_forPreferences_ (NSArray localizationsArray, NSArray preferencesArray)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1forPreferences_1,
+                localizationsArray !is null ? localizationsArray.id : null, preferencesArray !is null ? preferencesArray.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool preflightAndReturnError (objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preflightAndReturnError_1, error) !is null;
+    }
+
+    public objc.Class principalClass ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_principalClass);
+    }
+
+    public NSString privateFrameworksPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_privateFrameworksPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString resourcePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resourcePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString sharedFrameworksPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedFrameworksPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString sharedSupportPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedSupportPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool unload ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_unload) !is null;
+    }
+
+    public static bool loadNibFile (id fileName, id dict, id zone)
+    {
+        return OS.objc_msgSend(OS.class_NSBundle, OS.sel_loadNibFile_1externalNameTable_1withZone_1, fileName.id, dict.id, 0) !is null;
+    }
+
+}