| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); | 127 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); |
| 128 v8::Local<v8::Value> value = thisObject->Get(v8String(m_name, m_scriptState-
>isolate())); | 128 v8::Local<v8::Value> value = thisObject->Get(v8String(m_name, m_scriptState-
>isolate())); |
| 129 if (!scope.success()) { | 129 if (!scope.success()) { |
| 130 hadException = true; | 130 hadException = true; |
| 131 return ScriptValue(); | 131 return ScriptValue(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 ASSERT(value->IsFunction()); | 134 ASSERT(value->IsFunction()); |
| 135 | 135 |
| 136 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 136 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 137 OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); | 137 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); |
| 138 for (size_t i = 0; i < m_arguments.size(); ++i) { | 138 for (size_t i = 0; i < m_arguments.size(); ++i) { |
| 139 args[i] = m_arguments[i].v8Value(); | 139 info[i] = m_arguments[i].v8Value(); |
| 140 ASSERT(!args[i].IsEmpty()); | 140 ASSERT(!info[i].IsEmpty()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getExec
utionContext(), thisObject, m_arguments.size(), args.get(), m_scriptState->isola
te()); | 143 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getExec
utionContext(), thisObject, m_arguments.size(), info.get(), m_scriptState->isola
te()); |
| 144 if (!scope.success()) { | 144 if (!scope.success()) { |
| 145 hadException = true; | 145 hadException = true; |
| 146 return ScriptValue(); | 146 return ScriptValue(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 return ScriptValue(result, m_scriptState->isolate()); | 149 return ScriptValue(result, m_scriptState->isolate()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 ScriptValue ScriptFunctionCall::call() | 152 ScriptValue ScriptFunctionCall::call() |
| 153 { | 153 { |
| 154 bool hadException = false; | 154 bool hadException = false; |
| 155 return call(hadException); | 155 return call(hadException); |
| 156 } | 156 } |
| 157 | 157 |
| 158 ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
ions) | 158 ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
ions) |
| 159 { | 159 { |
| 160 ScriptScope scope(m_scriptState, reportExceptions); | 160 ScriptScope scope(m_scriptState, reportExceptions); |
| 161 | 161 |
| 162 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); | 162 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); |
| 163 v8::Local<v8::Value> value = thisObject->Get(v8String(m_name, m_scriptState-
>isolate())); | 163 v8::Local<v8::Value> value = thisObject->Get(v8String(m_name, m_scriptState-
>isolate())); |
| 164 if (!scope.success()) { | 164 if (!scope.success()) { |
| 165 hadException = true; | 165 hadException = true; |
| 166 return ScriptObject(); | 166 return ScriptObject(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 ASSERT(value->IsFunction()); | 169 ASSERT(value->IsFunction()); |
| 170 | 170 |
| 171 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value); | 171 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value); |
| 172 OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); | 172 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); |
| 173 for (size_t i = 0; i < m_arguments.size(); ++i) | 173 for (size_t i = 0; i < m_arguments.size(); ++i) |
| 174 args[i] = m_arguments[i].v8Value(); | 174 info[i] = m_arguments[i].v8Value(); |
| 175 | 175 |
| 176 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(constructor,
m_arguments.size(), args.get()); | 176 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(constructor,
m_arguments.size(), info.get()); |
| 177 if (!scope.success()) { | 177 if (!scope.success()) { |
| 178 hadException = true; | 178 hadException = true; |
| 179 return ScriptObject(); | 179 return ScriptObject(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 return ScriptObject(m_scriptState, result); | 182 return ScriptObject(m_scriptState, result); |
| 183 } | 183 } |
| 184 | 184 |
| 185 ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function) | 185 ScriptCallback::ScriptCallback(ScriptState* state, const ScriptValue& function) |
| 186 : ScriptCallArgumentHandler(state) | 186 : ScriptCallArgumentHandler(state) |
| 187 , m_scriptState(state) | 187 , m_scriptState(state) |
| 188 , m_function(function) | 188 , m_function(function) |
| 189 { | 189 { |
| 190 } | 190 } |
| 191 | 191 |
| 192 ScriptValue ScriptCallback::call() | 192 ScriptValue ScriptCallback::call() |
| 193 { | 193 { |
| 194 ASSERT(v8::Context::InContext()); | 194 ASSERT(v8::Context::InContext()); |
| 195 ASSERT(m_function.v8Value()->IsFunction()); | 195 ASSERT(m_function.v8Value()->IsFunction()); |
| 196 | 196 |
| 197 v8::TryCatch exceptionCatcher; | 197 v8::TryCatch exceptionCatcher; |
| 198 exceptionCatcher.SetVerbose(true); | 198 exceptionCatcher.SetVerbose(true); |
| 199 v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global(); | 199 v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global(); |
| 200 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(m_functio
n.v8Value()); | 200 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(m_functio
n.v8Value()); |
| 201 | 201 |
| 202 OwnPtr<v8::Handle<v8::Value>[]> args = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); | 202 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu
e>[m_arguments.size()]); |
| 203 for (size_t i = 0; i < m_arguments.size(); ++i) | 203 for (size_t i = 0; i < m_arguments.size(); ++i) |
| 204 args[i] = m_arguments[i].v8Value(); | 204 info[i] = m_arguments[i].v8Value(); |
| 205 | 205 |
| 206 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState-
>executionContext(), function, object, m_arguments.size(), args.get(), m_scriptS
tate->isolate()); | 206 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState-
>executionContext(), function, object, m_arguments.size(), info.get(), m_scriptS
tate->isolate()); |
| 207 return ScriptValue(result, m_scriptState->isolate()); | 207 return ScriptValue(result, m_scriptState->isolate()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace WebCore | 210 } // namespace WebCore |
| OLD | NEW |