X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174:/API/JSValueRef.cpp?ds=inline diff --git a/API/JSValueRef.cpp b/API/JSValueRef.cpp index 905dcbf..9b7268a 100644 --- a/API/JSValueRef.cpp +++ b/API/JSValueRef.cpp @@ -129,10 +129,10 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla JSValue jsValue = toJS(exec, value); if (JSObject* o = jsValue.getObject()) { - if (o->inherits(&JSCallbackObject::info)) - return static_cast*>(o)->inherits(jsClass); - else if (o->inherits(&JSCallbackObject::info)) - return static_cast*>(o)->inherits(jsClass); + if (o->inherits(&JSCallbackObject::s_info)) + return jsCast*>(o)->inherits(jsClass); + if (o->inherits(&JSCallbackObject::s_info)) + return jsCast*>(o)->inherits(jsClass); } return false; } @@ -175,7 +175,7 @@ bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObject JSObject* jsConstructor = toJS(constructor); if (!jsConstructor->structure()->typeInfo().implementsHasInstance()) return false; - bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown + bool result = jsConstructor->methodTable()->hasInstance(jsConstructor, exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown if (exec->hadException()) { if (exception) *exception = toRef(exec, exec->exception()); @@ -217,9 +217,9 @@ JSValueRef JSValueMakeNumber(JSContextRef ctx, double value) // generated internally to JavaScriptCore naturally have that representation, // but an external NaN might not. if (isnan(value)) - value = NaN; + value = std::numeric_limits::quiet_NaN(); - return toRef(exec, jsNumber(exec, value)); + return toRef(exec, jsNumber(value)); } JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) @@ -234,7 +234,12 @@ JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) { ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); - LiteralParser parser(exec, string->ustring(), LiteralParser::StrictJSON); + UString str = string->ustring(); + if (str.is8Bit()) { + LiteralParser parser(exec, str.characters8(), str.length(), StrictJSON); + return toRef(exec, parser.tryLiteralParse()); + } + LiteralParser parser(exec, str.characters16(), str.length(), StrictJSON); return toRef(exec, parser.tryLiteralParse()); } @@ -252,7 +257,7 @@ JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef apiValue, unsig exec->clearException(); return 0; } - return OpaqueJSString::create(result).releaseRef(); + return OpaqueJSString::create(result).leakRef(); } bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) @@ -276,7 +281,7 @@ double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception if (exception) *exception = toRef(exec, exec->exception()); exec->clearException(); - number = NaN; + number = std::numeric_limits::quiet_NaN(); } return number; } @@ -288,14 +293,14 @@ JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* JSValue jsValue = toJS(exec, value); - RefPtr stringRef(OpaqueJSString::create(jsValue.toString(exec))); + RefPtr stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec))); if (exec->hadException()) { if (exception) *exception = toRef(exec, exec->exception()); exec->clearException(); stringRef.clear(); } - return stringRef.release().releaseRef(); + return stringRef.release().leakRef(); } JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception)