Commit 248f91ad authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41159 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 998f4921
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.
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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;
}