Debian Codegraph @

build/clang-plugin/tests/TestJSHandleRootedTypedef.cpp

raw
1 #include "js/TypeDecls.h"
2 #include "js/Value.h"
3 #include "js/GCVector.h"
4 #include "js/Id.h"
5
6 class Foo {
7 void HandleFunction(JS::HandleFunction){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
8 void HandleId(JS::HandleId){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
9 void HandleObject(JS::HandleObject){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
10 void HandleScript(JS::HandleScript){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
11 void HandleString(JS::HandleString){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
12 void HandleSymbol(JS::HandleSymbol){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
13 void HandleBigInt(JS::HandleBigInt){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
14 void HandleValue(JS::HandleValue){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
15 void HandleValueVector(JS::HandleValueVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
16 void HandleObjectVector(JS::HandleObjectVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
17 void HandleIdVector(JS::HandleIdVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
18
19 void MutableHandleFunction(JS::MutableHandleFunction){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
20 void MutableHandleId(JS::MutableHandleId){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
21 void MutableHandleObject(JS::MutableHandleObject){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
22 void MutableHandleScript(JS::MutableHandleScript){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
23 void MutableHandleString(JS::MutableHandleString){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
24 void MutableHandleSymbol(JS::MutableHandleSymbol){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
25 void MutableHandleBigInt(JS::MutableHandleBigInt){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
26 void MutableHandleValue(JS::MutableHandleValue){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
27 void MutableHandleValueVector(JS::MutableHandleValueVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
28 void MutableHandleObjectVector(JS::MutableHandleObjectVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
29 void MutableHandleIdVector(JS::MutableHandleIdVector){}; // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
30
31 // Examples of preferred forms
32 void FullHandleFunction(JS::Handle<JSFunction*>){};
33 void FullHandleId(JS::Handle<JS::PropertyKey>){};
34 void FullHandleObject(JS::Handle<JSObject*>){};
35 void FullHandleScript(JS::Handle<JSScript*>){};
36 void FullHandleString(JS::Handle<JSString*>){};
37 void FullHandleSymbol(JS::Handle<JS::Symbol*>){};
38 void FullHandleBigInt(JS::Handle<JS::BigInt*>){};
39 void FullHandleValue(JS::Handle<JS::Value>){};
40 void FullHandleValueVector(JS::Handle<JS::StackGCVector<JS::Value>>){};
41 void FullHandleObjectVector(JS::Handle<JS::StackGCVector<JSObject*>>){};
42 void FullHandleIdVector(JS::HandleVector<JS::PropertyKey>){};
43 void FullHandleValueVectorShorter(JS::HandleVector<JS::Value>){};
44 void FullHandleObjectVectorShorter(JS::HandleVector<JSObject*>){};
45 void FullHandleIdVectorShorter(JS::HandleVector<JS::PropertyKey>){};
46
47 void FullMutableHandleFunction(JS::MutableHandle<JSFunction*>){};
48 void FullMutableHandleId(JS::MutableHandle<JS::PropertyKey>){};
49 void FullMutableHandleObject(JS::MutableHandle<JSObject*>){};
50 void FullMutableHandleScript(JS::MutableHandle<JSScript*>){};
51 void FullMutableHandleString(JS::MutableHandle<JSString*>){};
52 void FullMutableHandleSymbol(JS::MutableHandle<JS::Symbol*>){};
53 void FullMutableHandleBigInt(JS::MutableHandle<JS::BigInt*>){};
54 void FullMutableHandleValue(JS::MutableHandle<JS::Value*>){};
55 void FullMutableHandleValueVector(JS::MutableHandle<JS::StackGCVector<JS::Value>>){};
56 void FullMutableHandleObjectVector(JS::MutableHandle<JS::StackGCVector<JSObject*>>){};
57 void FullMutableHandleIdVector(JS::MutableHandle<JS::StackGCVector<JS::PropertyKey>>){};
58 void FullMutableHandleValueVectorShorter(JS::MutableHandleVector<JS::Value>){};
59 void FullMutableHandleObjectVectorShorter(JS::MutableHandleVector<JSObject*>){};
60 void FullMutableHandleIdVectorShorter(JS::MutableHandleVector<JS::PropertyKey>){};
61 };
62
63 static void Bar(JSContext *aCx) {
64 JS::RootedObject RootedObject(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
65 JS::RootedFunction RootedFunction(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
66 JS::RootedScript RootedScript(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
67 JS::RootedString RootedString(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
68 JS::RootedSymbol RootedSymbol(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
69 JS::RootedBigInt RootedBigInt(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
70 JS::RootedId RootedId(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
71 JS::RootedValue RootedValue(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
72
73 JS::RootedValueVector RootedValueVector(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
74 JS::RootedObjectVector RootedObjectVector(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
75 JS::RootedIdVector RootedIdVector(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
76
77 JS::PersistentRootedFunction PersistentRootedFunction(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
78 JS::PersistentRootedId PersistentRootedId(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
79 JS::PersistentRootedObject PersistentRootedObject(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
80 JS::PersistentRootedScript PersistentRootedScript(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
81 JS::PersistentRootedString PersistentRootedString(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
82 JS::PersistentRootedSymbol PersistentRootedSymbol(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
83 JS::PersistentRootedBigInt PersistentRootedBigInt(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
84 JS::PersistentRootedValue PersistentRootedValue(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
85
86 JS::PersistentRootedIdVector PersistentRootedIdVector(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
87 JS::PersistentRootedObjectVector PersistentRootedObjectVector(aCx); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
88
89 JS::HandleFunction HandleFunction(RootedFunction); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
90 JS::HandleId HandleId(RootedId); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
91 JS::HandleObject HandleObject(RootedObject); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
92 JS::HandleScript HandleScript(RootedScript); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
93 JS::HandleString HandleString(RootedString); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
94 JS::HandleSymbol HandleSymbol(RootedSymbol); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
95 JS::HandleBigInt HandleBigInt(RootedBigInt); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
96 JS::HandleValue HandleValue(RootedValue); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
97 JS::HandleValueVector HandleValueVector(RootedValueVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
98 JS::HandleObjectVector HandleObjectVector(RootedObjectVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
99 JS::HandleIdVector HandleIdVector(RootedIdVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
100
101 JS::MutableHandleFunction MutableHandleFunction(&RootedFunction); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
102 JS::MutableHandleId MutableHandleId(&RootedId); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
103 JS::MutableHandleObject MutableHandleObject(&RootedObject); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
104 JS::MutableHandleScript MutableHandleScript(&RootedScript); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
105 JS::MutableHandleString MutableHandleString(&RootedString); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
106 JS::MutableHandleSymbol MutableHandleSymbol(&RootedSymbol); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
107 JS::MutableHandleBigInt MutableHandleBigInt(&RootedBigInt); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
108 JS::MutableHandleValue MutableHandleValue(&RootedValue); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
109 JS::MutableHandleValueVector MutableHandleValueVector(&RootedValueVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
110 JS::MutableHandleObjectVector MutableHandleObjectVector(&RootedObjectVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
111 JS::MutableHandleIdVector MutableHandleIdVector(&RootedIdVector); // expected-error {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}}
112
113 // Examples of preferred forms
114 JS::Rooted<JSObject*> FullRootedObject(aCx);
115 JS::Rooted<JSFunction*> FullRootedFunction(aCx);
116 JS::Rooted<JSScript*> FullRootedScript(aCx);
117 JS::Rooted<JSString*> FullRootedString(aCx);
118 JS::Rooted<JS::Symbol*> FullRootedSymbol(aCx);
119 JS::Rooted<JS::BigInt*> FullRootedBigInt(aCx);
120 JS::Rooted<JS::PropertyKey> FullRootedId(aCx);
121 JS::Rooted<JS::Value> FullRootedValue(aCx);
122
123 JS::RootedVector<JS::Value> FullRootedValueVector(aCx);
124 JS::RootedVector<JSObject*> FullRootedObjectVector(aCx);
125 JS::RootedVector<JS::PropertyKey> FullRootedIdVector(aCx);
126
127 JS::PersistentRooted<JSFunction*> FullPersistentRootedFunction(aCx);
128 JS::PersistentRooted<JS::PropertyKey> FullPersistentRootedId(aCx);
129 JS::PersistentRooted<JSObject*> FullPersistentRootedObject(aCx);
130 JS::PersistentRooted<JSScript*> FullPersistentRootedScript(aCx);
131 JS::PersistentRooted<JSString*> FullPersistentRootedString(aCx);
132 JS::PersistentRooted<JS::Symbol*> FullPersistentRootedSymbol(aCx);
133 JS::PersistentRooted<JS::BigInt*> FullPersistentRootedBigInt(aCx);
134 JS::PersistentRooted<JS::Value> FullPersistentRootedValue(aCx);
135
136 JS::PersistentRootedVector<JS::PropertyKey> FullPersistentRootedIdVector(aCx);
137 JS::PersistentRootedVector<JSObject*> FullPersistentRootedObjectVector(aCx);
138
139 JS::Handle<JSFunction*> FullHandleFunction(FullRootedFunction);
140 JS::Handle<JS::PropertyKey> FullHandleId(FullRootedId);
141 JS::Handle<JSObject*> FullHandleObject(FullRootedObject);
142 JS::Handle<JSScript*> FullHandleScript(FullRootedScript);
143 JS::Handle<JSString*> FullHandleString(FullRootedString);
144 JS::Handle<JS::Symbol*> FullHandleSymbol(FullRootedSymbol);
145 JS::Handle<JS::BigInt*> FullHandleBigInt(FullRootedBigInt);
146 JS::Handle<JS::Value> FullHandleValue(FullRootedValue);
147 JS::Handle<JS::StackGCVector<JS::Value>> FullHandleValueVector(FullRootedValueVector);
148 JS::Handle<JS::StackGCVector<JSObject*>> FullHandleObjectVector(FullRootedObjectVector);
149 JS::Handle<JS::StackGCVector<JS::PropertyKey>> FullHandleIdVector(FullRootedIdVector);
150 JS::HandleVector<JS::Value> FullHandleValueVectorShorter(FullRootedValueVector);
151 JS::HandleVector<JSObject*> FullHandleObjectVectorShorter(FullRootedObjectVector);
152 JS::HandleVector<JS::PropertyKey> FullHandleIdVectorShorter(FullRootedIdVector);
153
154 JS::MutableHandle<JSFunction*> FullMutableHandleFunction(&FullRootedFunction);
155 JS::MutableHandle<JS::PropertyKey> FullMutableHandleId(&FullRootedId);
156 JS::MutableHandle<JSObject*> FullMutableHandleObject(&FullRootedObject);
157 JS::MutableHandle<JSScript*> FullMutableHandleScript(&FullRootedScript);
158 JS::MutableHandle<JSString*> FullMutableHandleString(&FullRootedString);
159 JS::MutableHandle<JS::Symbol*> FullMutableHandleSymbol(&FullRootedSymbol);
160 JS::MutableHandle<JS::BigInt*> FullMutableHandleBigInt(&FullRootedBigInt);
161 JS::MutableHandle<JS::Value> FullMutableHandleValue(&FullRootedValue);
162 JS::MutableHandle<JS::StackGCVector<JS::Value>> FullMutableHandleValueVector(&FullRootedValueVector);
163 JS::MutableHandle<JS::StackGCVector<JSObject*>> FullMutableHandleObjectVector(&FullRootedObjectVector);
164 JS::MutableHandle<JS::StackGCVector<JS::PropertyKey>> FullMutableHandleIdVector(&FullRootedIdVector);
165 JS::MutableHandleVector<JS::Value> FullMutableHandleValueVectorShorter(&FullRootedValueVector);
166 JS::MutableHandleVector<JSObject*> FullMutableHandleObjectVectorShorter(&FullRootedObjectVector);
167 JS::MutableHandleVector<JS::PropertyKey> FullMutableHandleIdVectorShorter(&FullRootedIdVector);
168 }