Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSBundle.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | c74ba20de292 |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSBundle.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSBundle.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,15 +1,15 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. +/******************************************************************************* + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSBundle; @@ -19,265 +19,52 @@ import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; 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 class NSBundle : NSObject { - 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 this() { + super(); +} - public objc.Class classNamed (NSString className) - { - return cast(objc.Class) 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 this(objc.id id) { + super(id); +} - 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 this(cocoa.id id) { + super(id); +} - 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 bool loadNibFile(NSString fileName, NSDictionary context, NSZone* zone) { + return OS.objc_msgSend_bool(OS.class_NSBundle, OS.sel_loadNibFile_externalNameTable_withZone_, fileName !is null ? fileName.id : null, + context !is null ? context.id : null, zone); +} - 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 bundleIdentifier() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleIdentifier); + 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 NSString bundlePath() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_bundlePath); + return result !is null ? new NSString(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 static NSBundle bundleWithPath(NSString path) { + objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_, path !is null ? path.id : null); + return result !is null ? new NSBundle(result) : null; +} - public objc.Class principalClass () - { - return cast(objc.Class) 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 NSDictionary infoDictionary() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_infoDictionary); + return result !is null ? new NSDictionary(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; - } +public cocoa.id objectForInfoDictionaryKey(NSString key) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForInfoDictionaryKey_, key !is null ? key.id : null); + return result !is null ? new cocoa.id(result) : null; } + +}