diff --git a/.gitmodules b/.gitmodules
index e27c8ab..6239b95 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,9 +4,6 @@
[submodule "ecl"]
path = ecl
url = git://git.code.sf.net/p/ecls/ecl
-[submodule "slime"]
- path = slime
- url = git://common-lisp.net/projects/mirror/slime.git
[submodule "lisp-packages/cl-opengl"]
path = lisp-packages/cl-opengl
url = git://github.com/ageneau/cl-opengl.git
@@ -23,3 +20,7 @@
[submodule "libatomic_ops"]
path = libatomic_ops
url = https://github.com/ivmai/libatomic_ops.git
+[submodule "slime"]
+ path = slime
+ url = https://github.com/slime/slime.git
+
diff --git a/Makefile b/Makefile
index a7d47f1..e2c900e 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ update-modules:
git submodule update
patch-ecl:
- cd ecl && git clean -dxf && git checkout HEAD . && for i in ../patches/ecl/*.patch; do patch -p1 < $$i; done
+ cd ecl && git clean -dxf && git checkout master . && for i in ../patches/ecl/*.patch; do patch -p1 < $$i; done
cp config.sub config.guess ecl/src/
cp config.sub config.guess ecl/src/gmp/
chmod +x ecl/src/config.* ecl/src/gmp/config.*
diff --git a/android/HelloEcl/AndroidManifest.xml b/android/HelloEcl/AndroidManifest.xml
index 7bf0421..1a92913 100644
--- a/android/HelloEcl/AndroidManifest.xml
+++ b/android/HelloEcl/AndroidManifest.xml
@@ -3,7 +3,7 @@
package="org.lisp.ecl"
android:versionCode="1"
android:versionName="1.0">
-
+
diff --git a/android/HelloEcl/jni/Android.mk b/android/HelloEcl/jni/Android.mk
index ed9d730..eba0c8d 100644
--- a/android/HelloEcl/jni/Android.mk
+++ b/android/HelloEcl/jni/Android.mk
@@ -25,13 +25,15 @@ endif
ECL_HOME := ../../local-install/$(PLATFORM)
ECL_VER := $(shell basename $(ECL_HOME)/lib/ecl-* |cut -d "-" -f2)
-LOCAL_MODULE := hello-ecl
-LOCAL_PATH := $(BASE_PATH)
-LOCAL_SRC_FILES := hello-ecl.c ecl_boot.c
-LOCAL_CFLAGS += -I$(ECL_HOME)/include
-LOCAL_CFLAGS += -g -Wall -DANDROID
-LOCAL_LDLIBS := -L$(ECL_HOME)/lib -lecl -lgmp -L$(ECL_HOME)/lib/ecl-$(ECL_VER) -lasdf -lsockets -lsb-bsd-sockets -lserve-event -lecl-help -lecl-cdb -lgc -latomic_ops
-LOCAL_LDLIBS += -llog
+LOCAL_MODULE := ecl_android
+LOCAL_PATH := $(BASE_PATH)
+LOCAL_SRC_FILES := org_lisp_ecl_EmbeddedCommonLisp.c ecl_boot.c
+LOCAL_CFLAGS += -I$(ECL_HOME)/include
+LOCAL_CFLAGS += -g -Wall -DANDROID
+LOCAL_LDLIBS := -L$(ECL_HOME)/lib
+LOCAL_LDLIBS += -L$(ECL_HOME)/lib/ecl-$(ECL_VER)
+LOCAL_LDLIBS += -lecl -lasdf -lgmp -lsockets -llog
+LOCAL_LDLIBS += -lsb-bsd-sockets -lserve-event -lecl-help
+LOCAL_LDLIBS += -lecl-cdb -lgc -latomic_ops
include $(BUILD_SHARED_LIBRARY)
-
diff --git a/android/HelloEcl/jni/hello-ecl.c b/android/HelloEcl/jni/hello-ecl.c
deleted file mode 100644
index 801da40..0000000
--- a/android/HelloEcl/jni/hello-ecl.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include
-#if ANDROID
-#include
-#endif
-#include
-#include
-#include
-#include
-
-#include
-#include "ecl_boot.h"
-
-#if ANDROID
-#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
-#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
-#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "native-activity", __VA_ARGS__))
-#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "native-activity", __VA_ARGS__))
-#else
-#define LOGI(...)
-#define LOGW(...)
-#define LOGE(...)
-#endif
-
-
-JNIEXPORT void JNICALL
-Java_org_lisp_ecl_HelloEclActivity_startECL( JNIEnv* env,
- jobject thiz )
-{
- LOGI("INIT ECL");
- jclass cls = (*env)->GetObjectClass(env, thiz);
- assert(cls);
- jmethodID mid = (*env)->GetStaticMethodID(env, cls, "getResourcesPath", "()Ljava/lang/String;");
- assert(mid);
-
- jstring file = (*env)->CallStaticObjectMethod(env, cls, mid);
- const char *lisp_dir = (*env)->GetStringUTFChars(env, file, NULL);
-
- LOGI("Path is: %s\n",lisp_dir);
- ecl_boot(lisp_dir);
- LOGI("INIT ECL DONE");
-}
-
-
-JNIEXPORT jstring JNICALL
-Java_org_lisp_ecl_HelloEclActivity_eclExec (JNIEnv * env, jobject obj, jstring str)
-{
- jstring ret;
-
- char* cmd = (*env)->GetStringUTFChars(env, str, NULL);
- cl_object result = si_safe_eval(3, c_string_to_object(cmd), Cnil, OBJNULL);
-
- if(result)
- {
- cl_object out = si_coerce_to_base_string(cl_princ_to_string(result));
- ret = (*env)->NewStringUTF(env, (const char*) out->base_string.self);
- }
- else
- {
- ret = (*env)->NewStringUTF(env, "ERROR in eval");
- }
-
- return ret;
-}
-
diff --git a/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.c b/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.c
new file mode 100644
index 0000000..2e6f85c
--- /dev/null
+++ b/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.c
@@ -0,0 +1,134 @@
+#include
+
+#if ANDROID
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+#include
+#include "ecl_boot.h"
+
+#if ANDROID
+#define ECL_TAG "ecl-native"
+#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ECL_TAG, __VA_ARGS__))
+#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ECL_TAG, __VA_ARGS__))
+#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, ECL_TAG, __VA_ARGS__))
+#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ECL_TAG, __VA_ARGS__))
+#else
+#define LOGI(...)
+#define LOGW(...)
+#define LOGE(...)
+#endif
+
+#define jni_ecl_read_from_string(x) si_string_to_object(1, x)
+
+/*
+ * Class: org_lisp_ecl_EmbeddedCommonLisp
+ * Method: start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_org_lisp_ecl_EmbeddedCommonLisp_start(JNIEnv *env, jobject this,
+ jstring path) {
+
+ const char *lisp_dir = (*env)->GetStringUTFChars(env, path, NULL);
+ LOGI("ECL starting: *default-pathname-defaults* to: %s\n", lisp_dir);
+ ecl_boot(lisp_dir);
+ LOGI("ECL started.");
+};
+
+/* This was fun to make UTF8 work across Java-C-Lisp boundaries.
+ -evrim, 2014. */
+cl_object java_string_to_ecl_string(JNIEnv *env, jstring str) {
+ const jchar *txt = (*env)->GetStringChars(env, str, NULL);
+ jsize len = (*env)->GetStringLength(env, str);
+ cl_object ecl_txt = ecl_alloc_simple_extended_string(len);
+ cl_index i;
+
+ for (i=0;istring.self[i] = txt[i];
+ };
+
+ (*env)->ReleaseStringChars(env, str, txt);
+
+ return ecl_txt;
+}
+
+
+jstring ecl_object_to_java_string(JNIEnv *env, cl_object o) {
+ jstring ret;
+ if (ECL_EXTENDED_STRING_P(o)) {
+ LOGI("ecl->java extended string of fillp: %d, dim: %d",
+ o->string.fillp,
+ o->string.dim);
+
+ jsize len = o->string.fillp;
+ jchar *arr = malloc(sizeof(jchar)*(len+1));
+ cl_index i;
+ for (i=0; istring.self[i];
+ }
+ arr[len] = 0;
+ ret = (*env)->NewString(env, arr, len);
+ free(arr);
+ } else if (ECL_STRINGP(o)) {
+ LOGI("ecl->java base string of len %d: %s",
+ o->base_string.dim,
+ o->base_string.self);
+
+ ret = (*env)->NewStringUTF(env,
+ (const char*)o->base_string.self);
+ } else {
+ LOGI("ecl->java not a string, coercing");
+ return ecl_object_to_java_string(env, cl_princ_to_string(o));
+ }
+
+ return ret;
+}
+
+/*
+ * Class: org_lisp_ecl_EmbeddedCommonLisp
+ * Method: exec
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_org_lisp_ecl_EmbeddedCommonLisp_exec(JNIEnv *env, jobject this, jstring str) {
+ jstring ret;
+ cl_object txt = java_string_to_ecl_string(env, str);
+ cl_object result = si_safe_eval(3, jni_ecl_read_from_string(txt), Cnil, OBJNULL);
+
+ if (result) {
+ ret = ecl_object_to_java_string(env, result);
+ } else {
+ ret = (*env)->NewStringUTF(env, "ERROR in eval");
+ }
+
+ return ret;
+};
+
+#undef jni_ecl_read_from_string
+
+/*
+ * Class: org_lisp_ecl_EmbeddedCommonLisp
+ * Method: exec_
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_org_lisp_ecl_EmbeddedCommonLisp_exec_(JNIEnv *env, jobject this, jstring str) {
+ jstring ret;
+ const char *cmd = (*env)->GetStringUTFChars(env, str, NULL);
+ cl_object result = si_safe_eval(3, c_string_to_object(cmd),
+ Cnil, OBJNULL);
+
+ if (result) {
+ cl_object out = si_coerce_to_base_string(cl_princ_to_string(result));
+ ret = (*env)->NewStringUTF(env, (const char*) out->base_string.self);
+ } else {
+ ret = (*env)->NewStringUTF(env, "ERROR in eval");
+ }
+ return ret;
+};
diff --git a/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.h b/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.h
new file mode 100644
index 0000000..9de49b3
--- /dev/null
+++ b/android/HelloEcl/jni/org_lisp_ecl_EmbeddedCommonLisp.h
@@ -0,0 +1,37 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class org_lisp_ecl_EmbeddedCommonLisp */
+
+#ifndef _Included_org_lisp_ecl_EmbeddedCommonLisp
+#define _Included_org_lisp_ecl_EmbeddedCommonLisp
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_lisp_ecl_EmbeddedCommonLisp
+ * Method: start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_lisp_ecl_EmbeddedCommonLisp_start
+(JNIEnv *, jobject, jstring);
+
+/*
+ * Class: org_lisp_ecl_EmbeddedCommonLisp
+ * Method: exec
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_org_lisp_ecl_EmbeddedCommonLisp_exec
+(JNIEnv *, jobject, jstring);
+
+/* /\* */
+/* * Class: org_lisp_ecl_EmbeddedCommonLisp */
+/* * Method: botExec */
+/* * Signature: (Ljava/lang/String;)Ljava/lang/String; */
+/* *\/ */
+/* JNIEXPORT jstring JNICALL Java_org_lisp_ecl_EmbeddedCommonLisp_exec_ */
+/* (JNIEnv *, jobject, jstring); */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/android/HelloEcl/src/org/lisp/ecl/EmbeddedCommonLisp.java b/android/HelloEcl/src/org/lisp/ecl/EmbeddedCommonLisp.java
new file mode 100644
index 0000000..b9b1ce3
--- /dev/null
+++ b/android/HelloEcl/src/org/lisp/ecl/EmbeddedCommonLisp.java
@@ -0,0 +1,19 @@
+package org.lisp.ecl;
+
+import android.util.Log;
+
+public class EmbeddedCommonLisp {
+ private static String TAG = "EmbeddedCommonLisp";
+
+ public void start() {
+ start(System.getenv("user.dir"));
+ }
+ public native void start(String path);
+ public native String exec(String string);
+ // public native String botExec(String string);
+
+ static {
+ System.loadLibrary("ecl_android");
+ Log.w(TAG,"Done loading library");
+ }
+}
diff --git a/android/HelloEcl/src/org/lisp/ecl/HelloEclActivity.java b/android/HelloEcl/src/org/lisp/ecl/HelloEclActivity.java
index 8d7b5d7..efd7454 100644
--- a/android/HelloEcl/src/org/lisp/ecl/HelloEclActivity.java
+++ b/android/HelloEcl/src/org/lisp/ecl/HelloEclActivity.java
@@ -1,31 +1,22 @@
package org.lisp.ecl;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
import android.app.Activity;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.res.AssetManager;
-import android.content.res.AssetFileDescriptor;
-import android.widget.TextView;
-import android.widget.Toast;
import android.os.Bundle;
import android.util.Log;
-import android.content.SharedPreferences;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.io.RandomAccessFile;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.io.Reader;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.Date;
+import android.widget.Toast;
public class HelloEclActivity extends Activity
@@ -33,6 +24,8 @@ public class HelloEclActivity extends Activity
private static String TAG = "HelloEcl";
private static String RESOURCES_DIR = "lisp";
private static String APP_RESOURCES_DIR = "resources";
+ private EmbeddedCommonLisp ecl = new EmbeddedCommonLisp();
+
private static boolean DEBUG = false;
static AssetManager assetManager;
@@ -57,13 +50,15 @@ public void onCreate(Bundle savedInstanceState)
editor.commit();
}
- Log.w(TAG,"ECL Starting...");
- startECL();
+ Log.w(TAG,"ECL starting.");
+
+
+ ecl.start(getResourcesPath());
Log.w(TAG,"ECL Started");
setContentView(R.layout.main);
- String result = eclExec("(format nil \"Hello from lisp\")");
+ String result = ecl.exec("(format nil \"Hello from lisp\")");
System.out.println("Result: " + result);
Context context = getApplicationContext();
@@ -155,15 +150,5 @@ public static void uncompressFile(File fileIn,File fileOut)
in.close();
out.close();
Log.i(TAG,"File copied.");
- }
-
-
- public native void startECL();
- public native String eclExec(String string);
-
- static
- {
- System.loadLibrary("hello-ecl");
- Log.w(TAG,"Done loading library");
- }
+ }
}
diff --git a/patches/ecl/0001-Fix-socket-implementation-on-android-getprotobyname-.patch b/patches/ecl/0001-Fix-socket-implementation-on-android-getprotobyname-.patch
index 418f320..8f76cfb 100644
--- a/patches/ecl/0001-Fix-socket-implementation-on-android-getprotobyname-.patch
+++ b/patches/ecl/0001-Fix-socket-implementation-on-android-getprotobyname-.patch
@@ -1,18 +1,16 @@
-From 379bc4b4d32acf3da9729ad543c1b6b188d603c9 Mon Sep 17 00:00:00 2001
-From: Sylvain Ageneau
-Date: Mon, 4 Apr 2011 19:57:38 -0300
-Subject: [PATCH 1/5] Fix socket implementation on android (getprotobyname is
- not implemented in bionic libc)
+commit 93a172a7c1307ee1ed78272c7ccb9d92bca91946
+Author: Evrim Ulu
+Date: Thu Jan 8 15:21:04 2015 +0900
----
- contrib/sockets/sockets.lisp | 53 ++++++++++++++++++++++++++++++++++++++++++--
- 1 file changed, 51 insertions(+), 2 deletions(-)
+ Fix socket implementation, getprotobyname not implemented in bionic.
diff --git a/contrib/sockets/sockets.lisp b/contrib/sockets/sockets.lisp
-index e85df1f..184ca80 100755
+old mode 100755
+new mode 100644
+index 9202122..c3db029
--- a/contrib/sockets/sockets.lisp
+++ b/contrib/sockets/sockets.lisp
-@@ -109,6 +109,28 @@
+@@ -111,6 +111,28 @@
+eagain+ "EAGAIN"
+eintr+ "EINTR")
@@ -41,46 +39,50 @@ index e85df1f..184ca80 100755
#+:wsock
(defconstant +af-named-pipe+ -2)
-@@ -514,10 +536,37 @@ safe_buffer_pointer(cl_object x, cl_index size)
+@@ -516,6 +538,7 @@ safe_buffer_pointer(cl_object x, cl_index size)
(defun get-protocol-by-name (string-or-symbol)
"Calls getprotobyname"
-+ #-:android
++ #-android
(let ((string (string string-or-symbol)))
- (c-inline (string) (:cstring) :int
- "getprotobyname(#0)->p_proto"
-- :one-liner t)))
-+ :one-liner t))
-+
+ (c-inline (string) (:cstring) :int
+ "{
+@@ -524,7 +547,33 @@ safe_buffer_pointer(cl_object x, cl_index size)
+ pe = getprotobyname(#0);
+ @(return 0) = pe ? pe->p_proto : -1;
+ }
+- ")))
++ "))
++ #+android
+ ;; getprotobyname is not yet implemented on bionic
-+ #+:android
-+ (let ((proto (string-downcase (if (symbolp string-or-symbol)
-+ (symbol-name string-or-symbol)
-+ string-or-symbol))))
++ (let ((proto (string-downcase
++ (if (symbolp string-or-symbol)
++ (symbol-name string-or-symbol)
++ string-or-symbol))))
+ (cond
-+ ((string= proto "ip") +ipproto_ip+)
-+ ((string= proto "icmp") +ipproto_icmp+)
-+ ((string= proto "igmp") +ipproto_igmp+)
-+ ((string= proto "ipip") +ipproto_ipip+)
-+ ((string= proto "tcp") +ipproto_tcp+)
-+ ((string= proto "egp") +ipproto_egp+)
-+ ((string= proto "pup") +ipproto_pup+)
-+ ((string= proto "udp") +ipproto_udp+)
-+ ((string= proto "idp") +ipproto_idp+)
-+ ((string= proto "dccp") +ipproto_dccp+)
-+ ((string= proto "rsvp") +ipproto_rsvp+)
-+ ((string= proto "gre") +ipproto_gre+)
-+ ((string= proto "ipv6") +ipproto_ipv6+)
-+ ((string= proto "esp") +ipproto_esp+)
-+ ((string= proto "ah") +ipproto_ah+)
-+ ((string= proto "pim") +ipproto_pim+)
-+ ((string= proto "comp") +ipproto_comp+)
-+ ((string= proto "sctp") +ipproto_sctp+)
-+ ((string= proto "raw") +ipproto_raw+))))
++ ((string= proto "ip") +ipproto_ip+)
++ ((string= proto "icmp") +ipproto_icmp+)
++ ((string= proto "igmp") +ipproto_igmp+)
++ ((string= proto "ipip") +ipproto_ipip+)
++ ((string= proto "tcp") +ipproto_tcp+)
++ ((string= proto "egp") +ipproto_egp+)
++ ((string= proto "pup") +ipproto_pup+)
++ ((string= proto "udp") +ipproto_udp+)
++ ((string= proto "idp") +ipproto_idp+)
++ ((string= proto "dccp") +ipproto_dccp+)
++ ((string= proto "rsvp") +ipproto_rsvp+)
++ ((string= proto "gre") +ipproto_gre+)
++ ((string= proto "ipv6") +ipproto_ipv6+)
++ ((string= proto "esp") +ipproto_esp+)
++ ((string= proto "ah") +ipproto_ah+)
++ ((string= proto "pim") +ipproto_pim+)
++ ((string= proto "comp") +ipproto_comp+)
++ ((string= proto "sctp") +ipproto_sctp+)
++ ((string= proto "raw") +ipproto_raw+))))
+
(defun make-inet-address (dotted-quads)
- "Return a vector of octets given a string DOTTED-QUADS in the format
-@@ -1648,7 +1697,7 @@ GET-NAME-SERVICE-ERRNO")
+@@ -1656,7 +1705,7 @@ GET-NAME-SERVICE-ERRNO")
(define-sockopt sockopt-dont-route "SOL_SOCKET" "SO_DONTROUTE" bool)
(define-sockopt sockopt-linger "SOL_SOCKET" "SO_LINGER" linger)
@@ -89,6 +91,3 @@ index e85df1f..184ca80 100755
(define-sockopt sockopt-reuse-port "SOL_SOCKET" "SO_REUSEPORT" bool)
(define-sockopt sockopt-tcp-nodelay "IPPROTO_TCP" "TCP_NODELAY" bool)
---
-1.8.0.2
-
diff --git a/patches/ecl/0005-Support-Nacl-and-PNacl.patch b/patches/ecl/0005-Support-Nacl-and-PNacl.patch.disabled
similarity index 100%
rename from patches/ecl/0005-Support-Nacl-and-PNacl.patch
rename to patches/ecl/0005-Support-Nacl-and-PNacl.patch.disabled
diff --git a/slime b/slime
index 847d102..462085f 160000
--- a/slime
+++ b/slime
@@ -1 +1 @@
-Subproject commit 847d102f3984cf241e11c8057b4d176f91c122dc
+Subproject commit 462085f1b7370e67babe9e7d50b37e5043c83fe1