From 88b0b4ece4728669084dce5b83bf1bd43443c6f1 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Mon, 25 Dec 2006 23:17:48 +0000 Subject: passes internal-cross-check --- org/freedesktop/dbus/DBusConnection.java | 2 ++ org/freedesktop/dbus/Marshalling.java | 6 ++++ org/freedesktop/dbus/Message.java | 43 ++++++++++++++++++++---- org/freedesktop/dbus/test/cross_test_client.java | 15 +++++++-- org/freedesktop/dbus/test/cross_test_server.java | 8 ++--- 5 files changed, 62 insertions(+), 12 deletions(-) (limited to 'org') 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(); + 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 o: ((Map) data).entrySet()) diff = appendone(sigb, i, o); + if (i == diff) { + // advance the type parser even on 0-size arrays. + Vector temp = new Vector(); + 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 temp = new Vector(); + 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 entries = new Vector(); @@ -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 temp = new Vector(); + 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 contents = new Vector(); @@ -927,9 +961,6 @@ public class Message break; case ArgumentType.SIGNATURE: length = (buf[ofs[1]++] & 0xFF); - /* TODO: put this somewhere else Vector types = new Vector(); - 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 { 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("(new Integer(1)), new Variant(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) { -- cgit v1.2.3