mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 16:47:29 +09:00
parent
3538814b92
commit
ee01217265
2 changed files with 33 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ SymbolObject::create(JSContext* cx, JS::HandleSymbol symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
const JSPropertySpec SymbolObject::properties[] = {
|
const JSPropertySpec SymbolObject::properties[] = {
|
||||||
|
JS_PSG("description", descriptionGetter, 0),
|
||||||
JS_PS_END
|
JS_PS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -227,6 +228,34 @@ SymbolObject::toPrimitive(JSContext* cx, unsigned argc, Value* vp)
|
||||||
return CallNonGenericMethod<IsSymbol, valueOf_impl>(cx, args);
|
return CallNonGenericMethod<IsSymbol, valueOf_impl>(cx, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ES2019 Stage 4 Draft / November 28, 2018
|
||||||
|
// Symbol description accessor
|
||||||
|
// See: https://tc39.github.io/proposal-Symbol-description/
|
||||||
|
bool
|
||||||
|
SymbolObject::descriptionGetter_impl(JSContext* cx, const CallArgs& args)
|
||||||
|
{
|
||||||
|
// Get symbol object pointer.
|
||||||
|
HandleValue thisv = args.thisv();
|
||||||
|
MOZ_ASSERT(IsSymbol(thisv));
|
||||||
|
Rooted<Symbol*> sym(cx, thisv.isSymbol()
|
||||||
|
? thisv.toSymbol()
|
||||||
|
: thisv.toObject().as<SymbolObject>().unbox());
|
||||||
|
|
||||||
|
// Return the symbol's description if present, otherwise return undefined.
|
||||||
|
if (JSString* str = sym->description())
|
||||||
|
args.rval().setString(str);
|
||||||
|
else
|
||||||
|
args.rval().setUndefined();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SymbolObject::descriptionGetter(JSContext* cx, unsigned argc, Value* vp)
|
||||||
|
{
|
||||||
|
CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
|
return CallNonGenericMethod<IsSymbol, descriptionGetter_impl>(cx, args);
|
||||||
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
js::InitSymbolClass(JSContext* cx, HandleObject obj)
|
js::InitSymbolClass(JSContext* cx, HandleObject obj)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ class SymbolObject : public NativeObject
|
||||||
static MOZ_MUST_USE bool valueOf(JSContext* cx, unsigned argc, Value* vp);
|
static MOZ_MUST_USE bool valueOf(JSContext* cx, unsigned argc, Value* vp);
|
||||||
static MOZ_MUST_USE bool toPrimitive(JSContext* cx, unsigned argc, Value* vp);
|
static MOZ_MUST_USE bool toPrimitive(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
|
// Properties defined on Symbol.prototype.
|
||||||
|
static MOZ_MUST_USE bool descriptionGetter_impl(JSContext* cx, const CallArgs& args);
|
||||||
|
static MOZ_MUST_USE bool descriptionGetter(JSContext* cx, unsigned argc, Value *vp);
|
||||||
|
|
||||||
static const JSPropertySpec properties[];
|
static const JSPropertySpec properties[];
|
||||||
static const JSFunctionSpec methods[];
|
static const JSFunctionSpec methods[];
|
||||||
static const JSFunctionSpec staticMethods[];
|
static const JSFunctionSpec staticMethods[];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue