Mercurial > projects > dstep
view dstep/foundation/NSBundle.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 | 7ff919f595d5 |
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.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; import bindings = dstep.foundation.NSBundle_bindings; private { NSString NSBundleDidLoadNotification_; NSString NSLoadedClasses_; } NSString NSBundleDidLoadNotification () { if (NSBundleDidLoadNotification_) return NSBundleDidLoadNotification_; return NSBundleDidLoadNotification_ = new NSString(bindings.NSBundleDidLoadNotification); } NSString NSLoadedClasses () { if (NSLoadedClasses_) return NSLoadedClasses_; return NSLoadedClasses_ = new NSString(bindings.NSLoadedClasses); } enum { NSBundleExecutableArchitectureI386 = 0x00000007, NSBundleExecutableArchitecturePPC = 0x00000012, NSBundleExecutableArchitectureX86_64 = 0x01000007, NSBundleExecutableArchitecturePPC64 = 0x01000012 } class NSBundle : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static NSBundle mainBundle () { return invokeObjcSuperClass!(NSBundle, "mainBundle"); } static NSBundle bundleWithPath (NSString path) { return invokeObjcSuperClass!(NSBundle, "bundleWithPath:", NSString)(path); } Object initWithPath (NSString path) { return invokeObjcSelf!(Object, "initWithPath:", NSString)(path); } this (NSString path) { typeof(this).alloc.initWithPath(path); } static NSBundle bundleForClass (Class aClass) { return invokeObjcSuperClass!(NSBundle, "bundleForClass:", Class)(aClass); } static NSBundle bundleWithIdentifier (NSString identifier) { return invokeObjcSuperClass!(NSBundle, "bundleWithIdentifier:", NSString)(identifier); } static NSArray allBundles () { return invokeObjcSuperClass!(NSArray, "allBundles"); } static NSArray allFrameworks () { return invokeObjcSuperClass!(NSArray, "allFrameworks"); } bool load () { return invokeObjcSelf!(bool, "load"); } bool isLoaded () { return invokeObjcSelf!(bool, "isLoaded"); } bool unload () { return invokeObjcSelf!(bool, "unload"); } bool preflightAndReturnError (ref NSError error) { id err; if (error) err = new objc_object; bool result = invokeObjcSelf!(bool, "preflightAndReturnError:", id*)(&err); if (err) error = new NSError(err); return result; } bool loadAndReturnError (ref NSError error) { id err; if (error) err = new objc_object; bool result = invokeObjcSelf!(bool, "loadAndReturnError:", id*)(&err); if (err) error = new NSError(err); return result; } 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 invokeObjcSuperClass!(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 invokeObjcSuperClass!(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 invokeObjcSuperClass!(NSArray, "preferredLocalizationsFromArray:", NSArray)(localizationsArray); } static NSArray preferredLocalizationsFromArray (NSArray localizationsArray, NSArray preferencesArray) { return invokeObjcSuperClass!(NSArray, "preferredLocalizationsFromArray:forPreferences:", NSArray, NSArray)(localizationsArray, preferencesArray); } NSArray executableArchitectures () { return invokeObjcSelf!(NSArray, "executableArchitectures"); } }