[armedbear-cvs] r11559 - branches/scripting/j/src/org/armedbear/lisp
Alessio Stalla
astalla at common-lisp.net
Thu Jan 15 23:52:27 UTC 2009
Author: astalla
Date: Thu Jan 15 23:52:27 2009
New Revision: 11559
Log:
Better handling of java<->lisp value conversion in (get/set)
jproperty-value
Modified:
branches/scripting/j/src/org/armedbear/lisp/Java.java
Modified: branches/scripting/j/src/org/armedbear/lisp/Java.java
==============================================================================
--- branches/scripting/j/src/org/armedbear/lisp/Java.java (original)
+++ branches/scripting/j/src/org/armedbear/lisp/Java.java Thu Jan 15 23:52:27 2009
@@ -704,7 +704,14 @@
try {
Object obj = javaObject.javaInstance();
PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName);
- return new JavaObject(pd.getReadMethod().invoke(obj));
+ Object value = pd.getReadMethod().invoke(obj);
+ if(value instanceof LispObject) {
+ return (LispObject) value;
+ } else if(value != null) {
+ return new JavaObject(value);
+ } else {
+ return NIL;
+ }
} catch (Exception e) {
ConditionThrowable t = new ConditionThrowable("Exception reading property");
t.initCause(e);
@@ -722,7 +729,18 @@
try {
obj = javaObject.javaInstance();
PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName);
- pd.getWriteMethod().invoke(obj, value.javaInstance());
+ Object jValue;
+ if(value == NIL) {
+ if(Boolean.TYPE.equals(pd.getPropertyType()) ||
+ Boolean.class.equals(pd.getPropertyType())) {
+ jValue = false;
+ } else {
+ jValue = null;
+ }
+ } else {
+ jValue = value.javaInstance();
+ }
+ pd.getWriteMethod().invoke(obj, jValue);
return value;
} catch (Exception e) {
ConditionThrowable t = new ConditionThrowable("Exception writing property " + propertyName.writeToString() + " in object " + obj + " to " + value.writeToString());
More information about the armedbear-cvs
mailing list