source: webkit/trunk/JavaScriptCore/kjs/JSValue.cpp@ 37799

Last change on this file since 37799 was 37706, checked in by Darin Adler, 17 years ago

JavaScriptCore:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • VM/Machine.cpp: (JSC::fastToUInt32): Call toUInt32SlowCase function; no longer a member of JSValue.
  • kjs/JSNumberCell.h: (JSC::JSNumberCell::toInt32): Ditto. (JSC::JSNumberCell::toUInt32): Ditto.
  • kjs/JSValue.cpp: (JSC::toInt32SlowCase): Made a non-member function. (JSC::JSValue::toInt32SlowCase): Changed to call non-member function. (JSC::toUInt32SlowCase): More of the same. (JSC::JSValue::toUInt32SlowCase): Ditto.
  • kjs/JSValue.h: Moved static member function so they are no longer member functions at all.
  • VM/CTI.h: Removed forward declaration of JSValue.
  • VM/ExceptionHelpers.h: Ditto.
  • kjs/CallData.h: Ditto.
  • kjs/ConstructData.h: Ditto.
  • kjs/JSGlobalObjectFunctions.h: Ditto.
  • kjs/PropertyMap.h: Ditto.
  • kjs/StructureID.h: Ditto.
  • kjs/collector.h: Ditto.
  • kjs/completion.h: Ditto.
  • kjs/grammar.y: (JSC::makeBitwiseNotNode): Call new non-member toInt32 function. (JSC::makeLeftShiftNode): More of the same. (JSC::makeRightShiftNode): Ditto.
  • kjs/protect.h: Added a specialization for ProtectedPtr<JSValuePtr> so this can be used with JSValuePtr.

JavaScriptGlue:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • JSValueWrapper.h: Use JSValuePtr instead of JSValue*.

WebCore:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • bindings/js/JSCustomXPathNSResolver.h: Removed declaration of JSValue and used JSValuePtr instead.
  • bindings/js/JSEventTarget.h: Ditto.
  • bindings/js/JSNodeFilterCondition.h: Ditto.
  • bindings/js/ScheduledAction.h: Ditto.
  • bindings/js/ScriptController.h: Ditto.
  • bindings/objc/WebScriptObjectPrivate.h: Ditto.
  • bridge/c/c_utility.h: Ditto.
  • bridge/jni/jni_jsobject.h: Ditto.
  • bridge/jni/jni_utility.h: Ditto.
  • bridge/objc/WebScriptObject.h: Ditto.
  • dom/Traversal.h: Ditto.
  • inspector/InspectorController.cpp: Ditto.
  • inspector/JavaScriptProfile.h: Ditto.
  • inspector/JavaScriptProfileNode.h: Ditto.
  • loader/FrameLoader.h: Ditto.
  • page/Console.h: Ditto.
  • plugins/MimeTypeArray.h: Ditto.
  • plugins/Plugin.h: Ditto.
  • plugins/PluginArray.h: Ditto.
  • plugins/PluginView.cpp: (WebCore::getString): Ditto. (WebCore::PluginView::performRequest): Ditto.
  • plugins/gtk/PluginViewGtk.cpp: Ditto.
  • plugins/qt/PluginViewQt.cpp: Ditto.
  • plugins/win/PluginViewWin.cpp: Ditto.
  • bridge/qt/qt_class.cpp: (JSC::Bindings::QtClass::fallbackObject): Use JSValuePtr and JSObject* instead of JSValue*.
  • bridge/qt/qt_class.h: Ditto.
  • bridge/qt/qt_instance.cpp: (JSC::Bindings::QtInstance::mark): Ditto. (JSC::Bindings::QtInstance::invokeMethod): Ditto. (JSC::Bindings::QtInstance::defaultValue): Ditto. (JSC::Bindings::QtInstance::stringValue): Ditto. (JSC::Bindings::QtInstance::numberValue): Ditto. (JSC::Bindings::QtInstance::booleanValue): Ditto. (JSC::Bindings::QtInstance::valueOf): Ditto. (JSC::Bindings::QtField::valueFromInstance): Ditto. (JSC::Bindings::QtField::setValueToInstance): Ditto.
  • bridge/qt/qt_instance.h: Ditto.
  • bridge/qt/qt_runtime.cpp: Ditto. (JSC::Bindings::valueRealType): Ditto. (JSC::Bindings::convertValueToQVariant): Ditto. (JSC::Bindings::convertQVariantToValue): Ditto. (JSC::Bindings::findMethodIndex): Ditto. (JSC::Bindings::QtRuntimeMetaMethod::call): Ditto. (JSC::Bindings::QtRuntimeMetaMethod::lengthGetter): Ditto. (JSC::Bindings::QtRuntimeMetaMethod::connectGetter): Ditto. (JSC::Bindings::QtRuntimeMetaMethod::disconnectGetter): Ditto. (JSC::Bindings::QtRuntimeConnectionMethod::call): Ditto. (JSC::Bindings::QtRuntimeConnectionMethod::lengthGetter): Ditto. (JSC::Bindings::QtArray::setValueAt): Ditto. (JSC::Bindings::QtArray::valueAt): Ditto.
  • bridge/qt/qt_runtime.h: Ditto.
  • bridge/testqtbindings.cpp: (main): Use JSValuePtr.

