aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/unsafe/lux/data/binary.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/unsafe/lux/data/binary.lux')
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux244
1 files changed, 122 insertions, 122 deletions
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index 1e3ef2118..e7936fd06 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -27,30 +27,30 @@
["[1]::[0]"
("static" copyOfRange [[byte] int int] [byte])
("static" equals [[byte] [byte]] boolean)]))]
- (for [@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)
-
- @.js
- (as_is (ffi.import: ArrayBuffer
- "[1]::[0]")
- (ffi.import: Uint8Array
- "[1]::[0]")
-
- (type: .public Binary
- Uint8Array))
-
- @.python
- (type: .public Binary
- (Primitive "bytearray"))
-
- @.scheme
- (as_is (type: .public Binary
- (Primitive "bytevector"))
-
- (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)))]
+ (for @.old (as_is <jvm>)
+ @.jvm (as_is <jvm>)
+
+ @.js
+ (as_is (ffi.import: ArrayBuffer
+ "[1]::[0]")
+ (ffi.import: Uint8Array
+ "[1]::[0]")
+
+ (type: .public Binary
+ Uint8Array))
+
+ @.python
+ (type: .public Binary
+ (Primitive "bytearray"))
+
+ @.scheme
+ (as_is (type: .public Binary
+ (Primitive "bytevector"))
+
+ (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: .public Binary
@@ -61,27 +61,27 @@
<jvm> (.: ..Binary <jvm>)]
(template: .public (empty size)
[(: ..Binary
- (for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>
-
- (~~ (.static @.js))
- (.|> <size>
- .int
- "lux i64 f64"
- []
- ("js object new" ("js constant" "ArrayBuffer"))
- []
- ("js object new" ("js constant" "Uint8Array"))
- (.:as ..Binary))
-
- (~~ (.static @.python))
- (.|> <size>
- []
- ("python apply" (.:as ffi.Function ("python constant" "bytearray")))
- (.:as ..Binary))
-
- (~~ (.static @.scheme))
- (..make-bytevector <size>)]
+ (for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
+
+ (~~ (.static @.js))
+ (.|> <size>
+ .int
+ "lux i64 f64"
+ []
+ ("js object new" ("js constant" "ArrayBuffer"))
+ []
+ ("js object new" ("js constant" "Uint8Array"))
+ (.:as ..Binary))
+
+ (~~ (.static @.python))
+ (.|> <size>
+ []
+ ("python apply" (.:as ffi.Function ("python constant" "bytearray")))
+ (.:as ..Binary))
+
+ (~~ (.static @.scheme))
+ (..make-bytevector <size>)
... Default
(array.empty <size>)))])))
@@ -90,23 +90,23 @@
<jvm> (ffi.length <it>)]
(template: .public (size it)
[(.: .Nat
- (.for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>
+ (.for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
- (~~ (.static @.js))
- (.|> <it>
- ("js object get" "length")
- (.:as .Frac)
- "lux f64 i64"
- .nat)
+ (~~ (.static @.js))
+ (.|> <it>
+ ("js object get" "length")
+ (.:as .Frac)
+ "lux f64 i64"
+ .nat)
- (~~ (.static @.python))
- (.|> <it>
- (.:as (array.Array (.I64 .Any)))
- "python array length")
+ (~~ (.static @.python))
+ (.|> <it>
+ (.:as (array.Array (.I64 .Any)))
+ "python array length")
- (~~ (.static @.scheme))
- (..bytevector-length [<it>])]
+ (~~ (.static @.scheme))
+ (..bytevector-length [<it>])
... Default
(array.size <it>)))])))
@@ -126,23 +126,23 @@
(template: .public (bytes/1 index it)
[(.<| (.:as .I64)
(.: (.I64 .Any))
- (`` (.for [(~~ (.static @.old)) (~~ <jvm>)
- (~~ (.static @.jvm)) (~~ <jvm>)
+ (`` (.for (~~ (.static @.old)) (~~ <jvm>)
+ (~~ (.static @.jvm)) (~~ <jvm>)
- (~~ (.static @.js))
- (.|> <it>
- (.:as (array.Array .Frac))
- ("js array read" <index>)
- "lux f64 i64"
- .i64)
+ (~~ (.static @.js))
+ (.|> <it>
+ (.:as (array.Array .Frac))
+ ("js array read" <index>)
+ "lux f64 i64"
+ .i64)
- (~~ (.static @.python))
- (.|> <it>
- (.:as (array.Array .I64))
- ("python array read" <index>))
+ (~~ (.static @.python))
+ (.|> <it>
+ (.:as (array.Array .I64))
+ ("python array read" <index>))
- (~~ (.static @.scheme))
- (..bytevector-u8-ref [<it> <index>])]
+ (~~ (.static @.scheme))
+ (..bytevector-u8-ref [<it> <index>])
... Default
(.if (array.lacks? <index> <it>)
@@ -188,43 +188,43 @@
<it> (.: ..Binary it)
<index> (.: .Nat index)
<value> (.: (.I64 .Any) value)
- <jvm_value> (`` (.for [(~~ (.static @.old))
- (.:as .Int <value>)
+ <jvm_value> (`` (.for (~~ (.static @.old))
+ (.:as .Int <value>)
- (~~ (.static @.jvm))
- (.:as (.Primitive "java.lang.Long") <value>)]
+ (~~ (.static @.jvm))
+ (.:as (.Primitive "java.lang.Long") <value>)
<value>))
<jvm_value> <jvm_value>
<jvm_value> (ffi.long_to_byte <jvm_value>)
<jvm> (ffi.write! <index> <jvm_value> <it>)]
(`` (template: .public (with/1! index value it)
[(.: ..Binary
- (.for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>
-
- (~~ (.static @.js))
- (.|> <it>
- (.: ..Binary)
- (.:as (array.Array .Frac))
- ("js array write" <index>
- (.|> <value>
- .int
- ("lux i64 and" (.int <byte>))
- "lux i64 f64"))
- (.:as ..Binary))
-
- (~~ (.static @.python))
- (.|> <it>
- (.: ..Binary)
- (.:as (array.Array (.I64 .Any)))
- ("python array write" <index> (.|> <value> ("lux i64 and" <byte>) (.: (.I64 .Any))))
- (.:as ..Binary))
-
- (~~ (.static @.scheme))
- (.let [it' <it>]
- (.exec
- (..bytevector-u8-set! [it' <index> <value>])
- it'))]
+ (.for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
+
+ (~~ (.static @.js))
+ (.|> <it>
+ (.: ..Binary)
+ (.:as (array.Array .Frac))
+ ("js array write" <index>
+ (.|> <value>
+ .int
+ ("lux i64 and" (.int <byte>))
+ "lux i64 f64"))
+ (.:as ..Binary))
+
+ (~~ (.static @.python))
+ (.|> <it>
+ (.: ..Binary)
+ (.:as (array.Array (.I64 .Any)))
+ ("python array write" <index> (.|> <value> ("lux i64 and" <byte>) (.: (.I64 .Any))))
+ (.:as ..Binary))
+
+ (~~ (.static @.scheme))
+ (.let [it' <it>]
+ (.exec
+ (..bytevector-u8-set! [it' <index> <value>])
+ it'))
... Default
(array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))])))
@@ -248,19 +248,19 @@
(`` (template: .public (with/8! index' value' it)
[(.let [index (.: .Nat index')
value (.: (.I64 .Any) value')]
- (.for [(~~ (.static @.scheme)) (.let [write_high (.: (.-> ..Binary ..Binary)
- (.|>> (..with/1! index ("lux i64 right-shift" 56 value))
- (..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
- (..with/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
- (..with/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))))
- write_low (.: (.-> ..Binary ..Binary)
- (.|>> (..with/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
- (..with/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
- (..with/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
- (..with/1! ("lux i64 +" 7 index) value)))]
- (.|> it
- write_high
- write_low))]
+ (.for (~~ (.static @.scheme)) (.let [write_high (.: (.-> ..Binary ..Binary)
+ (.|>> (..with/1! index ("lux i64 right-shift" 56 value))
+ (..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
+ (..with/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
+ (..with/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))))
+ write_low (.: (.-> ..Binary ..Binary)
+ (.|>> (..with/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
+ (..with/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
+ (..with/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
+ (..with/1! ("lux i64 +" 7 index) value)))]
+ (.|> it
+ write_high
+ write_low))
(.|> it
(..with/1! index ("lux i64 right-shift" 56 value))
(..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
@@ -276,8 +276,8 @@
<jvm> (java/util/Arrays::equals <reference> <sample>)
<jvm> (ffi.of_boolean <jvm>)]
(`` (template: .public (= reference' sample')
- [(.for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>]
+ [(.for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
(.let [reference <reference>
sample <sample>
limit (..size reference)]
@@ -299,8 +299,8 @@
<jvm> (.exec
<jvm>
target)]
- (.for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>]
+ (.for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
... Default
(.loop [index 0]
@@ -320,8 +320,8 @@
<jvm>)]
(inline: .public (slice offset size binary)
(-> .Nat .Nat ..Binary ..Binary)
- (.for [(~~ (.static @.old)) <jvm>
- (~~ (.static @.jvm)) <jvm>]
+ (.for (~~ (.static @.old)) <jvm>
+ (~~ (.static @.jvm)) <jvm>
... Default
(..copy! size offset binary 0 (..empty size))))))