summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-08-06 17:39:18 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-08-06 17:39:18 +0200
commitc191d8f49e58bbc5b769780a0a17b5cec82174f1 (patch)
tree72bb1fb5c57b577bf17f055c6a37f6396e2e6d61 /Objective-C
parent6ac284ebf50cc18f42115db05feecbccd659f8eb (diff)
Make class and selector name retrieval more portable.
darcs-hash:f7a369dba0dda3e067547210ce7c008ae60cdc05
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/libobjcl.h3
-rw-r--r--Objective-C/libobjcl.m26
2 files changed, 26 insertions, 3 deletions
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h
index eefeb5e..e8bcfaf 100644
--- a/Objective-C/libobjcl.h
+++ b/Objective-C/libobjcl.h
@@ -63,3 +63,6 @@ objcl_query_arglist_info (void *receiver,
const char *
objcl_class_name (OBJCL_OBJ_DATA class);
+
+const char *
+objcl_selector_name (OBJCL_OBJ_DATA class);
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m
index 7208498..916ffa3 100644
--- a/Objective-C/libobjcl.m
+++ b/Objective-C/libobjcl.m
@@ -293,10 +293,10 @@ objcl_find_selector (const char *class_name)
const char *
objcl_class_name (OBJCL_OBJ_DATA class)
{
+ const char *ns_name;
+ char *name;
Class cls = NULL;
- /* fprintf (stderr, "---------> %s <--------\n", class->type); */
- fflush (stderr);
assert (class->type[0] == '#'
|| class->type[0] == '@'
|| class->type[0] == 'E');
@@ -307,5 +307,25 @@ objcl_class_name (OBJCL_OBJ_DATA class)
case 'E': cls = (id) class->data.exc_val;
}
- return class_get_class_name (cls);
+ ns_name = [(NSStringFromClass (cls)) UTF8String];
+ name = malloc (strlen (ns_name) + 1);
+ strcpy (name, ns_name);
+
+ return name;
+}
+
+
+const char *
+objcl_selector_name (OBJCL_OBJ_DATA selector)
+{
+ const char *ns_name;
+ char *name;
+
+ assert (selector->type[0] == ':');
+ ns_name = [(NSStringFromSelector (selector->data.sel_val))
+ UTF8String];
+ name = malloc (strlen (ns_name) + 1);
+ strcpy (name, ns_name);
+
+ return name;
}