From b47bc1b65a3db942bb7e7b2e9b62ddc92d98ca8f Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Mon, 3 Mar 2008 18:33:47 +0100 Subject: Avoid calling objcl_class_name on unregistered classes. darcs-hash:ea38f791e7f2bdc840e92709e1b915d985cc9700 --- Lisp/libobjcl.lisp | 1 + Lisp/method-definition.lisp | 1 + Objective-C/libobjcl.h | 1 + Objective-C/libobjcl.m | 14 +++++++------- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index f13d298..394672e 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -162,6 +162,7 @@ (defcfun ("objcl_add_method" %objcl-add-method) :void (class :pointer) + (class-name :string) (method-name :pointer) (callback :pointer) (argc :int) diff --git a/Lisp/method-definition.lisp b/Lisp/method-definition.lisp index f368423..1ed0b9c 100644 --- a/Lisp/method-definition.lisp +++ b/Lisp/method-definition.lisp @@ -130,6 +130,7 @@ do (setf (mem-aref arg-typestring-buffer :string i) (allocate-temp typestring))) (%objcl-add-method (pointer-to class) + (symbol->objc-class-name (class-name class)) (pointer-to method-name) callback (- (length arg-typestrings) 2) diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index c9b7345..ee5e03f 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -199,6 +199,7 @@ objcl_create_class (const char *class_name, void objcl_add_method (Class class, + const char *class_name, SEL method_name, IMP callback, int argc, diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 5ef51c2..c4dc718 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -864,6 +864,7 @@ objcl_create_class (const char *class_name, void objcl_add_method (Class class, + const char *class_name, SEL method_name, IMP callback, int argc, @@ -884,15 +885,14 @@ objcl_add_method (Class class, else preclass_addMethod (class, method_name, imp, signature); #else - NSString *class_name; struct ObjCLMethod **methods; int index; - class_name = [NSString stringWithUTF8String: objcl_class_name (class)]; + NSString *class_name_id = [NSString stringWithUTF8String: class_name]; - TRACE (@"add-method: Find class."); - index = [[method_list_lengths objectForKey: class_name] intValue]; - methods = [[method_lists objectForKey: class_name] pointerValue]; + TRACE (@"add-method: Finding class."); + index = [[method_list_lengths objectForKey: class_name_id] intValue]; + methods = [[method_lists objectForKey: class_name_id] pointerValue]; TRACE (@"add-method: malloc"); methods = realloc (methods, (index + 1) * sizeof (struct ObjCLMethod *)); @@ -907,9 +907,9 @@ objcl_add_method (Class class, TRACE (@"add-method: Adding method to dictionary."); [method_lists setObject: [NSValue valueWithPointer: methods] - forKey: class_name]; + forKey: class_name_id]; [method_list_lengths setObject: [NSNumber numberWithInt: (index + 1)] - forKey: class_name]; + forKey: class_name_id]; #endif TRACE (@"Method added."); -- cgit v1.2.3