This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

define-syntax for runOnUiThread


Tried my hands at a macro today to reduce boilerplate code for running code
in the UI thread. It works, but I don't understand the difference between

java -jar libs/kawa-1.11.jar -f test2.scm

and

java -jar libs/kawa-1.11.jar test2.scm


(define-syntax run-ui
  (syntax-rules ()
   ((run-ui activity body ...)
    (android.view.Views:runOnUiThread activity
     (runnable
      (lambda ()
        body
        ...))))))

; test

(require 'syntax-utils)

(define test-form
     '(run-ui *activity*
        (android.util.Log:v "kawa-hello" "test log")
        ((Toast:makeText *activity* "Good Morning Australia"
Toast:LENGTH_LONG):show)))


(display (expand test-form))

The former (using -f) shows

((: android.view.Views (quote runOnUiThread)) *activity*
 (runnable
  (lambda ()
   (begin (android.util.Log:v kawa-hello test log)
    ((:
      ((: Toast (quote makeText)) *activity* Good Morning Australia
       (: Toast (quote LENGTH_LONG)))
      (quote show)))))))

while the latter shows only partial expansion.

(run-ui *activity* (android.util.Log:v kawa-hello test log)
 ((:
   ((: Toast (quote makeText)) *activity* Good Morning Australia
    (: Toast (quote LENGTH_LONG)))
   (quote show))))


note: the string isn't quoted?

-- 
View this message in context: http://old.nabble.com/define-syntax-for-runOnUiThread-tp33245984p33245984.html
Sent from the Sourceware - kawa list mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]