Update of /cvsroot/foo/foo/elkfoo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2674
Modified Files:
tell.m
Log Message:
started with avoiding objc runtime functions
Index: tell.m
===================================================================
RCS file: /cvsroot/foo/foo/elkfoo/src/tell.m,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** tell.m 6 Aug 2004 00:22:11 -0000 1.7
--- tell.m 8 Aug 2004 02:28:13 -0000 1.8
***************
*** 35,40 ****
#endif
! #include <Foundation/NSInvocation.h>
! #include <Foundation/NSMethodSignature.h>
#include <objc/objc.h>
--- 35,42 ----
#endif
! #import <Foundation/NSObjCRuntime.h>
! #import <Foundation/NSString.h>
! #import <Foundation/NSInvocation.h>
! #import <Foundation/NSMethodSignature.h>
#include <objc/objc.h>
***************
*** 658,672 ****
SchemeObject selector)
{
! STR name;
! SEL sel = @selector(name); // make compiler shut up
! id obj = nil; // idem
! #ifdef NeXT_RUNTIME
! Method meth;
! #elif GNU_RUNTIME
! Method_t meth;
! #else
! #error *** NEITHER NeXT NOR GNU RUNTIME PRESENT ***
! #endif
! // Alloca_Begin;
switch (TYPE(receiver))
--- 660,670 ----
SchemeObject selector)
{
! NSString *name;
! NSMethodSignature *signature;
! SEL sel;
! id obj;
! char *types;
! int i, k;
! SchemeObject ret;
switch (TYPE(receiver))
***************
*** 676,701 ****
case T_String:
! name = Get_String(receiver);
! #ifdef NeXT_RUNTIME
! if ((obj = objc_getClass(name)) == nil)
! #elif GNU_RUNTIME
! if ((obj = objc_get_class(name)) == nil)
! #else
! #error *** NEITHER NeXT NOR GNU RUNTIME PRESENT ***
! #endif
! {
! Primitive_Error("class not found: ~s", receiver);
! }
break;
default:
! if (TYPE(receiver) == T_Pointer) {
! if (POINTER_T(receiver)->type.data != C_ID)
! Primitive_Error("illegal receiver type: ~s", receiver);
! if ((obj = (id) POINTER_T(receiver)->pointer) == nil)
! Primitive_Error("null pointer: ~s", receiver);
! }
else
! Wrong_Type_Combination(receiver, "string, symbol or pointer");
}
--- 674,702 ----
case T_String:
! name = [NSString stringWithCString: Get_String(receiver)];
! AUTORELEASE(name);
!
! if ((obj = NSClassFromString(name)) == nil)
! {
! Primitive_Error("class not found: ~s", receiver);
! }
break;
default:
! if (TYPE(receiver) == T_Pointer)
! {
! if (POINTER_T(receiver)->type.data != C_ID)
! {
! Primitive_Error("illegal receiver type: ~s", receiver);
! }
! if ((obj = (id) POINTER_T(receiver)->pointer) == nil)
! {
! Primitive_Error("null pointer: ~s", receiver);
! }
! }
else
! {
! Wrong_Type_Combination(receiver, "string, symbol or pointer");
! }
}
***************
*** 706,727 ****
case T_String:
! name = Get_String(selector);
! #ifdef NeXT_RUNTIME
! if ((sel = sel_getUid(name)) == 0)
! #elif GNU_RUNTIME
! if ((sel = sel_get_uid(name)) == 0)
! #else
! #error *** NEITHER NeXT NOR GNU RUNTIME PRESENT ***
! #endif
! {
! Primitive_Error("selector not found: ~s", selector);
! }
! // new: this avoids breakdown in class_get_instance_method
! if ([obj respondsToSelector: sel] == NO)
{
! Primitive_Error("object does not understand selector: ~s", selector);
}
break;
--- 707,722 ----
case T_String:
! name = [NSString stringWithCString: Get_String(selector)];
! AUTORELEASE(name);
! if ((sel = NSSelectorFromString(name)) == 0)
{
! Primitive_Error("selector not found: ~s", selector);
}
+ if ((signature = [obj methodSignatureForSelector: sel]) == nil)
+ {
+ Primitive_Error("object does not understand selector: ~s", selector);
+ }
break;
***************
*** 730,746 ****
}
! #ifdef NeXT_RUNTIME
! if ((meth = class_getInstanceMethod(obj->isa, sel)) == NULL)
! #elif GNU_RUNTIME
! if ((meth = class_get_instance_method(obj->class_pointer, sel)) == NULL)
! #else
! #error *** NEITHER NeXT NOR GNU RUNTIME PRESENT ***
! #endif
! {
! Primitive_Error("can't access method for selector: ~s", selector);
! }
! // Alloca_End;
! return Make_String(meth->method_types, strlen(meth->method_types));
}
--- 725,740 ----
}
! types = malloc([signature frameLength]);
! *types = 0;
! for (i = 2; i < [signature numberOfArguments]; ++i)
! {
! strcat(types, [signature getArgumentTypeAtIndex: i]);
! }
!
! ret = Make_String(types, strlen(types));
! free(types);
!
! return ret;
}
***************
*** 749,756 ****
P_Selector (SchemeObject selector)
{
! STR name;
! SEL sel = @selector(name); // make compiler shut up
SchemeObject result;
- // Alloca_Begin;
switch (TYPE(selector))
--- 743,749 ----
P_Selector (SchemeObject selector)
{
! NSString *name;
! SEL sel;
SchemeObject result;
switch (TYPE(selector))
***************
*** 760,774 ****
case T_String:
! name = Get_String(selector);
! #ifdef NeXT_RUNTIME
! if ((sel = sel_getUid(name)) == 0)
! #elif GNU_RUNTIME
! if ((sel = sel_get_uid(name)) == 0)
! #else
! #error *** NEITHER NeXT NOR GNU RUNTIME PRESENT ***
! #endif
! {
! Primitive_Error("selector not found: ~s", selector);
! }
break;
--- 753,763 ----
case T_String:
! name = [NSString stringWithCString: Get_String(selector)];
! AUTORELEASE(name);
!
! if ((sel = NSSelectorFromString(name)) == 0)
! {
! Primitive_Error("selector not found: ~s", selector);
! }
break;
***************
*** 776,789 ****
Wrong_Type_Combination(selector, "string or symbol");
}
- // Alloca_End;
! if (sel_isMapped(sel) == NO)
! {
! return False;
! }
! else
! {
! return A_Make_Pointer((int)sel, C_SEL);
! }
}
--- 765,770 ----
Wrong_Type_Combination(selector, "string or symbol");
}
! return A_Make_Pointer((int)sel, C_SEL);
}
|