static v8::Handle<v8::Value> setRGBColorCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    SVGColor* imp = V8SVGColor::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, rgbColor, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    imp->setRGBColor(rgbColor, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
EncodedJSValue JSC_HOST_CALL jsSVGColorPrototypeFunctionSetRGBColor(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSSVGColor::s_info))
        return throwVMTypeError(exec);
    JSSVGColor* castedThis = static_cast<JSSVGColor*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSSVGColor::s_info);
    SVGColor* imp = static_cast<SVGColor*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
    ExceptionCode ec = 0;
    const String& rgbColor(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->setRGBColor(rgbColor, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}
Exemple #3
0
JSValue* JSSVGColorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSSVGColor::info))
      return throwError(exec, TypeError);

    SVGColor* imp = static_cast<SVGColor*>(static_cast<JSSVGColor*>(thisObj)->impl());

    switch (id) {
    case JSSVGColor::SetRGBColorFuncNum: {
        ExceptionCode ec = 0;
        String rgbColor = args[0]->toString(exec);

        imp->setRGBColor(rgbColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSSVGColor::SetRGBColorICCColorFuncNum: {
        ExceptionCode ec = 0;
        String rgbColor = args[0]->toString(exec);
        String iccColor = args[1]->toString(exec);

        imp->setRGBColorICCColor(rgbColor, iccColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSSVGColor::SetColorFuncNum: {
        ExceptionCode ec = 0;
        unsigned short colorType = args[0]->toInt32(exec);
        String rgbColor = args[1]->toString(exec);
        String iccColor = args[2]->toString(exec);

        imp->setColor(colorType, rgbColor, iccColor, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    }
    return 0;
}