]> gitweb.factorcode.org Git - factor.git/commitdiff
more struct changes
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 28 Aug 2009 02:43:29 +0000 (21:43 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 28 Aug 2009 02:43:29 +0000 (21:43 -0500)
basis/game-input/dinput/dinput.factor
basis/ui/backend/windows/windows.factor
basis/windows/types/types.factor
basis/windows/user32/user32.factor

index 6cd161bd28686e3dbaf36fa03e2b25dbeb5013a7..26d57871d72daa0e684f5ccbc32b6779ff3785fe 100755 (executable)
@@ -6,7 +6,7 @@ math.rectangles namespaces parser sequences shuffle
 struct-arrays ui.backend.windows vectors windows.com
 windows.dinput windows.dinput.constants windows.errors
 windows.kernel32 windows.messages windows.ole32
-windows.user32 ;
+windows.user32 classes.struct ;
 IN: game-input.dinput
 CONSTANT: MOUSE-BUFFER-SIZE 16
 
@@ -162,7 +162,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
     [ remove-controller ] each ;
 
 : device-interface? ( dbt-broadcast-hdr -- ? )
-    DEV_BROADCAST_HDR-dbch_devicetype DBT_DEVTYP_DEVICEINTERFACE = ;
+    dbch_devicetype>> DBT_DEVTYP_DEVICEINTERFACE = ;
 
 : device-arrived ( dbt-broadcast-hdr -- )
     device-interface? [ find-controllers ] when ;
@@ -185,9 +185,9 @@ TUPLE: window-rect < rect window-loc ;
     { 0 0 } >>dim ;
 
 : (device-notification-filter) ( -- DEV_BROADCAST_DEVICEW )
-    "DEV_BROADCAST_DEVICEW" <c-object>
-    "DEV_BROADCAST_DEVICEW" heap-size over set-DEV_BROADCAST_DEVICEW-dbcc_size
-    DBT_DEVTYP_DEVICEINTERFACE over set-DEV_BROADCAST_DEVICEW-dbcc_devicetype ;
+    DEV_BROADCAST_DEVICEW <struct>
+        DEV_BROADCAST_DEVICEW heap-size >>dbcc_size
+        DBT_DEVTYP_DEVICEINTERFACE >>dbcc_devicetype ;
 
 : create-device-change-window ( -- )
     <zero-window-rect> WS_OVERLAPPEDWINDOW 0 create-window
@@ -239,11 +239,13 @@ M: dinput-game-input-backend (close-game-input)
     delete-dinput ;
 
 M: dinput-game-input-backend (reset-game-input)
-    {
-        +dinput+ +keyboard-device+ +keyboard-state+
-        +controller-devices+ +controller-guids+
-        +device-change-window+ +device-change-handle+
-    } [ f swap set-global ] each ;
+    global [
+        {
+            +dinput+ +keyboard-device+ +keyboard-state+
+            +controller-devices+ +controller-guids+
+            +device-change-window+ +device-change-handle+
+        } [ off ] each
+    ] bind ;
 
 M: dinput-game-input-backend get-controllers
     +controller-devices+ get
index 5ff33c65d6652d51eb5e8dac06bad8adfbec2c2e..cf4966b75606f352597eaea92cebbb499b3d9038 100755 (executable)
@@ -751,17 +751,18 @@ M: windows-ui-backend beep ( -- )
 
 : fullscreen-RECT ( hwnd -- RECT )
     MONITOR_DEFAULTTONEAREST MonitorFromWindow
-    "MONITORINFOEX" <c-object> dup length over set-MONITORINFOEX-cbSize
-    [ GetMonitorInfo win32-error=0/f ] keep MONITORINFOEX-rcMonitor ;
+    MONITORINFOEX <struct>
+        MONITORINFOEX heap-size >>cbSize
+    [ GetMonitorInfo win32-error=0/f ] keep rcMonitor>> ;
 
 : client-area>RECT ( hwnd -- RECT )
-    "RECT" <c-object>
+    RECT <struct>
     [ GetClientRect win32-error=0/f ]
     [ "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ]
     [ nip ] 2tri ;
 
 : hwnd>RECT ( hwnd -- RECT )
-    "RECT" <c-object> [ GetWindowRect win32-error=0/f ] keep ;
+    RECT <struct> [ GetWindowRect win32-error=0/f ] keep ;
 
 M: windows-ui-backend (grab-input) ( handle -- )
     0 ShowCursor drop
index 081e03f292765cf590c0481cfb41f00fb0551ae2..59192bb3b6de2e1fcfe8b485e2841b2d294cf4a0 100755 (executable)
@@ -216,17 +216,17 @@ CONSTANT: TRUE 1
 
 ! typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
 
-C-STRUCT: WNDCLASS
-    { "UINT" "style" }
-    { "WNDPROC" "lpfnWndProc" }
-    { "int" "cbClsExtra" }
-    { "int" "cbWndExtra" }
-    { "HINSTANCE" "hInstance" }
-    { "HICON" "hIcon" }
-    { "HCURSOR" "hCursor" }
-    { "HBRUSH" "hbrBackground" }
-    { "LPCTSTR" "lpszMenuName" }
-    { "LPCTSTR" "lpszClassName" } ;
+STRUCT: WNDCLASS
+    { style UINT }
+    { lpfnWndProc WNDPROC }
+    { cbClsExtra int }
+    { cbWndExtra int }
+    { hInstance HINSTANCE }
+    { hIcon HICON }
+    { hCursor HCURSOR }
+    { hbrBackground HBRUSH }
+    { lpszMenuName LPCTSTR }
+    { lpszClassName LPCTSTR } ;
 
 STRUCT: WNDCLASSEX
     { cbSize UINT }
@@ -329,12 +329,6 @@ STRUCT: PIXELFORMATDESCRIPTOR
     { dwVisibleMask DWORD }
     { dwDamageMask DWORD } ;
 
-C-STRUCT: RECT
-    { "LONG" "left" }
-    { "LONG" "top" }
-    { "LONG" "right" }
-    { "LONG" "bottom" } ;
-
 : <RECT> ( loc dim -- RECT )
     [ RECT <struct> ] 2dip
     [ drop [ first >>left ] [ second >>top ] bi ]
index 543ce6e2920b6b2dc5cd3d71cc90f7c2d117d0b1..4c39385ce5b239c7c513929d312705efd694971c 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005, 2006 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.syntax parser namespaces kernel math
-windows.types generalizations math.bitwise classes.struct ;
+windows.types generalizations math.bitwise classes.struct
+literals ;
 IN: windows.user32
 
 ! HKL for ActivateKeyboardLayout
@@ -74,8 +75,10 @@ CONSTANT: WS_EX_RIGHTSCROLLBAR    HEX: 00000000
 CONSTANT: WS_EX_CONTROLPARENT     HEX: 00010000
 CONSTANT: WS_EX_STATICEDGE        HEX: 00020000
 CONSTANT: WS_EX_APPWINDOW         HEX: 00040000
+
 : WS_EX_OVERLAPPEDWINDOW ( -- n )
     WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE bitor ; foldable
+
 : WS_EX_PALETTEWINDOW ( -- n )
     { WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } flags ; foldable
 
@@ -538,26 +541,26 @@ CONSTANT: DEVICE_NOTIFY_SERVICE_HANDLE 1
 
 CONSTANT: DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 4
 
-C-STRUCT: DEV_BROADCAST_HDR
-    { "DWORD" "dbch_size" }
-    { "DWORD" "dbch_devicetype" }
-    { "DWORD" "dbch_reserved" } ;
+STRUCT: DEV_BROADCAST_HDR
+    { dbch_size DWORD }
+    { dbch_devicetype DWORD }
+    { dbch_reserved DWORD } ;
 
-C-STRUCT: DEV_BROADCAST_DEVICEW
-    { "DWORD" "dbcc_size" }
-    { "DWORD" "dbcc_devicetype" }
-    { "DWORD" "dbcc_reserved" }
-    { "GUID"  "dbcc_classguid" }
-    { { "WCHAR" 1 } "dbcc_name" } ;
+STRUCT: DEV_BROADCAST_DEVICEW
+    { dbcc_size DWORD }
+    { dbcc_devicetype DWORD }
+    { dbcc_reserved DWORD }
+    { dbcc_classguid GUID }
+    { dbcc_name WCHAR[1] } ;
 
 CONSTANT: CCHDEVICENAME 32
 
-C-STRUCT: MONITORINFOEX
-    { "DWORD" "cbSize" }
-    { "RECT"  "rcMonitor" }
-    { "RECT"  "rcWork" }
-    { "DWORD" "dwFlags" }
-    { { "TCHAR" CCHDEVICENAME } "szDevice" } ;
+STRUCT: MONITORINFOEX
+    { cbSize DWORD }
+    { rcMonitor RECT }
+    { rcWork RECT }
+    { dwFlags DWORD }
+    { szDevice { "TCHAR" $ CCHDEVICENAME } } ;
 
 TYPEDEF: MONITORINFOEX* LPMONITORINFOEX
 TYPEDEF: MONITORINFOEX* LPMONITORINFO