diff --git a/extra/cocoa/cocoa.factor b/extra/cocoa/cocoa.factor index c94984f00b..f4cfb20591 100755 --- a/extra/cocoa/cocoa.factor +++ b/extra/cocoa/cocoa.factor @@ -42,11 +42,13 @@ SYMBOL: super-sent-messages "NSArray" "NSAutoreleasePool" "NSBundle" + "NSDictionary" "NSError" "NSEvent" "NSException" "NSMenu" "NSMenuItem" + "NSMutableDictionary" "NSNib" "NSNotification" "NSNotificationCenter" diff --git a/extra/cocoa/plists/plists.factor b/extra/cocoa/plists/plists.factor index 5965c74af8..9e05773f53 100644 --- a/extra/cocoa/plists/plists.factor +++ b/extra/cocoa/plists/plists.factor @@ -1,23 +1,19 @@ -! Copyright (C) 2007 Slava Pestov. +! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: strings arrays hashtables assocs sequences -xml.writer xml.utilities kernel namespaces ; +cocoa.messages cocoa.classes cocoa.application cocoa kernel +namespaces io.backend ; IN: cocoa.plists -GENERIC: >plist ( obj -- tag ) +: assoc>NSDictionary ( assoc -- alien ) + NSMutableDictionary over assoc-size -> dictionaryWithCapacity: + [ + [ + spin [ ] bi@ -> setObject:forKey: + ] curry assoc-each + ] keep ; -M: string >plist "string" build-tag ; - -M: array >plist - [ >plist ] map "array" build-tag* ; - -M: hashtable >plist - >alist [ >r "key" build-tag r> >plist ] assoc-map concat - "dict" build-tag* ; - -: build-plist ( obj -- tag ) - >plist 1array "plist" build-tag* - dup { { "version" "1.0" } } update ; - -: plist>string ( obj -- string ) - build-plist build-xml xml>string ; +: write-plist ( assoc path -- ) + >r assoc>NSDictionary + r> normalize-path 0 -> writeToFile:atomically: + [ "write-plist failed" throw ] unless ; diff --git a/extra/tools/deploy/macosx/macosx.factor b/extra/tools/deploy/macosx/macosx.factor index 3a7f8e5d03..3121866d94 100755 --- a/extra/tools/deploy/macosx/macosx.factor +++ b/extra/tools/deploy/macosx/macosx.factor @@ -3,7 +3,8 @@ USING: io io.files kernel namespaces sequences system tools.deploy.backend tools.deploy.config assocs hashtables prettyprint io.unix.backend cocoa io.encodings.utf8 -cocoa.application cocoa.classes cocoa.plists qualified ; +io.backend cocoa.application cocoa.classes cocoa.plists +qualified ; IN: tools.deploy.macosx : bundle-dir ( -- dir ) @@ -20,23 +21,21 @@ IN: tools.deploy.macosx "fonts/" resource-path swap "Contents/Resources/" append-path copy-tree-into ; -: app-plist ( executable bundle-name -- string ) +: app-plist ( executable bundle-name -- assoc ) [ - namespace { - { "CFBundleInfoDictionaryVersion" "6.0" } - { "CFBundlePackageType" "APPL" } - } update + "6.0" "CFBundleInfoDictionaryVersion" set + "APPL" "CFBundlePackageType" set file-name "CFBundleName" set - dup "CFBundleExecutable" set - "org.factor." prepend "CFBundleIdentifier" set - ] H{ } make-assoc plist>string ; + [ "CFBundleExecutable" set ] + [ "org.factor." prepend "CFBundleIdentifier" set ] bi + ] H{ } make-assoc ; -: create-app-plist ( vocab bundle-name -- ) +: create-app-plist ( executable bundle-name -- ) [ app-plist ] keep "Contents/Info.plist" append-path - utf8 set-file-contents ; + write-plist ; : create-app-dir ( vocab bundle-name -- vm ) dup "Frameworks" copy-bundle-dir @@ -64,6 +63,6 @@ M: macosx deploy* ( vocab -- ) [ bundle-name create-app-dir ] keep [ bundle-name deploy.app-image ] keep namespace make-deploy-image - bundle-name show-in-finder + bundle-name normalize-path show-in-finder ] bind ] with-directory ;