dbus/mono Arguments.cs, 1.2, 1.3 ProxyBuilder.cs, 1.2, 1.3 Service.cs, 1.2, 1.3

Owen Fraser-Green ow3n at pdx.freedesktop.org
Wed Mar 24 05:15:22 PST 2004


Update of /cvs/dbus/dbus/mono
In directory pdx:/tmp/cvs-serv1352

Modified Files:
	Arguments.cs ProxyBuilder.cs Service.cs 
Log Message:
Made all DBusTypes take Service in the constructor because Array also needed it in the case of an array of OBJECT_PATH objects.


Index: Arguments.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Arguments.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/Arguments.cs	23 Mar 2004 18:07:48 -0000	1.2
+++ b/Arguments.cs	24 Mar 2004 13:15:20 -0000	1.3
@@ -74,17 +74,15 @@
     // Append an argument
     public void Append(DBusType.IDBusType dbusType)
     {
-      if (dbusType.GetType() == typeof(DBusType.ObjectPath)) {
-	((DBusType.ObjectPath) dbusType).SetService(message.Service);
-      }
       dbusType.Append(appenderIter);
     }
     
     // Append an argument of the specified type
     private void AppendType(Type type, object val)
     {
-      object [] pars = new Object[1];
+      object [] pars = new Object[2];
       pars[0] = val;
+      pars[1] = message.Service;
       DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(MatchType(type), pars);
       Append(dbusType);
     }
@@ -163,7 +161,7 @@
     // Get the appropriate constructor for a D-BUS type
     public static ConstructorInfo GetDBusTypeConstructor(Type dbusType, Type type) 
     {
-      ConstructorInfo constructor = dbusType.GetConstructor(new Type[] {type.UnderlyingSystemType});
+      ConstructorInfo constructor = dbusType.GetConstructor(new Type[] {type.UnderlyingSystemType, typeof(Service)});
       if (constructor == null)
 	throw new ArgumentException("There is no valid constructor for '" + dbusType + "' from type '" + type + "'");
       
@@ -254,17 +252,13 @@
       {
 	get
 	  {
-	    object [] pars = new Object[1];
+	    object [] pars = new Object[2];
 	    pars[0] = iter;
+	    pars[1] = arguments.message.Service;
 	    
 	    Type type = (Type) DBusTypes[(char) dbus_message_iter_get_arg_type(iter)];
 	    DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(type, pars);
 
-	    // Special case for ObjectPath
-	    if (type == typeof(DBusType.ObjectPath)) {
-	      ((DBusType.ObjectPath) dbusType).SetService(arguments.message.Service);
-	    }
-	    
 	    return dbusType;
 	  }
       }

Index: ProxyBuilder.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/ProxyBuilder.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/ProxyBuilder.cs	23 Mar 2004 18:07:48 -0000	1.2
+++ b/ProxyBuilder.cs	24 Mar 2004 13:15:20 -0000	1.3
@@ -108,7 +108,7 @@
       for (int parN = 0; parN < pars.Length; parN++) {
 	ParameterInfo par = pars[parN];
 	if (!par.IsOut) {
-	  EmitIn(generator, par.ParameterType, parN);
+	  EmitIn(generator, par.ParameterType, parN, serviceF);
 	}
       }
       
@@ -145,7 +145,7 @@
       typeB.DefineMethodOverride(methodBuilder, method);
     }
 
-    private void EmitIn(ILGenerator generator, Type parType, int parN)
+    private void EmitIn(ILGenerator generator, Type parType, int parN, FieldInfo serviceF)
     {
       Type inParType = Arguments.MatchType(parType);
       //generator.EmitWriteLine("methodCall.Arguments.Append(...)");
@@ -157,6 +157,7 @@
       object[] pars = new object[] {generator, parType};
       inParType.InvokeMember("EmitMarshalIn", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, pars, null);
 
+      generator.Emit(OpCodes.Ldsfld, serviceF);
       generator.Emit(OpCodes.Newobj, Arguments.GetDBusTypeConstructor(inParType, parType));
       generator.EmitCall(OpCodes.Callvirt, Arguments_AppendMI, null);
     }

Index: Service.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Service.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/Service.cs	23 Mar 2004 18:07:48 -0000	1.2
+++ b/Service.cs	24 Mar 2004 13:15:20 -0000	1.3
@@ -75,6 +75,10 @@
 
     internal Handler GetHandler(object handledObject) 
     {
+      if (!registeredHandlers.Contains(handledObject)) {
+	throw new ArgumentException("No handler registered for object: " + handledObject);
+      }
+      
       return (Handler) registeredHandlers[handledObject];
     }
 




More information about the dbus-commit mailing list