#ifndef KJS_RUNTIME_OBJECT_H
#define KJS_RUNTIME_OBJECT_H
#include "BridgeJSC.h"
#include <JavaScriptCore/JSGlobalObject.h>
namespace JSC {
namespace Bindings {
class WEBCORE_EXPORT RuntimeObject : public JSNonFinalObject {
public:
using Base = JSNonFinalObject;
static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames | OverridesGetCallData;
static constexpr bool needsDestruction = true;
template<typename CellType, JSC::SubspaceAccess>
static IsoSubspace* subspaceFor(JSC::VM& vm)
{
static_assert(sizeof(CellType) == sizeof(RuntimeObject), "RuntimeObject subclasses that add fields need to override subspaceFor<>()");
static_assert(CellType::destroy == RuntimeObject::destroy);
return subspaceForImpl(vm);
}
static RuntimeObject* create(VM& vm, Structure* structure, RefPtr<Instance>&& instance)
{
RuntimeObject* object = new (NotNull, allocateCell<RuntimeObject>(vm.heap)) RuntimeObject(vm, structure, WTFMove(instance));
object->finishCreation(vm);
return object;
}
static void destroy(JSCell*);
static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&);
static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&);
static JSValue defaultValue(const JSObject*, JSGlobalObject*, PreferredPrimitiveType);
static CallData getCallData(JSCell*);
static CallData getConstructData(JSCell*);
static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode);
void invalidate();
Instance* getInternalInstance() const { return m_instance.get(); }
static Exception* throwInvalidAccessError(JSGlobalObject*, ThrowScope&);
DECLARE_INFO;
static ObjectPrototype* createPrototype(VM&, JSGlobalObject& globalObject)
{
return globalObject.objectPrototype();
}
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
protected:
RuntimeObject(VM&, Structure*, RefPtr<Instance>&&);
void finishCreation(VM&);
private:
static EncodedJSValue fallbackObjectGetter(JSGlobalObject*, EncodedJSValue, PropertyName);
static EncodedJSValue fieldGetter(JSGlobalObject*, EncodedJSValue, PropertyName);
static EncodedJSValue methodGetter(JSGlobalObject*, EncodedJSValue, PropertyName);
static IsoSubspace* subspaceForImpl(VM&);
RefPtr<Instance> m_instance;
};
}
}
#endif