MapAndSet.h (3229B)
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 /* 8 * Maps and Sets. 9 */ 10 11 #ifndef js_MapAndSet_h 12 #define js_MapAndSet_h 13 14 #include "jspubtd.h" 15 16 namespace JS { 17 18 /* 19 * Map 20 */ 21 extern JS_PUBLIC_API JSObject* NewMapObject(JSContext* cx); 22 23 extern JS_PUBLIC_API uint32_t MapSize(JSContext* cx, HandleObject obj); 24 25 extern JS_PUBLIC_API bool MapGet(JSContext* cx, HandleObject obj, 26 HandleValue key, MutableHandleValue rval); 27 28 extern JS_PUBLIC_API bool MapHas(JSContext* cx, HandleObject obj, 29 HandleValue key, bool* rval); 30 31 extern JS_PUBLIC_API bool MapSet(JSContext* cx, HandleObject obj, 32 HandleValue key, HandleValue val); 33 34 extern JS_PUBLIC_API bool MapGetOrInsert(JSContext* cx, HandleObject obj, 35 HandleValue key, HandleValue val, 36 MutableHandleValue rval); 37 38 extern JS_PUBLIC_API bool MapDelete(JSContext* cx, HandleObject obj, 39 HandleValue key, bool* rval); 40 41 extern JS_PUBLIC_API bool MapClear(JSContext* cx, HandleObject obj); 42 43 extern JS_PUBLIC_API bool MapKeys(JSContext* cx, HandleObject obj, 44 MutableHandleValue rval); 45 46 extern JS_PUBLIC_API bool MapValues(JSContext* cx, HandleObject obj, 47 MutableHandleValue rval); 48 49 extern JS_PUBLIC_API bool MapEntries(JSContext* cx, HandleObject obj, 50 MutableHandleValue rval); 51 52 extern JS_PUBLIC_API bool MapForEach(JSContext* cx, HandleObject obj, 53 HandleValue callbackFn, 54 HandleValue thisVal); 55 56 /* 57 * Set 58 */ 59 extern JS_PUBLIC_API JSObject* NewSetObject(JSContext* cx); 60 61 extern JS_PUBLIC_API uint32_t SetSize(JSContext* cx, HandleObject obj); 62 63 extern JS_PUBLIC_API bool SetHas(JSContext* cx, HandleObject obj, 64 HandleValue key, bool* rval); 65 66 extern JS_PUBLIC_API bool SetDelete(JSContext* cx, HandleObject obj, 67 HandleValue key, bool* rval); 68 69 extern JS_PUBLIC_API bool SetAdd(JSContext* cx, HandleObject obj, 70 HandleValue key); 71 72 extern JS_PUBLIC_API bool SetClear(JSContext* cx, HandleObject obj); 73 74 extern JS_PUBLIC_API bool SetKeys(JSContext* cx, HandleObject obj, 75 MutableHandleValue rval); 76 77 extern JS_PUBLIC_API bool SetValues(JSContext* cx, HandleObject obj, 78 MutableHandleValue rval); 79 80 extern JS_PUBLIC_API bool SetEntries(JSContext* cx, HandleObject obj, 81 MutableHandleValue rval); 82 83 extern JS_PUBLIC_API bool SetForEach(JSContext* cx, HandleObject obj, 84 HandleValue callbackFn, 85 HandleValue thisVal); 86 87 } // namespace JS 88 89 #endif // js_MapAndSet_h