]> gitweb.factorcode.org Git - factor.git/commitdiff
Add os-version hook to system-info which returns f on every platform except windows...
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 8 Sep 2011 21:07:12 +0000 (14:07 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 8 Sep 2011 22:48:05 +0000 (15:48 -0700)
Move system-info platform loader into system-info.backend
Add win7? and winxp? words to system-info, clean up ping-tests with new word
Merge system-info.backend into system-info. Will throw an exception when loading on *bsd now

basis/system-info/backend/authors.txt [deleted file]
basis/system-info/backend/backend.factor [deleted file]
basis/system-info/linux/linux.factor
basis/system-info/macosx/macosx.factor
basis/system-info/system-info.factor
basis/system-info/windows/windows-tests.factor
basis/system-info/windows/windows.factor

diff --git a/basis/system-info/backend/authors.txt b/basis/system-info/backend/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/basis/system-info/backend/backend.factor b/basis/system-info/backend/backend.factor
deleted file mode 100644 (file)
index 6e6715f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: system ;
-IN: system-info.backend
-
-HOOK: cpus os ( -- n )
-HOOK: cpu-mhz os ( -- n )
-HOOK: memory-load os ( -- n )
-HOOK: physical-mem os ( -- n )
-HOOK: available-mem os ( -- n )
-HOOK: total-page-file os ( -- n )
-HOOK: available-page-file os ( -- n )
-HOOK: total-virtual-mem os ( -- n )
-HOOK: available-virtual-mem os ( -- n )
-HOOK: available-virtual-extended-mem os ( -- n )
index 2eb395b8d1b65cb5d6df813201ff34f0f5b61797..d5ee9915be24ea64962eb1a2622b6488986c5c0b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: unix alien alien.c-types kernel math sequences strings
 io.backend.unix splitting io.encodings.utf8 io.encodings.string
-specialized-arrays alien.syntax ;
+specialized-arrays alien.syntax system-info ;
 SPECIALIZED-ARRAY: char
 IN: system-info.linux
 
@@ -23,3 +23,5 @@ FUNCTION-ALIAS: (uname)
 
 : kernel-version ( -- seq )
     release ".-" split harvest 5 "" pad-tail ;
+
+M: linux os-version f ;
\ No newline at end of file
index d4f22771284537671bf10c36310935325a1db45b..faf69a881e124bc6be97f43db50eb60c20b0b717 100644 (file)
@@ -2,9 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.data alien.strings alien.syntax
 byte-arrays kernel namespaces sequences unix
-system-info.backend system io.encodings.utf8 ;
+system io.encodings.utf8 system-info ;
 IN: system-info.macosx
 
+M: macosx os-version f ;
+
 ! See /usr/include/sys/sysctl.h for constants
 
 LIBRARY: libc
index 5bf886abd8a50cb6c9ca095dc7a639f703fd22ad..fdeaa50fdeff810c7da90ca6c2b5cdefb9bfeb60 100644 (file)
@@ -1,9 +1,21 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax kernel math prettyprint io math.parser
-combinators vocabs.loader system-info.backend system ;
+USING: combinators io kernel math math.parser system
+vocabs.loader ;
 IN: system-info
 
+HOOK: os-version os ( -- version )    
+HOOK: cpus os ( -- n )
+HOOK: cpu-mhz os ( -- n )
+HOOK: memory-load os ( -- n )
+HOOK: physical-mem os ( -- n )
+HOOK: available-mem os ( -- n )
+HOOK: total-page-file os ( -- n )
+HOOK: available-page-file os ( -- n )
+HOOK: total-virtual-mem os ( -- n )
+HOOK: available-virtual-mem os ( -- n )
+HOOK: available-virtual-extended-mem os ( -- n )
+
 : write-unit ( x n str -- )
     [ 2^ /f number>string write bl ] [ write ] bi* ;
 
@@ -12,14 +24,13 @@ IN: system-info
 : gigs ( x -- ) 30 "GB" write-unit ;
 : ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ;
 
+: system-report. ( -- )
+    "CPUs: " write cpus number>string write nl
+    "CPU Speed: " write cpu-mhz ghz nl
+    "Physical RAM: " write physical-mem megs nl ;
+        
 << {
     { [ os windows? ] [ "system-info.windows" ] }
     { [ os linux? ] [ "system-info.linux" ] }
     { [ os macosx? ] [ "system-info.macosx" ] }
-    [ f ]
 } cond [ require ] when* >>
-
-: system-report. ( -- )
-    "CPUs: " write cpus number>string write nl
-    "CPU Speed: " write cpu-mhz ghz nl
-    "Physical RAM: " write physical-mem megs nl ;
index d26e86742c3c36a891a7e920aeeff88b8fb1d0b3..5e8bed7c6ce4ba75b41493a2e4a267f458d1a4cd 100644 (file)
@@ -1,6 +1,6 @@
-USING: math.order strings system-info.backend
-system-info.windows tools.test ;
+USING: math math.order strings system-info.windows tools.test
+system-info ;
 IN: system-info.windows.tests
 
-[ t ] [ cpus 0 1024 between? ] unit-test
+[ t ] [ cpus integer? ] unit-test
 [ t ] [ username string? ] unit-test
index 4ff252bf25641cb91670e6d14023732f494e040d..8aa295519a2df9b5f6a720c106f2cf6bee5b52be 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.strings
-byte-arrays classes.struct combinators kernel math namespaces
-specialized-arrays system system-info.backend vocabs.loader
-windows windows.advapi32 windows.errors windows.kernel32 words ;
+arrays byte-arrays classes.struct combinators kernel math
+namespaces specialized-arrays system
+vocabs.loader windows windows.advapi32
+windows.errors windows.kernel32 words ;
 SPECIALIZED-ARRAY: ushort
 IN: system-info.windows
 
@@ -21,25 +22,28 @@ IN: system-info.windows
 : processor-architecture ( -- n )
     system-info dwOemId>> HEX: ffff0000 bitand ;
 
-: os-version ( -- os-version )
+: os-version-struct ( -- os-version )
     OSVERSIONINFO <struct>
         OSVERSIONINFO heap-size >>dwOSVersionInfoSize
     dup GetVersionEx win32-error=0/f ;
 
 : windows-major ( -- n )
-    os-version dwMajorVersion>> ;
+    os-version-struct dwMajorVersion>> ;
 
 : windows-minor ( -- n )
-    os-version dwMinorVersion>> ;
+    os-version-struct dwMinorVersion>> ;
 
+M: winnt os-version ( -- obj )
+    os-version-struct [ dwMajorVersion>> ] [ dwMinorVersion>> ] bi 2array ;
+    
 : windows-build# ( -- n )
-    os-version dwBuildNumber>> ;
+    os-version-struct dwBuildNumber>> ;
 
 : windows-platform-id ( -- n )
-    os-version dwPlatformId>> ;
+    os-version-struct dwPlatformId>> ;
 
 : windows-service-pack ( -- string )
-    os-version szCSDVersion>> alien>native-string ;
+    os-version-struct szCSDVersion>> alien>native-string ;
 
 : feature-present? ( n -- ? )
     IsProcessorFeaturePresent zero? not ;