]> gitweb.factorcode.org Git - factor.git/commitdiff
native-thread-test: clean up
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 21 Feb 2010 04:40:19 +0000 (17:40 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 21 Feb 2010 04:48:05 +0000 (17:48 +1300)
core/alien/strings/strings.factor
extra/native-thread-test/native-thread-test.factor

index 15e0370ba081daa8f2ed53b25bf5da83e81920fb..0ad4f6c85ad3db2498190977cc8a6699150adfb8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays sequences kernel kernel.private accessors math
 alien.accessors byte-arrays io io.encodings io.encodings.utf8
@@ -37,17 +37,16 @@ M: string string>alien
 
 M: tuple string>alien drop underlying>> ;
 
-HOOK: alien>native-string os ( alien -- string )
+HOOK: native-string-encoding os ( -- encoding ) foldable
 
-M: windows alien>native-string utf16n alien>string ;
+M: unix native-string-encoding utf8 ;
+M: windows native-string-encoding utf16n ;
 
-M: unix alien>native-string utf8 alien>string ;
+: alien>native-string ( alien -- string )
+    native-string-encoding alien>string ; inline
 
-HOOK: native-string>alien os ( string -- alien )
-
-M: windows native-string>alien utf16n string>alien ;
-
-M: unix native-string>alien utf8 string>alien ;
+: native-string>alien ( string -- alien )
+    native-string-encoding string>alien ; inline
 
 : dll-path ( dll -- string )
     path>> alien>native-string ;
index 508e590d010275c6ab531a30ac51e07aa1da134b..4d0df1f454e3fad053d8e277d0eac1349c743b79 100644 (file)
@@ -1,26 +1,24 @@
-USING: alien.c-types alien.syntax io io.encodings.utf16n
-io.encodings.utf8 io.files kernel namespaces sequences system threads
+! Copyright (C) 2009 Phil Dawes.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.strings alien.syntax io
+io.encodings.utf8 io.files kernel sequences system threads
 unix.utilities ;
 IN: native-thread-test
 
 FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, char** argv ) ;
 
-HOOK: native-string-encoding os ( -- encoding )
-M: windows native-string-encoding utf16n ;
-M: unix native-string-encoding utf8 ;
-
 : start-vm-in-os-thread ( args -- threadhandle )
-    \ vm get-global prefix 
+    vm prefix
     [ length ] [ native-string-encoding strings>alien ] bi 
-     start_standalone_factor_in_new_thread ;
+    start_standalone_factor_in_new_thread ;
 
 : start-tetris-in-os-thread ( -- )
-     { "-run=tetris" } start-vm-in-os-thread drop ;
+    { "-run=tetris" } start-vm-in-os-thread drop ;
+
+: start-test-thread-in-os-thread ( -- )
+    { "-run=native-thread-test" } start-vm-in-os-thread drop ;
 
-: start-testthread-in-os-thread ( -- )
-     { "-run=native-thread-test" } start-vm-in-os-thread drop ;
-: testthread ( -- )
-     "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ;
+: test-thread ( -- )
+    "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ;
 
-MAIN: testthread
+MAIN: test-thread