diff options
author | Eduardo Julian | 2019-05-29 00:24:04 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-05-29 00:24:04 -0400 |
commit | 36d22e31ab696b2cf3382d77b0896dcb357dfb8c (patch) | |
tree | b8278f0e700843b52d859ea8478dccc8b7b4c48f /stdlib/source/lux/world/net/udp.lux | |
parent | 8cd61c00de00728759d0362a60dbca8d23e4d8dc (diff) |
More massaging of the stdlib for the sake of the new compiler.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/world/net/udp.lux | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/stdlib/source/lux/world/net/udp.lux b/stdlib/source/lux/world/net/udp.lux index df9244186..44a1354cc 100644 --- a/stdlib/source/lux/world/net/udp.lux +++ b/stdlib/source/lux/world/net/udp.lux @@ -45,52 +45,51 @@ [write //.can-write] [close //.can-close]))))) -(with-expansions [<for-jvm> (as-is (import: java/lang/AutoCloseable - (close [] #io #try void)) +(with-expansions [<for-jvm> (as-is (import: #long java/lang/String) - (import: java/io/Flushable - (flush [] #io #try void)) + (import: #long java/lang/AutoCloseable + (close [] #io #try void)) - (import: java/net/InetAddress - (#static getAllByName [String] #io #try [InetAddress]) - (getHostAddress [] String)) + (import: #long java/net/InetAddress + (#static getAllByName [java/lang/String] #io #try [java/net/InetAddress]) + (getHostAddress [] java/lang/String)) - (import: java/net/DatagramPacket - (new #as new|send [[byte] int int InetAddress int]) + (import: #long java/net/DatagramPacket + (new #as new|send [[byte] int int java/net/InetAddress int]) (new #as new|receive [[byte] int int]) - (getAddress [] InetAddress) + (getAddress [] java/net/InetAddress) (getPort [] int) (getLength [] int)) - (import: java/net/DatagramSocket + (import: #long java/net/DatagramSocket (new #as new|client [] #io #try) (new #as new|server [int] #io #try) - (receive [DatagramPacket] #io #try void) - (send [DatagramPacket] #io #try void)) + (receive [java/net/DatagramPacket] #io #try void) + (send [java/net/DatagramPacket] #io #try void)) (def: (resolve address) - (-> //.Address (IO (Error InetAddress))) + (-> //.Address (IO (Error java/net/InetAddress))) (do (error.with io.monad) - [addresses (InetAddress::getAllByName address)] - (: (IO (Error InetAddress)) + [addresses (java/net/InetAddress::getAllByName address)] + (: (IO (Error java/net/InetAddress)) (case (array.size addresses) 0 (io.io (ex.throw cannot-resolve-address address)) 1 (wrap (maybe.assume (array.read 0 addresses))) _ (io.io (ex.throw multiple-candidate-addresses address)))))) (def: (udp socket) - (-> DatagramSocket (UDP IO)) + (-> java/net/DatagramSocket (UDP IO)) (structure (def: read (//.can-read (function (read size) (let [data (binary.create size) - packet (DatagramPacket::new|receive data +0 (.int size))] + packet (java/net/DatagramPacket::new|receive data +0 (.int size))] (do (error.with io.monad) - [_ (DatagramSocket::receive packet socket) - #let [bytes-read (.nat (DatagramPacket::getLength packet))]] + [_ (java/net/DatagramSocket::receive packet socket) + #let [bytes-read (.nat (java/net/DatagramPacket::getLength packet))]] (wrap [bytes-read - {#//.address (|> packet DatagramPacket::getAddress InetAddress::getHostAddress) - #//.port (.nat (DatagramPacket::getPort packet))} + {#//.address (|> packet java/net/DatagramPacket::getAddress java/net/InetAddress::getHostAddress) + #//.port (.nat (java/net/DatagramPacket::getPort packet))} data])))))) (def: write @@ -98,23 +97,23 @@ (function (write [location data]) (do (error.with io.monad) [address (resolve (get@ #//.address location))] - (DatagramSocket::send (DatagramPacket::new|send data +0 (.int (binary.size data)) address (.int (get@ #//.port location))) - socket))))) + (java/net/DatagramSocket::send (java/net/DatagramPacket::new|send data +0 (.int (binary.size data)) address (.int (get@ #//.port location))) + socket))))) (def: close (//.can-close (function (close _) - (AutoCloseable::close socket)))))) + (java/lang/AutoCloseable::close socket)))))) (def: #export client (IO (Error (UDP IO))) - (|> (DatagramSocket::new|client) + (|> (java/net/DatagramSocket::new|client) (:: (error.with io.monad) map ..udp))) (def: #export server (-> //.Port (IO (Error (UDP IO)))) (|>> .int - DatagramSocket::new|server + java/net/DatagramSocket::new|server (:: (error.with io.monad) map ..udp))) )] (`` (for {(~~ (static @.old)) |