diff options
author | Eduardo Julian | 2021-05-24 19:29:13 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-05-24 19:29:13 -0400 |
commit | da27db478b368724ee4659eb674dcdbeb2cd8747 (patch) | |
tree | c1c5ef50644fa78ea899ac8c0afa1e234cd03b26 /stdlib/source/lux | |
parent | 1ffd2dd7e37d3be90522dfe768226334f60577f5 (diff) |
Re-named lux/host to lux/ffi.
Diffstat (limited to '')
35 files changed, 292 insertions, 335 deletions
diff --git a/stdlib/source/lux/control/concurrency/atom.lux b/stdlib/source/lux/control/concurrency/atom.lux index f8a95a41a..e3b711785 100644 --- a/stdlib/source/lux/control/concurrency/atom.lux +++ b/stdlib/source/lux/control/concurrency/atom.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] ["@" target] [abstract [monad (#+ do)]] @@ -14,7 +14,7 @@ [type abstract]]) -(with_expansions [<jvm> (as_is (host.import: (java/util/concurrent/atomic/AtomicReference a) +(with_expansions [<jvm> (as_is (ffi.import: (java/util/concurrent/atomic/AtomicReference a) ["#::." (new [a]) (get [] a) diff --git a/stdlib/source/lux/control/concurrency/thread.lux b/stdlib/source/lux/control/concurrency/thread.lux index d07edd0d8..4afa4dde3 100644 --- a/stdlib/source/lux/control/concurrency/thread.lux +++ b/stdlib/source/lux/control/concurrency/thread.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract ["." monad (#+ do)]] [control @@ -17,26 +17,26 @@ [// ["." atom (#+ Atom)]]) -(with_expansions [<jvm> (as_is (host.import: java/lang/Object) +(with_expansions [<jvm> (as_is (ffi.import: java/lang/Object) - (host.import: java/lang/Runtime + (ffi.import: java/lang/Runtime ["#::." (#static getRuntime [] java/lang/Runtime) (availableProcessors [] int)]) - (host.import: java/lang/Runnable) + (ffi.import: java/lang/Runnable) - (host.import: java/util/concurrent/TimeUnit + (ffi.import: java/util/concurrent/TimeUnit ["#::." (#enum MILLISECONDS)]) - (host.import: java/util/concurrent/Executor + (ffi.import: java/util/concurrent/Executor ["#::." (execute [java/lang/Runnable] #io void)]) - (host.import: (java/util/concurrent/ScheduledFuture a)) + (ffi.import: (java/util/concurrent/ScheduledFuture a)) - (host.import: java/util/concurrent/ScheduledThreadPoolExecutor + (ffi.import: java/util/concurrent/ScheduledThreadPoolExecutor ["#::." (new [int]) (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))]))] @@ -44,11 +44,11 @@ @.jvm (as_is <jvm>) @.js - (as_is (host.import: (setTimeout [host.Function host.Number] #io Any))) + (as_is (ffi.import: (setTimeout [ffi.Function ffi.Number] #io Any))) @.python - (host.import: threading/Timer - (new [host.Float host.Function]) + (ffi.import: threading/Timer + (new [ffi.Float ffi.Function]) (start [] #io #? Any))} ## Default @@ -84,7 +84,7 @@ (def: #export (schedule milli_seconds action) (-> Nat (IO Any) (IO Any)) (for {@.old - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -94,7 +94,7 @@ runner))) @.jvm - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -104,12 +104,12 @@ runner))) @.js - (..setTimeout [(host.closure [] (io.run action)) + (..setTimeout [(ffi.closure [] (io.run action)) (n.frac milli_seconds)]) @.python (do io.monad - [_ (|> (host.lambda [] (io.run action)) + [_ (|> (ffi.lambda [] (io.run action)) [(|> milli_seconds n.frac (f./ +1,000.0))] threading/Timer::new (threading/Timer::start []))] diff --git a/stdlib/source/lux/data/binary.lux b/stdlib/source/lux/data/binary.lux index 40a7b3fc7..ce8deb1d2 100644 --- a/stdlib/source/lux/data/binary.lux +++ b/stdlib/source/lux/data/binary.lux @@ -1,7 +1,7 @@ (.module: [lux (#- i64) ["@" target] - ["." host] + ["." ffi] [abstract [monad (#+ do)] [equivalence (#+ Equivalence)] @@ -37,15 +37,15 @@ [inverted_slice] ) -(with_expansions [<jvm> (as_is (type: #export Binary (host.type [byte])) +(with_expansions [<jvm> (as_is (type: #export Binary (ffi.type [byte])) - (host.import: java/lang/Object) + (ffi.import: java/lang/Object) - (host.import: java/lang/System + (ffi.import: java/lang/System ["#::." (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)]) - (host.import: java/util/Arrays + (ffi.import: java/util/Arrays ["#::." (#static copyOfRange [[byte] int int] [byte]) (#static equals [[byte] [byte]] boolean)]) @@ -56,25 +56,25 @@ (def: i64 (-> (primitive "java.lang.Byte") I64) - (|>> host.byte_to_long (:coerce I64) (i64.and ..byte_mask))) + (|>> ffi.byte_to_long (:coerce I64) (i64.and ..byte_mask))) (def: byte (-> (I64 Any) (primitive "java.lang.Byte")) (for {@.old - (|>> .int host.long_to_byte) + (|>> .int ffi.long_to_byte) @.jvm - (|>> .int (:coerce (primitive "java.lang.Long")) host.long_to_byte)})))] + (|>> .int (:coerce (primitive "java.lang.Long")) ffi.long_to_byte)})))] (for {@.old (as_is <jvm>) @.jvm (as_is <jvm>) @.js - (as_is (host.import: ArrayBuffer - (new [host.Number])) + (as_is (ffi.import: ArrayBuffer + (new [ffi.Number])) - (host.import: Uint8Array + (ffi.import: Uint8Array (new [ArrayBuffer]) - (length host.Number)) + (length ffi.Number)) (type: #export Binary Uint8Array)) @@ -87,18 +87,18 @@ (as_is (type: #export Binary (primitive "bytevector")) - (host.import: (make-bytevector [Nat] Binary)) - (host.import: (bytevector-u8-ref [Binary Nat] I64)) - (host.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) - (host.import: (bytevector-length [Binary] Nat)))} + (ffi.import: (make-bytevector [Nat] Binary)) + (ffi.import: (bytevector-u8-ref [Binary Nat] I64)) + (ffi.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) + (ffi.import: (bytevector-length [Binary] Nat)))} ## Default (type: #export Binary (array.Array (I64 Any))))) (template: (!size binary) - (for {@.old (host.array_length binary) - @.jvm (host.array_length binary) + (for {@.old (ffi.array_length binary) + @.jvm (ffi.array_length binary) @.js (|> binary @@ -117,8 +117,8 @@ (array.size binary))) (template: (!read idx binary) - (for {@.old (..i64 (host.array_read idx binary)) - @.jvm (..i64 (host.array_read idx binary)) + (for {@.old (..i64 (ffi.array_read idx binary)) + @.jvm (..i64 (ffi.array_read idx binary)) @.js (|> binary @@ -150,8 +150,8 @@ (:coerce ..Binary))) (template: (!write idx value binary) - (for {@.old (host.array_write idx (..byte value) binary) - @.jvm (host.array_write idx (..byte value) binary) + (for {@.old (ffi.array_write idx (..byte value) binary) + @.jvm (ffi.array_write idx (..byte value) binary) @.js (!!write .Frac n.frac "js array write" idx value binary) @.python (!!write (I64 Any) (:coerce (I64 Any)) "python array write" idx value binary) @@ -167,14 +167,14 @@ (def: #export create (-> Nat Binary) - (for {@.old (|>> (host.array byte)) - @.jvm (|>> (host.array byte)) + (for {@.old (|>> (ffi.array byte)) + @.jvm (|>> (ffi.array byte)) @.js (|>> n.frac ArrayBuffer::new Uint8Array::new) @.python - (|>> ("python apply" (:coerce host.Function ("python constant" "bytearray"))) + (|>> ("python apply" (:coerce ffi.Function ("python constant" "bytearray"))) (:coerce Binary)) @.scheme @@ -283,17 +283,17 @@ (def: (= reference sample) (with_expansions [<jvm> (java/util/Arrays::equals reference sample)] - (for {@.old <jvm> - @.jvm <jvm>} - (let [limit (!size reference)] - (and (n.= limit - (!size sample)) - (loop [idx 0] - (if (n.< limit idx) - (and (n.= (!read idx reference) - (!read idx sample)) - (recur (inc idx))) - true)))))))) + (for {@.old <jvm> + @.jvm <jvm>} + (let [limit (!size reference)] + (and (n.= limit + (!size sample)) + (loop [idx 0] + (if (n.< limit idx) + (and (n.= (!read idx reference) + (!read idx sample)) + (recur (inc idx))) + true)))))))) (for {@.old (as_is) @.jvm (as_is)} diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux index fe648023d..fb90ab15e 100644 --- a/stdlib/source/lux/data/text/buffer.lux +++ b/stdlib/source/lux/data/text/buffer.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] ["@" target] [control ["." function]] diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux index a081233c9..7445d5ebc 100644 --- a/stdlib/source/lux/data/text/encoding.lux +++ b/stdlib/source/lux/data/text/encoding.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract [codec (#+ Codec)]] [control @@ -169,7 +169,7 @@ (|>> :representation)) ) -(with_expansions [<jvm> (as_is (host.import: java/lang/String +(with_expansions [<jvm> (as_is (ffi.import: java/lang/String ["#::." (new [[byte] java/lang/String]) (getBytes [java/lang/String] [byte])]))] @@ -177,42 +177,42 @@ @.jvm (as_is <jvm>) @.js - (as_is (host.import: Uint8Array) + (as_is (ffi.import: Uint8Array) ## On Node - (host.import: Buffer - (#static from #as from|encode [host.String host.String] Buffer) + (ffi.import: Buffer + (#static from #as from|encode [ffi.String ffi.String] Buffer) (#static from #as from|decode [Uint8Array] Buffer) - (toString [host.String] host.String)) + (toString [ffi.String] ffi.String)) ## On the browser - (host.import: TextEncoder - (new [host.String]) - (encode [host.String] Uint8Array)) + (ffi.import: TextEncoder + (new [ffi.String]) + (encode [ffi.String] Uint8Array)) - (host.import: TextDecoder - (new [host.String]) - (decode [Uint8Array] host.String))) + (ffi.import: TextDecoder + (new [ffi.String]) + (decode [Uint8Array] ffi.String))) @.ruby - (as_is (host.import: String #as RubyString + (as_is (ffi.import: String #as RubyString (encode [Text] RubyString) (force_encoding [Text] Text) (bytes [] Binary)) - (host.import: Array #as RubyArray + (ffi.import: Array #as RubyArray (pack [Text] RubyString))) @.php - (as_is (host.import: Almost_Binary) - (host.import: (unpack [host.String host.String] Almost_Binary)) - (host.import: (array_values [Almost_Binary] Binary)) + (as_is (ffi.import: Almost_Binary) + (ffi.import: (unpack [ffi.String ffi.String] Almost_Binary)) + (ffi.import: (array_values [Almost_Binary] Binary)) (def: php_byte_array_format "C*")) @.scheme ## https://srfi.schemers.org/srfi-140/srfi-140.html - (as_is (host.import: (string->utf8 [Text] Binary)) - (host.import: (utf8->string [Binary] Text)))} + (as_is (ffi.import: (string->utf8 [Text] Binary)) + (ffi.import: (utf8->string [Binary] Text)))} (as_is))) (def: (utf8\encode value) @@ -229,10 +229,10 @@ (java/lang/String::getBytes (..name ..utf_8) value) @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (:coerce Binary ("js object do" "getBytes" value ["utf8"])) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|encode [value "utf8"]) ## This coercion is valid as per NodeJS's documentation: ## https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays @@ -271,12 +271,12 @@ @.jvm <jvm> @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:coerce Text) #try.Success) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|decode [value]) (Buffer::toString ["utf8"]) #try.Success) @@ -287,7 +287,7 @@ #try.Success)) @.python - (host.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) + (ffi.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) @.lua (#try.Success ("lua utf8 decode" value)) diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux index d5bbd3be2..a076942bc 100644 --- a/stdlib/source/lux/debug.lux +++ b/stdlib/source/lux/debug.lux @@ -2,7 +2,7 @@ [lux (#- type) ["@" target] ["." type] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monad (#+ do)]] [control @@ -66,23 +66,23 @@ @.js (as_is (import: JSON - (#static stringify [.Any] host.String)) + (#static stringify [.Any] ffi.String)) (import: Array - (#static isArray [.Any] host.Boolean))) + (#static isArray [.Any] ffi.Boolean))) @.python (as_is (type: PyType (primitive "python_type")) (import: (type [.Any] PyType)) - (import: (str [.Any] host.String))) + (import: (str [.Any] ffi.String))) @.lua - (as_is (import: (type [.Any] host.String)) - (import: (tostring [.Any] host.String)) + (as_is (import: (type [.Any] ffi.String)) + (import: (tostring [.Any] ffi.String)) (import: math - (#static type [.Any] #? host.String))) + (#static type [.Any] #? ffi.String))) @.ruby (as_is (import: Class) @@ -91,8 +91,8 @@ (type [] Class))) @.php - (as_is (import: (gettype [.Any] host.String)) - (import: (strval [.Any] host.String))) + (as_is (import: (gettype [.Any] ffi.String)) + (import: (strval [.Any] ffi.String))) @.scheme (as_is (import: (boolean? [.Any] Bit)) @@ -120,7 +120,7 @@ Inspector (with_expansions [<jvm> (let [object (:coerce java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] - [(case (host.check <class> object) + [(case (ffi.check <class> object) (#.Some value) (`` (|> value (~~ (template.splice <processing>)))) #.None)] @@ -130,12 +130,12 @@ [java/lang/Long [(:coerce .Int) %.int]] [java/lang/Number [java/lang/Number::doubleValue %.frac]] )) - (case (host.check [java/lang/Object] object) + (case (ffi.check [java/lang/Object] object) (#.Some value) (let [value (:coerce (array.Array java/lang/Object) value)] (case (array.read 0 value) (^multi (#.Some tag) - [(host.check java/lang/Integer tag) + [(ffi.check java/lang/Integer tag) (#.Some tag)] [[(array.read 1 value) (array.read 2 value)] @@ -157,7 +157,7 @@ @.jvm <jvm> @.js - (case (host.type_of value) + (case (ffi.type_of value) (^template [<type_of> <then>] [<type_of> (`` (|> value (~~ (template.splice <then>))))]) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/ffi.js.lux index 8bfe8cc94..8bfe8cc94 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/ffi.js.lux diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/ffi.jvm.lux index ad087f95b..ad087f95b 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/ffi.jvm.lux diff --git a/stdlib/source/lux/host.lua.lux b/stdlib/source/lux/ffi.lua.lux index 785ca82d6..785ca82d6 100644 --- a/stdlib/source/lux/host.lua.lux +++ b/stdlib/source/lux/ffi.lua.lux diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/ffi.old.lux index 3a69f2464..3a69f2464 100644 --- a/stdlib/source/lux/host.old.lux +++ b/stdlib/source/lux/ffi.old.lux diff --git a/stdlib/source/lux/host.php.lux b/stdlib/source/lux/ffi.php.lux index ac0daf9c5..ac0daf9c5 100644 --- a/stdlib/source/lux/host.php.lux +++ b/stdlib/source/lux/ffi.php.lux diff --git a/stdlib/source/lux/host.py.lux b/stdlib/source/lux/ffi.py.lux index ed67b3705..ed67b3705 100644 --- a/stdlib/source/lux/host.py.lux +++ b/stdlib/source/lux/ffi.py.lux diff --git a/stdlib/source/lux/host.rb.lux b/stdlib/source/lux/ffi.rb.lux index 63f14e8a3..63f14e8a3 100644 --- a/stdlib/source/lux/host.rb.lux +++ b/stdlib/source/lux/ffi.rb.lux diff --git a/stdlib/source/lux/host.scm.lux b/stdlib/source/lux/ffi.scm.lux index 1dde8ab69..1dde8ab69 100644 --- a/stdlib/source/lux/host.scm.lux +++ b/stdlib/source/lux/ffi.scm.lux diff --git a/stdlib/source/lux/target/jvm/bytecode.lux b/stdlib/source/lux/target/jvm/bytecode.lux index a319ef2a7..d79ba042a 100644 --- a/stdlib/source/lux/target/jvm/bytecode.lux +++ b/stdlib/source/lux/target/jvm/bytecode.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monoid (#+ Monoid)] ["." monad (#+ Monad do)]] @@ -507,18 +507,18 @@ (def: float_bits (-> java/lang/Float Int) (|>> java/lang/Float::floatToRawIntBits - host.int_to_long + ffi.int_to_long (:coerce Int))) (def: negative_zero_float_bits - (|> -0.0 (:coerce java/lang/Double) host.double_to_float ..float_bits)) + (|> -0.0 (:coerce java/lang/Double) ffi.double_to_float ..float_bits)) (def: #export (float value) (-> java/lang/Float (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) (..arbitrary_float value) - (case (|> value host.float_to_double (:coerce Frac)) + (case (|> value ffi.float_to_double (:coerce Frac)) (^template [<special> <instruction>] [<special> (..bytecode $0 $1 @_ <instruction> [])]) ([+0.0 _.fconst_0] diff --git a/stdlib/source/lux/target/jvm/constant.lux b/stdlib/source/lux/target/jvm/constant.lux index fbfbfebb3..5d44dfbd6 100644 --- a/stdlib/source/lux/target/jvm/constant.lux +++ b/stdlib/source/lux/target/jvm/constant.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["@" target] [abstract [monad (#+ do)] @@ -118,7 +118,7 @@ (~~ (template.splice <writer>)))))] [integer_writer Integer [] [binaryF.bits/32]] - [float_writer Float [java/lang/Float::floatToRawIntBits host.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]] + [float_writer Float [java/lang/Float::floatToRawIntBits ffi.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]] [long_writer Long [] [binaryF.bits/64]] [double_writer Double [java/lang/Double::doubleToRawLongBits] [binaryF.bits/64]] [string_writer String [] [//index.writer]] diff --git a/stdlib/source/lux/target/jvm/constant/pool.lux b/stdlib/source/lux/target/jvm/constant/pool.lux index 95dac3986..8f378ed00 100644 --- a/stdlib/source/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/lux/target/jvm/constant/pool.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] [abstract [equivalence (#+ Equivalence)] [monad (#+ Monad do)]] diff --git a/stdlib/source/lux/target/jvm/loader.lux b/stdlib/source/lux/target/jvm/loader.lux index a6a236e47..755f9526e 100644 --- a/stdlib/source/lux/target/jvm/loader.lux +++ b/stdlib/source/lux/target/jvm/loader.lux @@ -16,7 +16,7 @@ [collection ["." array] ["." dictionary (#+ Dictionary)]]] - ["." host (#+ import: object do_to)]]) + ["." ffi (#+ import: object do_to)]]) (type: #export Library (Atom (Dictionary Text Binary))) @@ -65,17 +65,17 @@ (with_expansions [<elemT> (as_is (java/lang/Class java/lang/Object))] (def: java/lang/ClassLoader::defineClass java/lang/reflect/Method - (let [signature (|> (host.array <elemT> 4) - (host.array_write 0 (:coerce <elemT> - (host.class_for java/lang/String))) - (host.array_write 1 (java/lang/Object::getClass (host.array byte 0))) - (host.array_write 2 (:coerce <elemT> - (java/lang/Integer::TYPE))) - (host.array_write 3 (:coerce <elemT> - (java/lang/Integer::TYPE))))] + (let [signature (|> (ffi.array <elemT> 4) + (ffi.array_write 0 (:coerce <elemT> + (ffi.class_for java/lang/String))) + (ffi.array_write 1 (java/lang/Object::getClass (ffi.array byte 0))) + (ffi.array_write 2 (:coerce <elemT> + (java/lang/Integer::TYPE))) + (ffi.array_write 3 (:coerce <elemT> + (java/lang/Integer::TYPE))))] (do_to (java/lang/Class::getDeclaredMethod "defineClass" signature - (host.class_for java/lang/ClassLoader)) + (ffi.class_for java/lang/ClassLoader)) (java/lang/reflect/AccessibleObject::setAccessible true))))) (def: #export (define class_name bytecode loader) @@ -87,12 +87,12 @@ (:coerce java/lang/Object (|> 0 (:coerce (primitive "java.lang.Long")) - host.long_to_int)) + ffi.long_to_int)) (:coerce java/lang/Object (|> bytecode binary.size (:coerce (primitive "java.lang.Long")) - host.long_to_int))))] + ffi.long_to_int))))] (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass))) (def: #export (new_library _) diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux index bb0a388e9..07afd5df0 100644 --- a/stdlib/source/lux/target/jvm/reflection.lux +++ b/stdlib/source/lux/target/jvm/reflection.lux @@ -1,6 +1,6 @@ (.module: [lux (#- type) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["." type] [abstract ["." monad (#+ do)]] @@ -142,7 +142,7 @@ (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type (Try (/.Type Class))) - (<| (case (host.check java/lang/Class reflection) + (<| (case (ffi.check java/lang/Class reflection) (#.Some class) (let [class_name (|> class (:coerce (java/lang/Class java/lang/Object)) @@ -163,10 +163,10 @@ (exception.throw ..not_a_class reflection) (#try.Success (/.class class_name (list)))))) _) - (case (host.check java/lang/reflect/ParameterizedType reflection) + (case (ffi.check java/lang/reflect/ParameterizedType reflection) (#.Some reflection) (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)] - (case (host.check java/lang/Class raw) + (case (ffi.check java/lang/Class raw) (#.Some raw) (do {! try.monad} [paramsT (|> reflection @@ -186,11 +186,11 @@ (def: #export (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) - (<| (case (host.check java/lang/reflect/TypeVariable reflection) + (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) (#.Some reflection) (#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection))) _) - (case (host.check java/lang/reflect/WildcardType reflection) + (case (ffi.check java/lang/reflect/WildcardType reflection) (#.Some reflection) ## TODO: Instead of having single lower/upper bounds, should ## allow for multiple ones. @@ -198,7 +198,7 @@ (array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))] (^template [<pattern> <kind>] [<pattern> - (case (host.check java/lang/reflect/GenericArrayType bound) + (case (ffi.check java/lang/reflect/GenericArrayType bound) (#.Some _) ## TODO: Array bounds should not be "erased" as they ## are right now. @@ -221,7 +221,7 @@ (def: #export (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) - (<| (case (host.check java/lang/Class reflection) + (<| (case (ffi.check java/lang/Class reflection) (#.Some reflection) (let [class_name (|> reflection (:coerce (java/lang/Class java/lang/Object)) @@ -243,7 +243,7 @@ (<t>.run /parser.value (|> class_name //name.internal //name.read)) (#try.Success (/.class class_name (list))))))) _) - (case (host.check java/lang/reflect/GenericArrayType reflection) + (case (ffi.check java/lang/reflect/GenericArrayType reflection) (#.Some reflection) (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType @@ -256,7 +256,7 @@ (def: #export (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (as_is (..type reflection))] - (case (host.check java/lang/Class reflection) + (case (ffi.check java/lang/Class reflection) (#.Some class) (let [class_name (|> reflection (:coerce (java/lang/Class java/lang/Object)) @@ -358,7 +358,7 @@ (def: #export deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> array.to_list - (list.all (|>> (host.check java/lang/Deprecated))) + (list.all (|>> (ffi.check java/lang/Deprecated))) list.empty? not)) diff --git a/stdlib/source/lux/target/lua.lux b/stdlib/source/lux/target/lua.lux index 4213cd339..144fc2d7b 100644 --- a/stdlib/source/lux/target/lua.lux +++ b/stdlib/source/lux/target/lua.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code int if cond function or and not let ^) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -27,21 +26,11 @@ [type abstract]]) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (def: input_separator ", ") diff --git a/stdlib/source/lux/target/php.lux b/stdlib/source/lux/target/php.lux index 9ef2511a7..5b976a325 100644 --- a/stdlib/source/lux/target/php.lux +++ b/stdlib/source/lux/target/php.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code Global static int if cond or and not comment for) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -29,21 +28,11 @@ (def: input_separator ", ") (def: statement_suffix ";") -(.for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (.for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (def: block (-> Text Text) diff --git a/stdlib/source/lux/target/python.lux b/stdlib/source/lux/target/python.lux index 1ae1cca64..77cc7cf28 100644 --- a/stdlib/source/lux/target/python.lux +++ b/stdlib/source/lux/target/python.lux @@ -1,7 +1,7 @@ (.module: [lux (#- Location Code not or and list if cond int comment exec) ["@" target] - ["." host] + ["." ffi] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -30,8 +30,8 @@ (-> Text Text) (text.enclose ["(" ")"])) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String +(for {@.old (as_is (ffi.import: java/lang/CharSequence) + (ffi.import: java/lang/String ["#::." (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} (as_is)) diff --git a/stdlib/source/lux/target/ruby.lux b/stdlib/source/lux/target/ruby.lux index 641cc8d2e..21a47c8d0 100644 --- a/stdlib/source/lux/target/ruby.lux +++ b/stdlib/source/lux/target/ruby.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Location Code static int if cond function or and not comment) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -29,21 +28,11 @@ (def: input_separator ", ") (def: statement_suffix ";") -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (format text.new_line) - (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (|>> (format text.new_line) + (text.replace_all text.new_line nested_new_line)))) (abstract: #export (Code brand) Text diff --git a/stdlib/source/lux/target/scheme.lux b/stdlib/source/lux/target/scheme.lux index 20bb08be3..408f1d9f1 100644 --- a/stdlib/source/lux/target/scheme.lux +++ b/stdlib/source/lux/target/scheme.lux @@ -1,7 +1,6 @@ (.module: [lux (#- Code int or and if cond let) ["@" target] - ["." host] [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)]] @@ -21,19 +20,10 @@ [type abstract]]) -(for {@.old (as_is (host.import: java/lang/CharSequence) - (host.import: java/lang/String - ["#::." - (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))} - (as_is)) - (def: nest (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (for {@.old (|>> (:coerce java/lang/String) - (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line) - (:coerce java/lang/CharSequence nested_new_line)))} - (text.replace_all text.new_line nested_new_line)))) + (text.replace_all text.new_line nested_new_line))) (abstract: #export (Code k) Text diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 1b29ee2e1..4203516d4 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type Module primitive type char int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["." meta] [abstract ["." monad (#+ do)]] @@ -159,7 +159,7 @@ (list& class super_class super_interfaces))) ## TODO: Get rid of this template block and use the definition in -## lux/host.jvm.lux ASAP +## lux/ffi.jvm.lux ASAP (template [<name> <class>] [(def: #export <name> .Type (#.Primitive <class> #.Nil))] @@ -873,7 +873,7 @@ #.None (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers from_class)) - (#.Cons (:coerce java/lang/reflect/Type (host.class_for java/lang/Object)) + (#.Cons (:coerce java/lang/reflect/Type (ffi.class_for java/lang/Object)) (array.to_list (java/lang/Class::getGenericInterfaces from_class))) (array.to_list (java/lang/Class::getGenericInterfaces from_class))))))) diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 96c39d8cb..12954ff51 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Definition) - ["." host (#+ import: do-to object)] + ["." ffi (#+ import: do-to object)] [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 3b12fe741..b6fb709fb 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -1,6 +1,6 @@ (.module: [lux (#- i64) - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monad (#+ do)]] [target diff --git a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux index d92d1e686..15552a656 100644 --- a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux @@ -1,7 +1,7 @@ (.module: [lux (#- Module Definition) [type (#+ :share)] - ["." host (#+ import: do_to)] + ["." ffi (#+ import: do_to)] [abstract ["." monad (#+ Monad do)]] [control @@ -106,8 +106,8 @@ (-> Context java/util/jar/Manifest) (let [manifest (java/util/jar/Manifest::new)] (exec (do_to (java/util/jar/Manifest::getMainAttributes manifest) - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external)) - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version)) + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external)) + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version)) manifest))) ## TODO: Delete ASAP @@ -124,10 +124,10 @@ content (!.use (\ artifact content) []) #let [class_path (format (runtime.class_name context) (get@ #static.artifact_extension static))]] (wrap (do_to sink - (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path)) - (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content))) - (java/io/Flushable::flush) - (java/util/zip/ZipOutputStream::closeEntry))))) + (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path)) + (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content))) + (java/io/Flushable::flush) + (java/util/zip/ZipOutputStream::closeEntry))))) (def: (write_module monad file_system static [module artifacts] sink) (All [!] @@ -164,6 +164,6 @@ sink (java/util/jar/JarOutputStream::new buffer (..manifest program))] sink (monad.fold ! (..write_module monad file_system static) sink order) #let [_ (do_to sink - (java/io/Flushable::flush) - (java/io/Closeable::close))]] + (java/io/Flushable::flush) + (java/io/Closeable::close))]] (wrap (java/io/ByteArrayOutputStream::toByteArray buffer)))) diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux index e5b17b7d6..9cf12bc5c 100644 --- a/stdlib/source/lux/world/console.lux +++ b/stdlib/source/lux/world/console.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] ["@" target] [abstract [monad (#+ do)]] diff --git a/stdlib/source/lux/world/db/jdbc/input.lux b/stdlib/source/lux/world/db/jdbc/input.lux index 625af00ba..f1183ab75 100644 --- a/stdlib/source/lux/world/db/jdbc/input.lux +++ b/stdlib/source/lux/world/db/jdbc/input.lux @@ -1,5 +1,6 @@ (.module: [lux (#- and int) + [ffi (#+ import:)] [control [functor (#+ Contravariant)] [monad (#+ Monad do)] @@ -8,8 +9,7 @@ ["." instant (#+ Instant)]] ["." io (#+ IO)] [world - [binary (#+ Binary)]] - [host (#+ import:)]]) + [binary (#+ Binary)]]]) (import: java/lang/String) diff --git a/stdlib/source/lux/world/db/jdbc/output.lux b/stdlib/source/lux/world/db/jdbc/output.lux index 08a74a4b0..66578ac8d 100644 --- a/stdlib/source/lux/world/db/jdbc/output.lux +++ b/stdlib/source/lux/world/db/jdbc/output.lux @@ -1,5 +1,6 @@ (.module: [lux (#- and int) + [ffi (#+ import:)] [control [functor (#+ Functor)] [apply (#+ Apply)] @@ -10,8 +11,7 @@ ["." instant (#+ Instant)]] ["." io (#+ IO)] [world - [binary (#+ Binary)]] - [host (#+ import:)]]) + [binary (#+ Binary)]]]) (import: java/lang/String) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 3b80a7ea8..48a024400 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] ["@" target] [abstract ["." monad (#+ Monad do)]] @@ -231,9 +231,9 @@ ["Instant" (%.instant instant)] ["Path" file])) - (host.import: java/lang/String) + (ffi.import: java/lang/String) - (`` (host.import: java/io/File + (`` (ffi.import: java/io/File ["#::." (new [java/lang/String]) (~~ (template [<name>] @@ -263,24 +263,24 @@ _ (wrap (exception.throw exception [path]))))) - (host.import: java/lang/AutoCloseable + (ffi.import: java/lang/AutoCloseable ["#::." (close [] #io #try void)]) - (host.import: java/io/OutputStream + (ffi.import: java/io/OutputStream ["#::." (write [[byte]] #io #try void) (flush [] #io #try void)]) - (host.import: java/io/FileOutputStream + (ffi.import: java/io/FileOutputStream ["#::." (new [java/io/File boolean] #io #try)]) - (host.import: java/io/InputStream + (ffi.import: java/io/InputStream ["#::." (read [[byte]] #io #try int)]) - (host.import: java/io/FileInputStream + (ffi.import: java/io/FileInputStream ["#::." (new [java/io/File] #io #try)]) @@ -444,45 +444,45 @@ @.jvm (as_is <for_jvm>) @.js - (as_is (host.import: Buffer + (as_is (ffi.import: Buffer (#static from [Binary] ..Buffer)) - (host.import: FileDescriptor) - - (host.import: Stats - (size host.Number) - (mtimeMs host.Number) - (isFile [] #io #try host.Boolean) - (isDirectory [] #io #try host.Boolean)) - - (host.import: FsConstants - (F_OK host.Number) - (R_OK host.Number) - (W_OK host.Number) - (X_OK host.Number)) + (ffi.import: FileDescriptor) + + (ffi.import: Stats + (size ffi.Number) + (mtimeMs ffi.Number) + (isFile [] #io #try ffi.Boolean) + (isDirectory [] #io #try ffi.Boolean)) + + (ffi.import: FsConstants + (F_OK ffi.Number) + (R_OK ffi.Number) + (W_OK ffi.Number) + (X_OK ffi.Number)) - (host.import: Fs + (ffi.import: Fs (constants FsConstants) - (readFileSync [host.String] #io #try Binary) - (appendFileSync [host.String Buffer] #io #try Any) - (writeFileSync [host.String Buffer] #io #try Any) - (statSync [host.String] #io #try Stats) - (accessSync [host.String host.Number] #io #try Any) - (renameSync [host.String host.String] #io #try Any) - (utimesSync [host.String host.Number host.Number] #io #try Any) - (unlink [host.String] #io #try Any) - (readdirSync [host.String] #io #try (Array host.String)) - (mkdirSync [host.String] #io #try Any) - (rmdirSync [host.String] #io #try Any)) - - (host.import: JsPath - (sep host.String) - (basename [host.String] host.String)) + (readFileSync [ffi.String] #io #try Binary) + (appendFileSync [ffi.String Buffer] #io #try Any) + (writeFileSync [ffi.String Buffer] #io #try Any) + (statSync [ffi.String] #io #try Stats) + (accessSync [ffi.String ffi.Number] #io #try Any) + (renameSync [ffi.String ffi.String] #io #try Any) + (utimesSync [ffi.String ffi.Number ffi.Number] #io #try Any) + (unlink [ffi.String] #io #try Any) + (readdirSync [ffi.String] #io #try (Array ffi.String)) + (mkdirSync [ffi.String] #io #try Any) + (rmdirSync [ffi.String] #io #try Any)) + + (ffi.import: JsPath + (sep ffi.String) + (basename [ffi.String] ffi.String)) (template [<name> <path>] [(def: (<name> _) - (-> [] (Maybe (-> host.String Any))) - (host.constant (-> host.String Any) <path>))] + (-> [] (Maybe (-> ffi.String Any))) + (ffi.constant (-> ffi.String Any) <path>))] [normal_require [require]] [global_require [global require]] @@ -490,7 +490,7 @@ ) (def: (require _) - (-> [] (-> host.String Any)) + (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] (^or [(#.Some require) _ _] [_ (#.Some require) _] @@ -675,7 +675,7 @@ )) (def: separator - (if host.on_node_js? + (if ffi.on_node_js? (JsPath::sep (..node_path [])) "/")) )) @@ -685,35 +685,35 @@ (as_is (type: (Tuple/2 left right) (primitive "python_tuple[2]" [left right])) - (host.import: PyFile + (ffi.import: PyFile (read [] #io #try Binary) (write [Binary] #io #try #? Any) (close [] #io #try #? Any)) - (host.import: (open [host.String host.String] #io #try PyFile)) - (host.import: (tuple [[host.Integer host.Integer]] (Tuple/2 host.Integer host.Integer))) - - (host.import: os - (#static F_OK host.Integer) - (#static R_OK host.Integer) - (#static W_OK host.Integer) - (#static X_OK host.Integer) - - (#static mkdir [host.String] #io #try #? Any) - (#static access [host.String host.Integer] #io #try host.Boolean) - (#static remove [host.String] #io #try #? Any) - (#static rmdir [host.String] #io #try #? Any) - (#static rename [host.String host.String] #io #try #? Any) - (#static utime [host.String (Tuple/2 host.Integer host.Integer)] #io #try #? Any) - (#static listdir [host.String] #io #try (Array host.String))) - - (host.import: os/path - (#static isfile [host.String] #io #try host.Boolean) - (#static isdir [host.String] #io #try host.Boolean) - (#static sep host.String) - (#static basename [host.String] host.String) - (#static getsize [host.String] #io #try host.Integer) - (#static getmtime [host.String] #io #try host.Float)) + (ffi.import: (open [ffi.String ffi.String] #io #try PyFile)) + (ffi.import: (tuple [[ffi.Integer ffi.Integer]] (Tuple/2 ffi.Integer ffi.Integer))) + + (ffi.import: os + (#static F_OK ffi.Integer) + (#static R_OK ffi.Integer) + (#static W_OK ffi.Integer) + (#static X_OK ffi.Integer) + + (#static mkdir [ffi.String] #io #try #? Any) + (#static access [ffi.String ffi.Integer] #io #try ffi.Boolean) + (#static remove [ffi.String] #io #try #? Any) + (#static rmdir [ffi.String] #io #try #? Any) + (#static rename [ffi.String ffi.String] #io #try #? Any) + (#static utime [ffi.String (Tuple/2 ffi.Integer ffi.Integer)] #io #try #? Any) + (#static listdir [ffi.String] #io #try (Array ffi.String))) + + (ffi.import: os/path + (#static isfile [ffi.String] #io #try ffi.Boolean) + (#static isdir [ffi.String] #io #try ffi.Boolean) + (#static sep ffi.String) + (#static basename [ffi.String] ffi.String) + (#static getsize [ffi.String] #io #try ffi.Integer) + (#static getmtime [ffi.String] #io #try ffi.Float)) (`` (structure: (file path) (-> Path (File IO)) @@ -881,19 +881,19 @@ ) @.lua - (as_is (host.import: LuaFile - (read [host.String] #io host.String) - (write [host.String] #io #? LuaFile) - (flush [] #io host.Boolean) - (close [] #io host.Boolean)) + (as_is (ffi.import: LuaFile + (read [ffi.String] #io ffi.String) + (write [ffi.String] #io #? LuaFile) + (flush [] #io ffi.Boolean) + (close [] #io ffi.Boolean)) - (host.import: (io/open [host.String host.String] #io #? LuaFile)) + (ffi.import: (io/open [ffi.String ffi.String] #io #? LuaFile)) - (host.import: (package/config host.String)) + (ffi.import: (package/config ffi.String)) - (host.import: (os/rename [host.String host.String] #io #? host.Boolean)) - (host.import: (os/remove [host.String] #io #? host.Boolean)) - (host.import: (os/execute [host.String] #io #? host.Boolean)) + (ffi.import: (os/rename [ffi.String ffi.String] #io #? ffi.Boolean)) + (ffi.import: (os/remove [ffi.String] #io #? ffi.Boolean)) + (ffi.import: (os/execute [ffi.String] #io #? ffi.Boolean)) (def: default_separator Text @@ -1142,19 +1142,19 @@ ) @.ruby - (as_is (host.import: Time #as RubyTime + (as_is (ffi.import: Time #as RubyTime (#static at [Frac] RubyTime) (to_f [] Frac)) - (host.import: Stat #as RubyStat + (ffi.import: Stat #as RubyStat (executable? [] Bit) (size Int) (mtime [] RubyTime)) - (host.import: File #as RubyFile - (#static SEPARATOR host.String) - (#static open [Path host.String] #io #try RubyFile) + (ffi.import: File #as RubyFile + (#static SEPARATOR ffi.String) + (#static open [Path ffi.String] #io #try RubyFile) (#static stat [Path] #io #try RubyStat) (#static delete [Path] #io #try Int) (#static file? [Path] #io #try Bit) @@ -1166,13 +1166,13 @@ (flush [] #io #try #? Any) (close [] #io #try #? Any)) - (host.import: Dir #as RubyDir + (ffi.import: Dir #as RubyDir (#static open [Path] #io #try RubyDir) (children [] #io #try (Array Path)) (close [] #io #try #? Any)) - (host.import: "fileutils" FileUtils #as RubyFileUtils + (ffi.import: "fileutils" FileUtils #as RubyFileUtils (#static touch [Path] #io #try #? Any) (#static move [Path Path] #io #try #? Any) (#static rmdir [Path] #io #try #? Any) @@ -1353,34 +1353,34 @@ ) @.php - (as_is (host.import: (FILE_APPEND Int)) + (as_is (ffi.import: (FILE_APPEND Int)) ## https://www.php.net/manual/en/dir.constants.php - (host.import: (DIRECTORY_SEPARATOR host.String)) + (ffi.import: (DIRECTORY_SEPARATOR ffi.String)) ## https://www.php.net/manual/en/function.pack.php ## https://www.php.net/manual/en/function.unpack.php - (host.import: (unpack [host.String host.String] Binary)) + (ffi.import: (unpack [ffi.String ffi.String] Binary)) ## https://www.php.net/manual/en/ref.filesystem.php ## https://www.php.net/manual/en/function.file-get-contents.php - (host.import: (file_get_contents [Path] #io #try host.String)) + (ffi.import: (file_get_contents [Path] #io #try ffi.String)) ## https://www.php.net/manual/en/function.file-put-contents.php - (host.import: (file_put_contents [Path host.String Int] #io #try host.Integer)) - (host.import: (filemtime [Path] #io #try host.Integer)) - (host.import: (filesize [Path] #io #try host.Integer)) - (host.import: (is_executable [Path] #io #try host.Boolean)) - (host.import: (touch [Path host.Integer] #io #try host.Boolean)) - (host.import: (rename [Path Path] #io #try host.Boolean)) - (host.import: (unlink [Path] #io #try host.Boolean)) + (ffi.import: (file_put_contents [Path ffi.String Int] #io #try ffi.Integer)) + (ffi.import: (filemtime [Path] #io #try ffi.Integer)) + (ffi.import: (filesize [Path] #io #try ffi.Integer)) + (ffi.import: (is_executable [Path] #io #try ffi.Boolean)) + (ffi.import: (touch [Path ffi.Integer] #io #try ffi.Boolean)) + (ffi.import: (rename [Path Path] #io #try ffi.Boolean)) + (ffi.import: (unlink [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.rmdir.php - (host.import: (rmdir [Path] #io #try host.Boolean)) + (ffi.import: (rmdir [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.scandir.php - (host.import: (scandir [Path] #io #try (Array Path))) + (ffi.import: (scandir [Path] #io #try (Array Path))) ## https://www.php.net/manual/en/function.is-file.php - (host.import: (is_file [Path] #io #try host.Boolean)) + (ffi.import: (is_file [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.is-dir.php - (host.import: (is_dir [Path] #io #try host.Boolean)) + (ffi.import: (is_dir [Path] #io #try ffi.Boolean)) ## https://www.php.net/manual/en/function.mkdir.php - (host.import: (mkdir [Path] #io #try host.Boolean)) + (ffi.import: (mkdir [Path] #io #try ffi.Boolean)) (def: byte_array_format "C*") (def: default_separator (..DIRECTORY_SEPARATOR)) diff --git a/stdlib/source/lux/world/file/watch.lux b/stdlib/source/lux/world/file/watch.lux index b3951068c..4695c1e00 100644 --- a/stdlib/source/lux/world/file/watch.lux +++ b/stdlib/source/lux/world/file/watch.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [predicate (#+ Predicate)] ["." monad (#+ do)]] diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux index 0abdb2225..07d7ad6be 100644 --- a/stdlib/source/lux/world/program.lux +++ b/stdlib/source/lux/world/program.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract ["." monad (#+ do)]] [control @@ -124,12 +124,12 @@ (|>> %.int error! io.io)) (import: NodeJs_Process - (exit [host.Number] #io Nothing) + (exit [ffi.Number] #io Nothing) (cwd [] #io Path)) (def: (exit_node_js! code) (-> Exit (IO Nothing)) - (case (host.constant ..NodeJs_Process [process]) + (case (ffi.constant ..NodeJs_Process [process]) (#.Some process) (NodeJs_Process::exit (i.frac code) process) @@ -144,8 +144,8 @@ (def: (exit_browser! code) (-> Exit (IO Nothing)) - (case [(host.constant ..Browser_Window [window]) - (host.constant ..Browser_Location [location])] + (case [(ffi.constant ..Browser_Window [window]) + (ffi.constant ..Browser_Location [location])] [(#.Some window) (#.Some location)] (exec (Browser_Window::close [] window) @@ -166,29 +166,29 @@ (..default_exit! code))) (import: Object - (#static entries [Object] (Array (Array host.String)))) + (#static entries [Object] (Array (Array ffi.String)))) (import: NodeJs_OS (homedir [] #io Path)) - (import: (require [host.String] Any))) + (import: (require [ffi.String] Any))) @.python (as_is (import: os - (#static getcwd [] #io host.String) - (#static _exit [host.Integer] #io Nothing)) + (#static getcwd [] #io ffi.String) + (#static _exit [ffi.Integer] #io Nothing)) (import: os/path - (#static expanduser [host.String] #io host.String)) + (#static expanduser [ffi.String] #io ffi.String)) (import: os/environ - (#static keys [] #io (Array host.String)) - (#static get [host.String] #io host.String))) - @.lua (as_is (host.import: LuaFile - (read [host.String] #io #? host.String) - (close [] #io host.Boolean)) + (#static keys [] #io (Array ffi.String)) + (#static get [ffi.String] #io ffi.String))) + @.lua (as_is (ffi.import: LuaFile + (read [ffi.String] #io #? ffi.String) + (close [] #io ffi.Boolean)) - (host.import: (io/popen [host.String] #io #try #? LuaFile)) - (host.import: (os/getenv [host.String] #io #? host.String)) - (host.import: (os/exit [host.Integer] #io Nothing)) + (ffi.import: (io/popen [ffi.String] #io #try #? LuaFile)) + (ffi.import: (os/getenv [ffi.String] #io #? ffi.String)) + (ffi.import: (os/exit [ffi.Integer] #io Nothing)) (def: (run_command default command) (-> Text Text (IO Text)) @@ -208,41 +208,41 @@ (#try.Failure _) (wrap default))))) - @.ruby (as_is (host.import: Env #as RubyEnv + @.ruby (as_is (ffi.import: Env #as RubyEnv (#static keys [] (Array Text)) (#static fetch [Text] Text)) - (host.import: "fileutils" FileUtils #as RubyFileUtils + (ffi.import: "fileutils" FileUtils #as RubyFileUtils (#static pwd [] #io Path)) - (host.import: Dir #as RubyDir + (ffi.import: Dir #as RubyDir (#static home [] #io Path)) - (host.import: Kernel #as RubyKernel + (ffi.import: Kernel #as RubyKernel (#static exit [Int] #io Nothing))) @.php - (as_is (host.import: (exit [Int] #io Nothing)) + (as_is (ffi.import: (exit [Int] #io Nothing)) ## https://www.php.net/manual/en/function.exit.php - (host.import: (getcwd [] #io host.String)) + (ffi.import: (getcwd [] #io ffi.String)) ## https://www.php.net/manual/en/function.getcwd.php - (host.import: (getenv #as getenv/1 [host.String] #io host.String)) - (host.import: (getenv #as getenv/0 [] #io (Array host.String))) + (ffi.import: (getenv #as getenv/1 [ffi.String] #io ffi.String)) + (ffi.import: (getenv #as getenv/0 [] #io (Array ffi.String))) ## https://www.php.net/manual/en/function.getenv.php ## https://www.php.net/manual/en/function.array-keys.php - (host.import: (array_keys [(Array host.String)] (Array host.String))) + (ffi.import: (array_keys [(Array ffi.String)] (Array ffi.String))) ) @.scheme - (as_is (host.import: (exit [Int] #io Nothing)) + (as_is (ffi.import: (exit [Int] #io Nothing)) ## https://srfi.schemers.org/srfi-98/srfi-98.html (abstract: Pair Any) (abstract: PList Any) - (host.import: (get-environment-variables [] #io PList)) - (host.import: (car [Pair] Text)) - (host.import: (cdr [Pair] Text)) - (host.import: (car #as head [PList] Pair)) - (host.import: (cdr #as tail [PList] PList)))} + (ffi.import: (get-environment-variables [] #io PList)) + (ffi.import: (car [Pair] Text)) + (ffi.import: (cdr [Pair] Text)) + (ffi.import: (car #as head [PList] Pair)) + (ffi.import: (cdr #as tail [PList] PList)))} (as_is))) (structure: #export default @@ -252,8 +252,8 @@ (with_expansions [<jvm> ..jvm\\environment] (for {@.old <jvm> @.jvm <jvm> - @.js (io.io (if host.on_node_js? - (case (host.constant Object [process env]) + @.js (io.io (if ffi.on_node_js? + (case (ffi.constant Object [process env]) (#.Some process/env) (array\fold (function (_ entry environment) (<| (maybe.default environment) @@ -306,7 +306,7 @@ <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.home")))] (for {@.old <jvm> @.jvm <jvm> - @.js (if host.on_node_js? + @.js (if ffi.on_node_js? (|> (..require "os") (:coerce NodeJs_OS) (NodeJs_OS::homedir [])) @@ -327,8 +327,8 @@ <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.dir")))] (for {@.old <jvm> @.jvm <jvm> - @.js (if host.on_node_js? - (case (host.constant ..NodeJs_Process [process]) + @.js (if ffi.on_node_js? + (case (ffi.constant ..NodeJs_Process [process]) (#.Some process) (NodeJs_Process::cwd [] process) @@ -357,10 +357,10 @@ (wrap (undefined)))] (for {@.old <jvm> @.jvm <jvm> - @.js (cond host.on_node_js? + @.js (cond ffi.on_node_js? (..exit_node_js! code) - host.on_browser? + ffi.on_browser? (..exit_browser! code) ## else diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux index 10c3f4718..482100853 100644 --- a/stdlib/source/lux/world/shell.lux +++ b/stdlib/source/lux/world/shell.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["jvm" host (#+ import:)] + ["jvm" ffi (#+ import:)] [abstract [monad (#+ do)]] [control |