/** @file JSMOMChannelListConstructor.cpp
 *
 * Copyright (C) Espial Limited 2015 - Company confidential - All rights reserved.
 *
 */

#include "config.h"

#if ENABLE(RMAI)

#include "JSMOMChannelListConstructor.h"

#include "MOMChannelList.h"
#include "JSMOMChannelList.h"

#include "ScriptExecutionContext.h"
#include <runtime/Error.h>

using namespace JSC;

namespace WebCore {

template<> EncodedJSValue JSC_HOST_CALL JSMOMChannelListConstructor::construct(ExecState* exec)
{
	JSMOMChannelListConstructor* jsConstructor = jsCast<JSMOMChannelListConstructor*>(exec->callee());
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();

    if (!context)
        return JSValue::encode(createReferenceError(exec, "MOMChannelList constructor associated document is unavailable"));

    ExceptionCode ec = 0;
    RefPtr<MOMChannelList> list = MOMChannelList::create(context, ec);
    if (ec) {
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }
    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), list.release())));
}

} // namespace WebCore

#endif // ENABLE(VIDEO)
