From 6ac284ebf50cc18f42115db05feecbccd659f8eb Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Mon, 6 Aug 2007 17:02:02 +0200 Subject: Add the FIND-SELECTOR function. darcs-hash:7d6f843c808b3d130201c85c6e806d68f5a9079c --- Objective-C/libobjcl.h | 9 ++++++--- Objective-C/libobjcl.m | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index 4d6d092..eefeb5e 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -36,21 +36,24 @@ objcl_initialise_runtime (void); void objcl_shutdown_runtime (void); -void * +OBJCL_OBJ_DATA objcl_invoke_instance_method (OBJCL_OBJ_DATA receiver, const char *method_name, int argc, ...); -void * +OBJCL_OBJ_DATA objcl_invoke_class_method (OBJCL_OBJ_DATA class, const char *method_name, int argc, ...); -void * +OBJCL_OBJ_DATA objcl_find_class (const char *class_name); +OBJCL_OBJ_DATA +objcl_find_selector (const char *selector_name); + /* Return a null-terminated list of type information strings. The first entry describes the type of the method's return value. */ char ** diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 41d165c..7208498 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -164,7 +164,7 @@ _objcl_invoke_method (id self_, } -void * +OBJCL_OBJ_DATA objcl_invoke_instance_method (OBJCL_OBJ_DATA receiver, const char *method_name, int argc, @@ -211,7 +211,7 @@ objcl_invoke_instance_method (OBJCL_OBJ_DATA receiver, } -void * +OBJCL_OBJ_DATA objcl_invoke_class_method (OBJCL_OBJ_DATA class, const char *method_name, int argc, @@ -258,7 +258,7 @@ objcl_invoke_class_method (OBJCL_OBJ_DATA class, } -void * +OBJCL_OBJ_DATA objcl_find_class (const char *class_name) { Class class = @@ -274,6 +274,22 @@ objcl_find_class (const char *class_name) } +OBJCL_OBJ_DATA +objcl_find_selector (const char *class_name) +{ + SEL selector = + NSSelectorFromString ([NSString stringWithUTF8String: class_name]); + OBJCL_OBJ_DATA result = malloc (sizeof (struct objcl_object)); + const char *const typespec = ":"; + + result->type = malloc (strlen (typespec) + 1); + strcpy (result->type, typespec); + result->data.sel_val = selector; + + return result; +} + + const char * objcl_class_name (OBJCL_OBJ_DATA class) { -- cgit v1.2.3