]> gitweb.factorcode.org Git - factor.git/blob - basis/cocoa/cocoa.factor
cocoa: Ask the OS for which image file extensions are supported.
[factor.git] / basis / cocoa / cocoa.factor
1 ! Copyright (C) 2006, 2009 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs cocoa.messages compiler.units core-foundation.bundles
4 hashtables init io kernel lexer namespaces sequences vocabs ;
5 IN: cocoa
6
7 SYMBOL: sent-messages
8
9 sent-messages [ H{ } clone ] initialize
10
11 : remember-send ( selector -- )
12     dup sent-messages get set-at ;
13
14 SYNTAX: ->
15     scan-token dup remember-send
16     [ lookup-objc-method suffix! ] [ suffix! ] bi \ send suffix! ;
17
18 SYNTAX: ?->
19     dup last cache-stubs
20     scan-token dup remember-send
21     suffix! \ send suffix! ;
22
23 SYNTAX: SEL:
24     scan-token dup remember-send
25     <selector> suffix! \ cocoa.messages:selector suffix! ;
26
27 SYMBOL: super-sent-messages
28
29 super-sent-messages [ H{ } clone ] initialize
30
31 : remember-super-send ( selector -- )
32     dup super-sent-messages get set-at ;
33
34 SYNTAX: SUPER->
35     scan-token dup remember-super-send
36     [ lookup-objc-method suffix! ] [ suffix! ] bi \ super-send suffix! ;
37
38 SYMBOL: frameworks
39
40 frameworks [ V{ } clone ] initialize
41
42 [ frameworks get [ load-framework ] each ] "cocoa" add-startup-hook
43
44 SYNTAX: FRAMEWORK: scan-token [ load-framework ] [ frameworks get push ] bi ;
45
46 SYNTAX: IMPORT: scan-token [ ] import-objc-class ;
47
48 "Importing Cocoa classes..." print
49
50 "cocoa.classes" create-vocab drop
51
52 [
53     {
54         "NSAlert"
55         "NSAppleScript"
56         "NSApplication"
57         "NSArray"
58         "NSAutoreleasePool"
59         "NSBitmapImageRep"
60         "NSBundle"
61         "NSButton"
62         "NSColorSpace"
63         "NSCustomTouchBarItem"
64         "NSData"
65         "NSDictionary"
66         "NSError"
67         "NSEvent"
68         "NSException"
69         "NSImage"
70         "NSMenu"
71         "NSMenuItem"
72         "NSMutableDictionary"
73         "NSNib"
74         "NSNotification"
75         "NSNotificationCenter"
76         "NSNumber"
77         "NSObject"
78         "NSOpenGLContext"
79         "NSOpenGLPixelFormat"
80         "NSOpenGLView"
81         "NSOpenPanel"
82         "NSPanel"
83         "NSPasteboard"
84         "NSPopover"
85         "NSPropertyListSerialization"
86         "NSResponder"
87         "NSSavePanel"
88         "NSScreen"
89         "NSString"
90         "NSTouchBar"
91         "NSTouchBarItem"
92         "NSView"
93         "NSWindow"
94         "NSWorkspace"
95     } [
96         [ ] import-objc-class
97     ] each
98 ] with-compilation-unit