| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 } | 56 } |
| 57 | 57 |
| 58 void V8TestCallbackInterface::voidMethod() | 58 void V8TestCallbackInterface::voidMethod() |
| 59 { | 59 { |
| 60 if (!canInvokeCallback()) | 60 if (!canInvokeCallback()) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 v8::HandleScope handleScope(m_isolate); | 63 v8::HandleScope handleScope(m_isolate); |
| 64 | 64 |
| 65 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 65 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 66 if (v8Context.IsEmpty()) | 66 if (v8Context.IsEmpty()) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 v8::Context::Scope scope(v8Context); | 69 v8::Context::Scope scope(v8Context); |
| 70 v8::Handle<v8::Value> *argv = 0; | 70 v8::Handle<v8::Value> *argv = 0; |
| 71 | 71 |
| 72 invokeCallback(m_callback.newLocal(m_isolate), 0, argv, executionContext(),
m_isolate); | 72 invokeCallback(m_callback.newLocal(m_isolate), 0, argv, executionContext(),
m_isolate); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool V8TestCallbackInterface::booleanMethod() | 75 bool V8TestCallbackInterface::booleanMethod() |
| 76 { | 76 { |
| 77 if (!canInvokeCallback()) | 77 if (!canInvokeCallback()) |
| 78 return true; | 78 return true; |
| 79 | 79 |
| 80 v8::HandleScope handleScope(m_isolate); | 80 v8::HandleScope handleScope(m_isolate); |
| 81 | 81 |
| 82 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 82 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 83 if (v8Context.IsEmpty()) | 83 if (v8Context.IsEmpty()) |
| 84 return true; | 84 return true; |
| 85 | 85 |
| 86 v8::Context::Scope scope(v8Context); | 86 v8::Context::Scope scope(v8Context); |
| 87 v8::Handle<v8::Value> *argv = 0; | 87 v8::Handle<v8::Value> *argv = 0; |
| 88 | 88 |
| 89 return invokeCallback(m_callback.newLocal(m_isolate), 0, argv, executionCont
ext(), m_isolate); | 89 return invokeCallback(m_callback.newLocal(m_isolate), 0, argv, executionCont
ext(), m_isolate); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) | 92 void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) |
| 93 { | 93 { |
| 94 if (!canInvokeCallback()) | 94 if (!canInvokeCallback()) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 v8::HandleScope handleScope(m_isolate); | 97 v8::HandleScope handleScope(m_isolate); |
| 98 | 98 |
| 99 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 99 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 100 if (v8Context.IsEmpty()) | 100 if (v8Context.IsEmpty()) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 v8::Context::Scope scope(v8Context); | 103 v8::Context::Scope scope(v8Context); |
| 104 v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, m_isolate); | 104 v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, m_isolate); |
| 105 if (boolArgHandle.IsEmpty()) { | 105 if (boolArgHandle.IsEmpty()) { |
| 106 if (!isScriptControllerTerminating()) | 106 if (!isScriptControllerTerminating()) |
| 107 CRASH(); | 107 CRASH(); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 v8::Handle<v8::Value> argv[] = { boolArgHandle }; | 110 v8::Handle<v8::Value> argv[] = { boolArgHandle }; |
| 111 | 111 |
| 112 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); | 112 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInte
rfaceEmpty> >& sequenceArg) | 115 void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInte
rfaceEmpty> >& sequenceArg) |
| 116 { | 116 { |
| 117 if (!canInvokeCallback()) | 117 if (!canInvokeCallback()) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 v8::HandleScope handleScope(m_isolate); | 120 v8::HandleScope handleScope(m_isolate); |
| 121 | 121 |
| 122 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 122 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 123 if (v8Context.IsEmpty()) | 123 if (v8Context.IsEmpty()) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 v8::Context::Scope scope(v8Context); | 126 v8::Context::Scope scope(v8Context); |
| 127 v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_isolate); | 127 v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_isolate); |
| 128 if (sequenceArgHandle.IsEmpty()) { | 128 if (sequenceArgHandle.IsEmpty()) { |
| 129 if (!isScriptControllerTerminating()) | 129 if (!isScriptControllerTerminating()) |
| 130 CRASH(); | 130 CRASH(); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; | 133 v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; |
| 134 | 134 |
| 135 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); | 135 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) | 138 void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) |
| 139 { | 139 { |
| 140 if (!canInvokeCallback()) | 140 if (!canInvokeCallback()) |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 v8::HandleScope handleScope(m_isolate); | 143 v8::HandleScope handleScope(m_isolate); |
| 144 | 144 |
| 145 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 145 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 146 if (v8Context.IsEmpty()) | 146 if (v8Context.IsEmpty()) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 v8::Context::Scope scope(v8Context); | 149 v8::Context::Scope scope(v8Context); |
| 150 v8::Handle<v8::Value> floatArgHandle = v8::Number::New(m_isolate, floatArg); | 150 v8::Handle<v8::Value> floatArgHandle = v8::Number::New(m_isolate, floatArg); |
| 151 if (floatArgHandle.IsEmpty()) { | 151 if (floatArgHandle.IsEmpty()) { |
| 152 if (!isScriptControllerTerminating()) | 152 if (!isScriptControllerTerminating()) |
| 153 CRASH(); | 153 CRASH(); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 v8::Handle<v8::Value> argv[] = { floatArgHandle }; | 156 v8::Handle<v8::Value> argv[] = { floatArgHandle }; |
| 157 | 157 |
| 158 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); | 158 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty
* testInterfaceEmptyArg) | 161 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty
* testInterfaceEmptyArg) |
| 162 { | 162 { |
| 163 if (!canInvokeCallback()) | 163 if (!canInvokeCallback()) |
| 164 return; | 164 return; |
| 165 | 165 |
| 166 v8::HandleScope handleScope(m_isolate); | 166 v8::HandleScope handleScope(m_isolate); |
| 167 | 167 |
| 168 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 168 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 169 if (v8Context.IsEmpty()) | 169 if (v8Context.IsEmpty()) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 v8::Context::Scope scope(v8Context); | 172 v8::Context::Scope scope(v8Context); |
| 173 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyA
rg, v8::Handle<v8::Object>(), m_isolate); | 173 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyA
rg, v8::Handle<v8::Object>(), m_isolate); |
| 174 if (testInterfaceEmptyArgHandle.IsEmpty()) { | 174 if (testInterfaceEmptyArgHandle.IsEmpty()) { |
| 175 if (!isScriptControllerTerminating()) | 175 if (!isScriptControllerTerminating()) |
| 176 CRASH(); | 176 CRASH(); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle }; | 179 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle }; |
| 180 | 180 |
| 181 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); | 181 invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(),
m_isolate); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac
eEmpty* testInterfaceEmptyArg, const String& stringArg) | 184 void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac
eEmpty* testInterfaceEmptyArg, const String& stringArg) |
| 185 { | 185 { |
| 186 if (!canInvokeCallback()) | 186 if (!canInvokeCallback()) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 v8::HandleScope handleScope(m_isolate); | 189 v8::HandleScope handleScope(m_isolate); |
| 190 | 190 |
| 191 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 191 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 192 if (v8Context.IsEmpty()) | 192 if (v8Context.IsEmpty()) |
| 193 return; | 193 return; |
| 194 | 194 |
| 195 v8::Context::Scope scope(v8Context); | 195 v8::Context::Scope scope(v8Context); |
| 196 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyA
rg, v8::Handle<v8::Object>(), m_isolate); | 196 v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyA
rg, v8::Handle<v8::Object>(), m_isolate); |
| 197 if (testInterfaceEmptyArgHandle.IsEmpty()) { | 197 if (testInterfaceEmptyArgHandle.IsEmpty()) { |
| 198 if (!isScriptControllerTerminating()) | 198 if (!isScriptControllerTerminating()) |
| 199 CRASH(); | 199 CRASH(); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg); | 202 v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg); |
| 203 if (stringArgHandle.IsEmpty()) { | 203 if (stringArgHandle.IsEmpty()) { |
| 204 if (!isScriptControllerTerminating()) | 204 if (!isScriptControllerTerminating()) |
| 205 CRASH(); | 205 CRASH(); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandl
e }; | 208 v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandl
e }; |
| 209 | 209 |
| 210 invokeCallback(m_callback.newLocal(m_isolate), 2, argv, executionContext(),
m_isolate); | 210 invokeCallback(m_callback.newLocal(m_isolate), 2, argv, executionContext(),
m_isolate); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal
ue thisValue, const String& stringArg) | 213 void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal
ue thisValue, const String& stringArg) |
| 214 { | 214 { |
| 215 if (!canInvokeCallback()) | 215 if (!canInvokeCallback()) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 v8::HandleScope handleScope(m_isolate); | 218 v8::HandleScope handleScope(m_isolate); |
| 219 | 219 |
| 220 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 220 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world)
; |
| 221 if (v8Context.IsEmpty()) | 221 if (v8Context.IsEmpty()) |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 v8::Context::Scope scope(v8Context); | 224 v8::Context::Scope scope(v8Context); |
| 225 v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); | 225 v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); |
| 226 if (thisHandle.IsEmpty()) { | 226 if (thisHandle.IsEmpty()) { |
| 227 if (!isScriptControllerTerminating()) | 227 if (!isScriptControllerTerminating()) |
| 228 CRASH(); | 228 CRASH(); |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 ASSERT(thisHandle->IsObject()); | 231 ASSERT(thisHandle->IsObject()); |
| 232 v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg); | 232 v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg); |
| 233 if (stringArgHandle.IsEmpty()) { | 233 if (stringArgHandle.IsEmpty()) { |
| 234 if (!isScriptControllerTerminating()) | 234 if (!isScriptControllerTerminating()) |
| 235 CRASH(); | 235 CRASH(); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 v8::Handle<v8::Value> argv[] = { stringArgHandle }; | 238 v8::Handle<v8::Value> argv[] = { stringArgHandle }; |
| 239 | 239 |
| 240 invokeCallback(m_callback.newLocal(m_isolate), v8::Handle<v8::Object>::Cast(
thisHandle), 1, argv, executionContext(), m_isolate); | 240 invokeCallback(m_callback.newLocal(m_isolate), v8::Handle<v8::Object>::Cast(
thisHandle), 1, argv, executionContext(), m_isolate); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace WebCore | 243 } // namespace WebCore |
| OLD | NEW |