[armedbear-devel] CL:FLOAT on Java Number objects could call {single, double}Float() on them

Mario Lang mlang at delysid.org
Sat Jun 19 18:53:10 UTC 2010


Hi.

Along the lines of the previously submitted string conversion patch,
here is some other possible interoperability thing.

Index: src/org/armedbear/lisp/SingleFloat.java
===================================================================
--- src/org/armedbear/lisp/SingleFloat.java	(revision 12758)
+++ src/org/armedbear/lisp/SingleFloat.java	(working copy)
@@ -635,6 +635,11 @@
             return new SingleFloat(((Bignum)obj).floatValue());
         if (obj instanceof Ratio)
             return new SingleFloat(((Ratio)obj).floatValue());
+        if (obj instanceof JavaObject) {
+            final Object jobj = ((JavaObject)obj).getObject();
+            if (jobj instanceof Number)
+                return new SingleFloat(((Number)jobj).floatValue());
+        }
         error(new TypeError("The value " + obj.writeToString() +
                              " cannot be converted to type SINGLE-FLOAT."));
         // Not reached.
Index: src/org/armedbear/lisp/DoubleFloat.java
===================================================================
--- src/org/armedbear/lisp/DoubleFloat.java	(revision 12758)
+++ src/org/armedbear/lisp/DoubleFloat.java	(working copy)
@@ -646,6 +646,11 @@
             return new DoubleFloat(((SingleFloat)obj).value);
         if (obj instanceof Ratio)
             return new DoubleFloat(((Ratio)obj).doubleValue());
+        if (obj instanceof JavaObject) {
+            final Object jobj = ((JavaObject)obj).getObject();
+            if (jobj instanceof Number)
+                return new DoubleFloat(((Number)jobj).doubleValue());
+        }
         error(new TypeError("The value " + obj.writeToString() +
                              " cannot be converted to type DOUBLE-FLOAT."));
         // Not reached.



P.S.: The following conditional is duplicated and could be removed:

Index: src/org/armedbear/lisp/Pathname.java
===================================================================
--- src/org/armedbear/lisp/Pathname.java	(revision 12758)
+++ src/org/armedbear/lisp/Pathname.java	(working copy)
@@ -1290,7 +1290,7 @@
             if (host == NIL) {
                 host = defaults.host;
             }
-            if (directory == NIL && defaults != null) {
+            if (directory == NIL) {
                 directory = defaults.directory;
             }
             if (!deviceSupplied) {

-- 
CYa,
  ⡍⠁⠗⠊⠕




More information about the armedbear-devel mailing list