summaryrefslogtreecommitdiff
path: root/org
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@hecate.trinhall.cam.ac.uk>2006-12-25 23:17:48 +0000
committerMatthew Johnson <mjj29@hecate.trinhall.cam.ac.uk>2006-12-25 23:17:48 +0000
commit88b0b4ece4728669084dce5b83bf1bd43443c6f1 (patch)
treede2592899f3de65e3a95bc76c42281377b32f98a /org
parent648ce9694ab64115317375f5a779eead513a98ac (diff)
passes internal-cross-check
Diffstat (limited to 'org')
-rw-r--r--org/freedesktop/dbus/DBusConnection.java2
-rw-r--r--org/freedesktop/dbus/Marshalling.java6
-rw-r--r--org/freedesktop/dbus/Message.java43
-rw-r--r--org/freedesktop/dbus/test/cross_test_client.java15
-rw-r--r--org/freedesktop/dbus/test/cross_test_server.java8
5 files changed, 62 insertions, 12 deletions
diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java
index 836b58e..7534534 100644
--- a/org/freedesktop/dbus/DBusConnection.java
+++ b/org/freedesktop/dbus/DBusConnection.java
@@ -963,6 +963,8 @@ public class DBusConnection
for (Message m: outgoing.getKeys())
if (m instanceof MethodCall)
((MethodCall) m).setReply(err);
+ else
+ sendMessage(m);
outgoing = null;
}
synchronized (pendingErrors) {
diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java
index 67bb614..e0d3785 100644
--- a/org/freedesktop/dbus/Marshalling.java
+++ b/org/freedesktop/dbus/Marshalling.java
@@ -312,6 +312,12 @@ public class Marshalling
case 'g':
rv.add(Type[].class);
break;
+ case '{':
+ rv.add(Map.Entry.class);
+ contained = new Vector<Type>();
+ c = getJavaType(dbus.substring(i+1), contained, 2);
+ i+=c+1;
+ break;
default:
throw new DBusException("Failed to parse DBus type signature: "+dbus+" ("+dbus.charAt(i)+")");
}
diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java
index 0edc902..171f4eb 100644
--- a/org/freedesktop/dbus/Message.java
+++ b/org/freedesktop/dbus/Message.java
@@ -565,11 +565,15 @@ public class Message
case ArgumentType.INT16:
case ArgumentType.INT32:
case ArgumentType.INT64:
- case ArgumentType.BOOLEAN:
primbuf = new byte[len*algn];
for (int j = 0, k = 0; j < len; j++, k += algn)
marshallint(Array.getLong(data, j), primbuf, k, algn);
break;
+ case ArgumentType.BOOLEAN:
+ primbuf = new byte[len*algn];
+ for (int j = 0, k = 0; j < len; j++, k += algn)
+ marshallint(Array.getBoolean(data, j)?1:0, primbuf, k, algn);
+ break;
case ArgumentType.DOUBLE:
primbuf = new byte[len*algn];
for (int j = 0, k = 0; j < len; j++, k += algn)
@@ -599,6 +603,15 @@ public class Message
int diff = i;
for (Map.Entry<Object,Object> o: ((Map<Object,Object>) data).entrySet())
diff = appendone(sigb, i, o);
+ if (i == diff) {
+ // advance the type parser even on 0-size arrays.
+ Vector<Type> temp = new Vector<Type>();
+ byte[] temp2 = new byte[sigb.length-diff];
+ System.arraycopy(sigb, diff, temp2, 0, temp2.length);
+ String temp3 = new String(temp2);
+ int temp4 = Marshalling.getJavaType(temp3, temp, 1);
+ diff += temp4;
+ }
i = diff;
} else {
Object[] contents = (Object[]) data;
@@ -727,8 +740,10 @@ public class Message
if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending sig: "+sig+" data: "+Arrays.deepToString(data));
byte[] sigb = sig.getBytes();
int j = 0;
- for (int i = 0; i < sigb.length; i++)
+ for (int i = 0; i < sigb.length; i++) {
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending item: "+i+" "+((char)sigb[i])+" "+j);
i = appendone(sigb, i, data[j++]);
+ }
}
/**
* Align a counter to the given type.
@@ -861,6 +876,16 @@ public class Message
Double.longBitsToDouble(demarshallint(buf, ofs[1], algn));
break;
case ArgumentType.DICT_ENTRY1:
+ if (0 == size) {
+ // advance the type parser even on 0-size arrays.
+ Vector<Type> temp = new Vector<Type>();
+ byte[] temp2 = new byte[sigb.length-ofs[0]];
+ System.arraycopy(sigb, ofs[0], temp2, 0, temp2.length);
+ String temp3 = new String(temp2);
+ int temp4 = Marshalling.getJavaType(temp3, temp, 1);
+ ofs[0] += temp4;
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Aligned type: "+temp3+" "+temp4+" "+ofs[0]);
+ }
int ofssave = ofs[0];
long end = ofs[1]+size;
Vector<Object[]> entries = new Vector<Object[]>();
@@ -871,7 +896,16 @@ public class Message
rv = new DBusMap(entries.toArray(new Object[0][]));
break;
default:
- // TODO: handle 0-size arrays
+ if (0 == size) {
+ // advance the type parser even on 0-size arrays.
+ Vector<Type> temp = new Vector<Type>();
+ byte[] temp2 = new byte[sigb.length-ofs[0]];
+ System.arraycopy(sigb, ofs[0], temp2, 0, temp2.length);
+ String temp3 = new String(temp2);
+ int temp4 = Marshalling.getJavaType(temp3, temp, 1);
+ ofs[0] += temp4;
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Aligned type: "+temp3+" "+temp4+" "+ofs[0]);
+ }
ofssave = ofs[0];
end = ofs[1]+size;
Vector<Object> contents = new Vector<Object>();
@@ -927,9 +961,6 @@ public class Message
break;
case ArgumentType.SIGNATURE:
length = (buf[ofs[1]++] & 0xFF);
- /* TODO: put this somewhere else Vector<Type> types = new Vector<Type>();
- Marshalling.getJavaType(new String(buf, ofs[1], (int)length), types, -1);
- rv = types.toArray(new Type[0]);*/
rv = new String(buf, ofs[1], (int)length);
ofs[1] += length + 1;
break;
diff --git a/org/freedesktop/dbus/test/cross_test_client.java b/org/freedesktop/dbus/test/cross_test_client.java
index c293b5c..3558c73 100644
--- a/org/freedesktop/dbus/test/cross_test_client.java
+++ b/org/freedesktop/dbus/test/cross_test_client.java
@@ -40,6 +40,8 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.types.DBusListType;
import org.freedesktop.dbus.types.DBusMapType;
+import cx.ath.matthew.debug.Debug;
+
public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHandler<DBus.Binding.TestSignals.Triggered>
{
private DBusConnection conn;
@@ -141,10 +143,13 @@ public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHan
fail(iface.getName()+"."+method, msg);
}
} catch (DBusExecutionException DBEe) {
+ DBEe.printStackTrace();
fail(iface.getName()+"."+method, "Error occurred during execution: "+DBEe.getClass().getName()+" "+DBEe.getMessage());
} catch (InvocationTargetException ITe) {
+ ITe.printStackTrace();
fail(iface.getName()+"."+method, "Error occurred during execution: "+ITe.getCause().getClass().getName()+" "+ITe.getCause().getMessage());
} catch (Exception e) {
+ e.printStackTrace();
fail(iface.getName()+"."+method, "Error occurred during execution: "+e.getClass().getName()+" "+e.getMessage());
}
}
@@ -235,6 +240,7 @@ public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHan
fail("org.freedesktop.DBus.Binding.Tests.Primitize", "Wrong Return Value; expected "+collapseArray(vs)+" got "+collapseArray(res));
} catch (Exception e) {
+ if (Debug.debug) Debug.print(e);
fail("org.freedesktop.DBus.Binding.Tests.Primitize", "Exception occurred during test: ("+e.getClass().getName()+") "+e.getMessage());
}
}
@@ -246,12 +252,16 @@ public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHan
try { if (intro.Introspect().startsWith("<!DOCTYPE")) pass("org.freedesktop.DBus.Introspectable.Introspect");
else fail("org.freedesktop.DBus.Introspectable.Introspect", "Didn't get valid xml data back when introspecting /Test");
- } catch (DBusExecutionException DBEe) { fail("org.freedesktop.DBus.Introspectable.Introspect", "Got exception during introspection on /Test ("+DBEe.getClass().getName()+"): "+DBEe.getMessage());
+ } catch (DBusExecutionException DBEe) {
+ if (Debug.debug) Debug.print(DBEe);
+ fail("org.freedesktop.DBus.Introspectable.Introspect", "Got exception during introspection on /Test ("+DBEe.getClass().getName()+"): "+DBEe.getMessage());
}
try { if (rootintro.Introspect().startsWith("<!DOCTYPE")) pass("org.freedesktop.DBus.Introspectable.Introspect");
else fail("org.freedesktop.DBus.Introspectable.Introspect", "Didn't get valid xml data back when introspecting /");
- } catch (DBusExecutionException DBEe) { fail("org.freedesktop.DBus.Introspectable.Introspect", "Got exception during introspection on / ("+DBEe.getClass().getName()+"): "+DBEe.getMessage());
+ } catch (DBusExecutionException DBEe) {
+ if (Debug.debug) Debug.print(DBEe);
+ fail("org.freedesktop.DBus.Introspectable.Introspect", "Got exception during introspection on / ("+DBEe.getClass().getName()+"): "+DBEe.getMessage());
}
test(DBus.Binding.Tests.class, tests, "Identity", new Variant<Integer>(new Integer(1)), new Variant<Integer>(new Integer(1)));
@@ -406,6 +416,7 @@ public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHan
try {
ctc.conn.sendSignal(new DBus.Binding.TestSignals.Trigger("/Test", new UInt16(15), 12.5));
} catch (DBusException DBe) {
+ if (Debug.debug) Debug.print(DBe);
throw new DBusExecutionException(DBe.getMessage());
}
diff --git a/org/freedesktop/dbus/test/cross_test_server.java b/org/freedesktop/dbus/test/cross_test_server.java
index 5b01be4..8938ab5 100644
--- a/org/freedesktop/dbus/test/cross_test_server.java
+++ b/org/freedesktop/dbus/test/cross_test_server.java
@@ -305,10 +305,6 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
{
done.add("org.freedesktop.DBus.Binding.Tests.Exit");
notdone.remove("org.freedesktop.DBus.Binding.Tests.Exit");
- for (String s: done)
- System.out.println(s+" ok");
- for (String s: notdone)
- System.out.println(s+" untested");
run = false;
synchronized (this) {
notifyAll();
@@ -340,6 +336,10 @@ public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.Singl
} catch (InterruptedException Ie) {}
}
}
+ for (String s: cts.done)
+ System.out.println(s+" ok");
+ for (String s: cts.notdone)
+ System.out.println(s+" untested");
conn.disconnect();
System.exit(0);
} catch (DBusException DBe) {