- Class _class(CYCastNSObject(pool, context, arguments[0]));
- SEL sel(internal->GetValue());
- objc_method *method(class_getInstanceMethod(_class, sel));
- const char *type(CYPoolTypeEncoding(pool, _class, sel, method));
- return type == NULL ? CYJSNull(context) : CYCastJSValue(context, CYJSString(type));
+ NSObject *value(CYCastNSObject(pool, context, arguments[0]));
+ if (value == NULL) lookup:
+ // XXX: do a lookup of some kind
+ return CYJSNull(context);
+ else if (!CYIsClass(value))
+ @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Selector.type takes a Class" userInfo:nil];
+ else {
+ Class _class((Class) value);
+ SEL sel(internal->GetValue());
+ if (objc_method *method = class_getInstanceMethod(_class, sel)) {
+ const char *type(CYPoolTypeEncoding(pool, _class, sel, method));
+ return type == NULL ? CYJSNull(context) : CYCastJSValue(context, CYJSString(type));
+ } else goto lookup;
+ }