Debian Codegraph @

js/src/ds/IdValuePair.h

raw
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 ds_IdValuePair_h
8 #define ds_IdValuePair_h
9
10 #include "gc/Tracer.h"
11 #include "js/GCVector.h"
12 #include "js/Id.h"
13 #include "js/Value.h"
14
15 namespace js {
16
17 struct IdValuePair {
18 JS::Value value;
19 jsid id;
20
21 IdValuePair() : value(JS::UndefinedValue()), id(JS::PropertyKey::Void()) {}
22 explicit IdValuePair(jsid idArg) : value(JS::UndefinedValue()), id(idArg) {}
23 IdValuePair(jsid idArg, const Value& valueArg) : value(valueArg), id(idArg) {}
24
25 void trace(JSTracer* trc) {
26 TraceRoot(trc, &value, "IdValuePair::value");
27 TraceRoot(trc, &id, "IdValuePair::id");
28 }
29 };
30
31 using IdValueVector = JS::GCVector<IdValuePair, 8>;
32
33 } /* namespace js */
34
35 #endif /* ds_IdValuePair_h */