X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..2d39b0e377c0896910ee49ae70082ba665faf986:/runtime/StringObject.h diff --git a/runtime/StringObject.h b/runtime/StringObject.h index 540c576..df63614 100644 --- a/runtime/StringObject.h +++ b/runtime/StringObject.h @@ -28,45 +28,59 @@ namespace JSC { class StringObject : public JSWrapperObject { public: - StringObject(ExecState*, PassRefPtr); - StringObject(ExecState*, PassRefPtr, const UString&); + typedef JSWrapperObject Base; - static StringObject* create(ExecState*, JSString*); + static StringObject* create(VM& vm, Structure* structure) + { + JSString* string = jsEmptyString(&vm); + StringObject* object = new (NotNull, allocateCell(vm.heap)) StringObject(vm, structure); + object->finishCreation(vm, string); + return object; + } + static StringObject* create(VM& vm, Structure* structure, JSString* string) + { + StringObject* object = new (NotNull, allocateCell(vm.heap)) StringObject(vm, structure); + object->finishCreation(vm, string); + return object; + } + static StringObject* create(VM&, JSGlobalObject*, JSString*); - virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); - virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); + static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); + static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned propertyName, PropertySlot&); - virtual void put(ExecState* exec, const Identifier& propertyName, JSValuePtr, PutPropertySlot&); - virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); + static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&); + static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow); - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; + static bool deleteProperty(JSCell*, ExecState*, PropertyName); + static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName); + static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); + static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow); + + DECLARE_EXPORT_INFO; JSString* internalValue() const { return asString(JSWrapperObject::internalValue());} - static PassRefPtr createStructure(JSValuePtr prototype) + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(prototype, TypeInfo(ObjectType)); + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); } protected: - StringObject(PassRefPtr, JSString*); - - private: - virtual UString toString(ExecState*) const; - virtual UString toThisString(ExecState*) const; - virtual JSString* toThisJSString(ExecState*); - }; + JS_EXPORT_PRIVATE void finishCreation(VM&, JSString*); + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | JSWrapperObject::StructureFlags; + JS_EXPORT_PRIVATE StringObject(VM&, Structure*); + }; - StringObject* asStringObject(JSValuePtr); + StringObject* asStringObject(JSValue); - inline StringObject* asStringObject(JSValuePtr value) + inline StringObject* asStringObject(JSValue value) { - ASSERT(asObject(value)->inherits(&StringObject::info)); + ASSERT(asObject(value)->inherits(StringObject::info())); return static_cast(asObject(value)); } + JS_EXPORT_PRIVATE StringObject* constructString(VM&, JSGlobalObject*, JSValue); + } // namespace JSC #endif // StringObject_h