#ifndef JSClassRef_h
#define JSClassRef_h
#include "JSObjectRef.h"
#include <kjs/object.h>
#include <kjs/protect.h>
#include <kjs/ustring.h>
#include <wtf/HashMap.h>
struct StaticValueEntry {
StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes)
: getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes)
{
}
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSPropertyAttributes attributes;
};
struct StaticFunctionEntry {
StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes)
: callAsFunction(_callAsFunction), attributes(_attributes)
{
}
JSObjectCallAsFunctionCallback callAsFunction;
JSPropertyAttributes attributes;
};
struct OpaqueJSClass {
static OpaqueJSClass* create(const JSClassDefinition*);
static OpaqueJSClass* createNoAutomaticPrototype(const JSClassDefinition*);
~OpaqueJSClass();
KJS::JSObject* prototype(JSContextRef ctx);
typedef HashMap<RefPtr<KJS::UString::Rep>, StaticValueEntry*> StaticValuesTable;
typedef HashMap<RefPtr<KJS::UString::Rep>, StaticFunctionEntry*> StaticFunctionsTable;
unsigned refCount;
KJS::UString className;
OpaqueJSClass* parentClass;
OpaqueJSClass* prototypeClass;
StaticValuesTable* staticValues;
StaticFunctionsTable* staticFunctions;
JSObjectInitializeCallback initialize;
JSObjectFinalizeCallback finalize;
JSObjectHasPropertyCallback hasProperty;
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSObjectDeletePropertyCallback deleteProperty;
JSObjectGetPropertyNamesCallback getPropertyNames;
JSObjectCallAsFunctionCallback callAsFunction;
JSObjectCallAsConstructorCallback callAsConstructor;
JSObjectHasInstanceCallback hasInstance;
JSObjectConvertToTypeCallback convertToType;
private:
OpaqueJSClass();
OpaqueJSClass(const OpaqueJSClass&);
OpaqueJSClass(const JSClassDefinition*, OpaqueJSClass* protoClass);
friend void clearReferenceToPrototype(JSObjectRef prototype);
KJS::JSObject* cachedPrototype;
};
#endif // JSClassRef_h