Ejemplo n.º 1
0
static v8::Handle<v8::Value> itemCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.MediaList.item");
    MediaList* imp = V8MediaList::toNative(args.Holder());
    EXCEPTION_BLOCK(unsigned, index, toUInt32(args[0]));
    return v8StringOrNull(imp->item(index));
}
Ejemplo n.º 2
0
JSValue* jsMediaListPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSMediaList::s_info))
        return throwError(exec, TypeError);
    JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisValue);
    MediaList* imp = static_cast<MediaList*>(castedThisObj->impl());
    unsigned index = args.at(exec, 0)->toInt32(exec);


    JSC::JSValue* result = jsStringOrNull(exec, imp->item(index));
    return result;
}
Ejemplo n.º 3
0
EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionItem(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSMediaList::s_info))
        return throwVMTypeError(exec);
    JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(thisValue));
    MediaList* imp = static_cast<MediaList*>(castedThis->impl());
    unsigned index(exec->argument(0).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = jsStringOrNull(exec, imp->item(index));
    return JSValue::encode(result);
}
Ejemplo n.º 4
0
JSValue* JSMediaListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSMediaList::info))
      return throwError(exec, TypeError);

    JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisObj);
    MediaList* imp = static_cast<MediaList*>(castedThisObj->impl());

    switch (id) {
    case JSMediaList::ItemFuncNum: {
        bool indexOk;
        unsigned index = args[0]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = jsStringOrNull(imp->item(index));
        return result;
    }
    case JSMediaList::DeleteMediumFuncNum: {
        ExceptionCode ec = 0;
        String oldMedium = args[0]->toString(exec);

        imp->deleteMedium(oldMedium, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSMediaList::AppendMediumFuncNum: {
        ExceptionCode ec = 0;
        String newMedium = args[0]->toString(exec);

        imp->appendMedium(newMedium, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    }
    return 0;
}