]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/cocoa/application/application.factor
core: subseq-index? -> subseq-of?
[factor.git] / basis / cocoa / application / application.factor
index 83213b47ba005ec11c6442898a74a9b96a9d214c..a73839789237046344ba046b4c41afed0d84cc55 100644 (file)
@@ -1,26 +1,23 @@
-! Copyright (C) 2006, 2008 Slava Pestov
+! Copyright (C) 2006, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.syntax io kernel namespaces core-foundation
-core-foundation.strings cocoa.messages cocoa cocoa.classes
-cocoa.runtime sequences init summary kernel.private
-assocs ;
+USING: alien.c-types alien.syntax cocoa cocoa.classes
+cocoa.runtime core-foundation.strings kernel sequences ;
 IN: cocoa.application
 
 : <NSString> ( str -- alien ) <CFString> -> autorelease ;
 
-C-ENUM:
-NSApplicationDelegateReplySuccess
-NSApplicationDelegateReplyCancel
-NSApplicationDelegateReplyFailure ;
+CONSTANT: NSApplicationDelegateReplySuccess 0
+CONSTANT: NSApplicationDelegateReplyCancel  1
+CONSTANT: NSApplicationDelegateReplyFailure 2
 
 : with-autorelease-pool ( quot -- )
     NSAutoreleasePool -> new [ call ] [ -> release ] bi* ; inline
 
 : NSApp ( -- app ) NSApplication -> sharedApplication ;
 
-CONSTANT: NSAnyEventMask HEX: ffffffff
+CONSTANT: NSAnyEventMask 0xffffffff
 
-FUNCTION: void NSBeep ( ) ;
+FUNCTION: void NSBeep ( )
 
 : with-cocoa ( quot -- )
     [ NSApp drop call ] with-autorelease-pool ; inline
@@ -41,21 +38,10 @@ FUNCTION: void NSBeep ( ) ;
 : install-delegate ( receiver delegate -- )
     -> alloc -> init -> setDelegate: ;
 
-TUPLE: objc-error alien reason ;
-
-: objc-error ( alien -- * )
-    dup -> reason CF>string \ objc-error boa throw ;
-
-M: objc-error summary ( error -- )
-    drop "Objective C exception" ;
-
-[ [ objc-error ] 19 setenv ] "cocoa.application" add-startup-hook
-
 : running.app? ( -- ? )
-    #! Test if we're running a .app.
-    ".app"
+    ! Test if we're running a .app.
     NSBundle -> mainBundle -> bundlePath CF>string
-    subseq? ;
+    ".app" subseq-of? ;
 
 : assert.app ( message -- )
     running.app? [