From a7e0e11235976ba18a8f2dd308f7d36346b60b98 Mon Sep 17 00:00:00 2001 From: ayers Date: Wed, 13 Dec 2006 09:32:15 +0000 Subject: [PATCH] * Source/mframe.m (mframe_do_call), * Source/cifframe.m (cifframe_do_call), * Source/callframe.m (callframe_do_call): Simplify by using GSObjCRuntime functions. Add fallback selector search for invocations passed to proxies. Add debug diagnostics. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24202 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/callframe.m | 50 ++++++++++++++++++++++++++++------------------ Source/cifframe.m | 50 ++++++++++++++++++++++++++++------------------ Source/mframe.m | 50 ++++++++++++++++++++++++++++------------------ 4 files changed, 101 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78c719ab7..bf103b7ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-12-13 David Ayers + + * Source/mframe.m (mframe_do_call), + * Source/cifframe.m (cifframe_do_call), + * Source/callframe.m (callframe_do_call): Simplify by using + GSObjCRuntime functions. Add fallback selector search for invocations + passed to proxies. Add debug diagnostics. + 2006-12-05 Matt Rice * Source/NSBundle.m (+initialize): Remove usage of classes local array. diff --git a/Source/callframe.m b/Source/callframe.m index dece3d5e5..f9c0878c5 100644 --- a/Source/callframe.m +++ b/Source/callframe.m @@ -28,6 +28,7 @@ #include "callframe.h" #include "Foundation/NSException.h" #include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" #include "GSInvocation.h" #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) @@ -235,6 +236,8 @@ callframe_do_call (DOContext *ctxt, id object; /* The selector for the message we're sending to the TARGET. */ SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; /* The OBJECT's implementation of the SELECTOR. */ IMP method_implementation; /* Type qualifier flags; see . */ @@ -276,25 +279,34 @@ callframe_do_call (DOContext *ctxt, as the ENCODED_TYPES string, but it will have different register and stack locations if the ENCODED_TYPES came from a machine of a different architecture. */ -#if NeXT_RUNTIME - { - Method m; - m = class_getInstanceMethod(object->isa, selector); - if (!m) - abort(); - type = m->method_types; - } -#elif 0 - { - Method_t m; - m = class_get_instance_method (object->class_pointer, - selector); - NSCParameterAssert (m); - type = m->method_types; - } -#else - type = sel_get_type (selector); -#endif /* NeXT_runtime */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } /* Make sure we successfully got the method type, and that its types match the ENCODED_TYPES. */ diff --git a/Source/cifframe.m b/Source/cifframe.m index d17b3d1ef..8c5d19a6d 100644 --- a/Source/cifframe.m +++ b/Source/cifframe.m @@ -28,6 +28,7 @@ #include "cifframe.h" #include "Foundation/NSException.h" #include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" #include "GSInvocation.h" #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) @@ -632,6 +633,8 @@ cifframe_do_call (DOContext *ctxt, id object; /* The selector for the message we're sending to the TARGET. */ SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; /* The OBJECT's implementation of the SELECTOR. */ IMP method_implementation; /* Type qualifier flags; see . */ @@ -673,25 +676,34 @@ cifframe_do_call (DOContext *ctxt, as the ENCODED_TYPES string, but it will have different register and stack locations if the ENCODED_TYPES came from a machine of a different architecture. */ -#if NeXT_RUNTIME - { - Method m; - m = class_getInstanceMethod(object->isa, selector); - if (!m) - abort(); - type = m->method_types; - } -#elif 0 - { - Method_t m; - m = class_get_instance_method (object->class_pointer, - selector); - NSCParameterAssert (m); - type = m->method_types; - } -#else - type = sel_get_type (selector); -#endif /* NeXT_runtime */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } /* Make sure we successfully got the method type, and that its types match the ENCODED_TYPES. */ diff --git a/Source/mframe.m b/Source/mframe.m index ffbaee1ca..956ce83ed 100644 --- a/Source/mframe.m +++ b/Source/mframe.m @@ -38,6 +38,7 @@ #include "Foundation/NSObjCRuntime.h" #include "Foundation/NSData.h" #include "Foundation/NSException.h" +#include "Foundation/NSDebug.h" #include #include #include @@ -801,6 +802,8 @@ mframe_do_call (DOContext *ctxt, id object; /* The selector for the message we're sending to the TARGET. */ SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; /* The OBJECT's implementation of the SELECTOR. */ IMP method_implementation; /* The number bytes for holding arguments passed on the stack. */ @@ -865,25 +868,34 @@ mframe_do_call (DOContext *ctxt, as the ENCODED_TYPES string, but it will have different register and stack locations if the ENCODED_TYPES came from a machine of a different architecture. */ -#if NeXT_RUNTIME - { - Method m; - m = class_getInstanceMethod(object->isa, selector); - if (!m) - abort(); - type = m->method_types; - } -#elif 0 - { - Method_t m; - m = class_get_instance_method (object->class_pointer, - selector); - NSCParameterAssert (m); - type = m->method_types; - } -#else - type = sel_get_type (selector); -#endif /* NeXT_runtime */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } /* Make sure we successfully got the method type, and that its types match the ENCODED_TYPES. */