dbus/mono/DBusType Array.cs, 1.6, 1.7 Boolean.cs, 1.3, 1.4 Byte.cs, 1.6, 1.7 Custom.cs, 1.3, NONE Double.cs, 1.3, 1.4 Int32.cs, 1.5, 1.6 Int64.cs, 1.5, 1.6 Nil.cs, 1.3, NONE ObjectPath.cs, 1.5, 1.6 String.cs, 1.3, 1.4 UInt32.cs, 1.5, 1.6 UInt64.cs, 1.5, 1.6

Joe Shaw joe@freedesktop.org
Tue Jan 25 11:47:15 PST 2005


Update of /cvs/dbus/dbus/mono/DBusType
In directory gabe:/tmp/cvs-serv1895/mono/DBusType

Modified Files:
	Array.cs Boolean.cs Byte.cs Double.cs Int32.cs Int64.cs 
	ObjectPath.cs String.cs UInt32.cs UInt64.cs 
Removed Files:
	Custom.cs Nil.cs 
Log Message:
2005-01-25  Joe Shaw  <joeshaw@novell.com>

	* Land the mono binding changes to conform to the new APIs.

	* mono/Makefile.am: Remove Custom.cs, DBusType/Custom.cs,
	DBusType/Dict.cs, and DBusType/Nil.cs from the build.

	* mono/Arguments.cs (GetCodeAsString): Added.  Returns the dbus
	type code as a string.
	(InitAppending): Rename dbus_message_append_iter_init() to
	dbus_message_iter_init_append().

	* mono/BusDriver.cs: Rename ServiceEventHandler to
	NameOwnerChangedHandler.  Rename GetServiceOwner to GetOwner.
	Rename ServiceOwnerChanged to NameOwnerChanged.

	* mono/Connection.cs: Rename BaseService to UniqueName, and the
	underlying C call.

	* mono/Custom.cs: Removed.  The CUSTOM type has been removed.

	* mono/Service.cs: Rename Exists to HasOwner, internally rename
	dbus_bus_acquire_service() to dbus_bus_request_name().

	* mono/DBusType/Array.cs (ctor): Use Type.GetElementType() instead
	of Type.UnderlyingSystemType to get the correct element type for
	the array.
	(ctor): Update code for new APIs: use dbus_message_iter_recurse(),
	dbus_message_get_{element|arg}_type() instead of
	dbus_message_iter_init_array_iterator().
	(Append): Replace dbus_message_iter_append_array() with
	dbus_message_iter_open_container() and
	dbus_message_iter_close_container().

	* mono/DBusType/Custom.cs, mono/DBusType/Nil.cs: Removed.  These
	types have been removed.
	
	* mono/DBusType/*.cs: Replace calls of
	dbus_message_iter_get_[type]() to dbus_message_iter_get_basic(),
	but specify the type in the DllImport extern declaration.  Ditto
	for dbus_message_iter_append_[type]() ->
	dbus_message_iter_append_basic().

	* mono/example/BusListener.cs: Update for ServiceEventHandler ->
	NameOwnerChangedHandler.

Index: Array.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Array.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Array.cs	11 Jan 2005 19:59:06 -0000	1.6
+++ Array.cs	25 Jan 2005 19:47:13 -0000	1.7
@@ -25,7 +25,7 @@
     public Array(System.Array val, Service service) 
     {
       this.val = val;
-      this.elementType = Arguments.MatchType(val.GetType().UnderlyingSystemType);
+      this.elementType = Arguments.MatchType(val.GetType().GetElementType());
       this.service = service;
     }
 
@@ -34,36 +34,37 @@
       this.service = service;
 
       IntPtr arrayIter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
-      
-      int elementTypeCode;
-      bool notEmpty = dbus_message_iter_init_array_iterator(iter, arrayIter, out elementTypeCode);
-      this.elementType = (Type) Arguments.DBusTypes[(char) elementTypeCode];
 
-      elements = new ArrayList();
+      int elementTypeCode = dbus_message_iter_get_element_type (iter);
+      dbus_message_iter_recurse (iter, arrayIter);
+      this.elementType = (Type) Arguments.DBusTypes [(char) elementTypeCode];
 
-      if (notEmpty) {
-	do {
-	  object [] pars = new Object[2];
+      elements = new ArrayList ();
+
+      if (dbus_message_iter_get_arg_type (arrayIter) != 0) {
+        do {
+          object [] pars = new Object[2];
 	  pars[0] = arrayIter;
-	  pars[1] = service;
+  	  pars[1] = service;
 	  DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(elementType, pars);
 	  elements.Add(dbusType);
-	} while (dbus_message_iter_next(arrayIter));
-      }
-      
+        } while (dbus_message_iter_next(arrayIter));
+      }      
+
       Marshal.FreeCoTaskMem(arrayIter);
     }
     
     public void Append(IntPtr iter)
     {
-      IntPtr arrayIter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
+      IntPtr arrayIter = Marshal.AllocCoTaskMem (Arguments.DBusMessageIterSize);
 
-      if (!dbus_message_iter_append_array(iter,
-					  arrayIter,
-					  (int) Arguments.GetCode(this.elementType))) {
-	throw new ApplicationException("Failed to append INT32 argument:" + val);
+      if (!dbus_message_iter_open_container (iter,
+					     (int) this.Code,
+					     Arguments.GetCodeAsString (elementType),
+					     arrayIter)) {
+	throw new ApplicationException("Failed to append array argument: " + val);
       }
-
+      
       foreach (object element in this.val) {
 	object [] pars = new Object[2];
 	pars[0] = element;
@@ -72,7 +73,11 @@
 	dbusType.Append(arrayIter);
       }
 
-      Marshal.FreeCoTaskMem(arrayIter);
+      if (!dbus_message_iter_close_container (iter, arrayIter)) {
+	throw new ApplicationException ("Failed to append array argument: " + val);
+      }
+
+      Marshal.FreeCoTaskMem (arrayIter);
     }    
 
     public static bool Suits(System.Type type) 
@@ -107,7 +112,7 @@
     public object Get(System.Type type)
     {
       if (type.IsArray)
-        type = type.GetElementType ();
+	type = type.GetElementType ();
 
       if (Arguments.Suits(elementType, type.UnderlyingSystemType)) {
 	this.val = System.Array.CreateInstance(type.UnderlyingSystemType, elements.Count);
@@ -123,19 +128,28 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_init_array_iterator(IntPtr iter,
-								     IntPtr arrayIter,
-								     out int elementType);
+    private extern static bool dbus_message_iter_open_container (IntPtr iter,
+								 int containerType,
+								 string elementType,
+								 IntPtr subIter);
+
+    [DllImport("dbus-1")]
+    private extern static bool dbus_message_iter_close_container (IntPtr iter,
+								  IntPtr subIter);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_array(IntPtr iter, 
-							      IntPtr arrayIter,
-							      int elementType);
+    private extern static int dbus_message_iter_get_element_type(IntPtr iter);
 
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_has_next(IntPtr iter);
+    private extern static int dbus_message_iter_get_arg_type(IntPtr iter);
+
+    [DllImport("dbus-1")]
+    private extern static void dbus_message_iter_recurse(IntPtr iter, IntPtr subIter);
 
     [DllImport("dbus-1")]
     private extern static bool dbus_message_iter_next(IntPtr iter);
+
+    [DllImport("dbus-1")]
+    private extern static bool dbus_message_iter_has_next (IntPtr iter);
   }
 }

Index: Boolean.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Boolean.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Boolean.cs	29 Aug 2004 18:14:30 -0000	1.3
+++ Boolean.cs	25 Jan 2005 19:47:13 -0000	1.4
@@ -25,12 +25,12 @@
 
     public Boolean(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_boolean(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_boolean(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append BOOLEAN argument:" + val);
     }
 
@@ -78,9 +78,9 @@
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Boolean dbus_message_iter_get_boolean(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out bool value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_boolean(IntPtr iter, System.Boolean value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref bool value);
   }
 }

Index: Byte.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Byte.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Byte.cs	17 Dec 2004 22:21:16 -0000	1.6
+++ Byte.cs	25 Jan 2005 19:47:13 -0000	1.7
@@ -30,12 +30,12 @@
 
     public Byte(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_byte(iter);
-    }
+      dbus_message_iter_get_basic (iter, out this.val);
+      }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_byte(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append BYTE argument:" + val);
     }
 
@@ -97,9 +97,9 @@
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Byte dbus_message_iter_get_byte(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out byte value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_byte(IntPtr iter, System.Byte value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref byte value);
   }
 }

--- Custom.cs DELETED ---

Index: Double.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Double.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Double.cs	29 Aug 2004 18:14:30 -0000	1.3
+++ Double.cs	25 Jan 2005 19:47:13 -0000	1.4
@@ -25,12 +25,12 @@
 
     public Double(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_double(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_double(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append DOUBLE argument:" + val);
     }
 
@@ -78,9 +78,9 @@
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Double dbus_message_iter_get_double(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out double value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_double(IntPtr iter, System.Double value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref double value);
   }
 }

Index: Int32.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Int32.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Int32.cs	17 Dec 2004 22:21:16 -0000	1.5
+++ Int32.cs	25 Jan 2005 19:47:13 -0000	1.6
@@ -25,12 +25,12 @@
 
     public Int32(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_int32(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_int32(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append INT32 argument:" + val);
     }
 
@@ -85,9 +85,9 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.Int32 dbus_message_iter_get_int32(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.Int32 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_int32(IntPtr iter, System.Int32 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.Int32 value);
   }
 }

Index: Int64.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/Int64.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Int64.cs	17 Dec 2004 22:21:16 -0000	1.5
+++ Int64.cs	25 Jan 2005 19:47:13 -0000	1.6
@@ -25,12 +25,12 @@
 
     public Int64(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_int64(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_int64(iter, val))
+	    if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append INT64 argument:" + val);
     }
 
@@ -86,9 +86,9 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.Int64 dbus_message_iter_get_int64(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.Int64 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_int64(IntPtr iter, System.Int64 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.Int64 value);
   }
 }

--- Nil.cs DELETED ---

Index: ObjectPath.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/ObjectPath.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ObjectPath.cs	29 Aug 2004 18:14:30 -0000	1.5
+++ ObjectPath.cs	25 Jan 2005 19:47:13 -0000	1.6
@@ -28,8 +28,11 @@
     
     public ObjectPath(IntPtr iter, Service service)
     {
-      
-      this.path = Marshal.PtrToStringAnsi(dbus_message_iter_get_object_path(iter));
+      IntPtr raw;
+
+      dbus_message_iter_get_basic (iter, out raw);
+
+      this.path = Marshal.PtrToStringAnsi (raw);
       this.service = service;
     }
 
@@ -47,7 +50,9 @@
 
     public void Append(IntPtr iter) 
     {
-      if (!dbus_message_iter_append_object_path(iter, Marshal.StringToHGlobalAnsi(Path)))
+      IntPtr marshalVal = Marshal.StringToHGlobalAnsi (Path);
+
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
 	throw new ApplicationException("Failed to append OBJECT_PATH argument:" + val);
     }
 
@@ -91,9 +96,9 @@
     }
 
     [DllImport("dbus-1")]
-    private extern static IntPtr dbus_message_iter_get_object_path(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr path);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_object_path(IntPtr iter, IntPtr path);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr path);
   }
 }

Index: String.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/String.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- String.cs	29 Aug 2004 18:14:30 -0000	1.3
+++ String.cs	25 Jan 2005 19:47:13 -0000	1.4
@@ -25,12 +25,18 @@
     
     public String(IntPtr iter, Service service)
     {
-      this.val = Marshal.PtrToStringAnsi(dbus_message_iter_get_string(iter));
+      IntPtr raw;
+
+      dbus_message_iter_get_basic (iter, out raw);
+
+      this.val = Marshal.PtrToStringAnsi (raw);
     }
 
     public void Append(IntPtr iter) 
     {
-      if (!dbus_message_iter_append_string(iter, Marshal.StringToHGlobalAnsi(val)))
+      IntPtr marshalVal = Marshal.StringToHGlobalAnsi (val);
+
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
 	throw new ApplicationException("Failed to append STRING argument:" + val);
     }
 
@@ -78,9 +84,9 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static IntPtr dbus_message_iter_get_string(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_string(IntPtr iter, IntPtr value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr value);
   }
 }

Index: UInt32.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/UInt32.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- UInt32.cs	17 Dec 2004 22:21:16 -0000	1.5
+++ UInt32.cs	25 Jan 2005 19:47:13 -0000	1.6
@@ -25,12 +25,12 @@
 
     public UInt32(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_uint32(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_uint32(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append UINT32 argument:" + val);
     }
 
@@ -87,9 +87,9 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.UInt32 dbus_message_iter_get_uint32(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.UInt32 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_uint32(IntPtr iter, System.UInt32 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.UInt32 value);
   }
 }

Index: UInt64.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusType/UInt64.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- UInt64.cs	17 Dec 2004 22:21:16 -0000	1.5
+++ UInt64.cs	25 Jan 2005 19:47:13 -0000	1.6
@@ -25,12 +25,12 @@
 
     public UInt64(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_uint64(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_uint64(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
 	throw new ApplicationException("Failed to append UINT64 argument:" + val);
     }
 
@@ -87,9 +87,9 @@
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.UInt64 dbus_message_iter_get_uint64(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.UInt64 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_uint64(IntPtr iter, System.UInt64 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.UInt64 value);
   }
 }



More information about the dbus-commit mailing list