Commit 7351e5bb authored by Diederik van Arkel's avatar Diederik van Arkel
Browse files

Move 'running OS X' check to Platform module;

parent af9c85b5
...@@ -20,3 +20,5 @@ BitmapDir :: String ...@@ -20,3 +20,5 @@ BitmapDir :: String
batchOptions :: !*World -> (!Bool,Bool,String,*File,!*World) batchOptions :: !*World -> (!Bool,Bool,String,*File,!*World)
wAbort :: !String !*World -> *World wAbort :: !String !*World -> *World
pAbort :: !(PSt .a) -> PSt .a pAbort :: !(PSt .a) -> PSt .a
onOSX :: Bool
implementation module Platform implementation module Platform
import StdInt, StdMisc, StdFile import StdInt, StdMisc, StdFile
import StdTuple,StdOverloaded,StdArray
import StdPSt import StdPSt
import StdIOCommon import StdIOCommon
import StdSystem import StdSystem
...@@ -25,6 +26,7 @@ openPlatformWindowMenu ps ...@@ -25,6 +26,7 @@ openPlatformWindowMenu ps
= ps = ps
// = openWindowMenu ps // = openWindowMenu ps
// FIXME: should be IdePlatform
batchOptions :: !*World -> (!Bool,Bool,String,*File,!*World) batchOptions :: !*World -> (!Bool,Bool,String,*File,!*World)
batchOptions world batchOptions world
# interact = True # interact = True
...@@ -33,12 +35,14 @@ batchOptions world ...@@ -33,12 +35,14 @@ batchOptions world
logfile = undef logfile = undef
= (interact,force_update,prj_name,logfile,world) = (interact,force_update,prj_name,logfile,world)
// FIXME: should be IdePlatform
wAbort :: !String !*World -> *World wAbort :: !String !*World -> *World
wAbort message world wAbort message world
# stderr = fwrites message stderr # stderr = fwrites message stderr
# (_,world) = fclose stderr world # (_,world) = fclose stderr world
= world = world
// FIXME: should be IdePlatform
pAbort :: !(PSt .a) -> PSt .a pAbort :: !(PSt .a) -> PSt .a
pAbort ps = ps pAbort ps = ps
...@@ -116,3 +120,22 @@ where ...@@ -116,3 +120,22 @@ where
} }
:: OSStatus :== Int :: OSStatus :== Int
onOSX :: Bool
onOSX =: fst (runningCarbonOSX OSNewToolbox)
runningCarbonOSX tb
# (err,res,tb) = Gestalt "sysv" tb
| err <> 0 = abort "Gestalt failed.\n"
= (res >= 0x01000, tb)
Gestalt :: !String !*Int -> (!Int,!Int,!*Int)
Gestalt sSel tb
| size sSel <> 4 = abort "Gestalt not called with four-char selector.\n"
# iSel = ((toInt sSel.[0]) << 24) bitor ((toInt sSel.[1]) << 16) bitor ((toInt sSel.[2]) << 8) bitor ((toInt sSel.[3]) << 0)
= Gestalt iSel tb
where
Gestalt :: !Int !*Int -> (!Int,!Int,!*Int)
Gestalt _ _ = code {
ccall Gestalt "PI:II:I"
}
...@@ -2,6 +2,7 @@ implementation module dodebug ...@@ -2,6 +2,7 @@ implementation module dodebug
import StdEnv,StdPictureDef import StdEnv,StdPictureDef
from quickdraw import QGetPort, :: GrafPtr from quickdraw import QGetPort, :: GrafPtr
import Platform
assert :: {#.Char} !.(.a -> (.Bool,.b)) .a -> .b assert :: {#.Char} !.(.a -> (.Bool,.b)) .a -> .b
assert txt test env assert txt test env
...@@ -203,21 +204,3 @@ trace_n` m a ...@@ -203,21 +204,3 @@ trace_n` m a
DebugStr` :: !msg !.a -> .a | toString msg DebugStr` :: !msg !.a -> .a | toString msg
DebugStr` msg a DebugStr` msg a
= DebugStr (toString msg) a = DebugStr (toString msg) a
onOSX =: fst (runningCarbonOSX OSNewToolbox)
runningCarbonOSX tb
# (err,res,tb) = Gestalt "sysv" tb
| err <> 0 = abort "Gestalt failed.\n"
= (res >= 0x01000, tb)
Gestalt :: !String !*Int -> (!Int,!Int,!*Int)
Gestalt sSel tb
| size sSel <> 4 = abort "Gestalt not called with four-char selector.\n"
# iSel = ((toInt sSel.[0]) << 24) bitor ((toInt sSel.[1]) << 16) bitor ((toInt sSel.[2]) << 8) bitor ((toInt sSel.[3]) << 0)
= Gestalt iSel tb
where
Gestalt :: !Int !*Int -> (!Int,!Int,!*Int)
Gestalt _ _ = code {
ccall Gestalt "PI:II:I"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment