Пример #1
0
static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "setNamedItem", "TestInterface2", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 2)) {
        setMinimumArityTypeError(exceptionState, 2, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
    V8StringResource<> name;
    TestInterfaceEmpty* value;
    {
        name = info[0];
        if (!name.prepare())
            return;
        value = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[1]);
        if (!value && !isUndefinedOrNull(info[1])) {
            exceptionState.throwTypeError("parameter 2 is not of type 'TestInterfaceEmpty'.");
            exceptionState.throwIfNeeded();
            return;
        }
    }
    TestInterfaceEmpty* result = impl->setNamedItem(name, value, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8SetReturnValue(info, result);
}
Пример #2
0
static void namedPropertySetter(const AtomicString& name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) {
  const CString& nameInUtf8 = name.utf8();
  ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface2", nameInUtf8.data());

  TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
  TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value);
  if (!propertyValue && !isUndefinedOrNull(v8Value)) {
    exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
    return;
  }

  bool result = impl->setNamedItem(name, propertyValue, exceptionState);
  if (exceptionState.hadException())
    return;
  if (!result)
    return;
  v8SetReturnValue(info, v8Value);
}
Пример #3
0
static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    if (!name->IsString())
        return;
    auto nameString = name.As<v8::String>();
    v8::String::Utf8Value namedProperty(nameString);
    ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate());
    TestInterface2* impl = V8TestInterface2::toImpl(info.Holder());
    V8StringResource<> propertyName(nameString);
    if (!propertyName.prepare())
        return;
    TestInterfaceEmpty* propertyValue = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), v8Value);
    if (!propertyValue && !isUndefinedOrNull(v8Value)) {
        exceptionState.throwTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
        exceptionState.throwIfNeeded();
        return;
    }
    bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    if (!result)
        return;
    v8SetReturnValue(info, v8Value);
}