MCPcopy Create free account
hub / github.com/mozilla/rhino / NativeSet

Class NativeSet

rhino/src/main/java/org/mozilla/javascript/NativeSet.java:16–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14import java.io.Serial;
15
16public class NativeSet extends ScriptableObject {
17 @Serial private static final long serialVersionUID = -8442212766987072986L;
18 private static final String CLASS_NAME = "Set";
19 static final String ITERATOR_TAG = "Set Iterator";
20
21 static final SymbolKey GETSIZE = new SymbolKey("[Symbol.getSize]", Symbol.Kind.REGULAR);
22
23 private static final ClassDescriptor DESCRIPTOR;
24 private static final ClassDescriptor ITER_DESCRIPTOR =
25 ES6Iterator.makeDescriptor(ITERATOR_TAG, ITERATOR_TAG);
26
27 static {
28 DESCRIPTOR =
29 new ClassDescriptor.Builder(
30 CLASS_NAME,
31 0,
32 ClassDescriptor.typeError(),
33 NativeSet::js_constructor)
34 .withMethod(PROTO, "add", 1, NativeSet::js_add)
35 .withMethod(PROTO, "delete", 1, NativeSet::js_delete)
36 .withMethod(PROTO, "has", 1, NativeSet::js_has)
37 .withMethod(PROTO, "clear", 0, NativeSet::js_clear)
38 .withMethod(PROTO, "values", 0, NativeSet::js_values)
39 .withProp(PROTO, "keys", alias("values", DONTENUM | READONLY))
40 .withProp(PROTO, SymbolKey.ITERATOR, alias("values", DONTENUM))
41 .withMethod(PROTO, "forEach", 1, NativeSet::js_forEach)
42 .withMethod(PROTO, "entries", 0, NativeSet::js_entries)
43
44 // ES2025 Set methods
45 .withMethod(PROTO, "intersection", 1, NativeSet::js_intersection)
46 .withMethod(PROTO, "union", 1, NativeSet::js_union)
47 .withMethod(PROTO, "difference", 1, NativeSet::js_difference)
48 .withMethod(
49 PROTO, "symmetricDifference", 1, NativeSet::js_symmetricDifference)
50 .withMethod(PROTO, "isSubsetOf", 1, NativeSet::js_isSubsetOf)
51 .withMethod(PROTO, "isSupersetOf", 1, NativeSet::js_isSupersetOf)
52 .withMethod(PROTO, "isDisjointFrom", 1, NativeSet::js_isDisjointFrom)
53 .withProp(
54 PROTO,
55 "size",
56 (thisObj) -> realThis(thisObj, "size").js_getSize(),
57 null,
58 DONTENUM)
59 .withProp(
60 PROTO,
61 NativeSet.GETSIZE,
62 (thisObj) -> realThis(thisObj, "size").js_getSize(),
63 null,
64 DONTENUM | PERMANENT)
65 .withProp(
66 PROTO,
67 SymbolKey.TO_STRING_TAG,
68 value(CLASS_NAME, DONTENUM | READONLY))
69 .withProp(CTOR, SymbolKey.SPECIES, ScriptRuntimeES6::symbolSpecies)
70 .build();
71 }
72
73 private final Hashtable entries = new Hashtable();

Callers

nothing calls this directly

Calls 9

makeDescriptorMethod · 0.95
typeErrorMethod · 0.95
realThisMethod · 0.95
withPropMethod · 0.80
withMethodMethod · 0.80
aliasMethod · 0.80
buildMethod · 0.45
js_getSizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected