static void methodWithSequenceArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { throwTypeError(ExceptionMessages::failedToExecute("methodWithSequenceArg", "TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); V8TRYCATCH_VOID(Vector<RefPtr<SerializedScriptValue> >, sequenceArg, (toRefPtrNativeArray<SerializedScriptValue, V8SerializedScriptValue>(info[0], 1, info.GetIsolate()))); v8SetReturnValue(info, static_cast<double>(imp->methodWithSequenceArg(sequenceArg))); }
static void methodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { throwTypeError(ExceptionMessages::failedToExecute("method", "TestMediaQueryListListener", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(info.Holder()); V8TRYCATCH_VOID(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(ScriptValue(info[0], info.GetIsolate()))); imp->method(listener); }
static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); if (UNLIKELY(info.Length() <= 0)) { imp->func(); return; } V8TRYCATCH_VOID(Vector<int>, x, toNativeArray<int>(info[0], 1, info.GetIsolate())); imp->func(x); }
static void nullableArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { throwTypeError(ExceptionMessages::failedToExecute("nullableArrayArg", "TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); bool arrayArgIsNull = info[0]->IsNull(); V8TRYCATCH_VOID(Vector<String>, arrayArg, toNativeArray<String>(info[0], 1, info.GetIsolate())); imp->nullableArrayArg(arrayArgIsNull ? 0 : &arrayArg); }
static void methodMethod(const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() < 1) { throwNotEnoughArgumentsError(args.GetIsolate()); return; } TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder()); V8TRYCATCH_VOID(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0])); imp->method(listener); return; }
static void stringArrayFunction2Method(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "stringArrayFunction2", "TestTypedefs", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 1)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length())); exceptionState.throwIfNeeded(); return; } TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(info[0], 1, info.GetIsolate())); Vector<String> result = imp->stringArrayFunction2(values, exceptionState); if (exceptionState.throwIfNeeded()) return; v8SetReturnValue(info, v8Array(result, info.GetIsolate())); }
void V8Element::scrollTopAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { ExceptionState exceptionState(ExceptionState::SetterContext, "scrollTop", "Element", info.Holder(), info.GetIsolate()); Element* imp = V8Element::toNative(info.Holder()); if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject()) { V8TRYCATCH_VOID(Dictionary, scrollOptionsVertical, Dictionary(value, info.GetIsolate())); imp->setScrollTop(scrollOptionsVertical, exceptionState); exceptionState.throwIfNeeded(); return; } V8TRYCATCH_EXCEPTION_VOID(int, position, toInt32(value, exceptionState), exceptionState); imp->setScrollTop(position); }
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() < 1) { throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructor", "An event name must be provided."), args.GetIsolate()); return; } V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); TestEventConstructorInit eventInit; if (args.Length() >= 2) { V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate())); if (!fillTestEventConstructorInit(eventInit, options)) return; } RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, eventInit); v8::Handle<v8::Object> wrapper = args.Holder(); V8DOMWrapper::associateObjectWithWrapper<V8TestEventConstructor>(event.release(), &V8TestEventConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); v8SetReturnValue(args, wrapper); }
static void immutableSerializedScriptValueAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) { TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder()); V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptValue::create(jsValue, info.GetIsolate())); imp->setImmutableSerializedScriptValue(WTF::getPtr(cppValue)); }
void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { if (!args.Length()) { RefPtr<Blob> blob = Blob::create(); args.GetReturnValue().Set(toV8(blob.get(), args.Holder(), args.GetIsolate())); return; } v8::Local<v8::Value> firstArg = args[0]; if (!firstArg->IsArray()) { throwTypeError("First argument of the constructor is not of type Array", args.GetIsolate()); return; } String type; String endings = ASCIILiteral("transparent"); if (args.Length() > 1) { if (!args[1]->IsObject()) { throwTypeError("Second argument of the constructor is not of type Object", args.GetIsolate()); return; } V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(args[1], args.GetIsolate())); V8TRYCATCH_VOID(bool, containsEndings, dictionary.get("endings", endings)); if (containsEndings) { if (endings != "transparent" && endings != "native") { throwTypeError("The endings property must be either \"transparent\" or \"native\"", args.GetIsolate()); return; } } V8TRYCATCH_VOID(bool, containsType, dictionary.get("type", type)); UNUSED_PARAM(containsType); if (!type.containsOnlyASCII()) { throwError(v8SyntaxError, "type must consist of ASCII characters", args.GetIsolate()); return; } type.makeLower(); } ASSERT(endings == "transparent" || endings == "native"); BlobBuilder blobBuilder; V8TRYCATCH_VOID(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg)); uint32_t length = blobParts->Length(); for (uint32_t i = 0; i < length; ++i) { v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i)); ASSERT(!item.IsEmpty()); if (V8ArrayBuffer::HasInstance(item, args.GetIsolate(), worldType(args.GetIsolate()))) { ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item)); ASSERT(arrayBuffer); blobBuilder.append(arrayBuffer); } else if (V8ArrayBufferView::HasInstance(item, args.GetIsolate(), worldType(args.GetIsolate()))) { ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item)); ASSERT(arrayBufferView); blobBuilder.append(arrayBufferView); } else if (V8Blob::HasInstance(item, args.GetIsolate(), worldType(args.GetIsolate()))) { Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); ASSERT(blob); blobBuilder.append(blob); } else { V8TRYCATCH_VOID(String, stringValue, toWebCoreString(item)); blobBuilder.append(stringValue, endings); } } RefPtr<Blob> blob = blobBuilder.getBlob(type); args.GetReturnValue().Set(toV8(blob.get(), args.Holder(), args.GetIsolate())); }