JavaScriptCore:
2008-07-04 Sam Weinig <sam@webkit.org>
Rubber-stamped by Dan Bernstein.
Split Error and GetterSetter out of JSObject.h.
* API/JSCallbackObjectFunctions.h:
* GNUmakefile.am:
* JavaScriptCore.pri:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* kjs/AllInOneFile.cpp:
* kjs/ClassInfo.h: Copied from JavaScriptCore/kjs/JSObject.h.
* kjs/Error.cpp: Copied from JavaScriptCore/kjs/JSObject.cpp.
* kjs/Error.h: Copied from JavaScriptCore/kjs/JSObject.h.
* kjs/GetterSetter.cpp:
* kjs/GetterSetter.h: Copied from JavaScriptCore/kjs/JSObject.h.
* kjs/JSObject.cpp:
* kjs/JSObject.h:
* kjs/nodes.h:
JavaScriptGlue:
2008-07-04 Sam Weinig <sam@webkit.org>
Rubber-stamped by Dan Bernstein.
* JSObject.h: Rename the header guard as it now conflicts with the
JSObject in JavaScriptCore.
WebCore:
2008-07-04 Sam Weinig <sam@webkit.org>
Rubber-stamped by Dan Bernstein.
Split Error and GetterSetter out of JSObject.h.
* ForwardingHeaders/kjs/Error.h: Added.
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
* bindings/js/JSClipboardCustom.cpp:
* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSEventTargetBase.cpp:
* bindings/js/JSHTMLDocumentCustom.cpp:
* bindings/js/JSXMLHttpRequestCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/NP_jsobject.cpp:
* bridge/jni/jni_instance.cpp:
* bridge/jni/jni_runtime.cpp:
* bridge/objc/objc_instance.mm:
* bridge/objc/objc_runtime.mm:
* bridge/objc/objc_utility.h:
* bridge/runtime_array.cpp:
* bridge/runtime_method.cpp:
* bridge/runtime_object.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35007 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index b9f34e0..792b0ca 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -26,6 +26,7 @@
*/
#include "APICast.h"
+#include "Error.h"
#include "JSCallbackFunction.h"
#include "JSClassRef.h"
#include "JSGlobalObject.h"
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a7a0142..8fd3ea4 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,25 @@
+2008-07-04 Sam Weinig <sam@webkit.org>
+
+ Rubber-stamped by Dan Bernstein.
+
+ Split Error and GetterSetter out of JSObject.h.
+
+ * API/JSCallbackObjectFunctions.h:
+ * GNUmakefile.am:
+ * JavaScriptCore.pri:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * JavaScriptCoreSources.bkl:
+ * kjs/AllInOneFile.cpp:
+ * kjs/ClassInfo.h: Copied from JavaScriptCore/kjs/JSObject.h.
+ * kjs/Error.cpp: Copied from JavaScriptCore/kjs/JSObject.cpp.
+ * kjs/Error.h: Copied from JavaScriptCore/kjs/JSObject.h.
+ * kjs/GetterSetter.cpp:
+ * kjs/GetterSetter.h: Copied from JavaScriptCore/kjs/JSObject.h.
+ * kjs/JSObject.cpp:
+ * kjs/JSObject.h:
+ * kjs/nodes.h:
+
2008-07-04 Simon Hausmann <hausmann@webkit.org>
Fix the Wx build, added TreeProfile.cpp to the build.
diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am
index 78c1e8e..4148291 100644
--- a/JavaScriptCore/GNUmakefile.am
+++ b/JavaScriptCore/GNUmakefile.am
@@ -93,6 +93,7 @@
JavaScriptCore/kjs/DatePrototype.cpp \
JavaScriptCore/kjs/debugger.cpp \
JavaScriptCore/kjs/dtoa.cpp \
+ JavaScriptCore/kjs/Error.cpp \
JavaScriptCore/kjs/ErrorConstructor.cpp \
JavaScriptCore/kjs/ErrorInstance.cpp \
JavaScriptCore/kjs/ErrorPrototype.cpp \
diff --git a/JavaScriptCore/JavaScriptCore.pri b/JavaScriptCore/JavaScriptCore.pri
index afa5618..2cb8293 100644
--- a/JavaScriptCore/JavaScriptCore.pri
+++ b/JavaScriptCore/JavaScriptCore.pri
@@ -77,6 +77,7 @@
kjs/DatePrototype.cpp \
kjs/DebuggerCallFrame.cpp \
kjs/dtoa.cpp \
+ kjs/Error.cpp \
kjs/ErrorConstructor.cpp \
kjs/ErrorInstance.cpp \
kjs/ErrorPrototype.cpp \
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
index 328e646..13526e8 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
@@ -313,6 +313,10 @@
>
</File>
<File
+ RelativePath="..\..\kjs\ClassInfo.h"
+ >
+ </File>
+ <File
RelativePath="..\..\kjs\collector.cpp"
>
</File>
@@ -381,6 +385,14 @@
>
</File>
<File
+ RelativePath="..\..\kjs\Error.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kjs\Error.h"
+ >
+ </File>
+ <File
RelativePath="..\..\kjs\ErrorConstructor.cpp"
>
</File>
@@ -433,6 +445,10 @@
>
</File>
<File
+ RelativePath="..\..\kjs\GetterSetter.h"
+ >
+ </File>
+ <File
RelativePath="..\..\kjs\identifier.cpp"
>
</File>
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index f51d110..d3565fc 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -642,6 +642,10 @@
BC2680C80E16D4E900A06E92 /* ObjectPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectPrototype.cpp; sourceTree = "<group>"; };
BC2680C90E16D4E900A06E92 /* ObjectPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectPrototype.h; sourceTree = "<group>"; };
BC2680E60E16D52300A06E92 /* NumberConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberConstructor.lut.h; sourceTree = "<group>"; };
+ BC337BDE0E1AF0B80076918A /* GetterSetter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetterSetter.h; sourceTree = "<group>"; };
+ BC337BE20E1AF4410076918A /* Error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Error.h; sourceTree = "<group>"; };
+ BC337BEA0E1B00CB0076918A /* Error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Error.cpp; sourceTree = "<group>"; };
+ BC337D760E1B6EB90076918A /* ClassInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassInfo.h; sourceTree = "<group>"; };
BC7952060E15E8A800A898AB /* ArrayConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayConstructor.cpp; sourceTree = "<group>"; };
BC7952070E15E8A800A898AB /* ArrayConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayConstructor.h; sourceTree = "<group>"; };
BC7952320E15EB5600A898AB /* BooleanConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanConstructor.cpp; sourceTree = "<group>"; };
@@ -1054,6 +1058,7 @@
BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */,
BC7952350E15EB5600A898AB /* BooleanPrototype.h */,
145C507F0D9DF63B0088F6B9 /* CallData.h */,
+ BC337D760E1B6EB90076918A /* ClassInfo.h */,
F692A8520255597D01FF60F7 /* collector.cpp */,
F692A8530255597D01FF60F7 /* collector.h */,
5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */,
@@ -1074,6 +1079,8 @@
D21202290AD4310C00ED79B6 /* DateMath.h */,
651F6412039D5B5F0078395C /* dtoa.cpp */,
651F6413039D5B5F0078395C /* dtoa.h */,
+ BC337BEA0E1B00CB0076918A /* Error.cpp */,
+ BC337BE20E1AF4410076918A /* Error.h */,
BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */,
BC02E9050E1839DB000F9297 /* ErrorConstructor.h */,
BC02E98A0E183E38000F9297 /* ErrorInstance.cpp */,
@@ -1088,6 +1095,7 @@
F692A85D0255597D01FF60F7 /* FunctionPrototype.h */,
933A3499038AE7C6008635CE /* grammar.y */,
BC02E9B80E184545000F9297 /* GetterSetter.cpp */,
+ BC337BDE0E1AF0B80076918A /* GetterSetter.h */,
933A349D038AE80F008635CE /* identifier.cpp */,
933A349A038AE7C6008635CE /* identifier.h */,
E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
diff --git a/JavaScriptCore/JavaScriptCoreSources.bkl b/JavaScriptCore/JavaScriptCoreSources.bkl
index 082f6b8..927b0c9 100644
--- a/JavaScriptCore/JavaScriptCoreSources.bkl
+++ b/JavaScriptCore/JavaScriptCoreSources.bkl
@@ -58,6 +58,7 @@
kjs/debugger.cpp
kjs/DebuggerCallFrame.cpp
kjs/dtoa.cpp
+ kjs/Error.cpp
kjs/ErrorConstructor.cpp
kjs/ErrorInstance.cpp
kjs/ErrorPrototype.cpp
diff --git a/JavaScriptCore/kjs/AllInOneFile.cpp b/JavaScriptCore/kjs/AllInOneFile.cpp
index dbff344..5c7cfe5 100644
--- a/JavaScriptCore/kjs/AllInOneFile.cpp
+++ b/JavaScriptCore/kjs/AllInOneFile.cpp
@@ -72,6 +72,7 @@
#include "nodes.cpp"
#include "nodes2string.cpp"
#include "JSObject.cpp"
+#include "Error.cpp"
#include "JSGlobalObject.cpp"
#include "ObjectConstructor.cpp"
#include "ObjectPrototype.cpp"
diff --git a/JavaScriptCore/kjs/ClassInfo.h b/JavaScriptCore/kjs/ClassInfo.h
new file mode 100644
index 0000000..8ecf403
--- /dev/null
+++ b/JavaScriptCore/kjs/ClassInfo.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ClassInfo_h
+#define ClassInfo_h
+
+#include "ExecState.h"
+
+namespace KJS {
+
+ struct HashEntry;
+ struct HashTable;
+
+ /**
+ * Class Information
+ */
+ struct ClassInfo {
+ /**
+ * A string denoting the class name. Example: "Window".
+ */
+ const char* className;
+ /**
+ * Pointer to the class information of the base class.
+ * 0L if there is none.
+ */
+ const ClassInfo* parentClass;
+ /**
+ * Static hash-table of properties.
+ * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
+ */
+ const HashTable* propHashTable(ExecState* exec) const
+ {
+ if (classPropHashTableGetterFunction)
+ return classPropHashTableGetterFunction(exec);
+ return staticPropHashTable;
+ }
+
+ const HashTable* staticPropHashTable;
+ typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
+ const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
+ };
+
+} // namespace KJS
+
+#endif // ClassInfo_h
diff --git a/JavaScriptCore/kjs/Error.cpp b/JavaScriptCore/kjs/Error.cpp
new file mode 100644
index 0000000..11910b8
--- /dev/null
+++ b/JavaScriptCore/kjs/Error.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Eric Seidel (eric@webkit.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "Error.h"
+
+#include "ConstructData.h"
+#include "ErrorConstructor.h"
+#include "JSGlobalObject.h"
+#include "JSObject.h"
+#include "NativeErrorConstructor.h"
+
+namespace KJS {
+
+JSObject* Error::create(ExecState* exec, ErrorType errtype, const UString& message,
+ int lineno, int sourceId, const UString& sourceURL)
+{
+ JSObject* cons;
+ const char* name;
+ switch (errtype) {
+ case EvalError:
+ cons = exec->lexicalGlobalObject()->evalErrorConstructor();
+ name = "Evaluation error";
+ break;
+ case RangeError:
+ cons = exec->lexicalGlobalObject()->rangeErrorConstructor();
+ name = "Range error";
+ break;
+ case ReferenceError:
+ cons = exec->lexicalGlobalObject()->referenceErrorConstructor();
+ name = "Reference error";
+ break;
+ case SyntaxError:
+ cons = exec->lexicalGlobalObject()->syntaxErrorConstructor();
+ name = "Syntax error";
+ break;
+ case TypeError:
+ cons = exec->lexicalGlobalObject()->typeErrorConstructor();
+ name = "Type error";
+ break;
+ case URIError:
+ cons = exec->lexicalGlobalObject()->URIErrorConstructor();
+ name = "URI error";
+ break;
+ default:
+ cons = exec->lexicalGlobalObject()->errorConstructor();
+ name = "Error";
+ break;
+ }
+
+ ArgList args;
+ if (message.isEmpty())
+ args.append(jsString(exec, name));
+ else
+ args.append(jsString(exec, message));
+ ConstructData constructData;
+ ConstructType constructType = cons->getConstructData(constructData);
+ JSObject* err = construct(exec, cons, constructType, constructData, args);
+
+ if (lineno != -1)
+ err->put(exec, Identifier(exec, "line"), jsNumber(exec, lineno));
+ if (sourceId != -1)
+ err->put(exec, Identifier(exec, "sourceId"), jsNumber(exec, sourceId));
+
+ if(!sourceURL.isNull())
+ err->put(exec, Identifier(exec, "sourceURL"), jsString(exec, sourceURL));
+
+ return err;
+}
+
+JSObject *Error::create(ExecState *exec, ErrorType type, const char *message)
+{
+ return create(exec, type, message, -1, -1, NULL);
+}
+
+JSObject *throwError(ExecState *exec, ErrorType type)
+{
+ JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+JSObject *throwError(ExecState *exec, ErrorType type, const UString &message)
+{
+ JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+JSObject *throwError(ExecState *exec, ErrorType type, const char *message)
+{
+ JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
+ exec->setException(error);
+ return error;
+}
+
+JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString &sourceURL)
+{
+ JSObject *error = Error::create(exec, type, message, line, sourceId, sourceURL);
+ exec->setException(error);
+ return error;
+}
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/Error.h b/JavaScriptCore/kjs/Error.h
new file mode 100644
index 0000000..45fa59d
--- /dev/null
+++ b/JavaScriptCore/kjs/Error.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef Error_h
+#define Error_h
+
+namespace KJS {
+
+ class ExecState;
+ class JSObject;
+ class UString;
+
+ /**
+ * Types of Native Errors available. For custom errors, GeneralError
+ * should be used.
+ */
+ enum ErrorType { GeneralError = 0,
+ EvalError = 1,
+ RangeError = 2,
+ ReferenceError = 3,
+ SyntaxError = 4,
+ TypeError = 5,
+ URIError = 6};
+
+ /**
+ * @short Factory methods for error objects.
+ */
+ class Error {
+ public:
+ /**
+ * Factory method for error objects.
+ *
+ * @param exec The current execution state
+ * @param errtype Type of error.
+ * @param message Optional error message.
+ * @param lineNumber Optional line number.
+ * @param sourceId Optional source id.
+ * @param sourceURL Optional source URL.
+ */
+ static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
+ static JSObject *create(ExecState *, ErrorType, const char *message);
+ };
+
+JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
+JSObject *throwError(ExecState *, ErrorType, const UString &message);
+JSObject *throwError(ExecState *, ErrorType, const char *message);
+JSObject *throwError(ExecState *, ErrorType);
+
+} // namespace KJS
+
+#endif // Error_h
diff --git a/JavaScriptCore/kjs/GetterSetter.cpp b/JavaScriptCore/kjs/GetterSetter.cpp
index df2e8d4..554d667 100644
--- a/JavaScriptCore/kjs/GetterSetter.cpp
+++ b/JavaScriptCore/kjs/GetterSetter.cpp
@@ -21,7 +21,7 @@
*/
#include "config.h"
-#include "JSObject.h"
+#include "GetterSetter.h"
#include <wtf/Assertions.h>
@@ -75,4 +75,4 @@
return jsNull()->toObject(exec);
}
-}
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/GetterSetter.h b/JavaScriptCore/kjs/GetterSetter.h
new file mode 100644
index 0000000..4203383
--- /dev/null
+++ b/JavaScriptCore/kjs/GetterSetter.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GetterSetter_h
+#define GetterSetter_h
+
+#include "JSCell.h"
+
+namespace KJS {
+
+ class JSObject;
+
+ // This is an internal value object which stores getter and setter functions
+ // for a property.
+ class GetterSetter : public JSCell {
+ public:
+ JSType type() const { return GetterSetterType; }
+
+ GetterSetter() : m_getter(0), m_setter(0) { }
+
+ virtual void mark();
+
+ JSObject* getter() const { return m_getter; }
+ void setGetter(JSObject* getter) { m_getter = getter; }
+ JSObject* setter() const { return m_setter; }
+ void setSetter(JSObject* setter) { m_setter = setter; }
+
+ private:
+ virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
+ virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
+ virtual bool toBoolean(ExecState*) const;
+ virtual double toNumber(ExecState*) const;
+ virtual UString toString(ExecState*) const;
+ virtual JSObject* toObject(ExecState*) const;
+
+ JSObject* m_getter;
+ JSObject* m_setter;
+ };
+
+} // namespace KJS
+
+#endif // GetterSetter_h
diff --git a/JavaScriptCore/kjs/JSObject.cpp b/JavaScriptCore/kjs/JSObject.cpp
index 967b3f9..904113c 100644
--- a/JavaScriptCore/kjs/JSObject.cpp
+++ b/JavaScriptCore/kjs/JSObject.cpp
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
@@ -27,6 +26,7 @@
#include "DatePrototype.h"
#include "ErrorConstructor.h"
+#include "GetterSetter.h"
#include "JSGlobalObject.h"
#include "NativeErrorConstructor.h"
#include "ObjectPrototype.h"
@@ -42,8 +42,6 @@
namespace KJS {
-// ------------------------------ JSObject ------------------------------------
-
void JSObject::mark()
{
JSCell::mark();
@@ -479,97 +477,6 @@
slot.setUndefined();
}
-// ------------------------------ Error ----------------------------------------
-
-JSObject* Error::create(ExecState* exec, ErrorType errtype, const UString& message,
- int lineno, int sourceId, const UString& sourceURL)
-{
- JSObject* cons;
- const char* name;
- switch (errtype) {
- case EvalError:
- cons = exec->lexicalGlobalObject()->evalErrorConstructor();
- name = "Evaluation error";
- break;
- case RangeError:
- cons = exec->lexicalGlobalObject()->rangeErrorConstructor();
- name = "Range error";
- break;
- case ReferenceError:
- cons = exec->lexicalGlobalObject()->referenceErrorConstructor();
- name = "Reference error";
- break;
- case SyntaxError:
- cons = exec->lexicalGlobalObject()->syntaxErrorConstructor();
- name = "Syntax error";
- break;
- case TypeError:
- cons = exec->lexicalGlobalObject()->typeErrorConstructor();
- name = "Type error";
- break;
- case URIError:
- cons = exec->lexicalGlobalObject()->URIErrorConstructor();
- name = "URI error";
- break;
- default:
- cons = exec->lexicalGlobalObject()->errorConstructor();
- name = "Error";
- break;
- }
-
- ArgList args;
- if (message.isEmpty())
- args.append(jsString(exec, name));
- else
- args.append(jsString(exec, message));
- ConstructData constructData;
- ConstructType constructType = cons->getConstructData(constructData);
- JSObject* err = construct(exec, cons, constructType, constructData, args);
-
- if (lineno != -1)
- err->put(exec, Identifier(exec, "line"), jsNumber(exec, lineno));
- if (sourceId != -1)
- err->put(exec, Identifier(exec, "sourceId"), jsNumber(exec, sourceId));
-
- if(!sourceURL.isNull())
- err->put(exec, Identifier(exec, "sourceURL"), jsString(exec, sourceURL));
-
- return err;
-}
-
-JSObject *Error::create(ExecState *exec, ErrorType type, const char *message)
-{
- return create(exec, type, message, -1, -1, NULL);
-}
-
-JSObject *throwError(ExecState *exec, ErrorType type)
-{
- JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL);
- exec->setException(error);
- return error;
-}
-
-JSObject *throwError(ExecState *exec, ErrorType type, const UString &message)
-{
- JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
- exec->setException(error);
- return error;
-}
-
-JSObject *throwError(ExecState *exec, ErrorType type, const char *message)
-{
- JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
- exec->setException(error);
- return error;
-}
-
-JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString &sourceURL)
-{
- JSObject *error = Error::create(exec, type, message, line, sourceId, sourceURL);
- exec->setException(error);
- return error;
-}
-
JSObject* constructEmptyObject(ExecState* exec)
{
return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
diff --git a/JavaScriptCore/kjs/JSObject.h b/JavaScriptCore/kjs/JSObject.h
index cac7ea3..5cd7099 100644
--- a/JavaScriptCore/kjs/JSObject.h
+++ b/JavaScriptCore/kjs/JSObject.h
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
@@ -21,9 +20,10 @@
*
*/
-#ifndef KJS_OBJECT_H
-#define KJS_OBJECT_H
+#ifndef JSObject_h
+#define JSObject_h
+#include "ClassInfo.h"
#include "CommonIdentifiers.h"
#include "ExecState.h"
#include "JSNumberCell.h"
@@ -37,7 +37,6 @@
class InternalFunction;
class PropertyNameArray;
-
struct HashEntry;
struct HashTable;
@@ -50,62 +49,6 @@
Function = 1 << 4, // property is a function - only used by static hashtables
IsGetterSetter = 1 << 5 }; // property is a getter or setter
- /**
- * Class Information
- */
- struct ClassInfo {
- /**
- * A string denoting the class name. Example: "Window".
- */
- const char* className;
- /**
- * Pointer to the class information of the base class.
- * 0L if there is none.
- */
- const ClassInfo* parentClass;
- /**
- * Static hash-table of properties.
- * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
- */
- const HashTable* propHashTable(ExecState* exec) const
- {
- if (classPropHashTableGetterFunction)
- return classPropHashTableGetterFunction(exec);
- return staticPropHashTable;
- }
-
- const HashTable* staticPropHashTable;
- typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
- const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
- };
-
- // This is an internal value object which stores getter and setter functions
- // for a property.
- class GetterSetter : public JSCell {
- public:
- JSType type() const { return GetterSetterType; }
-
- GetterSetter() : m_getter(0), m_setter(0) { }
-
- virtual void mark();
-
- JSObject* getter() const { return m_getter; }
- void setGetter(JSObject* getter) { m_getter = getter; }
- JSObject* setter() const { return m_setter; }
- void setSetter(JSObject* setter) { m_setter = setter; }
-
- private:
- virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
- virtual bool toBoolean(ExecState*) const;
- virtual double toNumber(ExecState*) const;
- virtual UString toString(ExecState*) const;
- virtual JSObject* toObject(ExecState*) const;
-
- JSObject* m_getter;
- JSObject* m_setter;
- };
-
class JSObject : public JSCell {
public:
/**
@@ -390,43 +333,7 @@
JSValue *_proto;
};
- JSObject* constructEmptyObject(ExecState*);
-
- /**
- * Types of Native Errors available. For custom errors, GeneralError
- * should be used.
- */
- enum ErrorType { GeneralError = 0,
- EvalError = 1,
- RangeError = 2,
- ReferenceError = 3,
- SyntaxError = 4,
- TypeError = 5,
- URIError = 6};
-
- /**
- * @short Factory methods for error objects.
- */
- class Error {
- public:
- /**
- * Factory method for error objects.
- *
- * @param exec The current execution state
- * @param errtype Type of error.
- * @param message Optional error message.
- * @param lineNumber Optional line number.
- * @param sourceId Optional source id.
- * @param sourceURL Optional source URL.
- */
- static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
- static JSObject *create(ExecState *, ErrorType, const char *message);
- };
-
-JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
-JSObject *throwError(ExecState *, ErrorType, const UString &message);
-JSObject *throwError(ExecState *, ErrorType, const char *message);
-JSObject *throwError(ExecState *, ErrorType);
+ JSObject* constructEmptyObject(ExecState*);
inline JSObject::JSObject(JSValue* proto)
: _proto(proto)
@@ -643,6 +550,6 @@
asCell()->put(exec, propertyName, value);
}
-} // namespace
+} // namespace KJS
-#endif // KJS_OBJECT_H
+#endif // JSObject_h
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index 7166579..1eeec58 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -26,6 +26,7 @@
#ifndef NODES_H_
#define NODES_H_
+#include "Error.h"
#include "JSString.h"
#include "LabelStack.h"
#include "Opcode.h"
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index 8efb8e0..0e19f67 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,10 @@
+2008-07-04 Sam Weinig <sam@webkit.org>
+
+ Rubber-stamped by Dan Bernstein.
+
+ * JSObject.h: Rename the header guard as it now conflicts with the
+ JSObject in JavaScriptCore.
+
2008-07-01 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
diff --git a/JavaScriptGlue/JSObject.h b/JavaScriptGlue/JSObject.h
index ba13f6f..ec00dac 100644
--- a/JavaScriptGlue/JSObject.h
+++ b/JavaScriptGlue/JSObject.h
@@ -26,8 +26,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef JSObject_h
-#define JSObject_h
+#ifndef JSGlue_JSObject_h
+#define JSGlue_JSObject_h
#include "JSBase.h"
#include "JSUtils.h"
@@ -58,4 +58,4 @@
int fDataType;
};
-#endif
+#endif // JSGlue_JSObject_h
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index aa6d0d0..84618e4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2008-07-04 Sam Weinig <sam@webkit.org>
+
+ Rubber-stamped by Dan Bernstein.
+
+ Split Error and GetterSetter out of JSObject.h.
+
+ * ForwardingHeaders/kjs/Error.h: Added.
+ * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
+ * bindings/js/JSClipboardCustom.cpp:
+ * bindings/js/JSDOMWindowBase.cpp:
+ * bindings/js/JSEventTargetBase.cpp:
+ * bindings/js/JSHTMLDocumentCustom.cpp:
+ * bindings/js/JSXMLHttpRequestCustom.cpp:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ * bridge/NP_jsobject.cpp:
+ * bridge/jni/jni_instance.cpp:
+ * bridge/jni/jni_runtime.cpp:
+ * bridge/objc/objc_instance.mm:
+ * bridge/objc/objc_runtime.mm:
+ * bridge/objc/objc_utility.h:
+ * bridge/runtime_array.cpp:
+ * bridge/runtime_method.cpp:
+ * bridge/runtime_object.cpp:
+
2008-07-04 David D. Kilzer <ddkilzer@webkit.org>
Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives
diff --git a/WebCore/ForwardingHeaders/kjs/Error.h b/WebCore/ForwardingHeaders/kjs/Error.h
new file mode 100644
index 0000000..4fbaabd
--- /dev/null
+++ b/WebCore/ForwardingHeaders/kjs/Error.h
@@ -0,0 +1 @@
+#include <JavaScriptCore/Error.h>
diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
index 4c4afae..cf140d4 100644
--- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
@@ -34,6 +34,7 @@
#include "JSHTMLCanvasElement.h"
#include "JSHTMLImageElement.h"
#include "JSImageData.h"
+#include <kjs/Error.h>
using namespace KJS;
diff --git a/WebCore/bindings/js/JSClipboardCustom.cpp b/WebCore/bindings/js/JSClipboardCustom.cpp
index 1d34e2c..4d02770 100644
--- a/WebCore/bindings/js/JSClipboardCustom.cpp
+++ b/WebCore/bindings/js/JSClipboardCustom.cpp
@@ -39,6 +39,7 @@
#include "PlatformString.h"
#include "StringHash.h"
#include <kjs/ArrayPrototype.h>
+#include <kjs/Error.h>
#include <wtf/HashSet.h>
using namespace KJS;
diff --git a/WebCore/bindings/js/JSDOMWindowBase.cpp b/WebCore/bindings/js/JSDOMWindowBase.cpp
index 4d7923c..dfa7ac9 100644
--- a/WebCore/bindings/js/JSDOMWindowBase.cpp
+++ b/WebCore/bindings/js/JSDOMWindowBase.cpp
@@ -55,11 +55,12 @@
#include "PluginInfoStore.h"
#include "RenderView.h"
#include "ScheduledAction.h"
+#include "ScriptController.h"
#include "SecurityOrigin.h"
#include "Settings.h"
#include "WindowFeatures.h"
#include "htmlediting.h"
-#include "ScriptController.h"
+#include <kjs/Error.h>
#include <kjs/JSLock.h>
#include <wtf/AlwaysInline.h>
#include <wtf/MathExtras.h>
diff --git a/WebCore/bindings/js/JSEventTargetBase.cpp b/WebCore/bindings/js/JSEventTargetBase.cpp
index 2d4fea9..da2cdb3 100644
--- a/WebCore/bindings/js/JSEventTargetBase.cpp
+++ b/WebCore/bindings/js/JSEventTargetBase.cpp
@@ -28,8 +28,9 @@
#include "JSEventTargetBase.h"
#include "JSDOMWindow.h"
-#include "JSEventTargetNode.h"
#include "JSEventListener.h"
+#include "JSEventTargetNode.h"
+#include <kjs/Error.h>
#if ENABLE(SVG)
#include "JSSVGElementInstance.h"
diff --git a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
index 73924eb..4b8783b 100644
--- a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
@@ -37,6 +37,7 @@
#include "JSDOMWindowCustom.h"
#include "JSDOMWindowShell.h"
#include "JSHTMLCollection.h"
+#include <kjs/Error.h>
using namespace KJS;
diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
index 4cecca7..659012d 100644
--- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
+++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
@@ -40,6 +40,7 @@
#include "JSEvent.h"
#include "JSEventListener.h"
#include "XMLHttpRequest.h"
+#include <kjs/Error.h>
using namespace KJS;
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index e25e87f..1f33117 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1206,6 +1206,8 @@
push(@implContent, "JSValue* ${functionName}(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)\n");
push(@implContent, "{\n");
+ $implKJSInclude{"Error.h"} = 1;
+
if ($interfaceName eq "DOMWindow") {
push(@implContent, " $className* castedThisObj = toJSDOMWindow(thisValue);\n");
push(@implContent, " if (!castedThisObj)\n");
diff --git a/WebCore/bridge/NP_jsobject.cpp b/WebCore/bridge/NP_jsobject.cpp
index 01f2924..3afdfa1 100644
--- a/WebCore/bridge/NP_jsobject.cpp
+++ b/WebCore/bridge/NP_jsobject.cpp
@@ -29,16 +29,17 @@
#include "NP_jsobject.h"
-#include <kjs/JSGlobalObject.h>
-#include <kjs/JSLock.h>
-#include <kjs/PropertyNameArray.h>
-#include "c_utility.h"
-#include <kjs/completion.h>
-#include <kjs/interpreter.h>
#include "PlatformString.h"
+#include "c_utility.h"
#include "npruntime_impl.h"
#include "npruntime_priv.h"
#include "runtime_root.h"
+#include <kjs/Error.h>
+#include <kjs/JSGlobalObject.h>
+#include <kjs/JSLock.h>
+#include <kjs/PropertyNameArray.h>
+#include <kjs/completion.h>
+#include <kjs/interpreter.h>
using WebCore::String;
using namespace KJS;
diff --git a/WebCore/bridge/jni/jni_instance.cpp b/WebCore/bridge/jni/jni_instance.cpp
index cefae3a..c3a32a4 100644
--- a/WebCore/bridge/jni/jni_instance.cpp
+++ b/WebCore/bridge/jni/jni_instance.cpp
@@ -33,6 +33,7 @@
#include "jni_utility.h"
#include "runtime_object.h"
#include "runtime_root.h"
+#include <kjs/Error.h>
#include <kjs/JSLock.h>
#ifdef NDEBUG
diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp
index 267584d..6ebfe32 100644
--- a/WebCore/bridge/jni/jni_runtime.cpp
+++ b/WebCore/bridge/jni/jni_runtime.cpp
@@ -33,6 +33,7 @@
#include "runtime_array.h"
#include "runtime_object.h"
#include "runtime_root.h"
+#include <kjs/Error.h>
#include <kjs/JSLock.h>
#ifdef NDEBUG
diff --git a/WebCore/bridge/objc/objc_instance.mm b/WebCore/bridge/objc/objc_instance.mm
index 2ebae20..a7756b6 100644
--- a/WebCore/bridge/objc/objc_instance.mm
+++ b/WebCore/bridge/objc/objc_instance.mm
@@ -28,6 +28,7 @@
#import "FoundationExtras.h"
#import "WebScriptObject.h"
+#include <kjs/Error.h>
#include <kjs/JSLock.h>
#include <wtf/Assertions.h>
diff --git a/WebCore/bridge/objc/objc_runtime.mm b/WebCore/bridge/objc/objc_runtime.mm
index c51cd2c..47648e4 100644
--- a/WebCore/bridge/objc/objc_runtime.mm
+++ b/WebCore/bridge/objc/objc_runtime.mm
@@ -26,10 +26,11 @@
#include "config.h"
#include "objc_runtime.h"
+#include "WebScriptObject.h"
#include "objc_instance.h"
#include "runtime_array.h"
#include "runtime_object.h"
-#include "WebScriptObject.h"
+#include <kjs/Error.h>
#include <kjs/JSLock.h>
#include <wtf/RetainPtr.h>
diff --git a/WebCore/bridge/objc/objc_utility.h b/WebCore/bridge/objc/objc_utility.h
index 0a5e613..d339afc 100644
--- a/WebCore/bridge/objc/objc_utility.h
+++ b/WebCore/bridge/objc/objc_utility.h
@@ -28,8 +28,9 @@
#include <CoreFoundation/CoreFoundation.h>
-#include <kjs/JSObject.h>
#include "objc_header.h"
+#include <kjs/Error.h>
+#include <kjs/JSObject.h>
#ifdef __OBJC__
@class NSString;
diff --git a/WebCore/bridge/runtime_array.cpp b/WebCore/bridge/runtime_array.cpp
index 0a4815c..315a848 100644
--- a/WebCore/bridge/runtime_array.cpp
+++ b/WebCore/bridge/runtime_array.cpp
@@ -27,6 +27,7 @@
#include "runtime_array.h"
#include <kjs/ArrayPrototype.h>
+#include <kjs/Error.h>
using namespace KJS;
diff --git a/WebCore/bridge/runtime_method.cpp b/WebCore/bridge/runtime_method.cpp
index b6f207e..0904927 100644
--- a/WebCore/bridge/runtime_method.cpp
+++ b/WebCore/bridge/runtime_method.cpp
@@ -26,8 +26,9 @@
#include "config.h"
#include "runtime_method.h"
-#include <kjs/JSGlobalObject.h>
#include "runtime_object.h"
+#include <kjs/Error.h>
+#include <kjs/JSGlobalObject.h>
namespace KJS {
diff --git a/WebCore/bridge/runtime_object.cpp b/WebCore/bridge/runtime_object.cpp
index 559bd42..7d694a5 100644
--- a/WebCore/bridge/runtime_object.cpp
+++ b/WebCore/bridge/runtime_object.cpp
@@ -28,6 +28,7 @@
#include "runtime_method.h"
#include "runtime_root.h"
+#include <kjs/Error.h>
using namespace KJS;
using namespace Bindings;