[Kde-bindings] branches/work/kdebindings-smoke2/csharp/qyoto/src

Arno Rehn kde at arnorehn.de
Sun Apr 20 11:56:16 UTC 2008


SVN commit 799107 by arnorehn:

* Since Mono 1.9 inherited private members are not included in the search
  by Type.Get*. So now search in the whole hierarchy for the private field
  'smokeObject'.
  (also ported to branch/4.0 and trunk)

CCMAIL: kde-bindings at kde.org



 M  +13 -5     SmokeMarshallers.cs  


--- branches/work/kdebindings-smoke2/csharp/qyoto/src/SmokeMarshallers.cs #799106:799107
@@ -236,7 +236,7 @@
 		
 		public static void SetSmokeObject(IntPtr instancePtr, IntPtr smokeObjectPtr) {
 			Object instance = ((GCHandle) instancePtr).Target;
-//			Debug.Assert(instance != null);
+// 			Debug.Assert(instance != null);
 
 			SmokeClassData data = GetSmokeClassData(instance.GetType());
 			data.smokeObjectField.SetValue(instance, smokeObjectPtr);
@@ -460,14 +460,22 @@
 //			Debug.Assert(	result.proxyCreator != null, 
 //							"GetSmokeClassData(\"" + result.className + "\") no CreateProxy() found" );
 
-			result.smokeObjectField = t.GetField(	"smokeObject", 
-													BindingFlags.NonPublic 
-													| BindingFlags.GetField
-													| BindingFlags.Instance );
+			result.smokeObjectField = GetPrivateFieldInfo(t, "smokeObject");
 
 			return result;
 		}
 
+		public static FieldInfo GetPrivateFieldInfo(Type type, string name) {
+			Type t = type;
+			FieldInfo fi = null;
+			while (t != typeof(object)) {
+				fi = t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
+				if (fi != null) return fi;
+				t = t.BaseType;
+			}
+			return null;
+		}
+
 		// The class is not a custom subclass of a Qyoto class, and also is not
 		// a superclass of a Qyoto class, such as a MarshalByRefObject.
 		public static bool IsSmokeClass(Type klass) {



More information about the Kde-bindings mailing list