/work/obj-fuzz/dom/bindings/NetworkOptionsBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM NetworkOptions.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "NetworkOptionsBinding.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
8 | | #include "mozilla/dom/PrimitiveConversions.h" |
9 | | #include "mozilla/dom/ScriptSettings.h" |
10 | | #include "mozilla/dom/SimpleGlobalObject.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace dom { |
14 | | |
15 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
16 | | using namespace mozilla::dom::binding_detail; |
17 | | |
18 | | |
19 | | |
20 | | NetworkCommandOptions::NetworkCommandOptions() |
21 | 0 | { |
22 | 0 | // Safe to pass a null context if we pass a null value |
23 | 0 | Init(nullptr, JS::NullHandleValue); |
24 | 0 | } |
25 | | |
26 | | |
27 | | |
28 | | bool |
29 | | NetworkCommandOptions::InitIds(JSContext* cx, NetworkCommandOptionsAtoms* atomsCache) |
30 | 0 | { |
31 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
32 | 0 |
|
33 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
34 | 0 | // uninitialized. |
35 | 0 | if (!atomsCache->wifictrlinterfacename_id.init(cx, "wifictrlinterfacename") || |
36 | 0 | !atomsCache->wifiStartIp_id.init(cx, "wifiStartIp") || |
37 | 0 | !atomsCache->wifiEndIp_id.init(cx, "wifiEndIp") || |
38 | 0 | !atomsCache->usbStartIp_id.init(cx, "usbStartIp") || |
39 | 0 | !atomsCache->usbEndIp_id.init(cx, "usbEndIp") || |
40 | 0 | !atomsCache->threshold_id.init(cx, "threshold") || |
41 | 0 | !atomsCache->startIp_id.init(cx, "startIp") || |
42 | 0 | !atomsCache->ssid_id.init(cx, "ssid") || |
43 | 0 | !atomsCache->serverIp_id.init(cx, "serverIp") || |
44 | 0 | !atomsCache->security_id.init(cx, "security") || |
45 | 0 | !atomsCache->report_id.init(cx, "report") || |
46 | 0 | !atomsCache->prefixLength_id.init(cx, "prefixLength") || |
47 | 0 | !atomsCache->prefix_id.init(cx, "prefix") || |
48 | 0 | !atomsCache->preInternalIfname_id.init(cx, "preInternalIfname") || |
49 | 0 | !atomsCache->preExternalIfname_id.init(cx, "preExternalIfname") || |
50 | 0 | !atomsCache->mtu_id.init(cx, "mtu") || |
51 | 0 | !atomsCache->mode_id.init(cx, "mode") || |
52 | 0 | !atomsCache->maskLength_id.init(cx, "maskLength") || |
53 | 0 | !atomsCache->mask_id.init(cx, "mask") || |
54 | 0 | !atomsCache->link_id.init(cx, "link") || |
55 | 0 | !atomsCache->key_id.init(cx, "key") || |
56 | 0 | !atomsCache->ipaddr_id.init(cx, "ipaddr") || |
57 | 0 | !atomsCache->ip_id.init(cx, "ip") || |
58 | 0 | !atomsCache->internalIfname_id.init(cx, "internalIfname") || |
59 | 0 | !atomsCache->interfaceList_id.init(cx, "interfaceList") || |
60 | 0 | !atomsCache->ifname_id.init(cx, "ifname") || |
61 | 0 | !atomsCache->id_id.init(cx, "id") || |
62 | 0 | !atomsCache->gateways_id.init(cx, "gateways") || |
63 | 0 | !atomsCache->gateway_long_id.init(cx, "gateway_long") || |
64 | 0 | !atomsCache->gateway_id.init(cx, "gateway") || |
65 | 0 | !atomsCache->externalIfname_id.init(cx, "externalIfname") || |
66 | 0 | !atomsCache->endIp_id.init(cx, "endIp") || |
67 | 0 | !atomsCache->enabled_id.init(cx, "enabled") || |
68 | 0 | !atomsCache->enable_id.init(cx, "enable") || |
69 | 0 | !atomsCache->domain_id.init(cx, "domain") || |
70 | 0 | !atomsCache->dnses_id.init(cx, "dnses") || |
71 | 0 | !atomsCache->dns2_long_id.init(cx, "dns2_long") || |
72 | 0 | !atomsCache->dns2_id.init(cx, "dns2") || |
73 | 0 | !atomsCache->dns1_long_id.init(cx, "dns1_long") || |
74 | 0 | !atomsCache->dns1_id.init(cx, "dns1") || |
75 | 0 | !atomsCache->curInternalIfname_id.init(cx, "curInternalIfname") || |
76 | 0 | !atomsCache->curExternalIfname_id.init(cx, "curExternalIfname") || |
77 | 0 | !atomsCache->cmd_id.init(cx, "cmd")) { |
78 | 0 | return false; |
79 | 0 | } |
80 | 0 | return true; |
81 | 0 | } |
82 | | |
83 | | bool |
84 | | NetworkCommandOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
85 | 0 | { |
86 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
87 | 0 | // Since in that case we will not have to do any property gets |
88 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
89 | 0 | // checkers by static analysis tools |
90 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
91 | 0 | NetworkCommandOptionsAtoms* atomsCache = nullptr; |
92 | 0 | if (cx) { |
93 | 0 | atomsCache = GetAtomCache<NetworkCommandOptionsAtoms>(cx); |
94 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
95 | 0 | return false; |
96 | 0 | } |
97 | 0 | } |
98 | 0 | |
99 | 0 | if (!IsConvertibleToDictionary(val)) { |
100 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
101 | 0 | } |
102 | 0 | |
103 | 0 | bool isNull = val.isNullOrUndefined(); |
104 | 0 | // We only need these if !isNull, in which case we have |cx|. |
105 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
106 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
107 | 0 | if (!isNull) { |
108 | 0 | MOZ_ASSERT(cx); |
109 | 0 | object.emplace(cx, &val.toObject()); |
110 | 0 | temp.emplace(cx); |
111 | 0 | } |
112 | 0 | if (!isNull) { |
113 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->cmd_id, temp.ptr())) { |
114 | 0 | return false; |
115 | 0 | } |
116 | 0 | } |
117 | 0 | if (!isNull && !temp->isUndefined()) { |
118 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCmd)) { |
119 | 0 | return false; |
120 | 0 | } |
121 | 0 | } else { |
122 | 0 | static const char16_t data[] = { 0 }; |
123 | 0 | mCmd.Rebind(data, ArrayLength(data) - 1); |
124 | 0 | } |
125 | 0 | mIsAnyMemberPresent = true; |
126 | 0 |
|
127 | 0 | if (!isNull) { |
128 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->curExternalIfname_id, temp.ptr())) { |
129 | 0 | return false; |
130 | 0 | } |
131 | 0 | } |
132 | 0 | if (!isNull && !temp->isUndefined()) { |
133 | 0 | mCurExternalIfname.Construct(); |
134 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCurExternalIfname.Value()))) { |
135 | 0 | return false; |
136 | 0 | } |
137 | 0 | mIsAnyMemberPresent = true; |
138 | 0 | } |
139 | 0 |
|
140 | 0 | if (!isNull) { |
141 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->curInternalIfname_id, temp.ptr())) { |
142 | 0 | return false; |
143 | 0 | } |
144 | 0 | } |
145 | 0 | if (!isNull && !temp->isUndefined()) { |
146 | 0 | mCurInternalIfname.Construct(); |
147 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCurInternalIfname.Value()))) { |
148 | 0 | return false; |
149 | 0 | } |
150 | 0 | mIsAnyMemberPresent = true; |
151 | 0 | } |
152 | 0 |
|
153 | 0 | if (!isNull) { |
154 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns1_id, temp.ptr())) { |
155 | 0 | return false; |
156 | 0 | } |
157 | 0 | } |
158 | 0 | if (!isNull && !temp->isUndefined()) { |
159 | 0 | mDns1.Construct(); |
160 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mDns1.Value()))) { |
161 | 0 | return false; |
162 | 0 | } |
163 | 0 | mIsAnyMemberPresent = true; |
164 | 0 | } |
165 | 0 |
|
166 | 0 | if (!isNull) { |
167 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns1_long_id, temp.ptr())) { |
168 | 0 | return false; |
169 | 0 | } |
170 | 0 | } |
171 | 0 | if (!isNull && !temp->isUndefined()) { |
172 | 0 | mDns1_long.Construct(); |
173 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mDns1_long.Value()))) { |
174 | 0 | return false; |
175 | 0 | } |
176 | 0 | mIsAnyMemberPresent = true; |
177 | 0 | } |
178 | 0 |
|
179 | 0 | if (!isNull) { |
180 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns2_id, temp.ptr())) { |
181 | 0 | return false; |
182 | 0 | } |
183 | 0 | } |
184 | 0 | if (!isNull && !temp->isUndefined()) { |
185 | 0 | mDns2.Construct(); |
186 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mDns2.Value()))) { |
187 | 0 | return false; |
188 | 0 | } |
189 | 0 | mIsAnyMemberPresent = true; |
190 | 0 | } |
191 | 0 |
|
192 | 0 | if (!isNull) { |
193 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns2_long_id, temp.ptr())) { |
194 | 0 | return false; |
195 | 0 | } |
196 | 0 | } |
197 | 0 | if (!isNull && !temp->isUndefined()) { |
198 | 0 | mDns2_long.Construct(); |
199 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mDns2_long.Value()))) { |
200 | 0 | return false; |
201 | 0 | } |
202 | 0 | mIsAnyMemberPresent = true; |
203 | 0 | } |
204 | 0 |
|
205 | 0 | if (!isNull) { |
206 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dnses_id, temp.ptr())) { |
207 | 0 | return false; |
208 | 0 | } |
209 | 0 | } |
210 | 0 | if (!isNull && !temp->isUndefined()) { |
211 | 0 | mDnses.Construct(); |
212 | 0 | if (temp.ref().isObject()) { |
213 | 0 | JS::ForOfIterator iter(cx); |
214 | 0 | if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) { |
215 | 0 | return false; |
216 | 0 | } |
217 | 0 | if (!iter.valueIsIterable()) { |
218 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'dnses' member of NetworkCommandOptions"); |
219 | 0 | return false; |
220 | 0 | } |
221 | 0 | Sequence<nsString> &arr = (mDnses.Value()); |
222 | 0 | JS::Rooted<JS::Value> temp(cx); |
223 | 0 | while (true) { |
224 | 0 | bool done; |
225 | 0 | if (!iter.next(&temp, &done)) { |
226 | 0 | return false; |
227 | 0 | } |
228 | 0 | if (done) { |
229 | 0 | break; |
230 | 0 | } |
231 | 0 | nsString* slotPtr = arr.AppendElement(mozilla::fallible); |
232 | 0 | if (!slotPtr) { |
233 | 0 | JS_ReportOutOfMemory(cx); |
234 | 0 | return false; |
235 | 0 | } |
236 | 0 | nsString& slot = *slotPtr; |
237 | 0 | if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) { |
238 | 0 | return false; |
239 | 0 | } |
240 | 0 | } |
241 | 0 | } else { |
242 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'dnses' member of NetworkCommandOptions"); |
243 | 0 | return false; |
244 | 0 | } |
245 | 0 | mIsAnyMemberPresent = true; |
246 | 0 | } |
247 | 0 |
|
248 | 0 | if (!isNull) { |
249 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->domain_id, temp.ptr())) { |
250 | 0 | return false; |
251 | 0 | } |
252 | 0 | } |
253 | 0 | if (!isNull && !temp->isUndefined()) { |
254 | 0 | mDomain.Construct(); |
255 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mDomain.Value()))) { |
256 | 0 | return false; |
257 | 0 | } |
258 | 0 | mIsAnyMemberPresent = true; |
259 | 0 | } |
260 | 0 |
|
261 | 0 | if (!isNull) { |
262 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->enable_id, temp.ptr())) { |
263 | 0 | return false; |
264 | 0 | } |
265 | 0 | } |
266 | 0 | if (!isNull && !temp->isUndefined()) { |
267 | 0 | mEnable.Construct(); |
268 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mEnable.Value()))) { |
269 | 0 | return false; |
270 | 0 | } |
271 | 0 | mIsAnyMemberPresent = true; |
272 | 0 | } |
273 | 0 |
|
274 | 0 | if (!isNull) { |
275 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->enabled_id, temp.ptr())) { |
276 | 0 | return false; |
277 | 0 | } |
278 | 0 | } |
279 | 0 | if (!isNull && !temp->isUndefined()) { |
280 | 0 | mEnabled.Construct(); |
281 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mEnabled.Value()))) { |
282 | 0 | return false; |
283 | 0 | } |
284 | 0 | mIsAnyMemberPresent = true; |
285 | 0 | } |
286 | 0 |
|
287 | 0 | if (!isNull) { |
288 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->endIp_id, temp.ptr())) { |
289 | 0 | return false; |
290 | 0 | } |
291 | 0 | } |
292 | 0 | if (!isNull && !temp->isUndefined()) { |
293 | 0 | mEndIp.Construct(); |
294 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mEndIp.Value()))) { |
295 | 0 | return false; |
296 | 0 | } |
297 | 0 | mIsAnyMemberPresent = true; |
298 | 0 | } |
299 | 0 |
|
300 | 0 | if (!isNull) { |
301 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->externalIfname_id, temp.ptr())) { |
302 | 0 | return false; |
303 | 0 | } |
304 | 0 | } |
305 | 0 | if (!isNull && !temp->isUndefined()) { |
306 | 0 | mExternalIfname.Construct(); |
307 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mExternalIfname.Value()))) { |
308 | 0 | return false; |
309 | 0 | } |
310 | 0 | mIsAnyMemberPresent = true; |
311 | 0 | } |
312 | 0 |
|
313 | 0 | if (!isNull) { |
314 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gateway_id, temp.ptr())) { |
315 | 0 | return false; |
316 | 0 | } |
317 | 0 | } |
318 | 0 | if (!isNull && !temp->isUndefined()) { |
319 | 0 | mGateway.Construct(); |
320 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mGateway.Value()))) { |
321 | 0 | return false; |
322 | 0 | } |
323 | 0 | mIsAnyMemberPresent = true; |
324 | 0 | } |
325 | 0 |
|
326 | 0 | if (!isNull) { |
327 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gateway_long_id, temp.ptr())) { |
328 | 0 | return false; |
329 | 0 | } |
330 | 0 | } |
331 | 0 | if (!isNull && !temp->isUndefined()) { |
332 | 0 | mGateway_long.Construct(); |
333 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mGateway_long.Value()))) { |
334 | 0 | return false; |
335 | 0 | } |
336 | 0 | mIsAnyMemberPresent = true; |
337 | 0 | } |
338 | 0 |
|
339 | 0 | if (!isNull) { |
340 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gateways_id, temp.ptr())) { |
341 | 0 | return false; |
342 | 0 | } |
343 | 0 | } |
344 | 0 | if (!isNull && !temp->isUndefined()) { |
345 | 0 | mGateways.Construct(); |
346 | 0 | if (temp.ref().isObject()) { |
347 | 0 | JS::ForOfIterator iter(cx); |
348 | 0 | if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) { |
349 | 0 | return false; |
350 | 0 | } |
351 | 0 | if (!iter.valueIsIterable()) { |
352 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'gateways' member of NetworkCommandOptions"); |
353 | 0 | return false; |
354 | 0 | } |
355 | 0 | Sequence<nsString> &arr = (mGateways.Value()); |
356 | 0 | JS::Rooted<JS::Value> temp(cx); |
357 | 0 | while (true) { |
358 | 0 | bool done; |
359 | 0 | if (!iter.next(&temp, &done)) { |
360 | 0 | return false; |
361 | 0 | } |
362 | 0 | if (done) { |
363 | 0 | break; |
364 | 0 | } |
365 | 0 | nsString* slotPtr = arr.AppendElement(mozilla::fallible); |
366 | 0 | if (!slotPtr) { |
367 | 0 | JS_ReportOutOfMemory(cx); |
368 | 0 | return false; |
369 | 0 | } |
370 | 0 | nsString& slot = *slotPtr; |
371 | 0 | if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) { |
372 | 0 | return false; |
373 | 0 | } |
374 | 0 | } |
375 | 0 | } else { |
376 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'gateways' member of NetworkCommandOptions"); |
377 | 0 | return false; |
378 | 0 | } |
379 | 0 | mIsAnyMemberPresent = true; |
380 | 0 | } |
381 | 0 |
|
382 | 0 | if (!isNull) { |
383 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->id_id, temp.ptr())) { |
384 | 0 | return false; |
385 | 0 | } |
386 | 0 | } |
387 | 0 | if (!isNull && !temp->isUndefined()) { |
388 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mId)) { |
389 | 0 | return false; |
390 | 0 | } |
391 | 0 | } else { |
392 | 0 | mId = 0; |
393 | 0 | } |
394 | 0 | mIsAnyMemberPresent = true; |
395 | 0 |
|
396 | 0 | if (!isNull) { |
397 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ifname_id, temp.ptr())) { |
398 | 0 | return false; |
399 | 0 | } |
400 | 0 | } |
401 | 0 | if (!isNull && !temp->isUndefined()) { |
402 | 0 | mIfname.Construct(); |
403 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIfname.Value()))) { |
404 | 0 | return false; |
405 | 0 | } |
406 | 0 | mIsAnyMemberPresent = true; |
407 | 0 | } |
408 | 0 |
|
409 | 0 | if (!isNull) { |
410 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->interfaceList_id, temp.ptr())) { |
411 | 0 | return false; |
412 | 0 | } |
413 | 0 | } |
414 | 0 | if (!isNull && !temp->isUndefined()) { |
415 | 0 | mInterfaceList.Construct(); |
416 | 0 | if (temp.ref().isObject()) { |
417 | 0 | JS::ForOfIterator iter(cx); |
418 | 0 | if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) { |
419 | 0 | return false; |
420 | 0 | } |
421 | 0 | if (!iter.valueIsIterable()) { |
422 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'interfaceList' member of NetworkCommandOptions"); |
423 | 0 | return false; |
424 | 0 | } |
425 | 0 | Sequence<nsString> &arr = (mInterfaceList.Value()); |
426 | 0 | JS::Rooted<JS::Value> temp(cx); |
427 | 0 | while (true) { |
428 | 0 | bool done; |
429 | 0 | if (!iter.next(&temp, &done)) { |
430 | 0 | return false; |
431 | 0 | } |
432 | 0 | if (done) { |
433 | 0 | break; |
434 | 0 | } |
435 | 0 | nsString* slotPtr = arr.AppendElement(mozilla::fallible); |
436 | 0 | if (!slotPtr) { |
437 | 0 | JS_ReportOutOfMemory(cx); |
438 | 0 | return false; |
439 | 0 | } |
440 | 0 | nsString& slot = *slotPtr; |
441 | 0 | if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) { |
442 | 0 | return false; |
443 | 0 | } |
444 | 0 | } |
445 | 0 | } else { |
446 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'interfaceList' member of NetworkCommandOptions"); |
447 | 0 | return false; |
448 | 0 | } |
449 | 0 | mIsAnyMemberPresent = true; |
450 | 0 | } |
451 | 0 |
|
452 | 0 | if (!isNull) { |
453 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->internalIfname_id, temp.ptr())) { |
454 | 0 | return false; |
455 | 0 | } |
456 | 0 | } |
457 | 0 | if (!isNull && !temp->isUndefined()) { |
458 | 0 | mInternalIfname.Construct(); |
459 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mInternalIfname.Value()))) { |
460 | 0 | return false; |
461 | 0 | } |
462 | 0 | mIsAnyMemberPresent = true; |
463 | 0 | } |
464 | 0 |
|
465 | 0 | if (!isNull) { |
466 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ip_id, temp.ptr())) { |
467 | 0 | return false; |
468 | 0 | } |
469 | 0 | } |
470 | 0 | if (!isNull && !temp->isUndefined()) { |
471 | 0 | mIp.Construct(); |
472 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIp.Value()))) { |
473 | 0 | return false; |
474 | 0 | } |
475 | 0 | mIsAnyMemberPresent = true; |
476 | 0 | } |
477 | 0 |
|
478 | 0 | if (!isNull) { |
479 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ipaddr_id, temp.ptr())) { |
480 | 0 | return false; |
481 | 0 | } |
482 | 0 | } |
483 | 0 | if (!isNull && !temp->isUndefined()) { |
484 | 0 | mIpaddr.Construct(); |
485 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mIpaddr.Value()))) { |
486 | 0 | return false; |
487 | 0 | } |
488 | 0 | mIsAnyMemberPresent = true; |
489 | 0 | } |
490 | 0 |
|
491 | 0 | if (!isNull) { |
492 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->key_id, temp.ptr())) { |
493 | 0 | return false; |
494 | 0 | } |
495 | 0 | } |
496 | 0 | if (!isNull && !temp->isUndefined()) { |
497 | 0 | mKey.Construct(); |
498 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mKey.Value()))) { |
499 | 0 | return false; |
500 | 0 | } |
501 | 0 | mIsAnyMemberPresent = true; |
502 | 0 | } |
503 | 0 |
|
504 | 0 | if (!isNull) { |
505 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->link_id, temp.ptr())) { |
506 | 0 | return false; |
507 | 0 | } |
508 | 0 | } |
509 | 0 | if (!isNull && !temp->isUndefined()) { |
510 | 0 | mLink.Construct(); |
511 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mLink.Value()))) { |
512 | 0 | return false; |
513 | 0 | } |
514 | 0 | mIsAnyMemberPresent = true; |
515 | 0 | } |
516 | 0 |
|
517 | 0 | if (!isNull) { |
518 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mask_id, temp.ptr())) { |
519 | 0 | return false; |
520 | 0 | } |
521 | 0 | } |
522 | 0 | if (!isNull && !temp->isUndefined()) { |
523 | 0 | mMask.Construct(); |
524 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mMask.Value()))) { |
525 | 0 | return false; |
526 | 0 | } |
527 | 0 | mIsAnyMemberPresent = true; |
528 | 0 | } |
529 | 0 |
|
530 | 0 | if (!isNull) { |
531 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->maskLength_id, temp.ptr())) { |
532 | 0 | return false; |
533 | 0 | } |
534 | 0 | } |
535 | 0 | if (!isNull && !temp->isUndefined()) { |
536 | 0 | mMaskLength.Construct(); |
537 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mMaskLength.Value()))) { |
538 | 0 | return false; |
539 | 0 | } |
540 | 0 | mIsAnyMemberPresent = true; |
541 | 0 | } |
542 | 0 |
|
543 | 0 | if (!isNull) { |
544 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mode_id, temp.ptr())) { |
545 | 0 | return false; |
546 | 0 | } |
547 | 0 | } |
548 | 0 | if (!isNull && !temp->isUndefined()) { |
549 | 0 | mMode.Construct(); |
550 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mMode.Value()))) { |
551 | 0 | return false; |
552 | 0 | } |
553 | 0 | mIsAnyMemberPresent = true; |
554 | 0 | } |
555 | 0 |
|
556 | 0 | if (!isNull) { |
557 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mtu_id, temp.ptr())) { |
558 | 0 | return false; |
559 | 0 | } |
560 | 0 | } |
561 | 0 | if (!isNull && !temp->isUndefined()) { |
562 | 0 | mMtu.Construct(); |
563 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mMtu.Value()))) { |
564 | 0 | return false; |
565 | 0 | } |
566 | 0 | mIsAnyMemberPresent = true; |
567 | 0 | } |
568 | 0 |
|
569 | 0 | if (!isNull) { |
570 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->preExternalIfname_id, temp.ptr())) { |
571 | 0 | return false; |
572 | 0 | } |
573 | 0 | } |
574 | 0 | if (!isNull && !temp->isUndefined()) { |
575 | 0 | mPreExternalIfname.Construct(); |
576 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPreExternalIfname.Value()))) { |
577 | 0 | return false; |
578 | 0 | } |
579 | 0 | mIsAnyMemberPresent = true; |
580 | 0 | } |
581 | 0 |
|
582 | 0 | if (!isNull) { |
583 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->preInternalIfname_id, temp.ptr())) { |
584 | 0 | return false; |
585 | 0 | } |
586 | 0 | } |
587 | 0 | if (!isNull && !temp->isUndefined()) { |
588 | 0 | mPreInternalIfname.Construct(); |
589 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPreInternalIfname.Value()))) { |
590 | 0 | return false; |
591 | 0 | } |
592 | 0 | mIsAnyMemberPresent = true; |
593 | 0 | } |
594 | 0 |
|
595 | 0 | if (!isNull) { |
596 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->prefix_id, temp.ptr())) { |
597 | 0 | return false; |
598 | 0 | } |
599 | 0 | } |
600 | 0 | if (!isNull && !temp->isUndefined()) { |
601 | 0 | mPrefix.Construct(); |
602 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mPrefix.Value()))) { |
603 | 0 | return false; |
604 | 0 | } |
605 | 0 | mIsAnyMemberPresent = true; |
606 | 0 | } |
607 | 0 |
|
608 | 0 | if (!isNull) { |
609 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->prefixLength_id, temp.ptr())) { |
610 | 0 | return false; |
611 | 0 | } |
612 | 0 | } |
613 | 0 | if (!isNull && !temp->isUndefined()) { |
614 | 0 | mPrefixLength.Construct(); |
615 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mPrefixLength.Value()))) { |
616 | 0 | return false; |
617 | 0 | } |
618 | 0 | mIsAnyMemberPresent = true; |
619 | 0 | } |
620 | 0 |
|
621 | 0 | if (!isNull) { |
622 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->report_id, temp.ptr())) { |
623 | 0 | return false; |
624 | 0 | } |
625 | 0 | } |
626 | 0 | if (!isNull && !temp->isUndefined()) { |
627 | 0 | mReport.Construct(); |
628 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mReport.Value()))) { |
629 | 0 | return false; |
630 | 0 | } |
631 | 0 | mIsAnyMemberPresent = true; |
632 | 0 | } |
633 | 0 |
|
634 | 0 | if (!isNull) { |
635 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->security_id, temp.ptr())) { |
636 | 0 | return false; |
637 | 0 | } |
638 | 0 | } |
639 | 0 | if (!isNull && !temp->isUndefined()) { |
640 | 0 | mSecurity.Construct(); |
641 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mSecurity.Value()))) { |
642 | 0 | return false; |
643 | 0 | } |
644 | 0 | mIsAnyMemberPresent = true; |
645 | 0 | } |
646 | 0 |
|
647 | 0 | if (!isNull) { |
648 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->serverIp_id, temp.ptr())) { |
649 | 0 | return false; |
650 | 0 | } |
651 | 0 | } |
652 | 0 | if (!isNull && !temp->isUndefined()) { |
653 | 0 | mServerIp.Construct(); |
654 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mServerIp.Value()))) { |
655 | 0 | return false; |
656 | 0 | } |
657 | 0 | mIsAnyMemberPresent = true; |
658 | 0 | } |
659 | 0 |
|
660 | 0 | if (!isNull) { |
661 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ssid_id, temp.ptr())) { |
662 | 0 | return false; |
663 | 0 | } |
664 | 0 | } |
665 | 0 | if (!isNull && !temp->isUndefined()) { |
666 | 0 | mSsid.Construct(); |
667 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mSsid.Value()))) { |
668 | 0 | return false; |
669 | 0 | } |
670 | 0 | mIsAnyMemberPresent = true; |
671 | 0 | } |
672 | 0 |
|
673 | 0 | if (!isNull) { |
674 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->startIp_id, temp.ptr())) { |
675 | 0 | return false; |
676 | 0 | } |
677 | 0 | } |
678 | 0 | if (!isNull && !temp->isUndefined()) { |
679 | 0 | mStartIp.Construct(); |
680 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mStartIp.Value()))) { |
681 | 0 | return false; |
682 | 0 | } |
683 | 0 | mIsAnyMemberPresent = true; |
684 | 0 | } |
685 | 0 |
|
686 | 0 | if (!isNull) { |
687 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->threshold_id, temp.ptr())) { |
688 | 0 | return false; |
689 | 0 | } |
690 | 0 | } |
691 | 0 | if (!isNull && !temp->isUndefined()) { |
692 | 0 | mThreshold.Construct(); |
693 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, temp.ref(), &(mThreshold.Value()))) { |
694 | 0 | return false; |
695 | 0 | } |
696 | 0 | mIsAnyMemberPresent = true; |
697 | 0 | } |
698 | 0 |
|
699 | 0 | if (!isNull) { |
700 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->usbEndIp_id, temp.ptr())) { |
701 | 0 | return false; |
702 | 0 | } |
703 | 0 | } |
704 | 0 | if (!isNull && !temp->isUndefined()) { |
705 | 0 | mUsbEndIp.Construct(); |
706 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mUsbEndIp.Value()))) { |
707 | 0 | return false; |
708 | 0 | } |
709 | 0 | mIsAnyMemberPresent = true; |
710 | 0 | } |
711 | 0 |
|
712 | 0 | if (!isNull) { |
713 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->usbStartIp_id, temp.ptr())) { |
714 | 0 | return false; |
715 | 0 | } |
716 | 0 | } |
717 | 0 | if (!isNull && !temp->isUndefined()) { |
718 | 0 | mUsbStartIp.Construct(); |
719 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mUsbStartIp.Value()))) { |
720 | 0 | return false; |
721 | 0 | } |
722 | 0 | mIsAnyMemberPresent = true; |
723 | 0 | } |
724 | 0 |
|
725 | 0 | if (!isNull) { |
726 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->wifiEndIp_id, temp.ptr())) { |
727 | 0 | return false; |
728 | 0 | } |
729 | 0 | } |
730 | 0 | if (!isNull && !temp->isUndefined()) { |
731 | 0 | mWifiEndIp.Construct(); |
732 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mWifiEndIp.Value()))) { |
733 | 0 | return false; |
734 | 0 | } |
735 | 0 | mIsAnyMemberPresent = true; |
736 | 0 | } |
737 | 0 |
|
738 | 0 | if (!isNull) { |
739 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->wifiStartIp_id, temp.ptr())) { |
740 | 0 | return false; |
741 | 0 | } |
742 | 0 | } |
743 | 0 | if (!isNull && !temp->isUndefined()) { |
744 | 0 | mWifiStartIp.Construct(); |
745 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mWifiStartIp.Value()))) { |
746 | 0 | return false; |
747 | 0 | } |
748 | 0 | mIsAnyMemberPresent = true; |
749 | 0 | } |
750 | 0 |
|
751 | 0 | if (!isNull) { |
752 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->wifictrlinterfacename_id, temp.ptr())) { |
753 | 0 | return false; |
754 | 0 | } |
755 | 0 | } |
756 | 0 | if (!isNull && !temp->isUndefined()) { |
757 | 0 | mWifictrlinterfacename.Construct(); |
758 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mWifictrlinterfacename.Value()))) { |
759 | 0 | return false; |
760 | 0 | } |
761 | 0 | mIsAnyMemberPresent = true; |
762 | 0 | } |
763 | 0 | return true; |
764 | 0 | } |
765 | | |
766 | | bool |
767 | | NetworkCommandOptions::Init(const nsAString& aJSON) |
768 | 0 | { |
769 | 0 | AutoJSAPI jsapi; |
770 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
771 | 0 | if (!cleanGlobal) { |
772 | 0 | return false; |
773 | 0 | } |
774 | 0 | if (!jsapi.Init(cleanGlobal)) { |
775 | 0 | return false; |
776 | 0 | } |
777 | 0 | JSContext* cx = jsapi.cx(); |
778 | 0 | JS::Rooted<JS::Value> json(cx); |
779 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
780 | 0 | NS_ENSURE_TRUE(ok, false); |
781 | 0 | return Init(cx, json); |
782 | 0 | } |
783 | | |
784 | | bool |
785 | | NetworkCommandOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
786 | 0 | { |
787 | 0 | NetworkCommandOptionsAtoms* atomsCache = GetAtomCache<NetworkCommandOptionsAtoms>(cx); |
788 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
789 | 0 | return false; |
790 | 0 | } |
791 | 0 | |
792 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
793 | 0 | if (!obj) { |
794 | 0 | return false; |
795 | 0 | } |
796 | 0 | rval.set(JS::ObjectValue(*obj)); |
797 | 0 |
|
798 | 0 | do { |
799 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
800 | 0 | JS::Rooted<JS::Value> temp(cx); |
801 | 0 | nsString const & currentValue = mCmd; |
802 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
803 | 0 | return false; |
804 | 0 | } |
805 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->cmd_id, temp, JSPROP_ENUMERATE)) { |
806 | 0 | return false; |
807 | 0 | } |
808 | 0 | break; |
809 | 0 | } while(false); |
810 | 0 |
|
811 | 0 | if (mCurExternalIfname.WasPassed()) { |
812 | 0 | do { |
813 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
814 | 0 | JS::Rooted<JS::Value> temp(cx); |
815 | 0 | nsString const & currentValue = mCurExternalIfname.InternalValue(); |
816 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
817 | 0 | return false; |
818 | 0 | } |
819 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->curExternalIfname_id, temp, JSPROP_ENUMERATE)) { |
820 | 0 | return false; |
821 | 0 | } |
822 | 0 | break; |
823 | 0 | } while(false); |
824 | 0 | } |
825 | 0 |
|
826 | 0 | if (mCurInternalIfname.WasPassed()) { |
827 | 0 | do { |
828 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
829 | 0 | JS::Rooted<JS::Value> temp(cx); |
830 | 0 | nsString const & currentValue = mCurInternalIfname.InternalValue(); |
831 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
832 | 0 | return false; |
833 | 0 | } |
834 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->curInternalIfname_id, temp, JSPROP_ENUMERATE)) { |
835 | 0 | return false; |
836 | 0 | } |
837 | 0 | break; |
838 | 0 | } while(false); |
839 | 0 | } |
840 | 0 |
|
841 | 0 | if (mDns1.WasPassed()) { |
842 | 0 | do { |
843 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
844 | 0 | JS::Rooted<JS::Value> temp(cx); |
845 | 0 | nsString const & currentValue = mDns1.InternalValue(); |
846 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
847 | 0 | return false; |
848 | 0 | } |
849 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns1_id, temp, JSPROP_ENUMERATE)) { |
850 | 0 | return false; |
851 | 0 | } |
852 | 0 | break; |
853 | 0 | } while(false); |
854 | 0 | } |
855 | 0 |
|
856 | 0 | if (mDns1_long.WasPassed()) { |
857 | 0 | do { |
858 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
859 | 0 | JS::Rooted<JS::Value> temp(cx); |
860 | 0 | int32_t const & currentValue = mDns1_long.InternalValue(); |
861 | 0 | temp.setInt32(int32_t(currentValue)); |
862 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns1_long_id, temp, JSPROP_ENUMERATE)) { |
863 | 0 | return false; |
864 | 0 | } |
865 | 0 | break; |
866 | 0 | } while(false); |
867 | 0 | } |
868 | 0 |
|
869 | 0 | if (mDns2.WasPassed()) { |
870 | 0 | do { |
871 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
872 | 0 | JS::Rooted<JS::Value> temp(cx); |
873 | 0 | nsString const & currentValue = mDns2.InternalValue(); |
874 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
875 | 0 | return false; |
876 | 0 | } |
877 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns2_id, temp, JSPROP_ENUMERATE)) { |
878 | 0 | return false; |
879 | 0 | } |
880 | 0 | break; |
881 | 0 | } while(false); |
882 | 0 | } |
883 | 0 |
|
884 | 0 | if (mDns2_long.WasPassed()) { |
885 | 0 | do { |
886 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
887 | 0 | JS::Rooted<JS::Value> temp(cx); |
888 | 0 | int32_t const & currentValue = mDns2_long.InternalValue(); |
889 | 0 | temp.setInt32(int32_t(currentValue)); |
890 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns2_long_id, temp, JSPROP_ENUMERATE)) { |
891 | 0 | return false; |
892 | 0 | } |
893 | 0 | break; |
894 | 0 | } while(false); |
895 | 0 | } |
896 | 0 |
|
897 | 0 | if (mDnses.WasPassed()) { |
898 | 0 | do { |
899 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
900 | 0 | JS::Rooted<JS::Value> temp(cx); |
901 | 0 | Sequence<nsString> const & currentValue = mDnses.InternalValue(); |
902 | 0 |
|
903 | 0 | uint32_t length = currentValue.Length(); |
904 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
905 | 0 | if (!returnArray) { |
906 | 0 | return false; |
907 | 0 | } |
908 | 0 | // Scope for 'tmp' |
909 | 0 | { |
910 | 0 | JS::Rooted<JS::Value> tmp(cx); |
911 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
912 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
913 | 0 | // are different ways to succeed at wrapping the object. |
914 | 0 | do { |
915 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &tmp)) { |
916 | 0 | return false; |
917 | 0 | } |
918 | 0 | break; |
919 | 0 | } while (false); |
920 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
921 | 0 | JSPROP_ENUMERATE)) { |
922 | 0 | return false; |
923 | 0 | } |
924 | 0 | } |
925 | 0 | } |
926 | 0 | temp.setObject(*returnArray); |
927 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dnses_id, temp, JSPROP_ENUMERATE)) { |
928 | 0 | return false; |
929 | 0 | } |
930 | 0 | break; |
931 | 0 | } while(false); |
932 | 0 | } |
933 | 0 |
|
934 | 0 | if (mDomain.WasPassed()) { |
935 | 0 | do { |
936 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
937 | 0 | JS::Rooted<JS::Value> temp(cx); |
938 | 0 | nsString const & currentValue = mDomain.InternalValue(); |
939 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
940 | 0 | return false; |
941 | 0 | } |
942 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->domain_id, temp, JSPROP_ENUMERATE)) { |
943 | 0 | return false; |
944 | 0 | } |
945 | 0 | break; |
946 | 0 | } while(false); |
947 | 0 | } |
948 | 0 |
|
949 | 0 | if (mEnable.WasPassed()) { |
950 | 0 | do { |
951 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
952 | 0 | JS::Rooted<JS::Value> temp(cx); |
953 | 0 | bool const & currentValue = mEnable.InternalValue(); |
954 | 0 | temp.setBoolean(currentValue); |
955 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->enable_id, temp, JSPROP_ENUMERATE)) { |
956 | 0 | return false; |
957 | 0 | } |
958 | 0 | break; |
959 | 0 | } while(false); |
960 | 0 | } |
961 | 0 |
|
962 | 0 | if (mEnabled.WasPassed()) { |
963 | 0 | do { |
964 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
965 | 0 | JS::Rooted<JS::Value> temp(cx); |
966 | 0 | bool const & currentValue = mEnabled.InternalValue(); |
967 | 0 | temp.setBoolean(currentValue); |
968 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->enabled_id, temp, JSPROP_ENUMERATE)) { |
969 | 0 | return false; |
970 | 0 | } |
971 | 0 | break; |
972 | 0 | } while(false); |
973 | 0 | } |
974 | 0 |
|
975 | 0 | if (mEndIp.WasPassed()) { |
976 | 0 | do { |
977 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
978 | 0 | JS::Rooted<JS::Value> temp(cx); |
979 | 0 | nsString const & currentValue = mEndIp.InternalValue(); |
980 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
981 | 0 | return false; |
982 | 0 | } |
983 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->endIp_id, temp, JSPROP_ENUMERATE)) { |
984 | 0 | return false; |
985 | 0 | } |
986 | 0 | break; |
987 | 0 | } while(false); |
988 | 0 | } |
989 | 0 |
|
990 | 0 | if (mExternalIfname.WasPassed()) { |
991 | 0 | do { |
992 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
993 | 0 | JS::Rooted<JS::Value> temp(cx); |
994 | 0 | nsString const & currentValue = mExternalIfname.InternalValue(); |
995 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
996 | 0 | return false; |
997 | 0 | } |
998 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->externalIfname_id, temp, JSPROP_ENUMERATE)) { |
999 | 0 | return false; |
1000 | 0 | } |
1001 | 0 | break; |
1002 | 0 | } while(false); |
1003 | 0 | } |
1004 | 0 |
|
1005 | 0 | if (mGateway.WasPassed()) { |
1006 | 0 | do { |
1007 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1008 | 0 | JS::Rooted<JS::Value> temp(cx); |
1009 | 0 | nsString const & currentValue = mGateway.InternalValue(); |
1010 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1011 | 0 | return false; |
1012 | 0 | } |
1013 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gateway_id, temp, JSPROP_ENUMERATE)) { |
1014 | 0 | return false; |
1015 | 0 | } |
1016 | 0 | break; |
1017 | 0 | } while(false); |
1018 | 0 | } |
1019 | 0 |
|
1020 | 0 | if (mGateway_long.WasPassed()) { |
1021 | 0 | do { |
1022 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1023 | 0 | JS::Rooted<JS::Value> temp(cx); |
1024 | 0 | int32_t const & currentValue = mGateway_long.InternalValue(); |
1025 | 0 | temp.setInt32(int32_t(currentValue)); |
1026 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gateway_long_id, temp, JSPROP_ENUMERATE)) { |
1027 | 0 | return false; |
1028 | 0 | } |
1029 | 0 | break; |
1030 | 0 | } while(false); |
1031 | 0 | } |
1032 | 0 |
|
1033 | 0 | if (mGateways.WasPassed()) { |
1034 | 0 | do { |
1035 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1036 | 0 | JS::Rooted<JS::Value> temp(cx); |
1037 | 0 | Sequence<nsString> const & currentValue = mGateways.InternalValue(); |
1038 | 0 |
|
1039 | 0 | uint32_t length = currentValue.Length(); |
1040 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
1041 | 0 | if (!returnArray) { |
1042 | 0 | return false; |
1043 | 0 | } |
1044 | 0 | // Scope for 'tmp' |
1045 | 0 | { |
1046 | 0 | JS::Rooted<JS::Value> tmp(cx); |
1047 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
1048 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
1049 | 0 | // are different ways to succeed at wrapping the object. |
1050 | 0 | do { |
1051 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &tmp)) { |
1052 | 0 | return false; |
1053 | 0 | } |
1054 | 0 | break; |
1055 | 0 | } while (false); |
1056 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
1057 | 0 | JSPROP_ENUMERATE)) { |
1058 | 0 | return false; |
1059 | 0 | } |
1060 | 0 | } |
1061 | 0 | } |
1062 | 0 | temp.setObject(*returnArray); |
1063 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gateways_id, temp, JSPROP_ENUMERATE)) { |
1064 | 0 | return false; |
1065 | 0 | } |
1066 | 0 | break; |
1067 | 0 | } while(false); |
1068 | 0 | } |
1069 | 0 |
|
1070 | 0 | do { |
1071 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1072 | 0 | JS::Rooted<JS::Value> temp(cx); |
1073 | 0 | int32_t const & currentValue = mId; |
1074 | 0 | temp.setInt32(int32_t(currentValue)); |
1075 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->id_id, temp, JSPROP_ENUMERATE)) { |
1076 | 0 | return false; |
1077 | 0 | } |
1078 | 0 | break; |
1079 | 0 | } while(false); |
1080 | 0 |
|
1081 | 0 | if (mIfname.WasPassed()) { |
1082 | 0 | do { |
1083 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1084 | 0 | JS::Rooted<JS::Value> temp(cx); |
1085 | 0 | nsString const & currentValue = mIfname.InternalValue(); |
1086 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1087 | 0 | return false; |
1088 | 0 | } |
1089 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ifname_id, temp, JSPROP_ENUMERATE)) { |
1090 | 0 | return false; |
1091 | 0 | } |
1092 | 0 | break; |
1093 | 0 | } while(false); |
1094 | 0 | } |
1095 | 0 |
|
1096 | 0 | if (mInterfaceList.WasPassed()) { |
1097 | 0 | do { |
1098 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1099 | 0 | JS::Rooted<JS::Value> temp(cx); |
1100 | 0 | Sequence<nsString> const & currentValue = mInterfaceList.InternalValue(); |
1101 | 0 |
|
1102 | 0 | uint32_t length = currentValue.Length(); |
1103 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
1104 | 0 | if (!returnArray) { |
1105 | 0 | return false; |
1106 | 0 | } |
1107 | 0 | // Scope for 'tmp' |
1108 | 0 | { |
1109 | 0 | JS::Rooted<JS::Value> tmp(cx); |
1110 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
1111 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
1112 | 0 | // are different ways to succeed at wrapping the object. |
1113 | 0 | do { |
1114 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &tmp)) { |
1115 | 0 | return false; |
1116 | 0 | } |
1117 | 0 | break; |
1118 | 0 | } while (false); |
1119 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
1120 | 0 | JSPROP_ENUMERATE)) { |
1121 | 0 | return false; |
1122 | 0 | } |
1123 | 0 | } |
1124 | 0 | } |
1125 | 0 | temp.setObject(*returnArray); |
1126 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->interfaceList_id, temp, JSPROP_ENUMERATE)) { |
1127 | 0 | return false; |
1128 | 0 | } |
1129 | 0 | break; |
1130 | 0 | } while(false); |
1131 | 0 | } |
1132 | 0 |
|
1133 | 0 | if (mInternalIfname.WasPassed()) { |
1134 | 0 | do { |
1135 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1136 | 0 | JS::Rooted<JS::Value> temp(cx); |
1137 | 0 | nsString const & currentValue = mInternalIfname.InternalValue(); |
1138 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1139 | 0 | return false; |
1140 | 0 | } |
1141 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->internalIfname_id, temp, JSPROP_ENUMERATE)) { |
1142 | 0 | return false; |
1143 | 0 | } |
1144 | 0 | break; |
1145 | 0 | } while(false); |
1146 | 0 | } |
1147 | 0 |
|
1148 | 0 | if (mIp.WasPassed()) { |
1149 | 0 | do { |
1150 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1151 | 0 | JS::Rooted<JS::Value> temp(cx); |
1152 | 0 | nsString const & currentValue = mIp.InternalValue(); |
1153 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1154 | 0 | return false; |
1155 | 0 | } |
1156 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ip_id, temp, JSPROP_ENUMERATE)) { |
1157 | 0 | return false; |
1158 | 0 | } |
1159 | 0 | break; |
1160 | 0 | } while(false); |
1161 | 0 | } |
1162 | 0 |
|
1163 | 0 | if (mIpaddr.WasPassed()) { |
1164 | 0 | do { |
1165 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1166 | 0 | JS::Rooted<JS::Value> temp(cx); |
1167 | 0 | int32_t const & currentValue = mIpaddr.InternalValue(); |
1168 | 0 | temp.setInt32(int32_t(currentValue)); |
1169 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ipaddr_id, temp, JSPROP_ENUMERATE)) { |
1170 | 0 | return false; |
1171 | 0 | } |
1172 | 0 | break; |
1173 | 0 | } while(false); |
1174 | 0 | } |
1175 | 0 |
|
1176 | 0 | if (mKey.WasPassed()) { |
1177 | 0 | do { |
1178 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1179 | 0 | JS::Rooted<JS::Value> temp(cx); |
1180 | 0 | nsString const & currentValue = mKey.InternalValue(); |
1181 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1182 | 0 | return false; |
1183 | 0 | } |
1184 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->key_id, temp, JSPROP_ENUMERATE)) { |
1185 | 0 | return false; |
1186 | 0 | } |
1187 | 0 | break; |
1188 | 0 | } while(false); |
1189 | 0 | } |
1190 | 0 |
|
1191 | 0 | if (mLink.WasPassed()) { |
1192 | 0 | do { |
1193 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1194 | 0 | JS::Rooted<JS::Value> temp(cx); |
1195 | 0 | nsString const & currentValue = mLink.InternalValue(); |
1196 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1197 | 0 | return false; |
1198 | 0 | } |
1199 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->link_id, temp, JSPROP_ENUMERATE)) { |
1200 | 0 | return false; |
1201 | 0 | } |
1202 | 0 | break; |
1203 | 0 | } while(false); |
1204 | 0 | } |
1205 | 0 |
|
1206 | 0 | if (mMask.WasPassed()) { |
1207 | 0 | do { |
1208 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1209 | 0 | JS::Rooted<JS::Value> temp(cx); |
1210 | 0 | int32_t const & currentValue = mMask.InternalValue(); |
1211 | 0 | temp.setInt32(int32_t(currentValue)); |
1212 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mask_id, temp, JSPROP_ENUMERATE)) { |
1213 | 0 | return false; |
1214 | 0 | } |
1215 | 0 | break; |
1216 | 0 | } while(false); |
1217 | 0 | } |
1218 | 0 |
|
1219 | 0 | if (mMaskLength.WasPassed()) { |
1220 | 0 | do { |
1221 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1222 | 0 | JS::Rooted<JS::Value> temp(cx); |
1223 | 0 | nsString const & currentValue = mMaskLength.InternalValue(); |
1224 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1225 | 0 | return false; |
1226 | 0 | } |
1227 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->maskLength_id, temp, JSPROP_ENUMERATE)) { |
1228 | 0 | return false; |
1229 | 0 | } |
1230 | 0 | break; |
1231 | 0 | } while(false); |
1232 | 0 | } |
1233 | 0 |
|
1234 | 0 | if (mMode.WasPassed()) { |
1235 | 0 | do { |
1236 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1237 | 0 | JS::Rooted<JS::Value> temp(cx); |
1238 | 0 | nsString const & currentValue = mMode.InternalValue(); |
1239 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1240 | 0 | return false; |
1241 | 0 | } |
1242 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mode_id, temp, JSPROP_ENUMERATE)) { |
1243 | 0 | return false; |
1244 | 0 | } |
1245 | 0 | break; |
1246 | 0 | } while(false); |
1247 | 0 | } |
1248 | 0 |
|
1249 | 0 | if (mMtu.WasPassed()) { |
1250 | 0 | do { |
1251 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1252 | 0 | JS::Rooted<JS::Value> temp(cx); |
1253 | 0 | int32_t const & currentValue = mMtu.InternalValue(); |
1254 | 0 | temp.setInt32(int32_t(currentValue)); |
1255 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mtu_id, temp, JSPROP_ENUMERATE)) { |
1256 | 0 | return false; |
1257 | 0 | } |
1258 | 0 | break; |
1259 | 0 | } while(false); |
1260 | 0 | } |
1261 | 0 |
|
1262 | 0 | if (mPreExternalIfname.WasPassed()) { |
1263 | 0 | do { |
1264 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1265 | 0 | JS::Rooted<JS::Value> temp(cx); |
1266 | 0 | nsString const & currentValue = mPreExternalIfname.InternalValue(); |
1267 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1268 | 0 | return false; |
1269 | 0 | } |
1270 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->preExternalIfname_id, temp, JSPROP_ENUMERATE)) { |
1271 | 0 | return false; |
1272 | 0 | } |
1273 | 0 | break; |
1274 | 0 | } while(false); |
1275 | 0 | } |
1276 | 0 |
|
1277 | 0 | if (mPreInternalIfname.WasPassed()) { |
1278 | 0 | do { |
1279 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1280 | 0 | JS::Rooted<JS::Value> temp(cx); |
1281 | 0 | nsString const & currentValue = mPreInternalIfname.InternalValue(); |
1282 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1283 | 0 | return false; |
1284 | 0 | } |
1285 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->preInternalIfname_id, temp, JSPROP_ENUMERATE)) { |
1286 | 0 | return false; |
1287 | 0 | } |
1288 | 0 | break; |
1289 | 0 | } while(false); |
1290 | 0 | } |
1291 | 0 |
|
1292 | 0 | if (mPrefix.WasPassed()) { |
1293 | 0 | do { |
1294 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1295 | 0 | JS::Rooted<JS::Value> temp(cx); |
1296 | 0 | nsString const & currentValue = mPrefix.InternalValue(); |
1297 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1298 | 0 | return false; |
1299 | 0 | } |
1300 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->prefix_id, temp, JSPROP_ENUMERATE)) { |
1301 | 0 | return false; |
1302 | 0 | } |
1303 | 0 | break; |
1304 | 0 | } while(false); |
1305 | 0 | } |
1306 | 0 |
|
1307 | 0 | if (mPrefixLength.WasPassed()) { |
1308 | 0 | do { |
1309 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1310 | 0 | JS::Rooted<JS::Value> temp(cx); |
1311 | 0 | uint32_t const & currentValue = mPrefixLength.InternalValue(); |
1312 | 0 | temp.setNumber(currentValue); |
1313 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->prefixLength_id, temp, JSPROP_ENUMERATE)) { |
1314 | 0 | return false; |
1315 | 0 | } |
1316 | 0 | break; |
1317 | 0 | } while(false); |
1318 | 0 | } |
1319 | 0 |
|
1320 | 0 | if (mReport.WasPassed()) { |
1321 | 0 | do { |
1322 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1323 | 0 | JS::Rooted<JS::Value> temp(cx); |
1324 | 0 | bool const & currentValue = mReport.InternalValue(); |
1325 | 0 | temp.setBoolean(currentValue); |
1326 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->report_id, temp, JSPROP_ENUMERATE)) { |
1327 | 0 | return false; |
1328 | 0 | } |
1329 | 0 | break; |
1330 | 0 | } while(false); |
1331 | 0 | } |
1332 | 0 |
|
1333 | 0 | if (mSecurity.WasPassed()) { |
1334 | 0 | do { |
1335 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1336 | 0 | JS::Rooted<JS::Value> temp(cx); |
1337 | 0 | nsString const & currentValue = mSecurity.InternalValue(); |
1338 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1339 | 0 | return false; |
1340 | 0 | } |
1341 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->security_id, temp, JSPROP_ENUMERATE)) { |
1342 | 0 | return false; |
1343 | 0 | } |
1344 | 0 | break; |
1345 | 0 | } while(false); |
1346 | 0 | } |
1347 | 0 |
|
1348 | 0 | if (mServerIp.WasPassed()) { |
1349 | 0 | do { |
1350 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1351 | 0 | JS::Rooted<JS::Value> temp(cx); |
1352 | 0 | nsString const & currentValue = mServerIp.InternalValue(); |
1353 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1354 | 0 | return false; |
1355 | 0 | } |
1356 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->serverIp_id, temp, JSPROP_ENUMERATE)) { |
1357 | 0 | return false; |
1358 | 0 | } |
1359 | 0 | break; |
1360 | 0 | } while(false); |
1361 | 0 | } |
1362 | 0 |
|
1363 | 0 | if (mSsid.WasPassed()) { |
1364 | 0 | do { |
1365 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1366 | 0 | JS::Rooted<JS::Value> temp(cx); |
1367 | 0 | nsString const & currentValue = mSsid.InternalValue(); |
1368 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1369 | 0 | return false; |
1370 | 0 | } |
1371 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ssid_id, temp, JSPROP_ENUMERATE)) { |
1372 | 0 | return false; |
1373 | 0 | } |
1374 | 0 | break; |
1375 | 0 | } while(false); |
1376 | 0 | } |
1377 | 0 |
|
1378 | 0 | if (mStartIp.WasPassed()) { |
1379 | 0 | do { |
1380 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1381 | 0 | JS::Rooted<JS::Value> temp(cx); |
1382 | 0 | nsString const & currentValue = mStartIp.InternalValue(); |
1383 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1384 | 0 | return false; |
1385 | 0 | } |
1386 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->startIp_id, temp, JSPROP_ENUMERATE)) { |
1387 | 0 | return false; |
1388 | 0 | } |
1389 | 0 | break; |
1390 | 0 | } while(false); |
1391 | 0 | } |
1392 | 0 |
|
1393 | 0 | if (mThreshold.WasPassed()) { |
1394 | 0 | do { |
1395 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1396 | 0 | JS::Rooted<JS::Value> temp(cx); |
1397 | 0 | int64_t const & currentValue = mThreshold.InternalValue(); |
1398 | 0 | temp.set(JS_NumberValue(double(currentValue))); |
1399 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->threshold_id, temp, JSPROP_ENUMERATE)) { |
1400 | 0 | return false; |
1401 | 0 | } |
1402 | 0 | break; |
1403 | 0 | } while(false); |
1404 | 0 | } |
1405 | 0 |
|
1406 | 0 | if (mUsbEndIp.WasPassed()) { |
1407 | 0 | do { |
1408 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1409 | 0 | JS::Rooted<JS::Value> temp(cx); |
1410 | 0 | nsString const & currentValue = mUsbEndIp.InternalValue(); |
1411 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1412 | 0 | return false; |
1413 | 0 | } |
1414 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->usbEndIp_id, temp, JSPROP_ENUMERATE)) { |
1415 | 0 | return false; |
1416 | 0 | } |
1417 | 0 | break; |
1418 | 0 | } while(false); |
1419 | 0 | } |
1420 | 0 |
|
1421 | 0 | if (mUsbStartIp.WasPassed()) { |
1422 | 0 | do { |
1423 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1424 | 0 | JS::Rooted<JS::Value> temp(cx); |
1425 | 0 | nsString const & currentValue = mUsbStartIp.InternalValue(); |
1426 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1427 | 0 | return false; |
1428 | 0 | } |
1429 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->usbStartIp_id, temp, JSPROP_ENUMERATE)) { |
1430 | 0 | return false; |
1431 | 0 | } |
1432 | 0 | break; |
1433 | 0 | } while(false); |
1434 | 0 | } |
1435 | 0 |
|
1436 | 0 | if (mWifiEndIp.WasPassed()) { |
1437 | 0 | do { |
1438 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1439 | 0 | JS::Rooted<JS::Value> temp(cx); |
1440 | 0 | nsString const & currentValue = mWifiEndIp.InternalValue(); |
1441 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1442 | 0 | return false; |
1443 | 0 | } |
1444 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->wifiEndIp_id, temp, JSPROP_ENUMERATE)) { |
1445 | 0 | return false; |
1446 | 0 | } |
1447 | 0 | break; |
1448 | 0 | } while(false); |
1449 | 0 | } |
1450 | 0 |
|
1451 | 0 | if (mWifiStartIp.WasPassed()) { |
1452 | 0 | do { |
1453 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1454 | 0 | JS::Rooted<JS::Value> temp(cx); |
1455 | 0 | nsString const & currentValue = mWifiStartIp.InternalValue(); |
1456 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1457 | 0 | return false; |
1458 | 0 | } |
1459 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->wifiStartIp_id, temp, JSPROP_ENUMERATE)) { |
1460 | 0 | return false; |
1461 | 0 | } |
1462 | 0 | break; |
1463 | 0 | } while(false); |
1464 | 0 | } |
1465 | 0 |
|
1466 | 0 | if (mWifictrlinterfacename.WasPassed()) { |
1467 | 0 | do { |
1468 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1469 | 0 | JS::Rooted<JS::Value> temp(cx); |
1470 | 0 | nsString const & currentValue = mWifictrlinterfacename.InternalValue(); |
1471 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
1472 | 0 | return false; |
1473 | 0 | } |
1474 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->wifictrlinterfacename_id, temp, JSPROP_ENUMERATE)) { |
1475 | 0 | return false; |
1476 | 0 | } |
1477 | 0 | break; |
1478 | 0 | } while(false); |
1479 | 0 | } |
1480 | 0 |
|
1481 | 0 | return true; |
1482 | 0 | } |
1483 | | |
1484 | | bool |
1485 | | NetworkCommandOptions::ToJSON(nsAString& aJSON) const |
1486 | 0 | { |
1487 | 0 | AutoJSAPI jsapi; |
1488 | 0 | jsapi.Init(); |
1489 | 0 | JSContext *cx = jsapi.cx(); |
1490 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
1491 | 0 | // because we'll only be creating objects, in ways that have no |
1492 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
1493 | 0 | // which likewise guarantees no side-effects for the sorts of |
1494 | 0 | // things we will pass it. |
1495 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
1496 | 0 | JS::Rooted<JS::Value> val(cx); |
1497 | 0 | if (!ToObjectInternal(cx, &val)) { |
1498 | 0 | return false; |
1499 | 0 | } |
1500 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
1501 | 0 | return StringifyToJSON(cx, obj, aJSON); |
1502 | 0 | } |
1503 | | |
1504 | | void |
1505 | | NetworkCommandOptions::TraceDictionary(JSTracer* trc) |
1506 | 0 | { |
1507 | 0 | } |
1508 | | |
1509 | | NetworkCommandOptions& |
1510 | | NetworkCommandOptions::operator=(const NetworkCommandOptions& aOther) |
1511 | 0 | { |
1512 | 0 | DictionaryBase::operator=(aOther); |
1513 | 0 | mCmd = aOther.mCmd; |
1514 | 0 | mCurExternalIfname.Reset(); |
1515 | 0 | if (aOther.mCurExternalIfname.WasPassed()) { |
1516 | 0 | mCurExternalIfname.Construct(aOther.mCurExternalIfname.Value()); |
1517 | 0 | } |
1518 | 0 | mCurInternalIfname.Reset(); |
1519 | 0 | if (aOther.mCurInternalIfname.WasPassed()) { |
1520 | 0 | mCurInternalIfname.Construct(aOther.mCurInternalIfname.Value()); |
1521 | 0 | } |
1522 | 0 | mDns1.Reset(); |
1523 | 0 | if (aOther.mDns1.WasPassed()) { |
1524 | 0 | mDns1.Construct(aOther.mDns1.Value()); |
1525 | 0 | } |
1526 | 0 | mDns1_long.Reset(); |
1527 | 0 | if (aOther.mDns1_long.WasPassed()) { |
1528 | 0 | mDns1_long.Construct(aOther.mDns1_long.Value()); |
1529 | 0 | } |
1530 | 0 | mDns2.Reset(); |
1531 | 0 | if (aOther.mDns2.WasPassed()) { |
1532 | 0 | mDns2.Construct(aOther.mDns2.Value()); |
1533 | 0 | } |
1534 | 0 | mDns2_long.Reset(); |
1535 | 0 | if (aOther.mDns2_long.WasPassed()) { |
1536 | 0 | mDns2_long.Construct(aOther.mDns2_long.Value()); |
1537 | 0 | } |
1538 | 0 | mDnses.Reset(); |
1539 | 0 | if (aOther.mDnses.WasPassed()) { |
1540 | 0 | mDnses.Construct(aOther.mDnses.Value()); |
1541 | 0 | } |
1542 | 0 | mDomain.Reset(); |
1543 | 0 | if (aOther.mDomain.WasPassed()) { |
1544 | 0 | mDomain.Construct(aOther.mDomain.Value()); |
1545 | 0 | } |
1546 | 0 | mEnable.Reset(); |
1547 | 0 | if (aOther.mEnable.WasPassed()) { |
1548 | 0 | mEnable.Construct(aOther.mEnable.Value()); |
1549 | 0 | } |
1550 | 0 | mEnabled.Reset(); |
1551 | 0 | if (aOther.mEnabled.WasPassed()) { |
1552 | 0 | mEnabled.Construct(aOther.mEnabled.Value()); |
1553 | 0 | } |
1554 | 0 | mEndIp.Reset(); |
1555 | 0 | if (aOther.mEndIp.WasPassed()) { |
1556 | 0 | mEndIp.Construct(aOther.mEndIp.Value()); |
1557 | 0 | } |
1558 | 0 | mExternalIfname.Reset(); |
1559 | 0 | if (aOther.mExternalIfname.WasPassed()) { |
1560 | 0 | mExternalIfname.Construct(aOther.mExternalIfname.Value()); |
1561 | 0 | } |
1562 | 0 | mGateway.Reset(); |
1563 | 0 | if (aOther.mGateway.WasPassed()) { |
1564 | 0 | mGateway.Construct(aOther.mGateway.Value()); |
1565 | 0 | } |
1566 | 0 | mGateway_long.Reset(); |
1567 | 0 | if (aOther.mGateway_long.WasPassed()) { |
1568 | 0 | mGateway_long.Construct(aOther.mGateway_long.Value()); |
1569 | 0 | } |
1570 | 0 | mGateways.Reset(); |
1571 | 0 | if (aOther.mGateways.WasPassed()) { |
1572 | 0 | mGateways.Construct(aOther.mGateways.Value()); |
1573 | 0 | } |
1574 | 0 | mId = aOther.mId; |
1575 | 0 | mIfname.Reset(); |
1576 | 0 | if (aOther.mIfname.WasPassed()) { |
1577 | 0 | mIfname.Construct(aOther.mIfname.Value()); |
1578 | 0 | } |
1579 | 0 | mInterfaceList.Reset(); |
1580 | 0 | if (aOther.mInterfaceList.WasPassed()) { |
1581 | 0 | mInterfaceList.Construct(aOther.mInterfaceList.Value()); |
1582 | 0 | } |
1583 | 0 | mInternalIfname.Reset(); |
1584 | 0 | if (aOther.mInternalIfname.WasPassed()) { |
1585 | 0 | mInternalIfname.Construct(aOther.mInternalIfname.Value()); |
1586 | 0 | } |
1587 | 0 | mIp.Reset(); |
1588 | 0 | if (aOther.mIp.WasPassed()) { |
1589 | 0 | mIp.Construct(aOther.mIp.Value()); |
1590 | 0 | } |
1591 | 0 | mIpaddr.Reset(); |
1592 | 0 | if (aOther.mIpaddr.WasPassed()) { |
1593 | 0 | mIpaddr.Construct(aOther.mIpaddr.Value()); |
1594 | 0 | } |
1595 | 0 | mKey.Reset(); |
1596 | 0 | if (aOther.mKey.WasPassed()) { |
1597 | 0 | mKey.Construct(aOther.mKey.Value()); |
1598 | 0 | } |
1599 | 0 | mLink.Reset(); |
1600 | 0 | if (aOther.mLink.WasPassed()) { |
1601 | 0 | mLink.Construct(aOther.mLink.Value()); |
1602 | 0 | } |
1603 | 0 | mMask.Reset(); |
1604 | 0 | if (aOther.mMask.WasPassed()) { |
1605 | 0 | mMask.Construct(aOther.mMask.Value()); |
1606 | 0 | } |
1607 | 0 | mMaskLength.Reset(); |
1608 | 0 | if (aOther.mMaskLength.WasPassed()) { |
1609 | 0 | mMaskLength.Construct(aOther.mMaskLength.Value()); |
1610 | 0 | } |
1611 | 0 | mMode.Reset(); |
1612 | 0 | if (aOther.mMode.WasPassed()) { |
1613 | 0 | mMode.Construct(aOther.mMode.Value()); |
1614 | 0 | } |
1615 | 0 | mMtu.Reset(); |
1616 | 0 | if (aOther.mMtu.WasPassed()) { |
1617 | 0 | mMtu.Construct(aOther.mMtu.Value()); |
1618 | 0 | } |
1619 | 0 | mPreExternalIfname.Reset(); |
1620 | 0 | if (aOther.mPreExternalIfname.WasPassed()) { |
1621 | 0 | mPreExternalIfname.Construct(aOther.mPreExternalIfname.Value()); |
1622 | 0 | } |
1623 | 0 | mPreInternalIfname.Reset(); |
1624 | 0 | if (aOther.mPreInternalIfname.WasPassed()) { |
1625 | 0 | mPreInternalIfname.Construct(aOther.mPreInternalIfname.Value()); |
1626 | 0 | } |
1627 | 0 | mPrefix.Reset(); |
1628 | 0 | if (aOther.mPrefix.WasPassed()) { |
1629 | 0 | mPrefix.Construct(aOther.mPrefix.Value()); |
1630 | 0 | } |
1631 | 0 | mPrefixLength.Reset(); |
1632 | 0 | if (aOther.mPrefixLength.WasPassed()) { |
1633 | 0 | mPrefixLength.Construct(aOther.mPrefixLength.Value()); |
1634 | 0 | } |
1635 | 0 | mReport.Reset(); |
1636 | 0 | if (aOther.mReport.WasPassed()) { |
1637 | 0 | mReport.Construct(aOther.mReport.Value()); |
1638 | 0 | } |
1639 | 0 | mSecurity.Reset(); |
1640 | 0 | if (aOther.mSecurity.WasPassed()) { |
1641 | 0 | mSecurity.Construct(aOther.mSecurity.Value()); |
1642 | 0 | } |
1643 | 0 | mServerIp.Reset(); |
1644 | 0 | if (aOther.mServerIp.WasPassed()) { |
1645 | 0 | mServerIp.Construct(aOther.mServerIp.Value()); |
1646 | 0 | } |
1647 | 0 | mSsid.Reset(); |
1648 | 0 | if (aOther.mSsid.WasPassed()) { |
1649 | 0 | mSsid.Construct(aOther.mSsid.Value()); |
1650 | 0 | } |
1651 | 0 | mStartIp.Reset(); |
1652 | 0 | if (aOther.mStartIp.WasPassed()) { |
1653 | 0 | mStartIp.Construct(aOther.mStartIp.Value()); |
1654 | 0 | } |
1655 | 0 | mThreshold.Reset(); |
1656 | 0 | if (aOther.mThreshold.WasPassed()) { |
1657 | 0 | mThreshold.Construct(aOther.mThreshold.Value()); |
1658 | 0 | } |
1659 | 0 | mUsbEndIp.Reset(); |
1660 | 0 | if (aOther.mUsbEndIp.WasPassed()) { |
1661 | 0 | mUsbEndIp.Construct(aOther.mUsbEndIp.Value()); |
1662 | 0 | } |
1663 | 0 | mUsbStartIp.Reset(); |
1664 | 0 | if (aOther.mUsbStartIp.WasPassed()) { |
1665 | 0 | mUsbStartIp.Construct(aOther.mUsbStartIp.Value()); |
1666 | 0 | } |
1667 | 0 | mWifiEndIp.Reset(); |
1668 | 0 | if (aOther.mWifiEndIp.WasPassed()) { |
1669 | 0 | mWifiEndIp.Construct(aOther.mWifiEndIp.Value()); |
1670 | 0 | } |
1671 | 0 | mWifiStartIp.Reset(); |
1672 | 0 | if (aOther.mWifiStartIp.WasPassed()) { |
1673 | 0 | mWifiStartIp.Construct(aOther.mWifiStartIp.Value()); |
1674 | 0 | } |
1675 | 0 | mWifictrlinterfacename.Reset(); |
1676 | 0 | if (aOther.mWifictrlinterfacename.WasPassed()) { |
1677 | 0 | mWifictrlinterfacename.Construct(aOther.mWifictrlinterfacename.Value()); |
1678 | 0 | } |
1679 | 0 | return *this; |
1680 | 0 | } |
1681 | | |
1682 | | namespace binding_detail { |
1683 | | } // namespace binding_detail |
1684 | | |
1685 | | |
1686 | | |
1687 | | NetworkResultOptions::NetworkResultOptions() |
1688 | 0 | { |
1689 | 0 | // Safe to pass a null context if we pass a null value |
1690 | 0 | Init(nullptr, JS::NullHandleValue); |
1691 | 0 | } |
1692 | | |
1693 | | |
1694 | | |
1695 | | bool |
1696 | | NetworkResultOptions::InitIds(JSContext* cx, NetworkResultOptionsAtoms* atomsCache) |
1697 | 0 | { |
1698 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
1699 | 0 |
|
1700 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
1701 | 0 | // uninitialized. |
1702 | 0 | if (!atomsCache->vendor_str_id.init(cx, "vendor_str") || |
1703 | 0 | !atomsCache->topic_id.init(cx, "topic") || |
1704 | 0 | !atomsCache->success_id.init(cx, "success") || |
1705 | 0 | !atomsCache->server_str_id.init(cx, "server_str") || |
1706 | 0 | !atomsCache->server_id.init(cx, "server") || |
1707 | 0 | !atomsCache->route_id.init(cx, "route") || |
1708 | 0 | !atomsCache->ret_id.init(cx, "ret") || |
1709 | 0 | !atomsCache->resultReason_id.init(cx, "resultReason") || |
1710 | 0 | !atomsCache->resultCode_id.init(cx, "resultCode") || |
1711 | 0 | !atomsCache->result_id.init(cx, "result") || |
1712 | 0 | !atomsCache->reply_id.init(cx, "reply") || |
1713 | 0 | !atomsCache->reason_id.init(cx, "reason") || |
1714 | 0 | !atomsCache->prefixLength_id.init(cx, "prefixLength") || |
1715 | 0 | !atomsCache->netId_id.init(cx, "netId") || |
1716 | 0 | !atomsCache->mask_str_id.init(cx, "mask_str") || |
1717 | 0 | !atomsCache->mask_id.init(cx, "mask") || |
1718 | 0 | !atomsCache->macAddr_id.init(cx, "macAddr") || |
1719 | 0 | !atomsCache->lease_id.init(cx, "lease") || |
1720 | 0 | !atomsCache->ipaddr_str_id.init(cx, "ipaddr_str") || |
1721 | 0 | !atomsCache->ipaddr_id.init(cx, "ipaddr") || |
1722 | 0 | !atomsCache->ipAddr_id.init(cx, "ipAddr") || |
1723 | 0 | !atomsCache->interfaceList_id.init(cx, "interfaceList") || |
1724 | 0 | !atomsCache->id_id.init(cx, "id") || |
1725 | 0 | !atomsCache->gateway_str_id.init(cx, "gateway_str") || |
1726 | 0 | !atomsCache->gateway_id.init(cx, "gateway") || |
1727 | 0 | !atomsCache->flag_id.init(cx, "flag") || |
1728 | 0 | !atomsCache->error_id.init(cx, "error") || |
1729 | 0 | !atomsCache->enable_id.init(cx, "enable") || |
1730 | 0 | !atomsCache->dns2_str_id.init(cx, "dns2_str") || |
1731 | 0 | !atomsCache->dns2_id.init(cx, "dns2") || |
1732 | 0 | !atomsCache->dns1_str_id.init(cx, "dns1_str") || |
1733 | 0 | !atomsCache->dns1_id.init(cx, "dns1") || |
1734 | 0 | !atomsCache->curInternalIfname_id.init(cx, "curInternalIfname") || |
1735 | 0 | !atomsCache->curExternalIfname_id.init(cx, "curExternalIfname") || |
1736 | 0 | !atomsCache->broadcast_id.init(cx, "broadcast")) { |
1737 | 0 | return false; |
1738 | 0 | } |
1739 | 0 | return true; |
1740 | 0 | } |
1741 | | |
1742 | | bool |
1743 | | NetworkResultOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
1744 | 0 | { |
1745 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
1746 | 0 | // Since in that case we will not have to do any property gets |
1747 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
1748 | 0 | // checkers by static analysis tools |
1749 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
1750 | 0 | NetworkResultOptionsAtoms* atomsCache = nullptr; |
1751 | 0 | if (cx) { |
1752 | 0 | atomsCache = GetAtomCache<NetworkResultOptionsAtoms>(cx); |
1753 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
1754 | 0 | return false; |
1755 | 0 | } |
1756 | 0 | } |
1757 | 0 | |
1758 | 0 | if (!IsConvertibleToDictionary(val)) { |
1759 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
1760 | 0 | } |
1761 | 0 | |
1762 | 0 | bool isNull = val.isNullOrUndefined(); |
1763 | 0 | // We only need these if !isNull, in which case we have |cx|. |
1764 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
1765 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
1766 | 0 | if (!isNull) { |
1767 | 0 | MOZ_ASSERT(cx); |
1768 | 0 | object.emplace(cx, &val.toObject()); |
1769 | 0 | temp.emplace(cx); |
1770 | 0 | } |
1771 | 0 | if (!isNull) { |
1772 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->broadcast_id, temp.ptr())) { |
1773 | 0 | return false; |
1774 | 0 | } |
1775 | 0 | } |
1776 | 0 | if (!isNull && !temp->isUndefined()) { |
1777 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mBroadcast)) { |
1778 | 0 | return false; |
1779 | 0 | } |
1780 | 0 | } else { |
1781 | 0 | mBroadcast = false; |
1782 | 0 | } |
1783 | 0 | mIsAnyMemberPresent = true; |
1784 | 0 |
|
1785 | 0 | if (!isNull) { |
1786 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->curExternalIfname_id, temp.ptr())) { |
1787 | 0 | return false; |
1788 | 0 | } |
1789 | 0 | } |
1790 | 0 | if (!isNull && !temp->isUndefined()) { |
1791 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCurExternalIfname)) { |
1792 | 0 | return false; |
1793 | 0 | } |
1794 | 0 | } else { |
1795 | 0 | static const char16_t data[] = { 0 }; |
1796 | 0 | mCurExternalIfname.Rebind(data, ArrayLength(data) - 1); |
1797 | 0 | } |
1798 | 0 | mIsAnyMemberPresent = true; |
1799 | 0 |
|
1800 | 0 | if (!isNull) { |
1801 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->curInternalIfname_id, temp.ptr())) { |
1802 | 0 | return false; |
1803 | 0 | } |
1804 | 0 | } |
1805 | 0 | if (!isNull && !temp->isUndefined()) { |
1806 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCurInternalIfname)) { |
1807 | 0 | return false; |
1808 | 0 | } |
1809 | 0 | } else { |
1810 | 0 | static const char16_t data[] = { 0 }; |
1811 | 0 | mCurInternalIfname.Rebind(data, ArrayLength(data) - 1); |
1812 | 0 | } |
1813 | 0 | mIsAnyMemberPresent = true; |
1814 | 0 |
|
1815 | 0 | if (!isNull) { |
1816 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns1_id, temp.ptr())) { |
1817 | 0 | return false; |
1818 | 0 | } |
1819 | 0 | } |
1820 | 0 | if (!isNull && !temp->isUndefined()) { |
1821 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mDns1)) { |
1822 | 0 | return false; |
1823 | 0 | } |
1824 | 0 | } else { |
1825 | 0 | mDns1 = 0; |
1826 | 0 | } |
1827 | 0 | mIsAnyMemberPresent = true; |
1828 | 0 |
|
1829 | 0 | if (!isNull) { |
1830 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns1_str_id, temp.ptr())) { |
1831 | 0 | return false; |
1832 | 0 | } |
1833 | 0 | } |
1834 | 0 | if (!isNull && !temp->isUndefined()) { |
1835 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDns1_str)) { |
1836 | 0 | return false; |
1837 | 0 | } |
1838 | 0 | } else { |
1839 | 0 | static const char16_t data[] = { 0 }; |
1840 | 0 | mDns1_str.Rebind(data, ArrayLength(data) - 1); |
1841 | 0 | } |
1842 | 0 | mIsAnyMemberPresent = true; |
1843 | 0 |
|
1844 | 0 | if (!isNull) { |
1845 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns2_id, temp.ptr())) { |
1846 | 0 | return false; |
1847 | 0 | } |
1848 | 0 | } |
1849 | 0 | if (!isNull && !temp->isUndefined()) { |
1850 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mDns2)) { |
1851 | 0 | return false; |
1852 | 0 | } |
1853 | 0 | } else { |
1854 | 0 | mDns2 = 0; |
1855 | 0 | } |
1856 | 0 | mIsAnyMemberPresent = true; |
1857 | 0 |
|
1858 | 0 | if (!isNull) { |
1859 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->dns2_str_id, temp.ptr())) { |
1860 | 0 | return false; |
1861 | 0 | } |
1862 | 0 | } |
1863 | 0 | if (!isNull && !temp->isUndefined()) { |
1864 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDns2_str)) { |
1865 | 0 | return false; |
1866 | 0 | } |
1867 | 0 | } else { |
1868 | 0 | static const char16_t data[] = { 0 }; |
1869 | 0 | mDns2_str.Rebind(data, ArrayLength(data) - 1); |
1870 | 0 | } |
1871 | 0 | mIsAnyMemberPresent = true; |
1872 | 0 |
|
1873 | 0 | if (!isNull) { |
1874 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->enable_id, temp.ptr())) { |
1875 | 0 | return false; |
1876 | 0 | } |
1877 | 0 | } |
1878 | 0 | if (!isNull && !temp->isUndefined()) { |
1879 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mEnable)) { |
1880 | 0 | return false; |
1881 | 0 | } |
1882 | 0 | } else { |
1883 | 0 | mEnable = false; |
1884 | 0 | } |
1885 | 0 | mIsAnyMemberPresent = true; |
1886 | 0 |
|
1887 | 0 | if (!isNull) { |
1888 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->error_id, temp.ptr())) { |
1889 | 0 | return false; |
1890 | 0 | } |
1891 | 0 | } |
1892 | 0 | if (!isNull && !temp->isUndefined()) { |
1893 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mError)) { |
1894 | 0 | return false; |
1895 | 0 | } |
1896 | 0 | } else { |
1897 | 0 | mError = false; |
1898 | 0 | } |
1899 | 0 | mIsAnyMemberPresent = true; |
1900 | 0 |
|
1901 | 0 | if (!isNull) { |
1902 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->flag_id, temp.ptr())) { |
1903 | 0 | return false; |
1904 | 0 | } |
1905 | 0 | } |
1906 | 0 | if (!isNull && !temp->isUndefined()) { |
1907 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFlag)) { |
1908 | 0 | return false; |
1909 | 0 | } |
1910 | 0 | } else { |
1911 | 0 | static const char16_t data[] = { 'd', 'o', 'w', 'n', 0 }; |
1912 | 0 | mFlag.Rebind(data, ArrayLength(data) - 1); |
1913 | 0 | } |
1914 | 0 | mIsAnyMemberPresent = true; |
1915 | 0 |
|
1916 | 0 | if (!isNull) { |
1917 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gateway_id, temp.ptr())) { |
1918 | 0 | return false; |
1919 | 0 | } |
1920 | 0 | } |
1921 | 0 | if (!isNull && !temp->isUndefined()) { |
1922 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mGateway)) { |
1923 | 0 | return false; |
1924 | 0 | } |
1925 | 0 | } else { |
1926 | 0 | mGateway = 0; |
1927 | 0 | } |
1928 | 0 | mIsAnyMemberPresent = true; |
1929 | 0 |
|
1930 | 0 | if (!isNull) { |
1931 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->gateway_str_id, temp.ptr())) { |
1932 | 0 | return false; |
1933 | 0 | } |
1934 | 0 | } |
1935 | 0 | if (!isNull && !temp->isUndefined()) { |
1936 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mGateway_str)) { |
1937 | 0 | return false; |
1938 | 0 | } |
1939 | 0 | } else { |
1940 | 0 | static const char16_t data[] = { 0 }; |
1941 | 0 | mGateway_str.Rebind(data, ArrayLength(data) - 1); |
1942 | 0 | } |
1943 | 0 | mIsAnyMemberPresent = true; |
1944 | 0 |
|
1945 | 0 | if (!isNull) { |
1946 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->id_id, temp.ptr())) { |
1947 | 0 | return false; |
1948 | 0 | } |
1949 | 0 | } |
1950 | 0 | if (!isNull && !temp->isUndefined()) { |
1951 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mId)) { |
1952 | 0 | return false; |
1953 | 0 | } |
1954 | 0 | } else { |
1955 | 0 | mId = 0; |
1956 | 0 | } |
1957 | 0 | mIsAnyMemberPresent = true; |
1958 | 0 |
|
1959 | 0 | if (!isNull) { |
1960 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->interfaceList_id, temp.ptr())) { |
1961 | 0 | return false; |
1962 | 0 | } |
1963 | 0 | } |
1964 | 0 | if (!isNull && !temp->isUndefined()) { |
1965 | 0 | mInterfaceList.Construct(); |
1966 | 0 | if (temp.ref().isObject()) { |
1967 | 0 | JS::ForOfIterator iter(cx); |
1968 | 0 | if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) { |
1969 | 0 | return false; |
1970 | 0 | } |
1971 | 0 | if (!iter.valueIsIterable()) { |
1972 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'interfaceList' member of NetworkResultOptions"); |
1973 | 0 | return false; |
1974 | 0 | } |
1975 | 0 | Sequence<nsString> &arr = (mInterfaceList.Value()); |
1976 | 0 | JS::Rooted<JS::Value> temp(cx); |
1977 | 0 | while (true) { |
1978 | 0 | bool done; |
1979 | 0 | if (!iter.next(&temp, &done)) { |
1980 | 0 | return false; |
1981 | 0 | } |
1982 | 0 | if (done) { |
1983 | 0 | break; |
1984 | 0 | } |
1985 | 0 | nsString* slotPtr = arr.AppendElement(mozilla::fallible); |
1986 | 0 | if (!slotPtr) { |
1987 | 0 | JS_ReportOutOfMemory(cx); |
1988 | 0 | return false; |
1989 | 0 | } |
1990 | 0 | nsString& slot = *slotPtr; |
1991 | 0 | if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) { |
1992 | 0 | return false; |
1993 | 0 | } |
1994 | 0 | } |
1995 | 0 | } else { |
1996 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'interfaceList' member of NetworkResultOptions"); |
1997 | 0 | return false; |
1998 | 0 | } |
1999 | 0 | mIsAnyMemberPresent = true; |
2000 | 0 | } |
2001 | 0 |
|
2002 | 0 | if (!isNull) { |
2003 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ipAddr_id, temp.ptr())) { |
2004 | 0 | return false; |
2005 | 0 | } |
2006 | 0 | } |
2007 | 0 | if (!isNull && !temp->isUndefined()) { |
2008 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mIpAddr)) { |
2009 | 0 | return false; |
2010 | 0 | } |
2011 | 0 | } else { |
2012 | 0 | static const char16_t data[] = { 0 }; |
2013 | 0 | mIpAddr.Rebind(data, ArrayLength(data) - 1); |
2014 | 0 | } |
2015 | 0 | mIsAnyMemberPresent = true; |
2016 | 0 |
|
2017 | 0 | if (!isNull) { |
2018 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ipaddr_id, temp.ptr())) { |
2019 | 0 | return false; |
2020 | 0 | } |
2021 | 0 | } |
2022 | 0 | if (!isNull && !temp->isUndefined()) { |
2023 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mIpaddr)) { |
2024 | 0 | return false; |
2025 | 0 | } |
2026 | 0 | } else { |
2027 | 0 | mIpaddr = 0; |
2028 | 0 | } |
2029 | 0 | mIsAnyMemberPresent = true; |
2030 | 0 |
|
2031 | 0 | if (!isNull) { |
2032 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ipaddr_str_id, temp.ptr())) { |
2033 | 0 | return false; |
2034 | 0 | } |
2035 | 0 | } |
2036 | 0 | if (!isNull && !temp->isUndefined()) { |
2037 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mIpaddr_str)) { |
2038 | 0 | return false; |
2039 | 0 | } |
2040 | 0 | } else { |
2041 | 0 | static const char16_t data[] = { 0 }; |
2042 | 0 | mIpaddr_str.Rebind(data, ArrayLength(data) - 1); |
2043 | 0 | } |
2044 | 0 | mIsAnyMemberPresent = true; |
2045 | 0 |
|
2046 | 0 | if (!isNull) { |
2047 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->lease_id, temp.ptr())) { |
2048 | 0 | return false; |
2049 | 0 | } |
2050 | 0 | } |
2051 | 0 | if (!isNull && !temp->isUndefined()) { |
2052 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mLease)) { |
2053 | 0 | return false; |
2054 | 0 | } |
2055 | 0 | } else { |
2056 | 0 | mLease = 0; |
2057 | 0 | } |
2058 | 0 | mIsAnyMemberPresent = true; |
2059 | 0 |
|
2060 | 0 | if (!isNull) { |
2061 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->macAddr_id, temp.ptr())) { |
2062 | 0 | return false; |
2063 | 0 | } |
2064 | 0 | } |
2065 | 0 | if (!isNull && !temp->isUndefined()) { |
2066 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMacAddr)) { |
2067 | 0 | return false; |
2068 | 0 | } |
2069 | 0 | } else { |
2070 | 0 | static const char16_t data[] = { 0 }; |
2071 | 0 | mMacAddr.Rebind(data, ArrayLength(data) - 1); |
2072 | 0 | } |
2073 | 0 | mIsAnyMemberPresent = true; |
2074 | 0 |
|
2075 | 0 | if (!isNull) { |
2076 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mask_id, temp.ptr())) { |
2077 | 0 | return false; |
2078 | 0 | } |
2079 | 0 | } |
2080 | 0 | if (!isNull && !temp->isUndefined()) { |
2081 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mMask)) { |
2082 | 0 | return false; |
2083 | 0 | } |
2084 | 0 | } else { |
2085 | 0 | mMask = 0; |
2086 | 0 | } |
2087 | 0 | mIsAnyMemberPresent = true; |
2088 | 0 |
|
2089 | 0 | if (!isNull) { |
2090 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mask_str_id, temp.ptr())) { |
2091 | 0 | return false; |
2092 | 0 | } |
2093 | 0 | } |
2094 | 0 | if (!isNull && !temp->isUndefined()) { |
2095 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMask_str)) { |
2096 | 0 | return false; |
2097 | 0 | } |
2098 | 0 | } else { |
2099 | 0 | static const char16_t data[] = { 0 }; |
2100 | 0 | mMask_str.Rebind(data, ArrayLength(data) - 1); |
2101 | 0 | } |
2102 | 0 | mIsAnyMemberPresent = true; |
2103 | 0 |
|
2104 | 0 | if (!isNull) { |
2105 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->netId_id, temp.ptr())) { |
2106 | 0 | return false; |
2107 | 0 | } |
2108 | 0 | } |
2109 | 0 | if (!isNull && !temp->isUndefined()) { |
2110 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mNetId)) { |
2111 | 0 | return false; |
2112 | 0 | } |
2113 | 0 | } else { |
2114 | 0 | static const char16_t data[] = { 0 }; |
2115 | 0 | mNetId.Rebind(data, ArrayLength(data) - 1); |
2116 | 0 | } |
2117 | 0 | mIsAnyMemberPresent = true; |
2118 | 0 |
|
2119 | 0 | if (!isNull) { |
2120 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->prefixLength_id, temp.ptr())) { |
2121 | 0 | return false; |
2122 | 0 | } |
2123 | 0 | } |
2124 | 0 | if (!isNull && !temp->isUndefined()) { |
2125 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mPrefixLength)) { |
2126 | 0 | return false; |
2127 | 0 | } |
2128 | 0 | } else { |
2129 | 0 | mPrefixLength = 0; |
2130 | 0 | } |
2131 | 0 | mIsAnyMemberPresent = true; |
2132 | 0 |
|
2133 | 0 | if (!isNull) { |
2134 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->reason_id, temp.ptr())) { |
2135 | 0 | return false; |
2136 | 0 | } |
2137 | 0 | } |
2138 | 0 | if (!isNull && !temp->isUndefined()) { |
2139 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mReason)) { |
2140 | 0 | return false; |
2141 | 0 | } |
2142 | 0 | } else { |
2143 | 0 | static const char16_t data[] = { 0 }; |
2144 | 0 | mReason.Rebind(data, ArrayLength(data) - 1); |
2145 | 0 | } |
2146 | 0 | mIsAnyMemberPresent = true; |
2147 | 0 |
|
2148 | 0 | if (!isNull) { |
2149 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->reply_id, temp.ptr())) { |
2150 | 0 | return false; |
2151 | 0 | } |
2152 | 0 | } |
2153 | 0 | if (!isNull && !temp->isUndefined()) { |
2154 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mReply)) { |
2155 | 0 | return false; |
2156 | 0 | } |
2157 | 0 | } else { |
2158 | 0 | static const char16_t data[] = { 0 }; |
2159 | 0 | mReply.Rebind(data, ArrayLength(data) - 1); |
2160 | 0 | } |
2161 | 0 | mIsAnyMemberPresent = true; |
2162 | 0 |
|
2163 | 0 | if (!isNull) { |
2164 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->result_id, temp.ptr())) { |
2165 | 0 | return false; |
2166 | 0 | } |
2167 | 0 | } |
2168 | 0 | if (!isNull && !temp->isUndefined()) { |
2169 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mResult)) { |
2170 | 0 | return false; |
2171 | 0 | } |
2172 | 0 | } else { |
2173 | 0 | mResult = false; |
2174 | 0 | } |
2175 | 0 | mIsAnyMemberPresent = true; |
2176 | 0 |
|
2177 | 0 | if (!isNull) { |
2178 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->resultCode_id, temp.ptr())) { |
2179 | 0 | return false; |
2180 | 0 | } |
2181 | 0 | } |
2182 | 0 | if (!isNull && !temp->isUndefined()) { |
2183 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mResultCode)) { |
2184 | 0 | return false; |
2185 | 0 | } |
2186 | 0 | } else { |
2187 | 0 | mResultCode = 0; |
2188 | 0 | } |
2189 | 0 | mIsAnyMemberPresent = true; |
2190 | 0 |
|
2191 | 0 | if (!isNull) { |
2192 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->resultReason_id, temp.ptr())) { |
2193 | 0 | return false; |
2194 | 0 | } |
2195 | 0 | } |
2196 | 0 | if (!isNull && !temp->isUndefined()) { |
2197 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mResultReason)) { |
2198 | 0 | return false; |
2199 | 0 | } |
2200 | 0 | } else { |
2201 | 0 | static const char16_t data[] = { 0 }; |
2202 | 0 | mResultReason.Rebind(data, ArrayLength(data) - 1); |
2203 | 0 | } |
2204 | 0 | mIsAnyMemberPresent = true; |
2205 | 0 |
|
2206 | 0 | if (!isNull) { |
2207 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->ret_id, temp.ptr())) { |
2208 | 0 | return false; |
2209 | 0 | } |
2210 | 0 | } |
2211 | 0 | if (!isNull && !temp->isUndefined()) { |
2212 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mRet)) { |
2213 | 0 | return false; |
2214 | 0 | } |
2215 | 0 | } else { |
2216 | 0 | mRet = false; |
2217 | 0 | } |
2218 | 0 | mIsAnyMemberPresent = true; |
2219 | 0 |
|
2220 | 0 | if (!isNull) { |
2221 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->route_id, temp.ptr())) { |
2222 | 0 | return false; |
2223 | 0 | } |
2224 | 0 | } |
2225 | 0 | if (!isNull && !temp->isUndefined()) { |
2226 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mRoute)) { |
2227 | 0 | return false; |
2228 | 0 | } |
2229 | 0 | } else { |
2230 | 0 | static const char16_t data[] = { 0 }; |
2231 | 0 | mRoute.Rebind(data, ArrayLength(data) - 1); |
2232 | 0 | } |
2233 | 0 | mIsAnyMemberPresent = true; |
2234 | 0 |
|
2235 | 0 | if (!isNull) { |
2236 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->server_id, temp.ptr())) { |
2237 | 0 | return false; |
2238 | 0 | } |
2239 | 0 | } |
2240 | 0 | if (!isNull && !temp->isUndefined()) { |
2241 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mServer)) { |
2242 | 0 | return false; |
2243 | 0 | } |
2244 | 0 | } else { |
2245 | 0 | mServer = 0; |
2246 | 0 | } |
2247 | 0 | mIsAnyMemberPresent = true; |
2248 | 0 |
|
2249 | 0 | if (!isNull) { |
2250 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->server_str_id, temp.ptr())) { |
2251 | 0 | return false; |
2252 | 0 | } |
2253 | 0 | } |
2254 | 0 | if (!isNull && !temp->isUndefined()) { |
2255 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mServer_str)) { |
2256 | 0 | return false; |
2257 | 0 | } |
2258 | 0 | } else { |
2259 | 0 | static const char16_t data[] = { 0 }; |
2260 | 0 | mServer_str.Rebind(data, ArrayLength(data) - 1); |
2261 | 0 | } |
2262 | 0 | mIsAnyMemberPresent = true; |
2263 | 0 |
|
2264 | 0 | if (!isNull) { |
2265 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->success_id, temp.ptr())) { |
2266 | 0 | return false; |
2267 | 0 | } |
2268 | 0 | } |
2269 | 0 | if (!isNull && !temp->isUndefined()) { |
2270 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mSuccess)) { |
2271 | 0 | return false; |
2272 | 0 | } |
2273 | 0 | } else { |
2274 | 0 | mSuccess = false; |
2275 | 0 | } |
2276 | 0 | mIsAnyMemberPresent = true; |
2277 | 0 |
|
2278 | 0 | if (!isNull) { |
2279 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->topic_id, temp.ptr())) { |
2280 | 0 | return false; |
2281 | 0 | } |
2282 | 0 | } |
2283 | 0 | if (!isNull && !temp->isUndefined()) { |
2284 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTopic)) { |
2285 | 0 | return false; |
2286 | 0 | } |
2287 | 0 | } else { |
2288 | 0 | static const char16_t data[] = { 0 }; |
2289 | 0 | mTopic.Rebind(data, ArrayLength(data) - 1); |
2290 | 0 | } |
2291 | 0 | mIsAnyMemberPresent = true; |
2292 | 0 |
|
2293 | 0 | if (!isNull) { |
2294 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->vendor_str_id, temp.ptr())) { |
2295 | 0 | return false; |
2296 | 0 | } |
2297 | 0 | } |
2298 | 0 | if (!isNull && !temp->isUndefined()) { |
2299 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVendor_str)) { |
2300 | 0 | return false; |
2301 | 0 | } |
2302 | 0 | } else { |
2303 | 0 | static const char16_t data[] = { 0 }; |
2304 | 0 | mVendor_str.Rebind(data, ArrayLength(data) - 1); |
2305 | 0 | } |
2306 | 0 | mIsAnyMemberPresent = true; |
2307 | 0 | return true; |
2308 | 0 | } |
2309 | | |
2310 | | bool |
2311 | | NetworkResultOptions::Init(const nsAString& aJSON) |
2312 | 0 | { |
2313 | 0 | AutoJSAPI jsapi; |
2314 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
2315 | 0 | if (!cleanGlobal) { |
2316 | 0 | return false; |
2317 | 0 | } |
2318 | 0 | if (!jsapi.Init(cleanGlobal)) { |
2319 | 0 | return false; |
2320 | 0 | } |
2321 | 0 | JSContext* cx = jsapi.cx(); |
2322 | 0 | JS::Rooted<JS::Value> json(cx); |
2323 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
2324 | 0 | NS_ENSURE_TRUE(ok, false); |
2325 | 0 | return Init(cx, json); |
2326 | 0 | } |
2327 | | |
2328 | | bool |
2329 | | NetworkResultOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
2330 | 0 | { |
2331 | 0 | NetworkResultOptionsAtoms* atomsCache = GetAtomCache<NetworkResultOptionsAtoms>(cx); |
2332 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
2333 | 0 | return false; |
2334 | 0 | } |
2335 | 0 | |
2336 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
2337 | 0 | if (!obj) { |
2338 | 0 | return false; |
2339 | 0 | } |
2340 | 0 | rval.set(JS::ObjectValue(*obj)); |
2341 | 0 |
|
2342 | 0 | do { |
2343 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2344 | 0 | JS::Rooted<JS::Value> temp(cx); |
2345 | 0 | bool const & currentValue = mBroadcast; |
2346 | 0 | temp.setBoolean(currentValue); |
2347 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->broadcast_id, temp, JSPROP_ENUMERATE)) { |
2348 | 0 | return false; |
2349 | 0 | } |
2350 | 0 | break; |
2351 | 0 | } while(false); |
2352 | 0 |
|
2353 | 0 | do { |
2354 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2355 | 0 | JS::Rooted<JS::Value> temp(cx); |
2356 | 0 | nsString const & currentValue = mCurExternalIfname; |
2357 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2358 | 0 | return false; |
2359 | 0 | } |
2360 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->curExternalIfname_id, temp, JSPROP_ENUMERATE)) { |
2361 | 0 | return false; |
2362 | 0 | } |
2363 | 0 | break; |
2364 | 0 | } while(false); |
2365 | 0 |
|
2366 | 0 | do { |
2367 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2368 | 0 | JS::Rooted<JS::Value> temp(cx); |
2369 | 0 | nsString const & currentValue = mCurInternalIfname; |
2370 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2371 | 0 | return false; |
2372 | 0 | } |
2373 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->curInternalIfname_id, temp, JSPROP_ENUMERATE)) { |
2374 | 0 | return false; |
2375 | 0 | } |
2376 | 0 | break; |
2377 | 0 | } while(false); |
2378 | 0 |
|
2379 | 0 | do { |
2380 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2381 | 0 | JS::Rooted<JS::Value> temp(cx); |
2382 | 0 | int32_t const & currentValue = mDns1; |
2383 | 0 | temp.setInt32(int32_t(currentValue)); |
2384 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns1_id, temp, JSPROP_ENUMERATE)) { |
2385 | 0 | return false; |
2386 | 0 | } |
2387 | 0 | break; |
2388 | 0 | } while(false); |
2389 | 0 |
|
2390 | 0 | do { |
2391 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2392 | 0 | JS::Rooted<JS::Value> temp(cx); |
2393 | 0 | nsString const & currentValue = mDns1_str; |
2394 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2395 | 0 | return false; |
2396 | 0 | } |
2397 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns1_str_id, temp, JSPROP_ENUMERATE)) { |
2398 | 0 | return false; |
2399 | 0 | } |
2400 | 0 | break; |
2401 | 0 | } while(false); |
2402 | 0 |
|
2403 | 0 | do { |
2404 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2405 | 0 | JS::Rooted<JS::Value> temp(cx); |
2406 | 0 | int32_t const & currentValue = mDns2; |
2407 | 0 | temp.setInt32(int32_t(currentValue)); |
2408 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns2_id, temp, JSPROP_ENUMERATE)) { |
2409 | 0 | return false; |
2410 | 0 | } |
2411 | 0 | break; |
2412 | 0 | } while(false); |
2413 | 0 |
|
2414 | 0 | do { |
2415 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2416 | 0 | JS::Rooted<JS::Value> temp(cx); |
2417 | 0 | nsString const & currentValue = mDns2_str; |
2418 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2419 | 0 | return false; |
2420 | 0 | } |
2421 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->dns2_str_id, temp, JSPROP_ENUMERATE)) { |
2422 | 0 | return false; |
2423 | 0 | } |
2424 | 0 | break; |
2425 | 0 | } while(false); |
2426 | 0 |
|
2427 | 0 | do { |
2428 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2429 | 0 | JS::Rooted<JS::Value> temp(cx); |
2430 | 0 | bool const & currentValue = mEnable; |
2431 | 0 | temp.setBoolean(currentValue); |
2432 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->enable_id, temp, JSPROP_ENUMERATE)) { |
2433 | 0 | return false; |
2434 | 0 | } |
2435 | 0 | break; |
2436 | 0 | } while(false); |
2437 | 0 |
|
2438 | 0 | do { |
2439 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2440 | 0 | JS::Rooted<JS::Value> temp(cx); |
2441 | 0 | bool const & currentValue = mError; |
2442 | 0 | temp.setBoolean(currentValue); |
2443 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->error_id, temp, JSPROP_ENUMERATE)) { |
2444 | 0 | return false; |
2445 | 0 | } |
2446 | 0 | break; |
2447 | 0 | } while(false); |
2448 | 0 |
|
2449 | 0 | do { |
2450 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2451 | 0 | JS::Rooted<JS::Value> temp(cx); |
2452 | 0 | nsString const & currentValue = mFlag; |
2453 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2454 | 0 | return false; |
2455 | 0 | } |
2456 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->flag_id, temp, JSPROP_ENUMERATE)) { |
2457 | 0 | return false; |
2458 | 0 | } |
2459 | 0 | break; |
2460 | 0 | } while(false); |
2461 | 0 |
|
2462 | 0 | do { |
2463 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2464 | 0 | JS::Rooted<JS::Value> temp(cx); |
2465 | 0 | int32_t const & currentValue = mGateway; |
2466 | 0 | temp.setInt32(int32_t(currentValue)); |
2467 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gateway_id, temp, JSPROP_ENUMERATE)) { |
2468 | 0 | return false; |
2469 | 0 | } |
2470 | 0 | break; |
2471 | 0 | } while(false); |
2472 | 0 |
|
2473 | 0 | do { |
2474 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2475 | 0 | JS::Rooted<JS::Value> temp(cx); |
2476 | 0 | nsString const & currentValue = mGateway_str; |
2477 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2478 | 0 | return false; |
2479 | 0 | } |
2480 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->gateway_str_id, temp, JSPROP_ENUMERATE)) { |
2481 | 0 | return false; |
2482 | 0 | } |
2483 | 0 | break; |
2484 | 0 | } while(false); |
2485 | 0 |
|
2486 | 0 | do { |
2487 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2488 | 0 | JS::Rooted<JS::Value> temp(cx); |
2489 | 0 | int32_t const & currentValue = mId; |
2490 | 0 | temp.setInt32(int32_t(currentValue)); |
2491 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->id_id, temp, JSPROP_ENUMERATE)) { |
2492 | 0 | return false; |
2493 | 0 | } |
2494 | 0 | break; |
2495 | 0 | } while(false); |
2496 | 0 |
|
2497 | 0 | if (mInterfaceList.WasPassed()) { |
2498 | 0 | do { |
2499 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2500 | 0 | JS::Rooted<JS::Value> temp(cx); |
2501 | 0 | Sequence<nsString> const & currentValue = mInterfaceList.InternalValue(); |
2502 | 0 |
|
2503 | 0 | uint32_t length = currentValue.Length(); |
2504 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
2505 | 0 | if (!returnArray) { |
2506 | 0 | return false; |
2507 | 0 | } |
2508 | 0 | // Scope for 'tmp' |
2509 | 0 | { |
2510 | 0 | JS::Rooted<JS::Value> tmp(cx); |
2511 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
2512 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
2513 | 0 | // are different ways to succeed at wrapping the object. |
2514 | 0 | do { |
2515 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue[sequenceIdx0], &tmp)) { |
2516 | 0 | return false; |
2517 | 0 | } |
2518 | 0 | break; |
2519 | 0 | } while (false); |
2520 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
2521 | 0 | JSPROP_ENUMERATE)) { |
2522 | 0 | return false; |
2523 | 0 | } |
2524 | 0 | } |
2525 | 0 | } |
2526 | 0 | temp.setObject(*returnArray); |
2527 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->interfaceList_id, temp, JSPROP_ENUMERATE)) { |
2528 | 0 | return false; |
2529 | 0 | } |
2530 | 0 | break; |
2531 | 0 | } while(false); |
2532 | 0 | } |
2533 | 0 |
|
2534 | 0 | do { |
2535 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2536 | 0 | JS::Rooted<JS::Value> temp(cx); |
2537 | 0 | nsString const & currentValue = mIpAddr; |
2538 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2539 | 0 | return false; |
2540 | 0 | } |
2541 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ipAddr_id, temp, JSPROP_ENUMERATE)) { |
2542 | 0 | return false; |
2543 | 0 | } |
2544 | 0 | break; |
2545 | 0 | } while(false); |
2546 | 0 |
|
2547 | 0 | do { |
2548 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2549 | 0 | JS::Rooted<JS::Value> temp(cx); |
2550 | 0 | int32_t const & currentValue = mIpaddr; |
2551 | 0 | temp.setInt32(int32_t(currentValue)); |
2552 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ipaddr_id, temp, JSPROP_ENUMERATE)) { |
2553 | 0 | return false; |
2554 | 0 | } |
2555 | 0 | break; |
2556 | 0 | } while(false); |
2557 | 0 |
|
2558 | 0 | do { |
2559 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2560 | 0 | JS::Rooted<JS::Value> temp(cx); |
2561 | 0 | nsString const & currentValue = mIpaddr_str; |
2562 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2563 | 0 | return false; |
2564 | 0 | } |
2565 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ipaddr_str_id, temp, JSPROP_ENUMERATE)) { |
2566 | 0 | return false; |
2567 | 0 | } |
2568 | 0 | break; |
2569 | 0 | } while(false); |
2570 | 0 |
|
2571 | 0 | do { |
2572 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2573 | 0 | JS::Rooted<JS::Value> temp(cx); |
2574 | 0 | int32_t const & currentValue = mLease; |
2575 | 0 | temp.setInt32(int32_t(currentValue)); |
2576 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->lease_id, temp, JSPROP_ENUMERATE)) { |
2577 | 0 | return false; |
2578 | 0 | } |
2579 | 0 | break; |
2580 | 0 | } while(false); |
2581 | 0 |
|
2582 | 0 | do { |
2583 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2584 | 0 | JS::Rooted<JS::Value> temp(cx); |
2585 | 0 | nsString const & currentValue = mMacAddr; |
2586 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2587 | 0 | return false; |
2588 | 0 | } |
2589 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->macAddr_id, temp, JSPROP_ENUMERATE)) { |
2590 | 0 | return false; |
2591 | 0 | } |
2592 | 0 | break; |
2593 | 0 | } while(false); |
2594 | 0 |
|
2595 | 0 | do { |
2596 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2597 | 0 | JS::Rooted<JS::Value> temp(cx); |
2598 | 0 | int32_t const & currentValue = mMask; |
2599 | 0 | temp.setInt32(int32_t(currentValue)); |
2600 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mask_id, temp, JSPROP_ENUMERATE)) { |
2601 | 0 | return false; |
2602 | 0 | } |
2603 | 0 | break; |
2604 | 0 | } while(false); |
2605 | 0 |
|
2606 | 0 | do { |
2607 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2608 | 0 | JS::Rooted<JS::Value> temp(cx); |
2609 | 0 | nsString const & currentValue = mMask_str; |
2610 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2611 | 0 | return false; |
2612 | 0 | } |
2613 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mask_str_id, temp, JSPROP_ENUMERATE)) { |
2614 | 0 | return false; |
2615 | 0 | } |
2616 | 0 | break; |
2617 | 0 | } while(false); |
2618 | 0 |
|
2619 | 0 | do { |
2620 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2621 | 0 | JS::Rooted<JS::Value> temp(cx); |
2622 | 0 | nsString const & currentValue = mNetId; |
2623 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2624 | 0 | return false; |
2625 | 0 | } |
2626 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->netId_id, temp, JSPROP_ENUMERATE)) { |
2627 | 0 | return false; |
2628 | 0 | } |
2629 | 0 | break; |
2630 | 0 | } while(false); |
2631 | 0 |
|
2632 | 0 | do { |
2633 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2634 | 0 | JS::Rooted<JS::Value> temp(cx); |
2635 | 0 | int32_t const & currentValue = mPrefixLength; |
2636 | 0 | temp.setInt32(int32_t(currentValue)); |
2637 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->prefixLength_id, temp, JSPROP_ENUMERATE)) { |
2638 | 0 | return false; |
2639 | 0 | } |
2640 | 0 | break; |
2641 | 0 | } while(false); |
2642 | 0 |
|
2643 | 0 | do { |
2644 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2645 | 0 | JS::Rooted<JS::Value> temp(cx); |
2646 | 0 | nsString const & currentValue = mReason; |
2647 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2648 | 0 | return false; |
2649 | 0 | } |
2650 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->reason_id, temp, JSPROP_ENUMERATE)) { |
2651 | 0 | return false; |
2652 | 0 | } |
2653 | 0 | break; |
2654 | 0 | } while(false); |
2655 | 0 |
|
2656 | 0 | do { |
2657 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2658 | 0 | JS::Rooted<JS::Value> temp(cx); |
2659 | 0 | nsString const & currentValue = mReply; |
2660 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2661 | 0 | return false; |
2662 | 0 | } |
2663 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->reply_id, temp, JSPROP_ENUMERATE)) { |
2664 | 0 | return false; |
2665 | 0 | } |
2666 | 0 | break; |
2667 | 0 | } while(false); |
2668 | 0 |
|
2669 | 0 | do { |
2670 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2671 | 0 | JS::Rooted<JS::Value> temp(cx); |
2672 | 0 | bool const & currentValue = mResult; |
2673 | 0 | temp.setBoolean(currentValue); |
2674 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->result_id, temp, JSPROP_ENUMERATE)) { |
2675 | 0 | return false; |
2676 | 0 | } |
2677 | 0 | break; |
2678 | 0 | } while(false); |
2679 | 0 |
|
2680 | 0 | do { |
2681 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2682 | 0 | JS::Rooted<JS::Value> temp(cx); |
2683 | 0 | int32_t const & currentValue = mResultCode; |
2684 | 0 | temp.setInt32(int32_t(currentValue)); |
2685 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->resultCode_id, temp, JSPROP_ENUMERATE)) { |
2686 | 0 | return false; |
2687 | 0 | } |
2688 | 0 | break; |
2689 | 0 | } while(false); |
2690 | 0 |
|
2691 | 0 | do { |
2692 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2693 | 0 | JS::Rooted<JS::Value> temp(cx); |
2694 | 0 | nsString const & currentValue = mResultReason; |
2695 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2696 | 0 | return false; |
2697 | 0 | } |
2698 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->resultReason_id, temp, JSPROP_ENUMERATE)) { |
2699 | 0 | return false; |
2700 | 0 | } |
2701 | 0 | break; |
2702 | 0 | } while(false); |
2703 | 0 |
|
2704 | 0 | do { |
2705 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2706 | 0 | JS::Rooted<JS::Value> temp(cx); |
2707 | 0 | bool const & currentValue = mRet; |
2708 | 0 | temp.setBoolean(currentValue); |
2709 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->ret_id, temp, JSPROP_ENUMERATE)) { |
2710 | 0 | return false; |
2711 | 0 | } |
2712 | 0 | break; |
2713 | 0 | } while(false); |
2714 | 0 |
|
2715 | 0 | do { |
2716 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2717 | 0 | JS::Rooted<JS::Value> temp(cx); |
2718 | 0 | nsString const & currentValue = mRoute; |
2719 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2720 | 0 | return false; |
2721 | 0 | } |
2722 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->route_id, temp, JSPROP_ENUMERATE)) { |
2723 | 0 | return false; |
2724 | 0 | } |
2725 | 0 | break; |
2726 | 0 | } while(false); |
2727 | 0 |
|
2728 | 0 | do { |
2729 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2730 | 0 | JS::Rooted<JS::Value> temp(cx); |
2731 | 0 | int32_t const & currentValue = mServer; |
2732 | 0 | temp.setInt32(int32_t(currentValue)); |
2733 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->server_id, temp, JSPROP_ENUMERATE)) { |
2734 | 0 | return false; |
2735 | 0 | } |
2736 | 0 | break; |
2737 | 0 | } while(false); |
2738 | 0 |
|
2739 | 0 | do { |
2740 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2741 | 0 | JS::Rooted<JS::Value> temp(cx); |
2742 | 0 | nsString const & currentValue = mServer_str; |
2743 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2744 | 0 | return false; |
2745 | 0 | } |
2746 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->server_str_id, temp, JSPROP_ENUMERATE)) { |
2747 | 0 | return false; |
2748 | 0 | } |
2749 | 0 | break; |
2750 | 0 | } while(false); |
2751 | 0 |
|
2752 | 0 | do { |
2753 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2754 | 0 | JS::Rooted<JS::Value> temp(cx); |
2755 | 0 | bool const & currentValue = mSuccess; |
2756 | 0 | temp.setBoolean(currentValue); |
2757 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->success_id, temp, JSPROP_ENUMERATE)) { |
2758 | 0 | return false; |
2759 | 0 | } |
2760 | 0 | break; |
2761 | 0 | } while(false); |
2762 | 0 |
|
2763 | 0 | do { |
2764 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2765 | 0 | JS::Rooted<JS::Value> temp(cx); |
2766 | 0 | nsString const & currentValue = mTopic; |
2767 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2768 | 0 | return false; |
2769 | 0 | } |
2770 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->topic_id, temp, JSPROP_ENUMERATE)) { |
2771 | 0 | return false; |
2772 | 0 | } |
2773 | 0 | break; |
2774 | 0 | } while(false); |
2775 | 0 |
|
2776 | 0 | do { |
2777 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
2778 | 0 | JS::Rooted<JS::Value> temp(cx); |
2779 | 0 | nsString const & currentValue = mVendor_str; |
2780 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
2781 | 0 | return false; |
2782 | 0 | } |
2783 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->vendor_str_id, temp, JSPROP_ENUMERATE)) { |
2784 | 0 | return false; |
2785 | 0 | } |
2786 | 0 | break; |
2787 | 0 | } while(false); |
2788 | 0 |
|
2789 | 0 | return true; |
2790 | 0 | } |
2791 | | |
2792 | | bool |
2793 | | NetworkResultOptions::ToJSON(nsAString& aJSON) const |
2794 | 0 | { |
2795 | 0 | AutoJSAPI jsapi; |
2796 | 0 | jsapi.Init(); |
2797 | 0 | JSContext *cx = jsapi.cx(); |
2798 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
2799 | 0 | // because we'll only be creating objects, in ways that have no |
2800 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
2801 | 0 | // which likewise guarantees no side-effects for the sorts of |
2802 | 0 | // things we will pass it. |
2803 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
2804 | 0 | JS::Rooted<JS::Value> val(cx); |
2805 | 0 | if (!ToObjectInternal(cx, &val)) { |
2806 | 0 | return false; |
2807 | 0 | } |
2808 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
2809 | 0 | return StringifyToJSON(cx, obj, aJSON); |
2810 | 0 | } |
2811 | | |
2812 | | void |
2813 | | NetworkResultOptions::TraceDictionary(JSTracer* trc) |
2814 | 0 | { |
2815 | 0 | } |
2816 | | |
2817 | | NetworkResultOptions& |
2818 | | NetworkResultOptions::operator=(const NetworkResultOptions& aOther) |
2819 | 0 | { |
2820 | 0 | DictionaryBase::operator=(aOther); |
2821 | 0 | mBroadcast = aOther.mBroadcast; |
2822 | 0 | mCurExternalIfname = aOther.mCurExternalIfname; |
2823 | 0 | mCurInternalIfname = aOther.mCurInternalIfname; |
2824 | 0 | mDns1 = aOther.mDns1; |
2825 | 0 | mDns1_str = aOther.mDns1_str; |
2826 | 0 | mDns2 = aOther.mDns2; |
2827 | 0 | mDns2_str = aOther.mDns2_str; |
2828 | 0 | mEnable = aOther.mEnable; |
2829 | 0 | mError = aOther.mError; |
2830 | 0 | mFlag = aOther.mFlag; |
2831 | 0 | mGateway = aOther.mGateway; |
2832 | 0 | mGateway_str = aOther.mGateway_str; |
2833 | 0 | mId = aOther.mId; |
2834 | 0 | mInterfaceList.Reset(); |
2835 | 0 | if (aOther.mInterfaceList.WasPassed()) { |
2836 | 0 | mInterfaceList.Construct(aOther.mInterfaceList.Value()); |
2837 | 0 | } |
2838 | 0 | mIpAddr = aOther.mIpAddr; |
2839 | 0 | mIpaddr = aOther.mIpaddr; |
2840 | 0 | mIpaddr_str = aOther.mIpaddr_str; |
2841 | 0 | mLease = aOther.mLease; |
2842 | 0 | mMacAddr = aOther.mMacAddr; |
2843 | 0 | mMask = aOther.mMask; |
2844 | 0 | mMask_str = aOther.mMask_str; |
2845 | 0 | mNetId = aOther.mNetId; |
2846 | 0 | mPrefixLength = aOther.mPrefixLength; |
2847 | 0 | mReason = aOther.mReason; |
2848 | 0 | mReply = aOther.mReply; |
2849 | 0 | mResult = aOther.mResult; |
2850 | 0 | mResultCode = aOther.mResultCode; |
2851 | 0 | mResultReason = aOther.mResultReason; |
2852 | 0 | mRet = aOther.mRet; |
2853 | 0 | mRoute = aOther.mRoute; |
2854 | 0 | mServer = aOther.mServer; |
2855 | 0 | mServer_str = aOther.mServer_str; |
2856 | 0 | mSuccess = aOther.mSuccess; |
2857 | 0 | mTopic = aOther.mTopic; |
2858 | 0 | mVendor_str = aOther.mVendor_str; |
2859 | 0 | return *this; |
2860 | 0 | } |
2861 | | |
2862 | | namespace binding_detail { |
2863 | | } // namespace binding_detail |
2864 | | |
2865 | | |
2866 | | } // namespace dom |
2867 | | } // namespace mozilla |