JavaScriptCore:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jul 2008 05:35:09 +0000 (05:35 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jul 2008 05:35:09 +0000 (05:35 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@35007 268f45cc-cd09-0410-ab3c-d52691b4dbfc

36 files changed:
JavaScriptCore/API/JSCallbackObjectFunctions.h
JavaScriptCore/ChangeLog
JavaScriptCore/GNUmakefile.am
JavaScriptCore/JavaScriptCore.pri
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/JavaScriptCoreSources.bkl
JavaScriptCore/kjs/AllInOneFile.cpp
JavaScriptCore/kjs/ClassInfo.h [new file with mode: 0644]
JavaScriptCore/kjs/Error.cpp [new file with mode: 0644]
JavaScriptCore/kjs/Error.h [new file with mode: 0644]
JavaScriptCore/kjs/GetterSetter.cpp
JavaScriptCore/kjs/GetterSetter.h [new file with mode: 0644]
JavaScriptCore/kjs/JSObject.cpp
JavaScriptCore/kjs/JSObject.h
JavaScriptCore/kjs/nodes.h
JavaScriptGlue/ChangeLog
JavaScriptGlue/JSObject.h
WebCore/ChangeLog
WebCore/ForwardingHeaders/kjs/Error.h [new file with mode: 0644]
WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
WebCore/bindings/js/JSClipboardCustom.cpp
WebCore/bindings/js/JSDOMWindowBase.cpp
WebCore/bindings/js/JSEventTargetBase.cpp
WebCore/bindings/js/JSHTMLDocumentCustom.cpp
WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bridge/NP_jsobject.cpp
WebCore/bridge/jni/jni_instance.cpp
WebCore/bridge/jni/jni_runtime.cpp
WebCore/bridge/objc/objc_instance.mm
WebCore/bridge/objc/objc_runtime.mm
WebCore/bridge/objc/objc_utility.h
WebCore/bridge/runtime_array.cpp
WebCore/bridge/runtime_method.cpp
WebCore/bridge/runtime_object.cpp

index b9f34e0..792b0ca 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include "APICast.h"
+#include "Error.h"
 #include "JSCallbackFunction.h"
 #include "JSClassRef.h"
 #include "JSGlobalObject.h"
index a7a0142..8fd3ea4 100644 (file)
@@ -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.
index 78c1e8e..4148291 100644 (file)
@@ -93,6 +93,7 @@ javascriptcore_sources += \
        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 \
index afa5618..2cb8293 100644 (file)
@@ -77,6 +77,7 @@ SOURCES += \
     kjs/DatePrototype.cpp \
     kjs/DebuggerCallFrame.cpp \
     kjs/dtoa.cpp \
+    kjs/Error.cpp \
     kjs/ErrorConstructor.cpp \
     kjs/ErrorInstance.cpp \
     kjs/ErrorPrototype.cpp \
index 328e646..13526e8 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\kjs\ClassInfo.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\kjs\collector.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\kjs\Error.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\kjs\Error.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\kjs\ErrorConstructor.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\kjs\GetterSetter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\kjs\identifier.cpp"\r
                                >\r
                        </File>\r
index f51d110..d3565fc 100644 (file)
                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>"; };
                                BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */,
                                BC7952350E15EB5600A898AB /* BooleanPrototype.h */,
                                145C507F0D9DF63B0088F6B9 /* CallData.h */,
+                               BC337D760E1B6EB90076918A /* ClassInfo.h */,
                                F692A8520255597D01FF60F7 /* collector.cpp */,
                                F692A8530255597D01FF60F7 /* collector.h */,
                                5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */,
                                D21202290AD4310C00ED79B6 /* DateMath.h */,
                                651F6412039D5B5F0078395C /* dtoa.cpp */,
                                651F6413039D5B5F0078395C /* dtoa.h */,
+                               BC337BEA0E1B00CB0076918A /* Error.cpp */,
+                               BC337BE20E1AF4410076918A /* Error.h */,
                                BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */,
                                BC02E9050E1839DB000F9297 /* ErrorConstructor.h */,
                                BC02E98A0E183E38000F9297 /* ErrorInstance.cpp */,
                                F692A85D0255597D01FF60F7 /* FunctionPrototype.h */,
                                933A3499038AE7C6008635CE /* grammar.y */,
                                BC02E9B80E184545000F9297 /* GetterSetter.cpp */,
+                               BC337BDE0E1AF0B80076918A /* GetterSetter.h */,
                                933A349D038AE80F008635CE /* identifier.cpp */,
                                933A349A038AE7C6008635CE /* identifier.h */,
                                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
index 082f6b8..927b0c9 100644 (file)
@@ -58,6 +58,7 @@ Source files for JSCore.
         kjs/debugger.cpp
         kjs/DebuggerCallFrame.cpp
         kjs/dtoa.cpp
+        kjs/Error.cpp
         kjs/ErrorConstructor.cpp
         kjs/ErrorInstance.cpp
         kjs/ErrorPrototype.cpp
index dbff344..5c7cfe5 100644 (file)
@@ -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 (file)
index 0000000..8ecf403
--- /dev/null
@@ -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 (file)
index 0000000..11910b8
--- /dev/null
@@ -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 (file)
index 0000000..45fa59d
--- /dev/null
@@ -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
index df2e8d4..554d667 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "config.h"
-#include "JSObject.h"
+#include "GetterSetter.h"
 
 #include <wtf/Assertions.h>
 
@@ -75,4 +75,4 @@ JSObject* GetterSetter::toObject(ExecState* exec) const
     return jsNull()->toObject(exec);
 }
 
-}
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/GetterSetter.h b/JavaScriptCore/kjs/GetterSetter.h
new file mode 100644 (file)
index 0000000..4203383
--- /dev/null
@@ -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
index 967b3f9..904113c 100644 (file)
@@ -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 @@ void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location)
         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());
