diff options
Diffstat (limited to 'WebCore/bindings/v8/V8NPUtils.cpp')
-rw-r--r-- | WebCore/bindings/v8/V8NPUtils.cpp | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/WebCore/bindings/v8/V8NPUtils.cpp b/WebCore/bindings/v8/V8NPUtils.cpp index 17855d7..8fa19d7 100644 --- a/WebCore/bindings/v8/V8NPUtils.cpp +++ b/WebCore/bindings/v8/V8NPUtils.cpp @@ -29,19 +29,18 @@ */ #include "config.h" - #include "V8NPUtils.h" #include "DOMWindow.h" #include "Frame.h" #include "PlatformString.h" -#undef LOG - +#include "npruntime_impl.h" +#include "npruntime_priv.h" #include "NPV8Object.h" #include "V8NPObject.h" #include "V8Proxy.h" -#include "npruntime_impl.h" -#include "npruntime_priv.h" + +namespace WebCore { void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NPVariant* result) { @@ -69,7 +68,7 @@ void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP char* utf8_chars = strdup(*utf8); STRINGN_TO_NPVARIANT(utf8_chars, utf8.length(), *result); } else if (object->IsObject()) { - WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(WebCore::V8Proxy::currentContext()); + DOMWindow* window = V8Proxy::retrieveWindow(V8Proxy::currentContext()); NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(object), window); if (npobject) _NPN_RegisterObject(npobject, owner); @@ -77,7 +76,6 @@ void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP } } - v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObject* npobject) { NPVariantType type = variant->type; @@ -128,3 +126,45 @@ NPIdentifier getStringIdentifier(v8::Handle<v8::String> str) v8::String::Utf8Value utf8(str); return _NPN_GetStringIdentifier(*utf8); } + +struct ExceptionHandlerInfo { + ExceptionHandlerInfo* previous; + ExceptionHandler handler; + void* data; +}; + +static ExceptionHandlerInfo* topHandler; + +void pushExceptionHandler(ExceptionHandler handler, void* data) +{ + ExceptionHandlerInfo* info = new ExceptionHandlerInfo; + info->previous = topHandler; + info->handler = handler; + info->data = data; + topHandler = info; +} + +void popExceptionHandler() +{ + ASSERT(topHandler); + ExceptionHandlerInfo* doomed = topHandler; + topHandler = topHandler->previous; + delete doomed; +} + +ExceptionCatcher::ExceptionCatcher() +{ + if (!topHandler) + m_tryCatch.SetVerbose(true); +} + +ExceptionCatcher::~ExceptionCatcher() +{ + if (!m_tryCatch.HasCaught()) + return; + + if (topHandler) + topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.Exception())); +} + +} // namespace WebCore |