From 6367c8ec85e1ad2417fa60530371ea3c7557bc45 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 21 Feb 2010 17:40:19 +1300 Subject: [PATCH] native-thread-test: clean up --- core/alien/strings/strings.factor | 17 ++++++----- .../native-thread-test.factor | 28 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 15e0370ba0..0ad4f6c85a 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -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 ; diff --git a/extra/native-thread-test/native-thread-test.factor b/extra/native-thread-test/native-thread-test.factor index 508e590d01..4d0df1f454 100644 --- a/extra/native-thread-test/native-thread-test.factor +++ b/extra/native-thread-test/native-thread-test.factor @@ -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-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 ; +: start-test-thread-in-os-thread ( -- ) + { "-run=native-thread-test" } start-vm-in-os-thread drop ; -MAIN: testthread +: test-thread ( -- ) + "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ; + +MAIN: test-thread