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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 m_arguments.append(argument); | 54 m_arguments.append(argument); |
55 } | 55 } |
56 | 56 |
57 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument) | 57 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument) |
58 { | 58 { |
59 m_arguments.append(argument); | 59 m_arguments.append(argument); |
60 } | 60 } |
61 | 61 |
62 void ScriptCallArgumentHandler::appendArgument(const String& argument) | 62 void ScriptCallArgumentHandler::appendArgument(const String& argument) |
63 { | 63 { |
| 64 v8::Isolate* isolate = m_scriptState->isolate(); |
64 ScriptScope scope(m_scriptState); | 65 ScriptScope scope(m_scriptState); |
65 m_arguments.append(v8String(argument, m_scriptState->isolate())); | 66 m_arguments.append(ScriptValue(v8String(argument, isolate), isolate)); |
66 } | 67 } |
67 | 68 |
68 void ScriptCallArgumentHandler::appendArgument(const char* argument) | 69 void ScriptCallArgumentHandler::appendArgument(const char* argument) |
69 { | 70 { |
| 71 v8::Isolate* isolate = m_scriptState->isolate(); |
70 ScriptScope scope(m_scriptState); | 72 ScriptScope scope(m_scriptState); |
71 m_arguments.append(v8String(argument, m_scriptState->isolate())); | 73 m_arguments.append(ScriptValue(v8String(argument, isolate), isolate)); |
72 } | 74 } |
73 | 75 |
74 void ScriptCallArgumentHandler::appendArgument(long argument) | 76 void ScriptCallArgumentHandler::appendArgument(long argument) |
75 { | 77 { |
| 78 v8::Isolate* isolate = m_scriptState->isolate(); |
76 ScriptScope scope(m_scriptState); | 79 ScriptScope scope(m_scriptState); |
77 m_arguments.append(v8::Number::New(m_scriptState->isolate(), argument)); | 80 m_arguments.append(ScriptValue(v8::Number::New(isolate, argument), isolate))
; |
78 } | 81 } |
79 | 82 |
80 void ScriptCallArgumentHandler::appendArgument(long long argument) | 83 void ScriptCallArgumentHandler::appendArgument(long long argument) |
81 { | 84 { |
| 85 v8::Isolate* isolate = m_scriptState->isolate(); |
82 ScriptScope scope(m_scriptState); | 86 ScriptScope scope(m_scriptState); |
83 m_arguments.append(v8::Number::New(m_scriptState->isolate(), argument)); | 87 m_arguments.append(ScriptValue(v8::Number::New(isolate, argument), isolate))
; |
84 } | 88 } |
85 | 89 |
86 void ScriptCallArgumentHandler::appendArgument(unsigned int argument) | 90 void ScriptCallArgumentHandler::appendArgument(unsigned int argument) |
87 { | 91 { |
| 92 v8::Isolate* isolate = m_scriptState->isolate(); |
88 ScriptScope scope(m_scriptState); | 93 ScriptScope scope(m_scriptState); |
89 m_arguments.append(v8::Number::New(m_scriptState->isolate(), argument)); | 94 m_arguments.append(ScriptValue(v8::Number::New(isolate, argument), isolate))
; |
90 } | 95 } |
91 | 96 |
92 void ScriptCallArgumentHandler::appendArgument(unsigned long argument) | 97 void ScriptCallArgumentHandler::appendArgument(unsigned long argument) |
93 { | 98 { |
| 99 v8::Isolate* isolate = m_scriptState->isolate(); |
94 ScriptScope scope(m_scriptState); | 100 ScriptScope scope(m_scriptState); |
95 m_arguments.append(v8::Number::New(m_scriptState->isolate(), argument)); | 101 m_arguments.append(ScriptValue(v8::Number::New(isolate, argument), isolate))
; |
96 } | 102 } |
97 | 103 |
98 void ScriptCallArgumentHandler::appendArgument(int argument) | 104 void ScriptCallArgumentHandler::appendArgument(int argument) |
99 { | 105 { |
| 106 v8::Isolate* isolate = m_scriptState->isolate(); |
100 ScriptScope scope(m_scriptState); | 107 ScriptScope scope(m_scriptState); |
101 m_arguments.append(v8::Number::New(m_scriptState->isolate(), argument)); | 108 m_arguments.append(ScriptValue(v8::Number::New(isolate, argument), isolate))
; |
102 } | 109 } |
103 | 110 |
104 void ScriptCallArgumentHandler::appendArgument(bool argument) | 111 void ScriptCallArgumentHandler::appendArgument(bool argument) |
105 { | 112 { |
106 m_arguments.append(v8Boolean(argument, m_scriptState->isolate())); | 113 v8::Isolate* isolate = m_scriptState->isolate(); |
| 114 m_arguments.append(ScriptValue(v8Boolean(argument, isolate), isolate)); |
107 } | 115 } |
108 | 116 |
109 ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const Str
ing& name) | 117 ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const Str
ing& name) |
110 : ScriptCallArgumentHandler(thisObject.scriptState()) | 118 : ScriptCallArgumentHandler(thisObject.scriptState()) |
111 , m_thisObject(thisObject) | 119 , m_thisObject(thisObject) |
112 , m_name(name) | 120 , m_name(name) |
113 { | 121 { |
114 } | 122 } |
115 | 123 |
116 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) | 124 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) |
(...skipping 15 matching lines...) Expand all Loading... |
132 args[i] = m_arguments[i].v8Value(); | 140 args[i] = m_arguments[i].v8Value(); |
133 ASSERT(!args[i].IsEmpty()); | 141 ASSERT(!args[i].IsEmpty()); |
134 } | 142 } |
135 | 143 |
136 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getScri
ptExecutionContext(), thisObject, m_arguments.size(), args.get(), m_scriptState-
>isolate()); | 144 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getScri
ptExecutionContext(), thisObject, m_arguments.size(), args.get(), m_scriptState-
>isolate()); |
137 if (!scope.success()) { | 145 if (!scope.success()) { |
138 hadException = true; | 146 hadException = true; |
139 return ScriptValue(); | 147 return ScriptValue(); |
140 } | 148 } |
141 | 149 |
142 return ScriptValue(result); | 150 return ScriptValue(result, m_scriptState->isolate()); |
143 } | 151 } |
144 | 152 |
145 ScriptValue ScriptFunctionCall::call() | 153 ScriptValue ScriptFunctionCall::call() |
146 { | 154 { |
147 bool hadException = false; | 155 bool hadException = false; |
148 return call(hadException); | 156 return call(hadException); |
149 } | 157 } |
150 | 158 |
151 ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
ions) | 159 ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
ions) |
152 { | 160 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 v8::TryCatch exceptionCatcher; | 197 v8::TryCatch exceptionCatcher; |
190 exceptionCatcher.SetVerbose(true); | 198 exceptionCatcher.SetVerbose(true); |
191 v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global(); | 199 v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global(); |
192 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()); |
193 | 201 |
194 OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::
Value>[m_arguments.size()]); | 202 OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::
Value>[m_arguments.size()]); |
195 for (size_t i = 0; i < m_arguments.size(); ++i) | 203 for (size_t i = 0; i < m_arguments.size(); ++i) |
196 args[i] = m_arguments[i].v8Value(); | 204 args[i] = m_arguments[i].v8Value(); |
197 | 205 |
198 v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumenta
tion(0, function, object, m_arguments.size(), args.get(), m_scriptState->isolate
()); | 206 v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumenta
tion(0, function, object, m_arguments.size(), args.get(), m_scriptState->isolate
()); |
199 return ScriptValue(result); | 207 return ScriptValue(result, m_scriptState->isolate()); |
200 } | 208 } |
201 | 209 |
202 } // namespace WebCore | 210 } // namespace WebCore |
OLD | NEW |