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 "jsapi.h"
11 
12 #include "js/Value.h"
13 #include "vm/NativeObject.h"
14 
15 namespace js {
16 
17 class PlainObject;
18 
19 // Object constructor native. Exposed only so the JIT can know its address.
20 MOZ_MUST_USE bool obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
21 
22 PlainObject* ObjectCreateImpl(JSContext* cx, HandleObject proto,
23                               NewObjectKind newKind = GenericObject,
24                               HandleObjectGroup group = nullptr);
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 MOZ_MUST_USE bool obj_propertyIsEnumerable(JSContext* cx, unsigned argc,
31                                            Value* vp);
32 
33 MOZ_MUST_USE bool obj_create(JSContext* cx, unsigned argc, JS::Value* vp);
34 
35 MOZ_MUST_USE bool obj_is(JSContext* cx, unsigned argc, JS::Value* vp);
36 
37 MOZ_MUST_USE bool obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
38 
39 MOZ_MUST_USE bool obj_setProto(JSContext* cx, unsigned argc, JS::Value* vp);
40 
41 JSString* ObjectClassToString(JSContext* cx, HandleObject obj);
42 
43 MOZ_MUST_USE bool GetOwnPropertyKeys(JSContext* cx, HandleObject obj,
44                                      unsigned flags,
45                                      JS::MutableHandleValue rval);
46 
47 // Exposed for SelfHosting.cpp
48 MOZ_MUST_USE bool GetOwnPropertyDescriptorToArray(JSContext* cx, unsigned argc,
49                                                   JS::Value* vp);
50 
51 /*
52  * Like IdToValue, but convert int jsids to strings. This is used when
53  * exposing a jsid to script for Object.getOwnProperty{Names,Symbols}
54  * or scriptable proxy traps.
55  */
56 MOZ_MUST_USE bool IdToStringOrSymbol(JSContext* cx, JS::HandleId id,
57                                      JS::MutableHandleValue result);
58 
59 // Object.prototype.toSource. Function.prototype.toSource and uneval use this.
60 JSString* ObjectToSource(JSContext* cx, JS::HandleObject obj);
61 
62 } /* namespace js */
63 
64 #endif /* builtin_Object_h */
65