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]

eval on Android


Is eval supposed to work on Android?

I'm trying to start a REPL on a socket but I always get
NullPointerExceptions during eval.  

I basically followed the instructions here
http://per.bothner.com/blog/2010/AndroidHelloScheme/ to compile an .apk
file with the kawa.jar as described there.

I had to change build.xml a bit for Android SDK Tools version 16 and I
also added <uses-permission android:name="android.permission.INTERNET"/>
to AndroidManifest.xml.  The code for hello.scm is below.
After: adb forward tcp:4444 tcp:4444 
I can connect to the device but eval doesn't work:

shell$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

> 1
form: 1
java.lang.NullPointerException
        at kawa.lang.Eval.evalBody(Eval.java:74)
        at kawa.lang.Eval.evalForm$X(Eval.java:26)
        at kawa.lib.std_syntax.eval$X(std_syntax.scm:303)
        at kawa.android.hello.startRepl(hello.scm:29)
        at kawa.android.hello.onCreate(hello.scm:38)
        at android.app.Activity.performCreate(Activity.java:4397)
...



Code for hello.scm:


(module-static #t)

(module-compile-options
 warn-unknown-member: #t
 warn-undefined-variable: #t
 )

(require 'android-defs)

(define (msg (fstring string) #!rest args)
  (android.util.Log:v "kawa-hello" (apply format fstring args)))

(define (start-repl port)
  (let* ((server (java.net.ServerSocket port)))
    (msg "listing on ~a (~a)" port server)
    (let ((socket (server:accept)))
      (msg "connected ~a " socket)
      (let ((in (gnu.mapping.InPort (socket:getInputStream)))
            (out (gnu.mapping.OutPort (socket:getOutputStream))))
        (parameterize ((current-input-port in)
                       (current-output-port out))
          (do () (#f)
            (try-catch 
             (begin
               (format #t "\n> " )
               (force-output)
               (let ((form (read)))
                 (format #t "form: ~s\n" form)
                 (format #t "~s" (eval form (interaction-environment)))))
             (e java.lang.Exception
                (e:printStackTrace out)))))))))

(activity hello
  (on-create-view
   (android.widget.TextView (this)
    text: (begin
            (start-repl 4444)
            "Hello, Android from Kawa Scheme!"))))


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