#ifndef JSClassRef_h
#define JSClassRef_h
#include "JSObjectRef.h"
#include <runtime/JSObject.h>
#include <runtime/Protect.h>
#include <runtime/UString.h>
#include <runtime/WeakGCPtr.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
struct StaticValueEntry : FastAllocBase {
StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes)
: getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes)
{
}
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSPropertyAttributes attributes;
};
struct StaticFunctionEntry : FastAllocBase {
StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes)
: callAsFunction(_callAsFunction), attributes(_attributes)
{
}
JSObjectCallAsFunctionCallback callAsFunction;
JSPropertyAttributes attributes;
};
typedef HashMap<RefPtr<JSC::UString::Rep>, StaticValueEntry*> OpaqueJSClassStaticValuesTable;
typedef HashMap<RefPtr<JSC::UString::Rep>, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable;
struct OpaqueJSClass;
struct OpaqueJSClassContextData : Noncopyable {
OpaqueJSClassContextData(OpaqueJSClass*);
~OpaqueJSClassContextData();
RefPtr<OpaqueJSClass> m_class;
OpaqueJSClassStaticValuesTable* staticValues;
OpaqueJSClassStaticFunctionsTable* staticFunctions;
JSC::WeakGCPtr<JSC::JSObject> cachedPrototype;
};
struct OpaqueJSClass : public ThreadSafeShared<OpaqueJSClass> {
static PassRefPtr<OpaqueJSClass> create(const JSClassDefinition*);
static PassRefPtr<OpaqueJSClass> createNoAutomaticPrototype(const JSClassDefinition*);
~OpaqueJSClass();
JSC::UString className();
OpaqueJSClassStaticValuesTable* staticValues(JSC::ExecState*);
OpaqueJSClassStaticFunctionsTable* staticFunctions(JSC::ExecState*);
JSC::JSObject* prototype(JSC::ExecState*);
OpaqueJSClass* parentClass;
OpaqueJSClass* prototypeClass;
JSObjectInitializeCallback initialize;
JSObjectFinalizeCallback finalize;
JSObjectHasPropertyCallback hasProperty;
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSObjectDeletePropertyCallback deleteProperty;
JSObjectGetPropertyNamesCallback getPropertyNames;
JSObjectCallAsFunctionCallback callAsFunction;
JSObjectCallAsConstructorCallback callAsConstructor;
JSObjectHasInstanceCallback hasInstance;
JSObjectConvertToTypeCallback convertToType;
private:
friend struct OpaqueJSClassContextData;
OpaqueJSClass();
OpaqueJSClass(const OpaqueJSClass&);
OpaqueJSClass(const JSClassDefinition*, OpaqueJSClass* protoClass);
OpaqueJSClassContextData& contextData(JSC::ExecState*);
JSC::UString m_className;
OpaqueJSClassStaticValuesTable* m_staticValues;
OpaqueJSClassStaticFunctionsTable* m_staticFunctions;
};
#endif // JSClassRef_h