aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/host.jvm.lux82
1 files changed, 22 insertions, 60 deletions
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index 42a076b8f..62a3da2a6 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -1308,47 +1308,24 @@
[methods (p;some (method-def^ imports class-vars))])
{#;doc (doc "Allows defining JVM classes in Lux code."
"For example:"
- (class: #final (JvmPromise A) []
+ (class: #final (TestClass A) [Runnable]
## Fields
- (#private resolved boolean)
- (#private datum A)
- (#private waitingList (java.util.List lux.Function))
+ (#private foo boolean)
+ (#private bar A)
+ (#private baz java.lang.Object)
## Methods
- (#public [] new [] []
- (exec (:= .resolved false)
- (:= .waitingList (ArrayList.new []))
+ (#public [] (new [value A]) []
+ (exec (:= .foo true)
+ (:= .bar value)
+ (:= .baz "")
[]))
- (#public [] resolve [{value A}] boolean
- (let [container (.new! [])]
- (synchronized _jvm_this
- (if .resolved
- false
- (exec (:= .datum value)
- (:= .resolved true)
- (let [sleepers .waitingList
- sleepers-count (java.util.List.size [] sleepers)]
- (L/map (function [idx]
- (let [sleeper (java.util.List.get [(l2i idx)] sleepers)]
- (Executor.execute [(runnable (lux.Function.apply [(:! Object value)] sleeper))]
- executor)))
- (i.range 0 (i.dec (i2l sleepers-count)))))
- (:= .waitingList (null))
- true)))))
- (#public [] poll [] A
- .datum)
- (#public [] wasResolved [] boolean
- (synchronized _jvm_this
- .resolved))
- (#public [] waitOn [{callback lux.Function}] void
- (synchronized _jvm_this
- (exec (if .resolved
- (lux.Function.apply [(:! Object .datum)] callback)
- (:! Object (java.util.List.add [callback] .waitingList)))
- [])))
- (#public #static [A] make [{value A}] (lux.concurrency.promise.JvmPromise A)
- (let [container (.new! [])]
- (exec (.resolve! (:! (host lux.concurrency.promise.JvmPromise [Unit]) container) [(:! Unit value)])
- container))))
+ (#public (virtual) java.lang.Object
+ "")
+ (#public #static (static) java.lang.Object
+ "")
+ (Runnable [] (run) void
+ [])
+ )
"The vector corresponds to parent interfaces."
"An optional super-class can be specified before the vector. If not specified, java.lang.Object will be assumed."
@@ -1410,11 +1387,11 @@
"The 1st vector corresponds to parent interfaces."
"The 2nd vector corresponds to arguments to the super class constructor."
"An optional super-class can be specified before the 1st vector. If not specified, java.lang.Object will be assumed."
- (object [java.lang.Runnable]
+ (object [Runnable]
[]
- (java.lang.Runnable (run) void
- (exec (do-something some-input)
- [])))
+ (Runnable [] (run) void
+ (exec (do-something some-value)
+ [])))
)}
(let [def-code (format "anon-class:"
(spaced (list (super-class-decl$ super)
@@ -1506,24 +1483,9 @@
(syntax: #export (do-to obj [methods (p;some partial-call^)])
{#;doc (doc "Call a variety of methods on an object; then return the object."
- (do-to vreq
- (HttpServerRequest.setExpectMultipart [true])
- (ReadStream.handler [(object [(Handler Buffer)]
- []
- ((Handler A) (handle [buffer A]) void
- (io;run (do Monad<IO>
- [_ (write (Buffer.getBytes [] buffer) body)]
- (wrap []))))
- )])
- (ReadStream.endHandler [[(object [(Handler Void)]
- []
- ((Handler A) (handle [_ A]) void
- (exec (do Monad<Promise>
- [#let [_ (io;run (close body))]
- response (handler (request$ vreq body))]
- (respond! response vreq))
- []))
- )]])))}
+ (do-to object
+ (ClassName.method1 [arg0 arg1 arg2])
+ (ClassName.method2 [arg3 arg4 arg5])))}
(with-gensyms [g!obj]
(wrap (list (` (let [(~ g!obj) (~ obj)]
(exec (~@ (L/map (complete-call$ g!obj) methods))