diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 01:28:21 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 01:28:21 +0200 |
commit | c9d12c3ac0b14ec509ab63ac8d915bcf33f5ae06 (patch) | |
tree | 8c6686055ecc1bb0029d383bcf0180d90ceb567d | |
parent | dccb7b26e4999d0c0c6a44cc1cae585bfdd92863 (diff) |
Objective-C layer: Remove the code needed by the obsolete version of INVOKE-BY-NAME.
darcs-hash:e0df5f7b1d7a3aa5e06170dbe318b31ebeb73241
-rw-r--r-- | Lisp/data-types.lisp | 32 | ||||
-rw-r--r-- | Lisp/libobjcl.lisp | 7 | ||||
-rw-r--r-- | Objective-C/libobjcl.h | 27 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 230 |
4 files changed, 0 insertions, 296 deletions
diff --git a/Lisp/data-types.lisp b/Lisp/data-types.lisp index 7b07624..7515d3a 100644 --- a/Lisp/data-types.lisp +++ b/Lisp/data-types.lisp @@ -12,38 +12,6 @@ ;;;; (@* "Foreign data types") (defctype char-pointer :pointer) -;; Let us just hope that two longs make a long long, space-wise. -(defcstruct double-long - (left :long) - (right :long)) - -(defcunion obj-data-union - (id-val :pointer) - (class-val :pointer) - (exc-val :pointer) - (sel-val :pointer) - (char-val :char) - (short-val :short) - (int-val :int) - (long-val :long) - #-cffi-features:no-long-long (long-long-val :long-long) - #+cffi-features:no-long-long (double-long-val double-long) - (float-val :float) - (double-val :double) - (bool-val :boolean) - (charptr-val :pointer) - (ptr-val :pointer)) - -(defcstruct obj-data - (type char-pointer) - (data obj-data-union)) - -(defmethod translate-to-foreign ((value string) (type (eql 'char-pointer))) - (foreign-string-alloc value)) - -(defmethod translate-from-foreign (c-value (type (eql 'char-pointer))) - (foreign-string-to-lisp c-value)) - ;;;; (@* "Objective C object wrapper classes") (defclass c-pointer-wrapper () diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index 85dfc45..33bc460 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -25,13 +25,6 @@ (defcfun ("objcl_shutdown_runtime" %shutdown-runtime) :void) -(defcfun ("objcl_invoke_method" - %objcl-invoke-method) obj-data - (receiver obj-data) - (method-selector :pointer) - (argc :int) - &rest) - (defcfun ("objcl_invoke_with_types" %objcl-invoke-with-types) :pointer (argc :int) (return_typespec :string) diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index 8b37609..fae8636 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -11,33 +11,6 @@ extern NSException *objcl_oom_exception; -typedef struct objcl_object -{ - char* type; - - union - { - id id_val; - Class class_val; - NSException *exc_val; - SEL sel_val; - char char_val; - short short_val; - int int_val; - long long_val; - long long long_long_val; - float float_val; - double double_val; - BOOL bool_val; - char *charptr_val; - void *ptr_val; - } data; -} *OBJCL_OBJ_DATA; - - -#define EXCEPTION_TYPESPEC "ERROR" - - void objcl_initialise_runtime (void); diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 15855ed..11450f7 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -36,236 +36,6 @@ objcl_shutdown_runtime (void) } -#ifdef __NEXT_RUNTIME__ -size_t -objc_sizeof_type (const char *typespec) -{ - switch (typespec[0]) - { - case '@': return sizeof (id); - case '#': return sizeof (Class); - case ':': return sizeof (SEL); - case 'c': return sizeof (char); - case 'C': return sizeof (unsigned char); - case 's': return sizeof (short); - case 'S': return sizeof (unsigned short); - case 'i': return sizeof (int); - case 'I': return sizeof (unsigned int); - case 'l': return sizeof (long); - case 'L': return sizeof (unsigned long); - case 'q': return sizeof (long long); - case 'Q': return sizeof (unsigned long long); - case 'f': return sizeof (float); - case 'd': return sizeof (double); - case 'B': return sizeof (BOOL); - case '?': - case '^': return sizeof (void *); - case '*': return sizeof (char *); - default: - NSLog (@"Dammit. What the heck is `%s' supposed to mean?", - typespec); - return 0; /* FIXME: Should signal an error. */ - } -} -#endif - - -static void -_objcl_get_arg_pointer (void *buffer, OBJCL_OBJ_DATA argdata) -{ - void *source = NULL; - - switch (argdata->type[0]) - { - case '@': source = &argdata->data.id_val; break; - case '#': source = &argdata->data.id_val; break; - case ':': source = &argdata->data.sel_val; break; - case 'c': source = &argdata->data.char_val; break; - case 'C': source = &argdata->data.char_val; break; - case 's': source = &argdata->data.short_val; break; - case 'S': source = &argdata->data.short_val; break; - case 'i': source = &argdata->data.int_val; break; - case 'I': source = &argdata->data.int_val; break; - case 'l': source = &argdata->data.long_val; break; - case 'L': source = &argdata->data.long_val; break; - case 'q': source = &argdata->data.long_long_val; break; - case 'Q': source = &argdata->data.long_long_val; break; - case 'f': source = &argdata->data.float_val; break; - case 'd': source = &argdata->data.double_val; break; - case 'B': source = &argdata->data.bool_val; break; -/* _OBJCL_ARG_CASE(_C_PTR, ptr); */ - case '^': source = &argdata->data.ptr_val; break; - case '?': source = &argdata->data.ptr_val; break; - case '*': source = &argdata->data.charptr_val; break; -/* - case 'v': source = &argdata->data.oid_val; break; - case 'b': source = &argdata->data.bitfield_val; break; - _OBJCL_ARG_CASE(_C_ATOM, atom); - _OBJCL_ARG_CASE(_C_ARY_B, ); - _OBJCL_ARG_CASE(_C_UNION_B, ); - _OBJCL_ARG_CASE(_C_STRUCT_B, ); - _OBJCL_ARG_CASE(_C_VECTOR, ); - _OBJCL_ARG_CASE(_C_COMPLEX, ); -*/ -/* case '?': */ - default: - NSLog (@"Dammit. What the heck is `%s' supposed to mean?", - argdata->type); - return; /* FIXME: Should signal an error. */ - } - - memmove (buffer, source, objc_sizeof_type (argdata->type)); -} - - -static void -_objcl_invoke_method (id self_, - OBJCL_OBJ_DATA result, - NSMethodSignature *signature, - SEL selector, - int argc, - va_list arglist) -{ - int i; - NSInvocation *invocation; - void *result_ptr = NULL; - const char *type = [signature methodReturnType]; - - result->type = malloc (strlen (type) + 1); - strcpy (result->type, type); - - if (signature == NULL) - { - [[NSException exceptionWithName: @"MLKNoSignatureFoundException" - reason: @"No signature found" - userInfo: NULL] raise]; - } - - - switch (type[0]) - { - case '@': result_ptr = &(result->data.id_val); break; - case '#': result_ptr = &result->data.id_val; break; - case ':': result_ptr = &result->data.sel_val; break; - case 'c': result_ptr = &result->data.char_val; break; - case 'C': result_ptr = &result->data.char_val; break; - case 's': result_ptr = &result->data.short_val; break; - case 'S': result_ptr = &result->data.short_val; break; - case 'i': result_ptr = &result->data.int_val; break; - case 'I': result_ptr = &result->data.int_val; break; - case 'l': result_ptr = &result->data.long_val; break; - case 'L': result_ptr = &result->data.long_val; break; - case 'q': result_ptr = &result->data.long_long_val; break; - case 'Q': result_ptr = &result->data.long_long_val; break; - case 'f': result_ptr = &result->data.float_val; break; - case 'd': result_ptr = &result->data.double_val; break; - case 'B': result_ptr = &result->data.bool_val; break; - case '?': - case '^': result_ptr = &result->data.ptr_val; break; - case '*': result_ptr = &result->data.charptr_val; break; - /* - case _C_BFLD: result_ptr = &result->data._val; break; - case _C_VOID: result_ptr = &result->data._val; break; - case _C_UNDEF: result_ptr = &result->data._val; break; - case _C_ATOM: result_ptr = &result->data._val; break; - case _C_ARY_B: result_ptr = &result->data._val; break; - case _C_ARY_E: result_ptr = &result->data._val; break; - case _C_UNION_B: result_ptr = &result->data._val; break; - case _C_UNION_E: result_ptr = &result->data._val; break; - case _C_STRUCT_B: result_ptr = &result->data._val; break; - case _C_STRUCT_E: result_ptr = &result->data._val; break; - case _C_VECTOR: result_ptr = &result->data._val; break; - case _C_COMPLEX: result_ptr = &result->data._val; break; - */ - } - - invocation = [NSInvocation invocationWithMethodSignature: signature]; - [invocation setTarget: self_]; - [invocation setSelector: selector]; - - for (i = 0; i < argc; i++) - { - const char* type = [signature getArgumentTypeAtIndex: (i + 2)]; - void *buffer = malloc (objc_sizeof_type (type)); - OBJCL_OBJ_DATA arg = va_arg (arglist, OBJCL_OBJ_DATA); - _objcl_get_arg_pointer (buffer, arg); - - if (type[0] == '#') - NSLog (@"Argument %d: %@ (type %s)", i, buffer, type); - else - NSLog (@"Argument %d: type %s.", i, type); - - [invocation setArgument: buffer - atIndex: (i + 2)]; - - free (buffer); - } - - [invocation retainArguments]; - NSLog (@"Invoking %@ on %@.", invocation, self_); - [invocation invoke]; - NSLog (@"Fetching return value."); - [invocation getReturnValue: result_ptr]; - if (result->type[0] == '#') - NSLog (@"Returning: %@", result->data.id_val); - else - NSLog (@"Returning."); -} - - -OBJCL_OBJ_DATA -objcl_invoke_method (OBJCL_OBJ_DATA receiver, - SEL method_selector, - int argc, - ...) -{ - va_list arglist; - id self_ = NULL; - NSMethodSignature *signature; - OBJCL_OBJ_DATA result = malloc (sizeof (struct objcl_object)); - - NS_DURING - { - switch (receiver->type[0]) - { - case '#': - self_ = receiver->data.class_val; - break; - case '@': - self_ = receiver->data.id_val; - break; - case 'E': - self_ = receiver->data.exc_val; - break; - default: - return NULL; - } - - - signature = [self_ methodSignatureForSelector: method_selector]; - - va_start (arglist, argc); - _objcl_invoke_method (self_, - result, - signature, - method_selector, - argc, - arglist); - va_end (arglist); - } - NS_HANDLER - { - result->type = malloc (strlen (EXCEPTION_TYPESPEC) + 1); - strcpy (result->type, EXCEPTION_TYPESPEC); - result->data.exc_val = localException; - NS_VALUERETURN (result, void *); - } - NS_ENDHANDLER - - return result; -} - - #ifdef USE_LIBFFI id objcl_invoke_with_types (int argc, |