WebKit/mac:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • WebView/WebFrame.mm: (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]): Use JSValuePtr instead of JSValue.
  • WebView/WebScriptDebugger.h: Removed declaration of JSValue.

WebKit/qt:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • Api/qwebframe.cpp: (QWebFrame::evaluateJavaScript): Use JSValuePtr.

WebKit/win:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • WebScriptCallFrame.cpp: (WebScriptCallFrame::jsValueToString): Use JSValuePtr. (WebScriptCallFrame::stringByEvaluatingJavaScriptFromString): Ditto. (WebScriptCallFrame::valueForVariable): Put more code inside and ifdef. (WebScriptCallFrame::valueByEvaluatingJavaScriptFromString): Ditto.
  • WebScriptCallFrame.h: Use JSValuePtr.
  • WebView.cpp: (WebView::stringByEvaluatingJavaScriptFromString): Use JSValuePtr.

WebKit/wx:

2008-10-19 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove most uses of JSValue, which will be removed in a future patch.

  • WebFrame.cpp: (wxWebFrame::RunScript): Use JSValuePtr.
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "config.h"
24#include "JSValue.h"
25
26#include "JSFunction.h"
27#include <wtf/MathExtras.h>
28
29namespace JSC {
30
31static const double D32 = 4294967296.0;
32
33// ECMA 9.4
34double JSValue::toInteger(ExecState* exec) const
35{
36 int32_t i;
37 if (getTruncatedInt32(i))
38 return i;
39 double d = toNumber(exec);
40 return isnan(d) ? 0.0 : trunc(d);
41}
42
43double JSValue::toIntegerPreserveNaN(ExecState* exec) const
44{
45 int32_t i;
46 if (getTruncatedInt32(i))
47 return i;
48 return trunc(toNumber(exec));
49}
50
51int32_t toInt32SlowCase(double d, bool& ok)
52{
53 ok = true;
54
55 if (d >= -D32 / 2 && d < D32 / 2)
56 return static_cast<int32_t>(d);
57
58 if (isnan(d) || isinf(d)) {
59 ok = false;
60 return 0;
61 }
62
63 double d32 = fmod(trunc(d), D32);
64 if (d32 >= D32 / 2)
65 d32 -= D32;
66 else if (d32 < -D32 / 2)
67 d32 += D32;
68 return static_cast<int32_t>(d32);
69}
70
71int32_t JSValue::toInt32SlowCase(ExecState* exec, bool& ok) const
72{
73 return JSC::toInt32SlowCase(toNumber(exec), ok);
74}
75
76uint32_t toUInt32SlowCase(double d, bool& ok)
77{
78 ok = true;
79
80 if (d >= 0.0 && d < D32)
81 return static_cast<uint32_t>(d);
82
83 if (isnan(d) || isinf(d)) {
84 ok = false;
85 return 0;
86 }
87
88 double d32 = fmod(trunc(d), D32);
89 if (d32 < 0)
90 d32 += D32;
91 return static_cast<uint32_t>(d32);
92}
93
94uint32_t JSValue::toUInt32SlowCase(ExecState* exec, bool& ok) const
95{
96 return JSC::toUInt32SlowCase(toNumber(exec), ok);
97}
98
99float JSValue::toFloat(ExecState* exec) const
100{
101 return static_cast<float>(toNumber(exec));
102}
103
104} // namespace JSC
Note: See TracBrowser for help on using the repository browser.