This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Android REPL - add* syntax-sugar not available in constructor
Thank you. I used the latest svn sources and I'm now able to use the addXXX
in constructors. It works very well for specifying layout.
The following works on the REPL:
(*activity*:runOnUiThread
(runnable
(lambda ()
(try-catch
(*activity*:setContentView
(android.widget.LinearLayout *activity*
orientation: android.widget.LinearLayout:VERTICAL
view: (android.widget.TextView *activity* text: "Hello")
view: (android.widget.Button *activity* text: "Click")))
(e java.lang.Exception
(android.util.Log:v "kawa-hello" e))))))
Unfortunately, I couldn't attach any event handlers from the REPL, as
the following fails with "this expression must be compiled, but compiler is
unavailable"
(*activity*:runOnUiThread
(runnable
(lambda ()
(try-catch
(*activity*:setContentView
(android.widget.LinearLayout *activity*
orientation: android.widget.LinearLayout:VERTICAL
view: (android.widget.TextView *activity* text: "Hello")
view: (android.widget.Button *activity* text: "Click"
on-click-listener:
(lambda (v) ((android.widget.Toast:makeText *activity*
"Clicked Me" andoird.widget.Toast:LENGTH_LONG):show))))
(e java.lang.Exception
(android.util.Log:v "kawa-hello" e))))))
Is this is hard limitation, since kawa has to generate an anonymous class on
the fly to handle the event?
Is there anyway I can use a precompiled MouseAdapter class that would invoke
a closure? I tried something like the following:
; a job that is posted on a UI thread.
(define-simple-class Job (java.lang.Runnable)
(result type: java.lang.Object init-value: #!null)
;((*init*) #!void
; (display "Init Job"))
(form init-keyword: form:)
((*init* (form0 :: java.lang.Object))
(set! form form0))
((run) :: #!void
(synchronized (this)
(if (not (eq? #!null form))
(set! result (eval form (interaction-environment))))
(sleep 2.0)
(notify))
))
but the verifier didn't like it (perhaps the code is too dynamic?)
#|kawa:4|# kawa.android.Job
unbound location kawa.android.Job
at gnu.expr.ReferenceExp.apply(ReferenceExp.java:153)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:284)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:200)
at kawa.Shell.run(Shell.java:279)
at kawa.Shell.run(Shell.java:194)
at kawa.Shell.run(Shell.java:175)
at kawa.TelnetRepl.apply0(TelnetRepl.java:23)
at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
at gnu.mapping.Future.run(Future.java:44)
W/dalvikvm( 4908): VFY: invoke type does not match method type of
Lkawa/android/Job;.$finit$
W/dalvikvm( 4908): VFY: rejecting opcode 0x6e at 0x0003
W/dalvikvm( 4908): VFY: rejected Lkawa/android/Job;.<init>
(Ljava/lang/Object;)V
--
View this message in context: http://old.nabble.com/Android-REPL---add*-syntax-sugar-not-available-in-constructor-tp33222365p33235591.html
Sent from the Sourceware - kawa list mailing list archive at Nabble.com.