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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 if (object->IsNumber()) | 56 if (object->IsNumber()) |
57 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); | 57 DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); |
58 else if (object->IsBoolean()) | 58 else if (object->IsBoolean()) |
59 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); | 59 BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result); |
60 else if (object->IsNull()) | 60 else if (object->IsNull()) |
61 NULL_TO_NPVARIANT(*result); | 61 NULL_TO_NPVARIANT(*result); |
62 else if (object->IsUndefined()) | 62 else if (object->IsUndefined()) |
63 VOID_TO_NPVARIANT(*result); | 63 VOID_TO_NPVARIANT(*result); |
64 else if (object->IsString()) { | 64 else if (object->IsString()) { |
65 v8::Handle<v8::String> str = object->ToString(); | 65 v8::String::Utf8Value utf8(object); |
66 int length = str->Utf8Length() + 1; | 66 int length = utf8.length() + 1; |
67 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); | 67 char* utf8Chars = reinterpret_cast<char*>(malloc(length)); |
68 str->WriteUtf8(utf8Chars, length, 0, v8::String::HINT_MANY_WRITES_EXPECT
ED); | 68 memcpy(utf8Chars, *utf8, length); |
69 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); | 69 STRINGN_TO_NPVARIANT(utf8Chars, utf8.length(), *result); |
70 } else if (object->IsObject()) { | 70 } else if (object->IsObject()) { |
71 DOMWindow* window = V8Proxy::retrieveWindow(V8Proxy::currentContext()); | 71 DOMWindow* window = V8Proxy::retrieveWindow(V8Proxy::currentContext()); |
72 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window); | 72 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::C
ast(object), window); |
73 if (npobject) | 73 if (npobject) |
74 _NPN_RegisterObject(npobject, owner); | 74 _NPN_RegisterObject(npobject, owner); |
75 OBJECT_TO_NPVARIANT(npobject, *result); | 75 OBJECT_TO_NPVARIANT(npobject, *result); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* npobject) | 79 v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObj
ect* npobject) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ExceptionCatcher::~ExceptionCatcher() | 161 ExceptionCatcher::~ExceptionCatcher() |
162 { | 162 { |
163 if (!m_tryCatch.HasCaught()) | 163 if (!m_tryCatch.HasCaught()) |
164 return; | 164 return; |
165 | 165 |
166 if (topHandler) | 166 if (topHandler) |
167 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); | 167 topHandler->handler(topHandler->data, *v8::String::Utf8Value(m_tryCatch.
Exception())); |
168 } | 168 } |
169 | 169 |
170 } // namespace WebCore | 170 } // namespace WebCore |
OLD | NEW |