| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/V8NPUtils.h" | 32 #include "bindings/v8/V8NPUtils.h" |
| 33 | 33 |
| 34 #include "bindings/v8/NPV8Object.h" | 34 #include "bindings/v8/NPV8Object.h" |
| 35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
| 36 #include "bindings/v8/V8NPObject.h" | 36 #include "bindings/v8/V8NPObject.h" |
| 37 #include "bindings/v8/npruntime_impl.h" | 37 #include "bindings/v8/npruntime_impl.h" |
| 38 #include "bindings/v8/npruntime_priv.h" | 38 #include "bindings/v8/npruntime_priv.h" |
| 39 #include "core/frame/DOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 #include <stdlib.h> | 42 #include <stdlib.h> |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result, v8::Isolate* isolate) | 46 void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP
Variant* result, v8::Isolate* isolate) |
| 47 { | 47 { |
| 48 VOID_TO_NPVARIANT(*result); | 48 VOID_TO_NPVARIANT(*result); |
| 49 | 49 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 NULL_TO_NPVARIANT(*result); | 62 NULL_TO_NPVARIANT(*result); |
| 63 else if (object->IsUndefined()) | 63 else if (object->IsUndefined()) |
| 64 VOID_TO_NPVARIANT(*result); | 64 VOID_TO_NPVARIANT(*result); |
| 65 else if (object->IsString()) { | 65 else if (object->IsString()) { |
| 66 v8::Handle<v8::String> str = object.As<v8::String>(); | 66 v8::Handle<v8::String> str = object.As<v8::String>(); |
| 67 int length = str->Utf8Length() + 1; | 67 int length = str->Utf8Length() + 1; |
| 68 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); | 68 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); |
| 69 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); | 69 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); |
| 70 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); | 70 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); |
| 71 } else if (object->IsObject()) { | 71 } else if (object->IsObject()) { |
| 72 DOMWindow* window = currentDOMWindow(isolate); | 72 LocalDOMWindow* window = currentDOMWindow(isolate); |
| 73 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window, isolate); | 73 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window, isolate); |
| 74 if (npobject) | 74 if (npobject) |
| 75 _NPN_RegisterObject(npobject, owner); | 75 _NPN_RegisterObject(npobject, owner); |
| 76 OBJECT_TO_NPVARIANT(npobject, *result); | 76 OBJECT_TO_NPVARIANT(npobject, *result); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* owner, v8::Isolate* isolate) | 80 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* owner, v8::Isolate* isolate) |
| 81 { | 81 { |
| 82 NPVariantType type = variant->type; | 82 NPVariantType type = variant->type; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ExceptionCatcher::~ExceptionCatcher() | 162 ExceptionCatcher::~ExceptionCatcher() |
| 163 { | 163 { |
| 164 if (!m_tryCatch.HasCaught()) | 164 if (!m_tryCatch.HasCaught()) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 if (topHandler) | 167 if (topHandler) |
| 168 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); | 168 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace WebCore | 171 } // namespace WebCore |
| OLD | NEW |