mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-20 22:27:31 +09:00
1320408 - Part 18: Change StringObject::init to static method.
This commit is contained in:
parent
d102bd41c8
commit
3fb93ffdf6
3 changed files with 13 additions and 12 deletions
|
|
@ -2918,7 +2918,10 @@ js::InitStringClass(JSContext* cx, HandleObject obj)
|
||||||
|
|
||||||
Rooted<JSString*> empty(cx, cx->runtime()->emptyString);
|
Rooted<JSString*> empty(cx, cx->runtime()->emptyString);
|
||||||
RootedObject proto(cx, GlobalObject::createBlankPrototype(cx, global, &StringObject::class_));
|
RootedObject proto(cx, GlobalObject::createBlankPrototype(cx, global, &StringObject::class_));
|
||||||
if (!proto || !proto->as<StringObject>().init(cx, empty))
|
if (!proto)
|
||||||
|
return nullptr;
|
||||||
|
Handle<StringObject*> protoObj = proto.as<StringObject>();
|
||||||
|
if (!StringObject::init(cx, protoObj, empty))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
/* Now create the String function. */
|
/* Now create the String function. */
|
||||||
|
|
|
||||||
|
|
@ -15,31 +15,29 @@
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
inline bool
|
/* static */ inline bool
|
||||||
StringObject::init(JSContext* cx, HandleString str)
|
StringObject::init(JSContext* cx, Handle<StringObject*> obj, HandleString str)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(numFixedSlots() == 2);
|
MOZ_ASSERT(obj->numFixedSlots() == 2);
|
||||||
|
|
||||||
Rooted<StringObject*> self(cx, this);
|
if (!EmptyShape::ensureInitialCustomShape<StringObject>(cx, obj))
|
||||||
|
|
||||||
if (!EmptyShape::ensureInitialCustomShape<StringObject>(cx, self))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MOZ_ASSERT(self->lookup(cx, NameToId(cx->names().length))->slot() == LENGTH_SLOT);
|
MOZ_ASSERT(obj->lookup(cx, NameToId(cx->names().length))->slot() == LENGTH_SLOT);
|
||||||
|
|
||||||
self->setStringThis(str);
|
obj->setStringThis(str);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline StringObject*
|
/* static */ inline StringObject*
|
||||||
StringObject::create(JSContext* cx, HandleString str, HandleObject proto, NewObjectKind newKind)
|
StringObject::create(JSContext* cx, HandleString str, HandleObject proto, NewObjectKind newKind)
|
||||||
{
|
{
|
||||||
JSObject* obj = NewObjectWithClassProto(cx, &class_, proto, newKind);
|
JSObject* obj = NewObjectWithClassProto(cx, &class_, proto, newKind);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
Rooted<StringObject*> strobj(cx, &obj->as<StringObject>());
|
Rooted<StringObject*> strobj(cx, &obj->as<StringObject>());
|
||||||
if (!strobj->init(cx, str))
|
if (!StringObject::init(cx, strobj, str))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return strobj;
|
return strobj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class StringObject : public NativeObject
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool init(JSContext* cx, HandleString str);
|
static inline bool init(JSContext* cx, Handle<StringObject*> obj, HandleString str);
|
||||||
|
|
||||||
void setStringThis(JSString* str) {
|
void setStringThis(JSString* str) {
|
||||||
MOZ_ASSERT(getReservedSlot(PRIMITIVE_VALUE_SLOT).isUndefined());
|
MOZ_ASSERT(getReservedSlot(PRIMITIVE_VALUE_SLOT).isUndefined());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue