* 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
This commit is contained in:
ayers 2006-12-13 09:32:15 +00:00
parent aa738fa379
commit a7e0e11235
4 changed files with 101 additions and 57 deletions

View file

@ -1,3 +1,11 @@
2006-12-13 David Ayers <ayers@fsfe.org>
* 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 <ratmice@gmail.com> 2006-12-05 Matt Rice <ratmice@gmail.com>
* Source/NSBundle.m (+initialize): Remove usage of classes local array. * Source/NSBundle.m (+initialize): Remove usage of classes local array.

View file

@ -28,6 +28,7 @@
#include "callframe.h" #include "callframe.h"
#include "Foundation/NSException.h" #include "Foundation/NSException.h"
#include "Foundation/NSData.h" #include "Foundation/NSData.h"
#include "Foundation/NSDebug.h"
#include "GSInvocation.h" #include "GSInvocation.h"
#if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32))
@ -235,6 +236,8 @@ callframe_do_call (DOContext *ctxt,
id object; id object;
/* The selector for the message we're sending to the TARGET. */ /* The selector for the message we're sending to the TARGET. */
SEL selector; SEL selector;
/* The OBJECT's Method(_t) pointer for the SELECTOR. */
GSMethod meth;
/* The OBJECT's implementation of the SELECTOR. */ /* The OBJECT's implementation of the SELECTOR. */
IMP method_implementation; IMP method_implementation;
/* Type qualifier flags; see <objc/objc-api.h>. */ /* Type qualifier flags; see <objc/objc-api.h>. */
@ -276,25 +279,34 @@ callframe_do_call (DOContext *ctxt,
as the ENCODED_TYPES string, but it will have different register as the ENCODED_TYPES string, but it will have different register
and stack locations if the ENCODED_TYPES came from a machine of a and stack locations if the ENCODED_TYPES came from a machine of a
different architecture. */ different architecture. */
#if NeXT_RUNTIME if (GSObjCIsClass(object))
{ {
Method m; meth = GSGetMethod(object, selector, NO, YES);
m = class_getInstanceMethod(object->isa, selector); }
if (!m) else if (GSObjCIsInstance)
abort(); {
type = m->method_types; meth = GSGetMethod(GSObjCClass(object), selector, YES, YES);
} }
#elif 0 else
{ {
Method_t m; [NSException raise: NSInvalidArgumentException
m = class_get_instance_method (object->class_pointer, format: @"decoded object %p is invalid", object];
selector); }
NSCParameterAssert (m);
type = m->method_types; if (meth != 0)
} {
#else type = meth->method_types;
type = sel_get_type (selector); }
#endif /* NeXT_runtime */ 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 /* Make sure we successfully got the method type, and that its
types match the ENCODED_TYPES. */ types match the ENCODED_TYPES. */

View file

@ -28,6 +28,7 @@
#include "cifframe.h" #include "cifframe.h"
#include "Foundation/NSException.h" #include "Foundation/NSException.h"
#include "Foundation/NSData.h" #include "Foundation/NSData.h"
#include "Foundation/NSDebug.h"
#include "GSInvocation.h" #include "GSInvocation.h"
#if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32))
@ -632,6 +633,8 @@ cifframe_do_call (DOContext *ctxt,
id object; id object;
/* The selector for the message we're sending to the TARGET. */ /* The selector for the message we're sending to the TARGET. */
SEL selector; SEL selector;
/* The OBJECT's Method(_t) pointer for the SELECTOR. */
GSMethod meth;
/* The OBJECT's implementation of the SELECTOR. */ /* The OBJECT's implementation of the SELECTOR. */
IMP method_implementation; IMP method_implementation;
/* Type qualifier flags; see <objc/objc-api.h>. */ /* Type qualifier flags; see <objc/objc-api.h>. */
@ -673,25 +676,34 @@ cifframe_do_call (DOContext *ctxt,
as the ENCODED_TYPES string, but it will have different register as the ENCODED_TYPES string, but it will have different register
and stack locations if the ENCODED_TYPES came from a machine of a and stack locations if the ENCODED_TYPES came from a machine of a
different architecture. */ different architecture. */
#if NeXT_RUNTIME if (GSObjCIsClass(object))
{ {
Method m; meth = GSGetMethod(object, selector, NO, YES);
m = class_getInstanceMethod(object->isa, selector); }
if (!m) else if (GSObjCIsInstance)
abort(); {
type = m->method_types; meth = GSGetMethod(GSObjCClass(object), selector, YES, YES);
} }
#elif 0 else
{ {
Method_t m; [NSException raise: NSInvalidArgumentException
m = class_get_instance_method (object->class_pointer, format: @"decoded object %p is invalid", object];
selector); }
NSCParameterAssert (m);
type = m->method_types; if (meth != 0)
} {
#else type = meth->method_types;
type = sel_get_type (selector); }
#endif /* NeXT_runtime */ 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 /* Make sure we successfully got the method type, and that its
types match the ENCODED_TYPES. */ types match the ENCODED_TYPES. */

View file

@ -38,6 +38,7 @@
#include "Foundation/NSObjCRuntime.h" #include "Foundation/NSObjCRuntime.h"
#include "Foundation/NSData.h" #include "Foundation/NSData.h"
#include "Foundation/NSException.h" #include "Foundation/NSException.h"
#include "Foundation/NSDebug.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
@ -801,6 +802,8 @@ mframe_do_call (DOContext *ctxt,
id object; id object;
/* The selector for the message we're sending to the TARGET. */ /* The selector for the message we're sending to the TARGET. */
SEL selector; SEL selector;
/* The OBJECT's Method(_t) pointer for the SELECTOR. */
GSMethod meth;
/* The OBJECT's implementation of the SELECTOR. */ /* The OBJECT's implementation of the SELECTOR. */
IMP method_implementation; IMP method_implementation;
/* The number bytes for holding arguments passed on the stack. */ /* 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 as the ENCODED_TYPES string, but it will have different register
and stack locations if the ENCODED_TYPES came from a machine of a and stack locations if the ENCODED_TYPES came from a machine of a
different architecture. */ different architecture. */
#if NeXT_RUNTIME if (GSObjCIsClass(object))
{ {
Method m; meth = GSGetMethod(object, selector, NO, YES);
m = class_getInstanceMethod(object->isa, selector); }
if (!m) else if (GSObjCIsInstance)
abort(); {
type = m->method_types; meth = GSGetMethod(GSObjCClass(object), selector, YES, YES);
} }
#elif 0 else
{ {
Method_t m; [NSException raise: NSInvalidArgumentException
m = class_get_instance_method (object->class_pointer, format: @"decoded object %p is invalid", object];
selector); }
NSCParameterAssert (m);
type = m->method_types; if (meth != 0)
} {
#else type = meth->method_types;
type = sel_get_type (selector); }
#endif /* NeXT_runtime */ 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 /* Make sure we successfully got the method type, and that its
types match the ENCODED_TYPES. */ types match the ENCODED_TYPES. */