2009-02-23 Dimitri Glazkov <dglazkov@chromium.org>
authordglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2009 00:04:16 +0000 (00:04 +0000)
committerdglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2009 00:04:16 +0000 (00:04 +0000)
        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=24109
        Upstream V8 Script abstractions, all except ScriptController.

        * bindings/v8/ScriptCachedFrameData.h: Added.
        (WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
        (WebCore::ScriptCachedFrameData::~ScriptCachedFrameData):
        (WebCore::ScriptCachedFrameData::restore):
        (WebCore::ScriptCachedFrameData::clear):
        (WebCore::ScriptCachedFrameData::domWindow):
        * bindings/v8/ScriptCallFrame.cpp: Added.
        (WebCore::ScriptCallFrame::ScriptCallFrame):
        (WebCore::ScriptCallFrame::~ScriptCallFrame):
        (WebCore::ScriptCallFrame::argumentAt):
        * bindings/v8/ScriptCallFrame.h: Added.
        (WebCore::ScriptCallFrame::functionName):
        (WebCore::ScriptCallFrame::sourceURL):
        (WebCore::ScriptCallFrame::lineNumber):
        (WebCore::ScriptCallFrame::argumentCount):
        * bindings/v8/ScriptCallStack.cpp: Added.
        (WebCore::ScriptCallStack::ScriptCallStack):
        (WebCore::ScriptCallStack::~ScriptCallStack):
        (WebCore::ScriptCallStack::at):
        * bindings/v8/ScriptCallStack.h: Added.
        (WebCore::ScriptCallStack::size):
        * bindings/v8/ScriptInstance.cpp: Added.
        (WebCore::V8ScriptInstance::V8ScriptInstance):
        (WebCore::V8ScriptInstance::~V8ScriptInstance):
        (WebCore::V8ScriptInstance::instance):
        (WebCore::V8ScriptInstance::clear):
        (WebCore::V8ScriptInstance::set):
        * bindings/v8/ScriptInstance.h: Added.
        (WebCore::V8ScriptInstance::create):
        * bindings/v8/ScriptSourceCode.h: Added.
        (WebCore::ScriptSourceCode::ScriptSourceCode):
        (WebCore::ScriptSourceCode::isEmpty):
        (WebCore::ScriptSourceCode::source):
        (WebCore::ScriptSourceCode::url):
        (WebCore::ScriptSourceCode::startLine):
        * bindings/v8/ScriptState.h: Added.
        (WebCore::ScriptState::hadException):
        (WebCore::ScriptState::setException):
        (WebCore::ScriptState::exception):
        * bindings/v8/ScriptString.h: Added.
        (WebCore::ScriptString::ScriptString):
        (WebCore::ScriptString::operator String):
        (WebCore::ScriptString::isNull):
        (WebCore::ScriptString::size):
        (WebCore::ScriptString::operator=):
        (WebCore::ScriptString::operator+=):
        * bindings/v8/ScriptValue.cpp: Added.
        (WebCore::ScriptValue::getString):
        * bindings/v8/ScriptValue.h: Added.
        (WebCore::ScriptValue::ScriptValue):
        (WebCore::ScriptValue::operator=):
        (WebCore::ScriptValue::operator==):
        (WebCore::ScriptValue::operator!=):
        (WebCore::ScriptValue::isNull):
        (WebCore::ScriptValue::isUndefined):
        (WebCore::ScriptValue::clear):
        (WebCore::ScriptValue::~ScriptValue):
        (WebCore::ScriptValue::v8Value):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41159 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/bindings/v8/ScriptCachedFrameData.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptCallFrame.cpp [new file with mode: 0644]
WebCore/bindings/v8/ScriptCallFrame.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptCallStack.cpp [new file with mode: 0644]
WebCore/bindings/v8/ScriptCallStack.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptInstance.cpp [new file with mode: 0644]
WebCore/bindings/v8/ScriptInstance.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptSourceCode.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptState.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptString.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptValue.cpp [new file with mode: 0644]
WebCore/bindings/v8/ScriptValue.h [new file with mode: 0644]

index 45db223221ee1ba8922167c577b3385e4b3eb367..c4f64649de2e211d121475cd4074849fc0635a26 100644 (file)
@@ -1,3 +1,69 @@
+2009-02-23  Dimitri Glazkov  <dglazkov@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24109
+        Upstream V8 Script abstractions, all except ScriptController.
+
+        * bindings/v8/ScriptCachedFrameData.h: Added.
+        (WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
+        (WebCore::ScriptCachedFrameData::~ScriptCachedFrameData):
+        (WebCore::ScriptCachedFrameData::restore):
+        (WebCore::ScriptCachedFrameData::clear):
+        (WebCore::ScriptCachedFrameData::domWindow):
+        * bindings/v8/ScriptCallFrame.cpp: Added.
+        (WebCore::ScriptCallFrame::ScriptCallFrame):
+        (WebCore::ScriptCallFrame::~ScriptCallFrame):
+        (WebCore::ScriptCallFrame::argumentAt):
+        * bindings/v8/ScriptCallFrame.h: Added.
+        (WebCore::ScriptCallFrame::functionName):
+        (WebCore::ScriptCallFrame::sourceURL):
+        (WebCore::ScriptCallFrame::lineNumber):
+        (WebCore::ScriptCallFrame::argumentCount):
+        * bindings/v8/ScriptCallStack.cpp: Added.
+        (WebCore::ScriptCallStack::ScriptCallStack):
+        (WebCore::ScriptCallStack::~ScriptCallStack):
+        (WebCore::ScriptCallStack::at):
+        * bindings/v8/ScriptCallStack.h: Added.
+        (WebCore::ScriptCallStack::size):
+        * bindings/v8/ScriptInstance.cpp: Added.
+        (WebCore::V8ScriptInstance::V8ScriptInstance):
+        (WebCore::V8ScriptInstance::~V8ScriptInstance):
+        (WebCore::V8ScriptInstance::instance):
+        (WebCore::V8ScriptInstance::clear):
+        (WebCore::V8ScriptInstance::set):
+        * bindings/v8/ScriptInstance.h: Added.
+        (WebCore::V8ScriptInstance::create):
+        * bindings/v8/ScriptSourceCode.h: Added.
+        (WebCore::ScriptSourceCode::ScriptSourceCode):
+        (WebCore::ScriptSourceCode::isEmpty):
+        (WebCore::ScriptSourceCode::source):
+        (WebCore::ScriptSourceCode::url):
+        (WebCore::ScriptSourceCode::startLine):
+        * bindings/v8/ScriptState.h: Added.
+        (WebCore::ScriptState::hadException):
+        (WebCore::ScriptState::setException):
+        (WebCore::ScriptState::exception):
+        * bindings/v8/ScriptString.h: Added.
+        (WebCore::ScriptString::ScriptString):
+        (WebCore::ScriptString::operator String):
+        (WebCore::ScriptString::isNull):
+        (WebCore::ScriptString::size):
+        (WebCore::ScriptString::operator=):
+        (WebCore::ScriptString::operator+=):
+        * bindings/v8/ScriptValue.cpp: Added.
+        (WebCore::ScriptValue::getString):
+        * bindings/v8/ScriptValue.h: Added.
+        (WebCore::ScriptValue::ScriptValue):
+        (WebCore::ScriptValue::operator=):
+        (WebCore::ScriptValue::operator==):
+        (WebCore::ScriptValue::operator!=):
+        (WebCore::ScriptValue::isNull):
+        (WebCore::ScriptValue::isUndefined):
+        (WebCore::ScriptValue::clear):
+        (WebCore::ScriptValue::~ScriptValue):
+        (WebCore::ScriptValue::v8Value):
+
 2009-02-23  Adam Treat  <adam.treat@torchmobile.com>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/bindings/v8/ScriptCachedFrameData.h b/WebCore/bindings/v8/ScriptCachedFrameData.h
new file mode 100644 (file)
index 0000000..e6530f4
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCachedPageData_h
+#define ScriptCachedPageData_h
+
+// We don't use WebKit's page caching, so this implementation is just a stub.
+
+namespace WebCore {
+    class Frame;
+    class DOMWindow;
+
+    class ScriptCachedFrameData  {
+    public:
+        ScriptCachedFrameData(Frame*) { }
+        ~ScriptCachedFrameData() { }
+
+        void restore(Frame*) { }
+        void clear() { }
+        DOMWindow* domWindow() const { return 0; }
+    };
+
+} // namespace WebCore
+
+#endif // ScriptCachedPageData_h
diff --git a/WebCore/bindings/v8/ScriptCallFrame.cpp b/WebCore/bindings/v8/ScriptCallFrame.cpp
new file mode 100644 (file)
index 0000000..ab30862
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallFrame.h"
+
+#include <v8.h>
+
+#include "PlatformString.h"
+#include "V8Binding.h"
+#include "V8Proxy.h"
+#include "ScriptValue.h"
+
+namespace WebCore {
+
+ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
+    : m_functionName(functionName)
+    , m_sourceURL(urlString)
+    , m_lineNumber(lineNumber)
+{
+    for (int i = 0; i < arguments.Length(); ++i)
+        m_arguments.append(ScriptValue(arguments[i]));
+}
+
+ScriptCallFrame::~ScriptCallFrame()
+{
+}
+
+const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
+{
+    ASSERT(m_arguments.size() > index);
+    return m_arguments[index];
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallFrame.h b/WebCore/bindings/v8/ScriptCallFrame.h
new file mode 100644 (file)
index 0000000..50357cf
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallFrame_h
+#define ScriptCallFrame_h
+
+#include "KURL.h"
+#include "ScriptString.h"
+
+#include <wtf/Vector.h>
+
+namespace v8 {
+    class Arguments;
+}
+
+namespace WebCore {
+    class ScriptValue;
+
+    // FIXME: Implement retrieving line number and source URL and storing here
+    // for all call frames, not just the first one.
+    // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and
+    // <https://bugs.webkit.org/show_bug.cgi?id=21180>
+    class ScriptCallFrame  {
+    public:
+        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount);
+        ~ScriptCallFrame();
+
+        const ScriptString& functionName() const { return m_functionName; }
+        const KURL& sourceURL() const { return m_sourceURL; }
+        unsigned lineNumber() const { return m_lineNumber; }
+
+        // argument retrieval methods
+        const ScriptValue& argumentAt(unsigned) const;
+        unsigned argumentCount() const { return m_arguments.size(); }
+
+    private:
+        ScriptString m_functionName;
+        KURL m_sourceURL;
+        unsigned m_lineNumber;
+
+        Vector<ScriptValue> m_arguments;
+    };
+
+} // namespace WebCore
+
+#endif // ScriptCallFrame_h
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp
new file mode 100644 (file)
index 0000000..9188dcf
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallStack.h"
+
+#include <v8.h>
+
+#include "V8Binding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount)
+    : m_lastCaller(String(), V8Proxy::GetSourceName(), V8Proxy::GetSourceLineNumber() + 1, arguments, skipArgumentCount)
+{
+}
+
+ScriptCallStack::~ScriptCallStack()
+{
+}
+
+const ScriptCallFrame& ScriptCallStack::at(unsigned index) const
+{
+    // Currently, only one ScriptCallFrame is supported. When we can get
+    // a full stack trace from V8, we can do this right.
+    ASSERT(index == 0);
+    return m_lastCaller;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
new file mode 100644 (file)
index 0000000..113ff99
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallStack_h
+#define ScriptCallStack_h
+
+#include "ScriptCallFrame.h"
+#include "ScriptValue.h"
+#include <wtf/Noncopyable.h>
+
+namespace v8 {
+    class Arguments;
+}
+
+namespace WebCore {
+
+    class ScriptCallStack : public Noncopyable {
+    public:
+        ScriptCallStack(const v8::Arguments&, unsigned skipArgumentCount = 0);
+        ~ScriptCallStack();
+
+        const ScriptCallFrame& at(unsigned) const;
+        // FIXME: implement retrieving and storing call stack trace
+        unsigned size() const { return 1; }
+
+    private:
+        ScriptCallFrame m_lastCaller;
+    };
+
+} // namespace WebCore
+
+#endif // ScriptCallStack_h
diff --git a/WebCore/bindings/v8/ScriptInstance.cpp b/WebCore/bindings/v8/ScriptInstance.cpp
new file mode 100644 (file)
index 0000000..aa4a396
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptInstance.h"
+
+#ifndef NDEBUG
+#include "V8Proxy.h"
+#endif
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+V8ScriptInstance::V8ScriptInstance()
+{
+}
+
+V8ScriptInstance::V8ScriptInstance(v8::Handle<v8::Object> instance)
+{
+    set(instance);
+}
+
+V8ScriptInstance::~V8ScriptInstance()
+{
+    clear();
+}
+
+v8::Persistent<v8::Object> V8ScriptInstance::instance()
+{
+    return m_instance;
+}
+
+void V8ScriptInstance::clear()
+{
+    if (m_instance.IsEmpty())
+        return;
+#ifndef NDEBUG
+    V8Proxy::UnregisterGlobalHandle(this, m_instance);
+#endif
+    m_instance.Dispose();
+    m_instance.Clear();
+}
+
+void V8ScriptInstance::set(v8::Handle<v8::Object> instance)
+{
+    clear();
+    if (instance.IsEmpty())
+        return;
+
+    m_instance = v8::Persistent<v8::Object>::New(instance);
+#ifndef NDEBUG
+    V8Proxy::RegisterGlobalHandle(SCRIPTINSTANCE, this, m_instance);
+#endif
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptInstance.h b/WebCore/bindings/v8/ScriptInstance.h
new file mode 100644 (file)
index 0000000..ed0be86
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptInstance_h
+#define ScriptInstance_h
+
+#include <v8.h>
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class V8ScriptInstance : public RefCounted<V8ScriptInstance> {
+public:
+    static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance)
+    {
+        return adoptRef(new V8ScriptInstance(instance));
+    }
+    V8ScriptInstance();
+    V8ScriptInstance(v8::Handle<v8::Object>);
+    ~V8ScriptInstance();
+    v8::Persistent<v8::Object> instance();
+
+private:
+    void clear();
+    void set(v8::Handle<v8::Object>);
+    mutable v8::Persistent<v8::Object> m_instance;
+};
+
+typedef RefPtr<V8ScriptInstance> ScriptInstance;
+typedef PassRefPtr<V8ScriptInstance> PassScriptInstance;
+
+} // namespace WebCore
+
+#endif // ScriptInstance_h
diff --git a/WebCore/bindings/v8/ScriptSourceCode.h b/WebCore/bindings/v8/ScriptSourceCode.h
new file mode 100644 (file)
index 0000000..fea387a
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptSourceCode_h
+#define ScriptSourceCode_h
+
+#include "CachedScript.h"
+#include "KURL.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class ScriptSourceCode {
+public:
+    ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1)
+        : m_source(source)
+        , m_url(url)
+        , m_startLine(startLine)
+    {
+    }
+
+    // We lose the encoding information from CachedScript.
+    // Not sure if that matters.
+    ScriptSourceCode(CachedScript* cs)
+        : m_source(cs->script())
+        , m_url(cs->url())
+        , m_startLine(1)
+    {
+    }
+
+    bool isEmpty() const { return m_source.isEmpty(); }
+
+    const String& source() const { return m_source; }
+    const KURL& url() const { return m_url; }
+    int startLine() const { return m_startLine; }
+
+private:
+    String m_source;
+    KURL m_url;
+    int m_startLine;
+};
+
+} // namespace WebCore
+
+#endif // ScriptSourceCode_h
diff --git a/WebCore/bindings/v8/ScriptState.h b/WebCore/bindings/v8/ScriptState.h
new file mode 100644 (file)
index 0000000..b5a9578
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptState_h
+#define ScriptState_h
+
+#include <v8.h>
+
+namespace WebCore {
+    class ScriptState {
+    public:
+        bool hadException() { return !m_exception.IsEmpty(); }
+        void setException(v8::Local<v8::Value> exception)
+        {
+            m_exception = exception;
+        }
+        v8::Local<v8::Value> exception() { return m_exception; }
+
+    private:
+        v8::Local<v8::Value> m_exception;
+    };
+}
+
+#endif // ScriptState_h
diff --git a/WebCore/bindings/v8/ScriptString.h b/WebCore/bindings/v8/ScriptString.h
new file mode 100644 (file)
index 0000000..66a575f
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptString_h
+#define ScriptString_h
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class ScriptString {
+public:
+    ScriptString(const String& s) : m_str(s) {}
+    ScriptString(const char* s) : m_str(s) {}
+
+    operator String() const { return m_str; }
+
+    bool isNull() const { return m_str.isNull(); }
+    size_t size() const { return m_str.length(); }
+
+    ScriptString& operator=(const char* s)
+    {
+        m_str = s;
+        return *this;
+    }
+
+    ScriptString& operator+=(const String& s)
+    {
+        m_str += s;
+        return *this;
+    }
+
+private:
+    String m_str;
+};
+
+} // namespace WebCore
+
+#endif // ScriptString_h
diff --git a/WebCore/bindings/v8/ScriptValue.cpp b/WebCore/bindings/v8/ScriptValue.cpp
new file mode 100644 (file)
index 0000000..ffdd3ce
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptValue.h"
+
+#include "V8Binding.h"
+
+namespace WebCore {
+
+bool ScriptValue::getString(String& result) const
+{
+    if (m_value.IsEmpty())
+        return false;
+
+    if (!m_value->IsString())
+        return false;
+
+    result = toWebCoreString(m_value);
+    return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptValue.h b/WebCore/bindings/v8/ScriptValue.h
new file mode 100644 (file)
index 0000000..32fcdd4
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptValue_h
+#define ScriptValue_h
+
+#include <v8.h>
+
+#ifndef NDEBUG
+#include "V8Proxy.h"  // for register and unregister global handles.
+#endif
+
+namespace WebCore {
+
+class String;
+
+class ScriptValue {
+public:
+    ScriptValue() {}
+
+    ScriptValue(v8::Handle<v8::Value> value) 
+    {
+        if (value.IsEmpty())
+            return;
+
+        m_value = v8::Persistent<v8::Value>::New(value);
+#ifndef NDEBUG
+        V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value);
+#endif
+    }
+
+    ScriptValue(const ScriptValue& value) 
+    {
+        if (value.m_value.IsEmpty())
+            return;
+
+        m_value = v8::Persistent<v8::Value>::New(value.m_value);
+#ifndef NDEBUG
+        V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value);
+#endif
+    }
+
+    ScriptValue& operator=(const ScriptValue& value) 
+    {
+        if (this == &value) 
+            return *this;
+
+        clear();
+
+        if (value.m_value.IsEmpty())
+            return *this;
+
+        m_value = v8::Persistent<v8::Value>::New(value.m_value);
+#ifndef NDEBUG
+        V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value);
+#endif
+
+        return *this;
+    }
+
+    bool operator==(const ScriptValue value) const
+    {
+        return m_value == value.m_value;
+    }
+
+    bool operator!=(const ScriptValue value) const
+    {
+        return !operator==(value);
+    }
+
+    bool isNull() const
+    {
+        return m_value->IsNull();
+    }
+
+    bool isUndefined() const
+    {
+        return m_value->IsUndefined();
+    }
+
+    void clear()
+    {
+        if (!m_value.IsEmpty())
+            return;
+
+#ifndef NDEBUG
+        V8Proxy::UnregisterGlobalHandle(this, m_value);
+#endif
+        m_value.Dispose();
+        m_value.Clear();
+    }
+
+    ~ScriptValue() 
+    {
+        clear();
+    }
+
+    v8::Handle<v8::Value> v8Value() const { return m_value; }
+    bool getString(String& result) const;
+
+private:
+    mutable v8::Persistent<v8::Value> m_value;
+};
+
+} // namespace WebCore
+
+#endif // ScriptValue_h