#include "config.h"
#include "JSTestNode.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "TestNode.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
JSC::EncodedJSValue jsTestNodeConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
class JSTestNodePrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSTestNodePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSTestNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNodePrototype>(vm.heap)) JSTestNodePrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSTestNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
class JSTestNodeConstructor : public DOMConstructorObject {
private:
JSTestNodeConstructor(JSC::Structure*, JSDOMGlobalObject*);
void finishCreation(JSC::VM&, JSDOMGlobalObject*);
public:
typedef DOMConstructorObject Base;
static JSTestNodeConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
{
JSTestNodeConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestNodeConstructor>(vm.heap)) JSTestNodeConstructor(structure, globalObject);
ptr->finishCreation(vm, globalObject);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
protected:
static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestNode(JSC::ExecState*);
static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
};
EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::constructJSTestNode(ExecState* exec)
{
JSTestNodeConstructor* castedThis = jsCast<JSTestNodeConstructor*>(exec->callee());
RefPtr<TestNode> object = TestNode::create();
return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
}
const ClassInfo JSTestNodeConstructor::s_info = { "TestNodeConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNodeConstructor) };
JSTestNodeConstructor::JSTestNodeConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
: DOMConstructorObject(structure, globalObject)
{
}
void JSTestNodeConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
putDirect(vm, vm.propertyNames->prototype, JSTestNode::getPrototype(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
ConstructType JSTestNodeConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructJSTestNode;
return ConstructTypeHost;
}
static const HashTableValue JSTestNodePrototypeTableValues[] =
{
{ "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
};
const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNodePrototype) };
void JSTestNodePrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this);
}
const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, 0, 0 , CREATE_METHOD_TABLE(JSTestNode) };
JSTestNode::JSTestNode(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestNode> impl)
: JSNode(structure, globalObject, impl)
{
}
JSObject* JSTestNode::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSTestNodePrototype::create(vm, globalObject, JSTestNodePrototype::createStructure(vm, globalObject, JSNode::getPrototype(vm, globalObject)));
}
JSObject* JSTestNode::getPrototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSTestNode>(vm, globalObject);
}
EncodedJSValue jsTestNodeConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
{
JSTestNodePrototype* domObject = jsDynamicCast<JSTestNodePrototype*>(baseValue);
if (!domObject)
return throwVMTypeError(exec);
return JSValue::encode(JSTestNode::getConstructor(exec->vm(), domObject->globalObject()));
}
JSValue JSTestNode::getConstructor(VM& vm, JSGlobalObject* globalObject)
{
return getDOMConstructor<JSTestNodeConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
}
void JSTestNode::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSTestNode* thisObject = jsCast<JSTestNode*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
thisObject->impl().visitJSEventListeners(visitor);
}
}