cocoa no longer depends on xml

db4
Slava Pestov 2008-04-05 08:30:02 -05:00
parent 2c76171c8a
commit 6f1d3d9174
3 changed files with 27 additions and 30 deletions

View File

@ -42,11 +42,13 @@ SYMBOL: super-sent-messages
"NSArray" "NSArray"
"NSAutoreleasePool" "NSAutoreleasePool"
"NSBundle" "NSBundle"
"NSDictionary"
"NSError" "NSError"
"NSEvent" "NSEvent"
"NSException" "NSException"
"NSMenu" "NSMenu"
"NSMenuItem" "NSMenuItem"
"NSMutableDictionary"
"NSNib" "NSNib"
"NSNotification" "NSNotification"
"NSNotificationCenter" "NSNotificationCenter"

View File

@ -1,23 +1,19 @@
! Copyright (C) 2007 Slava Pestov. ! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: strings arrays hashtables assocs sequences 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 IN: cocoa.plists
GENERIC: >plist ( obj -- tag ) : assoc>NSDictionary ( assoc -- alien )
NSMutableDictionary over assoc-size -> dictionaryWithCapacity:
[
[
spin [ <NSString> ] bi@ -> setObject:forKey:
] curry assoc-each
] keep ;
M: string >plist "string" build-tag ; : write-plist ( assoc path -- )
>r assoc>NSDictionary
M: array >plist r> normalize-path <NSString> 0 -> writeToFile:atomically:
[ >plist ] map "array" build-tag* ; [ "write-plist failed" throw ] unless ;
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 ;

View File

@ -3,7 +3,8 @@
USING: io io.files kernel namespaces sequences USING: io io.files kernel namespaces sequences
system tools.deploy.backend tools.deploy.config assocs system tools.deploy.backend tools.deploy.config assocs
hashtables prettyprint io.unix.backend cocoa io.encodings.utf8 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 IN: tools.deploy.macosx
: bundle-dir ( -- dir ) : bundle-dir ( -- dir )
@ -20,23 +21,21 @@ IN: tools.deploy.macosx
"fonts/" resource-path "fonts/" resource-path
swap "Contents/Resources/" append-path copy-tree-into ; swap "Contents/Resources/" append-path copy-tree-into ;
: app-plist ( executable bundle-name -- string ) : app-plist ( executable bundle-name -- assoc )
[ [
namespace { "6.0" "CFBundleInfoDictionaryVersion" set
{ "CFBundleInfoDictionaryVersion" "6.0" } "APPL" "CFBundlePackageType" set
{ "CFBundlePackageType" "APPL" }
} update
file-name "CFBundleName" set file-name "CFBundleName" set
dup "CFBundleExecutable" set [ "CFBundleExecutable" set ]
"org.factor." prepend "CFBundleIdentifier" set [ "org.factor." prepend "CFBundleIdentifier" set ] bi
] H{ } make-assoc plist>string ; ] H{ } make-assoc ;
: create-app-plist ( vocab bundle-name -- ) : create-app-plist ( executable bundle-name -- )
[ app-plist ] keep [ app-plist ] keep
"Contents/Info.plist" append-path "Contents/Info.plist" append-path
utf8 set-file-contents ; write-plist ;
: create-app-dir ( vocab bundle-name -- vm ) : create-app-dir ( vocab bundle-name -- vm )
dup "Frameworks" copy-bundle-dir dup "Frameworks" copy-bundle-dir
@ -64,6 +63,6 @@ M: macosx deploy* ( vocab -- )
[ bundle-name create-app-dir ] keep [ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep [ bundle-name deploy.app-image ] keep
namespace make-deploy-image namespace make-deploy-image
bundle-name show-in-finder bundle-name normalize-path show-in-finder
] bind ] bind
] with-directory ; ] with-directory ;