| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef builtin_Object_h |
| 8 |
#define builtin_Object_h |
| 9 |
|
| 10 |
#include "vm/JSObject.h" |
| 11 |
|
| 12 |
namespace JS { |
| 13 |
class Value; |
| 14 |
} |
| 15 |
|
| 16 |
namespace js { |
| 17 |
|
| 18 |
class PlainObject; |
| 19 |
|
| 20 |
// Object constructor native. Exposed only so the JIT can know its address. |
| 21 |
[[nodiscard]] bool obj_construct(JSContext* cx, unsigned argc, JS::Value* vp); |
| 22 |
|
| 23 |
PlainObject* ObjectCreateImpl(JSContext* cx, HandleObject proto, |
| 24 |
NewObjectKind newKind = GenericObject); |
| 25 |
|
| 26 |
PlainObject* ObjectCreateWithTemplate(JSContext* cx, |
| 27 |
Handle<PlainObject*> templateObj); |
| 28 |
|
| 29 |
// Object methods exposed so they can be installed in the self-hosting global. |
| 30 |
[[nodiscard]] bool obj_propertyIsEnumerable(JSContext* cx, unsigned argc, |
| 31 |
Value* vp); |
| 32 |
|
| 33 |
[[nodiscard]] bool obj_isPrototypeOf(JSContext* cx, unsigned argc, Value* vp); |
| 34 |
|
| 35 |
[[nodiscard]] bool obj_create(JSContext* cx, unsigned argc, JS::Value* vp); |
| 36 |
|
| 37 |
[[nodiscard]] bool obj_keys(JSContext* cx, unsigned argc, JS::Value* vp); |
| 38 |
|
| 39 |
// Similar to calling obj_keys followed by asking the length property, except |
| 40 |
// that we do not materialize the keys array. |
| 41 |
[[nodiscard]] bool obj_keys_length(JSContext* cx, HandleObject obj, |
| 42 |
int32_t& length); |
| 43 |
|
| 44 |
[[nodiscard]] bool obj_is(JSContext* cx, unsigned argc, JS::Value* vp); |
| 45 |
|
| 46 |
[[nodiscard]] bool obj_toString(JSContext* cx, unsigned argc, JS::Value* vp); |
| 47 |
|
| 48 |
[[nodiscard]] bool obj_setProto(JSContext* cx, unsigned argc, JS::Value* vp); |
| 49 |
|
| 50 |
JSString* ObjectClassToString(JSContext* cx, JSObject* obj); |
| 51 |
|
| 52 |
[[nodiscard]] bool GetOwnPropertyKeys(JSContext* cx, HandleObject obj, |
| 53 |
unsigned flags, |
| 54 |
JS::MutableHandleValue rval); |
| 55 |
|
| 56 |
// Exposed for SelfHosting.cpp |
| 57 |
[[nodiscard]] bool GetOwnPropertyDescriptorToArray(JSContext* cx, unsigned argc, |
| 58 |
JS::Value* vp); |
| 59 |
|
| 60 |
/* |
| 61 |
* Like IdToValue, but convert int jsids to strings. This is used when |
| 62 |
* exposing a jsid to script for Object.getOwnProperty{Names,Symbols} |
| 63 |
* or scriptable proxy traps. |
| 64 |
*/ |
| 65 |
[[nodiscard]] bool IdToStringOrSymbol(JSContext* cx, JS::HandleId id, |
| 66 |
JS::MutableHandleValue result); |
| 67 |
|
| 68 |
// Object.prototype.toSource. Function.prototype.toSource and uneval use this. |
| 69 |
JSString* ObjectToSource(JSContext* cx, JS::HandleObject obj); |
| 70 |
|
| 71 |
} /* namespace js */ |
| 72 |
|
| 73 |
#endif /* builtin_Object_h */ |