Author: joncham
Date: 2007-05-25 16:55:14 -0400 (Fri, 25 May 2007)
New Revision: 77973

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/marshal.c
Log:
2007-05-25  Jonathan Chambers  <[EMAIL PROTECTED]>

       * marshal.c: Fix interface lookup loops for
       cominterop_get_com_slot_for_method and 
       cominterop_get_method_interface. Only need to lookup
       if type is a class, else use interface type method is on.

       Code is contributed under MIT/X11 license.



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-05-25 20:22:40 UTC (rev 77972)
+++ trunk/mono/mono/metadata/ChangeLog  2007-05-25 20:55:14 UTC (rev 77973)
@@ -1,3 +1,12 @@
+2007-05-25  Jonathan Chambers  <[EMAIL PROTECTED]>
+
+       * marshal.c: Fix interface lookup loops for
+       cominterop_get_com_slot_for_method and 
+       cominterop_get_method_interface. Only need to lookup
+       if type is a class, else use interface type method is on.
+
+       Code is contributed under MIT/X11 license.
+
 2007-05-25  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * reflection.c: HasSecurity can be present even if no specially 

Modified: trunk/mono/mono/metadata/marshal.c
===================================================================
--- trunk/mono/mono/metadata/marshal.c  2007-05-25 20:22:40 UTC (rev 77972)
+++ trunk/mono/mono/metadata/marshal.c  2007-05-25 20:55:14 UTC (rev 77973)
@@ -416,27 +416,27 @@
 cominterop_get_com_slot_for_method (MonoMethod* method)
 {
        guint32 slot = method->slot;
-       GPtrArray *ifaces;
-       MonoClass *ic = NULL;
-       int i;
+       MonoClass *ic = method->klass;
 
-       ifaces = mono_class_get_implemented_interfaces (method->klass);
-       if (ifaces) {
-               int offset;
-               for (i = 0; i < ifaces->len; ++i) {
-                       ic = g_ptr_array_index (ifaces, i);
-                       offset = mono_class_interface_offset (method->klass, 
ic);
-                       if (method->slot >= offset && method->slot < offset + 
ic->method.count) {
-                               slot -= offset;
-                               break;
+       /* if method is on a class, we need to look up interface method exists 
on */
+       if (!MONO_CLASS_IS_INTERFACE(method->klass)) {
+               GPtrArray *ifaces = mono_class_get_implemented_interfaces 
(method->klass);
+               if (ifaces) {
+                       int i;
+                       for (i = 0; i < ifaces->len; ++i) {
+                               int offset;
+                               ic = g_ptr_array_index (ifaces, i);
+                               offset = mono_class_interface_offset 
(method->klass, ic);
+                               if (method->slot >= offset && method->slot < 
offset + ic->method.count) {
+                                       slot -= offset;
+                                       break;
+                               }
+                               ic = NULL;
                        }
+                       g_ptr_array_free (ifaces, TRUE);
                }
-               g_ptr_array_free (ifaces, TRUE);
        }
 
-       if (!ic)
-               ic = method->klass;
-       
        g_assert (ic);
        g_assert (MONO_CLASS_IS_INTERFACE (ic));
 
@@ -452,28 +452,27 @@
 static MonoReflectionType*
 cominterop_get_method_interface (MonoMethod* method)
 {
-       GPtrArray *ifaces;
        MonoType* t = NULL;
-       MonoClass *ic = NULL;
-       int i;
        MonoReflectionType* rt = NULL;
+       MonoClass *ic = method->klass;
 
-       ifaces = mono_class_get_implemented_interfaces (method->klass);
-       if (ifaces) {
-               int offset;
-               for (i = 0; i < ifaces->len; ++i) {
-                       ic = g_ptr_array_index (ifaces, i);
-                       offset = mono_class_interface_offset (method->klass, 
ic);
-                       if (method->slot >= offset && method->slot < offset + 
ic->method.count)
-                               break;
-                       ic = NULL;
+       /* if method is on a class, we need to look up interface method exists 
on */
+       if (!MONO_CLASS_IS_INTERFACE(method->klass)) {
+               GPtrArray *ifaces = mono_class_get_implemented_interfaces 
(method->klass);
+               if (ifaces) {
+                       int i;
+                       for (i = 0; i < ifaces->len; ++i) {
+                               int offset;
+                               ic = g_ptr_array_index (ifaces, i);
+                               offset = mono_class_interface_offset 
(method->klass, ic);
+                               if (method->slot >= offset && method->slot < 
offset + ic->method.count)
+                                       break;
+                               ic = NULL;
+                       }
+                       g_ptr_array_free (ifaces, TRUE);
                }
-               g_ptr_array_free (ifaces, TRUE);
        }
 
-       if (!ic)
-               ic = method->klass;
-
        g_assert (ic);
        g_assert (MONO_CLASS_IS_INTERFACE (ic));
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to