index cac7ea3..5cd7099 100644 (file)
@@ -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)
  *
  */
 
-#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 @@ namespace KJS {
 
   class InternalFunction;
   class PropertyNameArray;
-
   struct HashEntry;
   struct HashTable;
 
@@ -50,62 +49,6 @@ namespace KJS {
                    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 @@ namespace KJS {
     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 @@ inline void JSValue::put(ExecState* exec, unsigned propertyName, JSValue* value)
     asCell()->put(exec, propertyName, value);
 }
 
-} // namespace
+} // namespace KJS
 
-#endif // KJS_OBJECT_H
+#endif // JSObject_h
index 7166579..1eeec58 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef NODES_H_
 #define NODES_H_
 
+#include "Error.h"
 #include "JSString.h"
 #include "LabelStack.h"
 #include "Opcode.h"
index 8efb8e0..0e19f67 100644 (file)
@@ -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.
index ba13f6f..ec00dac 100644 (file)
@@ -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 @@ class JSUserObject : public JSBase {
                 int fDataType;
 };
 
-#endif
+#endif // JSGlue_JSObject_h
index aa6d0d0..84618e4 100644 (file)
@@ -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 (file)
index 0000000..4fbaabd
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/Error.h>
index 4c4afae..cf140d4 100644 (file)
@@ -34,6 +34,7 @@
 #include "JSHTMLCanvasElement.h"
 #include "JSHTMLImageElement.h"
 #include "JSImageData.h"
+#include <kjs/Error.h>
 
 using namespace KJS;
 
index 1d34e2c..4d02770 100644 (file)
@@ -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;
index 4d7923c..dfa7ac9 100644 (file)
 #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>
index 2d4fea9..da2cdb3 100644 (file)
@@ -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"
index 73924eb..4b8783b 100644 (file)
@@ -37,6 +37,7 @@
 #include "JSDOMWindowCustom.h"
 #include "JSDOMWindowShell.h"
 #include "JSHTMLCollection.h"
+#include <kjs/Error.h>
 
 using namespace KJS;
 
index 4cecca7..659012d 100644 (file)
@@ -40,6 +40,7 @@
 #include "JSEvent.h"
 #include "JSEventListener.h"
 #include "XMLHttpRequest.h"
+#include <kjs/Error.h>
 
 using namespace KJS;
 
index e25e87f..1f33117 100644 (file)
@@ -1206,6 +1206,8 @@ sub GenerateImplementation
             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");
index 01f2924..3afdfa1 100644 (file)
 
 #include "NP_jsobject.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 "c_utility.h"
 #include <kjs/completion.h>
 #include <kjs/interpreter.h>
-#include "PlatformString.h"
-#include "npruntime_impl.h"
-#include "npruntime_priv.h"
-#include "runtime_root.h"
 
 using WebCore::String;
 using namespace KJS;
index cefae3a..c3a32a4 100644 (file)
@@ -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
index 267584d..6ebfe32 100644 (file)
@@ -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
index 2ebae20..a7756b6 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "FoundationExtras.h"
 #import "WebScriptObject.h"
+#include <kjs/Error.h>
 #include <kjs/JSLock.h>
 #include <wtf/Assertions.h>
 
index c51cd2c..47648e4 100644 (file)
 #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>
 
index 0a5e613..d339afc 100644 (file)
@@ -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;
index 0a4815c..315a848 100644 (file)
@@ -27,6 +27,7 @@
 #include "runtime_array.h"
 
 #include <kjs/ArrayPrototype.h>
+#include <kjs/Error.h>
 
 using namespace KJS;
 
index b6f207e..0904927 100644 (file)
@@ -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 {
 
index 559bd42..7d694a5 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "runtime_method.h"
 #include "runtime_root.h"
+#include <kjs/Error.h>
 
 using namespace KJS;
 using namespace Bindings;