/*
 * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
 *
 * This file was generated by the dom/make_names.pl script.
 *
 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"
#include "JSMathMLElementWrapperFactory.h"


#if ENABLE(MATHML)

#include "JSMathMLTextElement.h"
#include "JSMathMLInlineContainerElement.h"
#include "JSMathMLSelectElement.h"
#include "JSMathMLMathElement.h"
#include "JSMathMLMencloseElement.h"
#include "JSMathMLElement.h"
#include "MathMLTextElement.h"
#include "MathMLInlineContainerElement.h"
#include "MathMLSelectElement.h"
#include "MathMLElement.h"
#include "MathMLMathElement.h"
#include "MathMLMencloseElement.h"
#include "MathMLElement.h"

#include "MathMLNames.h"

#include "Document.h"
#include "RuntimeEnabledFeatures.h"
#include "Settings.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>

using namespace JSC;

namespace WebCore {

using namespace MathMLNames;

typedef JSDOMWrapper* (*CreateMathMLElementWrapperFunction)(ExecState*, JSDOMGlobalObject*, PassRefPtr<MathMLElement>);

static JSDOMWrapper* createMathMLTextElementWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLTextElement, element.get());
}

static JSDOMWrapper* createMathMLInlineContainerElementWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLInlineContainerElement, element.get());
}

static JSDOMWrapper* createMathMLSelectElementWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLSelectElement, element.get());
}

static JSDOMWrapper* createMathMLMathElementWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLMathElement, element.get());
}

static JSDOMWrapper* createMathMLMencloseElementWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLMencloseElement, element.get());
}


static NEVER_INLINE void populateMathMLWrapperMap(HashMap<AtomicStringImpl*, CreateMathMLElementWrapperFunction>& map)
{
    struct TableEntry {
        const QualifiedName& name;
        CreateMathMLElementWrapperFunction function;
    };

    static const TableEntry table[] = {
        { annotationTag, &createMathMLTextElementWrapper },
        { annotation_xmlTag, &createMathMLInlineContainerElementWrapper },
        { mactionTag, &createMathMLSelectElementWrapper },
        { mathTag, &createMathMLMathElementWrapper },
        { mencloseTag, &createMathMLMencloseElementWrapper },
        { merrorTag, &createMathMLInlineContainerElementWrapper },
        { mfencedTag, &createMathMLInlineContainerElementWrapper },
        { mfracTag, &createMathMLInlineContainerElementWrapper },
        { miTag, &createMathMLTextElementWrapper },
        { mmultiscriptsTag, &createMathMLInlineContainerElementWrapper },
        { mnTag, &createMathMLTextElementWrapper },
        { moTag, &createMathMLTextElementWrapper },
        { moverTag, &createMathMLInlineContainerElementWrapper },
        { mphantomTag, &createMathMLInlineContainerElementWrapper },
        { mprescriptsTag, &createMathMLInlineContainerElementWrapper },
        { mrootTag, &createMathMLInlineContainerElementWrapper },
        { mrowTag, &createMathMLInlineContainerElementWrapper },
        { mspaceTag, &createMathMLTextElementWrapper },
        { msqrtTag, &createMathMLInlineContainerElementWrapper },
        { mstyleTag, &createMathMLInlineContainerElementWrapper },
        { msubTag, &createMathMLInlineContainerElementWrapper },
        { msubsupTag, &createMathMLInlineContainerElementWrapper },
        { msupTag, &createMathMLInlineContainerElementWrapper },
        { mtableTag, &createMathMLInlineContainerElementWrapper },
        { mtextTag, &createMathMLTextElementWrapper },
        { munderTag, &createMathMLInlineContainerElementWrapper },
        { munderoverTag, &createMathMLInlineContainerElementWrapper },
        { noneTag, &createMathMLInlineContainerElementWrapper },
        { semanticsTag, &createMathMLSelectElementWrapper },
    };

    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(table); ++i)
        map.add(table[i].name.localName().impl(), table[i].function);
}

JSDOMWrapper* createJSMathMLWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<MathMLElement> element)
{
    static NeverDestroyed<HashMap<AtomicStringImpl*, CreateMathMLElementWrapperFunction>> functions;
    if (functions.get().isEmpty())
        populateMathMLWrapperMap(functions);
    if (auto function = functions.get().get(element->localName().impl()))
        return function(exec, globalObject, element);
    return CREATE_DOM_WRAPPER(exec, globalObject, MathMLElement, element.get());
}

}

#endif
