147 NSString *formatted =
nil;
149 if (JSVAL_IS_INT(val)) formatted = [NSString stringWithFormat:@"%i", JSVAL_TO_INT(val)];
150 else if (JSVAL_IS_DOUBLE(val)) formatted = [NSString stringWithFormat:@"%g", JSVAL_TO_DOUBLE(val)];
151 else if (JSVAL_IS_BOOLEAN(val)) formatted = (JSVAL_TO_BOOLEAN(val)) ?
@"true" :
@"false";
152 else if (JSVAL_IS_STRING(val))
154 JSString *
string = JSVAL_TO_STRING(val);
155 const jschar *chars = NULL;
156 size_t length = JS_GetStringLength(
string);
158 if (JS_StringHasBeenInterned(
string))
160 chars = JS_GetInternedStringChars(
string);
164 if (chars == NULL) formatted = [NSString stringWithFormat:@"string [%zu chars]", length];
165 else formatted = [NSString stringWithCharacters:chars length:length];
167 else if (JSVAL_IS_VOID(val))
return "undefined";
170 return [formatted UTF8String];
190 NSString *formatted =
nil;
192 if (JSID_IS_INT(anID)) formatted = [NSString stringWithFormat:@"%i", JSID_TO_INT(anID)];
193 else if (JSID_IS_VOID(anID))
return "void";
194 else if (JSID_IS_EMPTY(anID))
return "empty";
195 else if (JSID_IS_ZERO(anID))
return "0";
196 else if (JSID_IS_OBJECT(anID))
return OOJSGetClass(NULL, JSID_TO_OBJECT(anID))->name;
197 else if (JSID_IS_DEFAULT_XML_NAMESPACE(anID))
return "default XML namespace";
198 else if (JSID_IS_STRING(anID))
200 JSString *
string = JSID_TO_STRING(anID);
201 const jschar *chars = NULL;
202 size_t length = JS_GetStringLength(
string);
204 if (JS_StringHasBeenInterned(
string))
206 chars = JS_GetInternedStringChars(
string);
211 return "*** uninterned string in jsid! ***";
213 formatted = [NSString stringWithCharacters:chars length:length];
217 formatted = [NSString stringWithFormat:@"unknown <0x%llX>", (long long)JSID_BITS(anID)];
220 return [formatted UTF8String];