Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/bindings/v8/ScriptFunctionCall.cpp

Issue 293963003: Remove ScriptObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/ScriptFunctionCall.h ('k') | Source/bindings/v8/ScriptObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 #include "bindings/v8/ScriptState.h" 35 #include "bindings/v8/ScriptState.h"
36 #include "bindings/v8/ScriptValue.h" 36 #include "bindings/v8/ScriptValue.h"
37 #include "bindings/v8/V8Binding.h" 37 #include "bindings/v8/V8Binding.h"
38 #include "bindings/v8/V8ObjectConstructor.h" 38 #include "bindings/v8/V8ObjectConstructor.h"
39 #include "bindings/v8/V8ScriptRunner.h" 39 #include "bindings/v8/V8ScriptRunner.h"
40 40
41 #include <v8.h> 41 #include <v8.h>
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 void ScriptCallArgumentHandler::appendArgument(const ScriptObject& argument) 45 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument)
46 { 46 {
47 if (argument.scriptState() != m_scriptState) { 47 if (argument.scriptState() != m_scriptState) {
48 ASSERT_NOT_REACHED(); 48 ASSERT_NOT_REACHED();
49 return; 49 return;
50 } 50 }
51 m_arguments.append(argument); 51 m_arguments.append(argument);
52 } 52 }
53 53
54 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument)
55 {
56 m_arguments.append(argument);
57 }
58
59 void ScriptCallArgumentHandler::appendArgument(const String& argument) 54 void ScriptCallArgumentHandler::appendArgument(const String& argument)
60 { 55 {
61 v8::Isolate* isolate = m_scriptState->isolate(); 56 v8::Isolate* isolate = m_scriptState->isolate();
62 ScriptState::Scope scope(m_scriptState.get()); 57 ScriptState::Scope scope(m_scriptState.get());
63 m_arguments.append(ScriptValue(m_scriptState.get(), v8String(isolate, argume nt))); 58 m_arguments.append(ScriptValue(m_scriptState.get(), v8String(isolate, argume nt)));
64 } 59 }
65 60
66 void ScriptCallArgumentHandler::appendArgument(const char* argument) 61 void ScriptCallArgumentHandler::appendArgument(const char* argument)
67 { 62 {
68 v8::Isolate* isolate = m_scriptState->isolate(); 63 v8::Isolate* isolate = m_scriptState->isolate();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void ScriptCallArgumentHandler::appendArgument(const Vector<ScriptValue>& argume nt) 109 void ScriptCallArgumentHandler::appendArgument(const Vector<ScriptValue>& argume nt)
115 { 110 {
116 v8::Isolate* isolate = m_scriptState->isolate(); 111 v8::Isolate* isolate = m_scriptState->isolate();
117 ScriptState::Scope scope(m_scriptState.get()); 112 ScriptState::Scope scope(m_scriptState.get());
118 v8::Handle<v8::Array> result = v8::Array::New(isolate, argument.size()); 113 v8::Handle<v8::Array> result = v8::Array::New(isolate, argument.size());
119 for (size_t i = 0; i < argument.size(); ++i) 114 for (size_t i = 0; i < argument.size(); ++i)
120 result->Set(v8::Integer::New(isolate, i), argument[i].v8Value()); 115 result->Set(v8::Integer::New(isolate, i), argument[i].v8Value());
121 m_arguments.append(ScriptValue(m_scriptState.get(), result)); 116 m_arguments.append(ScriptValue(m_scriptState.get(), result));
122 } 117 }
123 118
124 ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const Str ing& name) 119 ScriptFunctionCall::ScriptFunctionCall(const ScriptValue& thisObject, const Stri ng& name)
125 : ScriptCallArgumentHandler(thisObject.scriptState()) 120 : ScriptCallArgumentHandler(thisObject.scriptState())
126 , m_thisObject(thisObject) 121 , m_thisObject(thisObject)
127 , m_name(name) 122 , m_name(name)
128 { 123 {
129 } 124 }
130 125
131 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) 126 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions)
132 { 127 {
133 ScriptState::Scope scope(m_scriptState.get()); 128 ScriptState::Scope scope(m_scriptState.get());
134 v8::TryCatch tryCatch; 129 v8::TryCatch tryCatch;
135 tryCatch.SetVerbose(reportExceptions); 130 tryCatch.SetVerbose(reportExceptions);
136 131
137 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); 132 v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(m_thisObjec t.v8Value());
138 v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate (), m_name)); 133 v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate (), m_name));
139 if (tryCatch.HasCaught()) { 134 if (tryCatch.HasCaught()) {
140 hadException = true; 135 hadException = true;
141 return ScriptValue(); 136 return ScriptValue();
142 } 137 }
143 138
144 ASSERT(value->IsFunction()); 139 ASSERT(value->IsFunction());
145 140
146 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); 141 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
147 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[m_arguments.size()]); 142 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[m_arguments.size()]);
(...skipping 10 matching lines...) Expand all
158 153
159 return ScriptValue(m_scriptState.get(), result); 154 return ScriptValue(m_scriptState.get(), result);
160 } 155 }
161 156
162 ScriptValue ScriptFunctionCall::call() 157 ScriptValue ScriptFunctionCall::call()
163 { 158 {
164 bool hadException = false; 159 bool hadException = false;
165 return call(hadException); 160 return call(hadException);
166 } 161 }
167 162
168 ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept ions) 163 ScriptValue ScriptFunctionCall::construct(bool& hadException, bool reportExcepti ons)
169 { 164 {
170 ScriptState::Scope scope(m_scriptState.get()); 165 ScriptState::Scope scope(m_scriptState.get());
171 v8::TryCatch tryCatch; 166 v8::TryCatch tryCatch;
172 tryCatch.SetVerbose(reportExceptions); 167 tryCatch.SetVerbose(reportExceptions);
173 168
174 v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); 169 v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(m_thisObjec t.v8Value());
175 v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate (), m_name)); 170 v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate (), m_name));
176 if (tryCatch.HasCaught()) { 171 if (tryCatch.HasCaught()) {
177 hadException = true; 172 hadException = true;
178 return ScriptObject(); 173 return ScriptValue();
179 } 174 }
180 175
181 ASSERT(value->IsFunction()); 176 ASSERT(value->IsFunction());
182 177
183 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value); 178 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value);
184 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[m_arguments.size()]); 179 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[m_arguments.size()]);
185 for (size_t i = 0; i < m_arguments.size(); ++i) 180 for (size_t i = 0; i < m_arguments.size(); ++i)
186 info[i] = m_arguments[i].v8Value(); 181 info[i] = m_arguments[i].v8Value();
187 182
188 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptStat e->isolate(), constructor, m_arguments.size(), info.get()); 183 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptStat e->isolate(), constructor, m_arguments.size(), info.get());
189 if (tryCatch.HasCaught()) { 184 if (tryCatch.HasCaught()) {
190 hadException = true; 185 hadException = true;
191 return ScriptObject(); 186 return ScriptValue();
192 } 187 }
193 188
194 return ScriptObject(m_scriptState.get(), result); 189 return ScriptValue(m_scriptState.get(), result);
195 } 190 }
196 191
197 } // namespace WebCore 192 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptFunctionCall.h ('k') | Source/bindings/v8/ScriptObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698