1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
//
// DO NOT EDIT.  THIS FILE IS GENERATED FROM ../../../dist/idl/nsICrashReporter.idl
//


/// `interface nsICrashReporter : nsISupports`
///

/// ```text
/// /**
///  * Provides access to crash reporting functionality.
///  *
///  * @status UNSTABLE - This interface is not frozen and will probably change in
///  *                    future releases.
///  */
/// ```
///

// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.

#[repr(C)]
pub struct nsICrashReporter {
    vtable: *const nsICrashReporterVTable,

    /// This field is a phantomdata to ensure that the VTable type and any
    /// struct containing it is not safe to send across threads, as XPCOM is
    /// generally not threadsafe.
    ///
    /// XPCOM interfaces in general are not safe to send across threads.
    __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
}

// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsICrashReporter.
unsafe impl XpCom for nsICrashReporter {
    const IID: nsIID = nsID(0x4b74c39a, 0xcf69, 0x4a8a,
        [0x8e, 0x63, 0x16, 0x9d, 0x81, 0xad, 0x1e, 0xcf]);
}

// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsICrashReporter {
    #[inline]
    unsafe fn addref(&self) {
        self.AddRef();
    }
    #[inline]
    unsafe fn release(&self) {
        self.Release();
    }
}

// This trait is implemented on all types which can be coerced to from nsICrashReporter.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsICrashReporterCoerce {
    /// Cheaply cast a value of this type from a `nsICrashReporter`.
    fn coerce_from(v: &nsICrashReporter) -> &Self;
}

// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsICrashReporterCoerce for nsICrashReporter {
    #[inline]
    fn coerce_from(v: &nsICrashReporter) -> &Self {
        v
    }
}

impl nsICrashReporter {
    /// Cast this `nsICrashReporter` to one of its base interfaces.
    #[inline]
    pub fn coerce<T: nsICrashReporterCoerce>(&self) -> &T {
        T::coerce_from(self)
    }
}

// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsICrashReporter {
    type Target = nsISupports;
    #[inline]
    fn deref(&self) -> &nsISupports {
        unsafe {
            ::std::mem::transmute(self)
        }
    }
}

// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsICrashReporterCoerce for T {
    #[inline]
    fn coerce_from(v: &nsICrashReporter) -> &Self {
        T::coerce_from(v)
    }
}

// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsICrashReporter
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsICrashReporterVTable {
    /// We need to include the members from the base interface's vtable at the start
    /// of the VTable definition.
    pub __base: nsISupportsVTable,

    /* readonly attribute boolean enabled; */
    pub GetEnabled: unsafe extern "system" fn (this: *const nsICrashReporter, aEnabled: *mut bool) -> nsresult,

    /* [noscript] void setEnabled (in bool enabled); */
    pub SetEnabled: unsafe extern "system" fn (this: *const nsICrashReporter, enabled: bool) -> nsresult,

    /* attribute nsIURL serverURL; */
    pub GetServerURL: unsafe extern "system" fn (this: *const nsICrashReporter, aServerURL: *mut *const nsIURL) -> nsresult,

    /* attribute nsIURL serverURL; */
    pub SetServerURL: unsafe extern "system" fn (this: *const nsICrashReporter, aServerURL: *const nsIURL) -> nsresult,

    /* attribute nsIFile minidumpPath; */
    pub GetMinidumpPath: unsafe extern "system" fn (this: *const nsICrashReporter, aMinidumpPath: *mut *const nsIFile) -> nsresult,

    /* attribute nsIFile minidumpPath; */
    pub SetMinidumpPath: unsafe extern "system" fn (this: *const nsICrashReporter, aMinidumpPath: *const nsIFile) -> nsresult,

    /* nsIFile getMinidumpForID (in AString id); */
    pub GetMinidumpForID: unsafe extern "system" fn (this: *const nsICrashReporter, id: &::nsstring::nsAString, _retval: *mut *const nsIFile) -> nsresult,

    /* nsIFile getExtraFileForID (in AString id); */
    pub GetExtraFileForID: unsafe extern "system" fn (this: *const nsICrashReporter, id: &::nsstring::nsAString, _retval: *mut *const nsIFile) -> nsresult,

    /* void annotateCrashReport (in AUTF8String key, in AUTF8String data); */
    pub AnnotateCrashReport: unsafe extern "system" fn (this: *const nsICrashReporter, key: &::nsstring::nsACString, data: &::nsstring::nsACString) -> nsresult,

    /* void appendAppNotesToCrashReport (in ACString data); */
    pub AppendAppNotesToCrashReport: unsafe extern "system" fn (this: *const nsICrashReporter, data: &::nsstring::nsACString) -> nsresult,

    /* void registerAppMemory (in unsigned long long ptr, in unsigned long long size); */
    pub RegisterAppMemory: unsafe extern "system" fn (this: *const nsICrashReporter, ptr: libc::uint64_t, size: libc::uint64_t) -> nsresult,

    /* [noscript] void writeMinidumpForException (in voidPtr aExceptionInfo); */
    pub WriteMinidumpForException: unsafe extern "system" fn (this: *const nsICrashReporter, aExceptionInfo: *mut libc::c_void) -> nsresult,

    /* [noscript] void appendObjCExceptionInfoToAppNotes (in voidPtr aException); */
    pub AppendObjCExceptionInfoToAppNotes: unsafe extern "system" fn (this: *const nsICrashReporter, aException: *mut libc::c_void) -> nsresult,

    /* attribute boolean submitReports; */
    pub GetSubmitReports: unsafe extern "system" fn (this: *const nsICrashReporter, aSubmitReports: *mut bool) -> nsresult,

    /* attribute boolean submitReports; */
    pub SetSubmitReports: unsafe extern "system" fn (this: *const nsICrashReporter, aSubmitReports: bool) -> nsresult,

    /* void UpdateCrashEventsDir (); */
    pub UpdateCrashEventsDir: unsafe extern "system" fn (this: *const nsICrashReporter) -> nsresult,

    /* void saveMemoryReport (); */
    pub SaveMemoryReport: unsafe extern "system" fn (this: *const nsICrashReporter) -> nsresult,

    /* void setTelemetrySessionId (in AUTF8String id); */
    pub SetTelemetrySessionId: unsafe extern "system" fn (this: *const nsICrashReporter, id: &::nsstring::nsACString) -> nsresult,
}


// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsICrashReporter {

    /// ```text
    /// /**
    ///    * Get the enabled status of the crash reporter.
    ///    */
    /// ```
    ///

    /// `readonly attribute boolean enabled;`
    #[inline]
    pub unsafe fn GetEnabled(&self, aEnabled: *mut bool) -> nsresult {
        ((*self.vtable).GetEnabled)(self, aEnabled)
    }


    /// ```text
    /// /**
    ///    * Enable or disable crash reporting at runtime. Not available to script
    ///    * because the JS engine relies on proper exception handler chaining.
    ///    */
    /// ```
    ///

    /// `[noscript] void setEnabled (in bool enabled);`
    #[inline]
    pub unsafe fn SetEnabled(&self, enabled: bool) -> nsresult {
        ((*self.vtable).SetEnabled)(self, enabled)
    }


    /// ```text
    /// /**
    ///    * Get or set the URL to which crash reports will be submitted.
    ///    * Only https and http URLs are allowed, as the submission is handled
    ///    * by OS-native networking libraries.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting is not initialized
    ///    * @throw NS_ERROR_INVALID_ARG on set if a non-http(s) URL is assigned
    ///    * @throw NS_ERROR_FAILURE on get if no URL is set
    ///    */
    /// ```
    ///

    /// `attribute nsIURL serverURL;`
    #[inline]
    pub unsafe fn GetServerURL(&self, aServerURL: *mut *const nsIURL) -> nsresult {
        ((*self.vtable).GetServerURL)(self, aServerURL)
    }


    /// ```text
    /// /**
    ///    * Get or set the URL to which crash reports will be submitted.
    ///    * Only https and http URLs are allowed, as the submission is handled
    ///    * by OS-native networking libraries.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting is not initialized
    ///    * @throw NS_ERROR_INVALID_ARG on set if a non-http(s) URL is assigned
    ///    * @throw NS_ERROR_FAILURE on get if no URL is set
    ///    */
    /// ```
    ///

    /// `attribute nsIURL serverURL;`
    #[inline]
    pub unsafe fn SetServerURL(&self, aServerURL: *const nsIURL) -> nsresult {
        ((*self.vtable).SetServerURL)(self, aServerURL)
    }


    /// ```text
    /// /**
    ///    * Get or set the path on the local system to which minidumps will be
    ///    * written when a crash happens.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting is not initialized
    ///    */
    /// ```
    ///

    /// `attribute nsIFile minidumpPath;`
    #[inline]
    pub unsafe fn GetMinidumpPath(&self, aMinidumpPath: *mut *const nsIFile) -> nsresult {
        ((*self.vtable).GetMinidumpPath)(self, aMinidumpPath)
    }


    /// ```text
    /// /**
    ///    * Get or set the path on the local system to which minidumps will be
    ///    * written when a crash happens.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting is not initialized
    ///    */
    /// ```
    ///

    /// `attribute nsIFile minidumpPath;`
    #[inline]
    pub unsafe fn SetMinidumpPath(&self, aMinidumpPath: *const nsIFile) -> nsresult {
        ((*self.vtable).SetMinidumpPath)(self, aMinidumpPath)
    }


    /// ```text
    /// /**
    ///    * Get the minidump file corresponding to the specified ID.
    ///    *
    ///    * @param id
    ///    *        ID of the crash. Likely a UUID.
    ///    *
    ///    * @return The minidump file associated with the ID.
    ///    *
    ///    * @throw NS_ERROR_FILE_NOT_FOUND if the minidump could not be found
    ///    */
    /// ```
    ///

    /// `nsIFile getMinidumpForID (in AString id);`
    #[inline]
    pub unsafe fn GetMinidumpForID(&self, id: &::nsstring::nsAString, _retval: *mut *const nsIFile) -> nsresult {
        ((*self.vtable).GetMinidumpForID)(self, id, _retval)
    }


    /// ```text
    /// /**
    ///    * Get the extra file corresponding to the specified ID.
    ///    *
    ///    * @param id
    ///    *        ID of the crash. Likely a UUID.
    ///    *
    ///    * @return The extra file associated with the ID.
    ///    *
    ///    * @throw NS_ERROR_FILE_NOT_FOUND if the extra file could not be found
    ///    */
    /// ```
    ///

    /// `nsIFile getExtraFileForID (in AString id);`
    #[inline]
    pub unsafe fn GetExtraFileForID(&self, id: &::nsstring::nsAString, _retval: *mut *const nsIFile) -> nsresult {
        ((*self.vtable).GetExtraFileForID)(self, id, _retval)
    }


    /// ```text
    /// /**
    ///    * Add some extra data to be submitted with a crash report.
    ///    *
    ///    * @param key
    ///    *        Name of the data to be added.
    ///    * @param data
    ///    *        Data to be added.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting not initialized
    ///    * @throw NS_ERROR_INVALID_ARG if key or data contain invalid characters.
    ///    *                             Invalid characters for key are '=' and
    ///    *                             '\n'.  Invalid character for data is '\0'.
    ///    */
    /// ```
    ///

    /// `void annotateCrashReport (in AUTF8String key, in AUTF8String data);`
    #[inline]
    pub unsafe fn AnnotateCrashReport(&self, key: &::nsstring::nsACString, data: &::nsstring::nsACString) -> nsresult {
        ((*self.vtable).AnnotateCrashReport)(self, key, data)
    }


    /// ```text
    /// /**
    ///    * Append some data to the "Notes" field, to be submitted with a crash report.
    ///    * Unlike annotateCrashReport, this method will append to existing data.
    ///    *
    ///    * @param data
    ///    *        Data to be added.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting not initialized
    ///    * @throw NS_ERROR_INVALID_ARG if data contains invalid characters.
    ///    *                             The only invalid character is '\0'.
    ///    */
    /// ```
    ///

    /// `void appendAppNotesToCrashReport (in ACString data);`
    #[inline]
    pub unsafe fn AppendAppNotesToCrashReport(&self, data: &::nsstring::nsACString) -> nsresult {
        ((*self.vtable).AppendAppNotesToCrashReport)(self, data)
    }


    /// ```text
    /// /**
    ///    * Register a given memory range to be included in the crash report.
    ///    *
    ///    * @param ptr
    ///    *        The starting address for the bytes.
    ///    * @param size
    ///    *        The number of bytes to include.
    ///    *
    ///    * @throw NS_ERROR_NOT_INITIALIZED if crash reporting not initialized
    ///    * @throw NS_ERROR_NOT_IMPLEMENTED if unavailable on the current OS
    ///    */
    /// ```
    ///

    /// `void registerAppMemory (in unsigned long long ptr, in unsigned long long size);`
    #[inline]
    pub unsafe fn RegisterAppMemory(&self, ptr: libc::uint64_t, size: libc::uint64_t) -> nsresult {
        ((*self.vtable).RegisterAppMemory)(self, ptr, size)
    }


    /// ```text
    /// /**
    ///    * Write a minidump immediately, with the user-supplied exception
    ///    * information. This is implemented on Windows only, because
    ///    * SEH (structured exception handling) exists on Windows only.
    ///    *
    ///    * @param aExceptionInfo  EXCEPTION_INFO* provided by Window's SEH
    ///    */
    /// ```
    ///

    /// `[noscript] void writeMinidumpForException (in voidPtr aExceptionInfo);`
    #[inline]
    pub unsafe fn WriteMinidumpForException(&self, aExceptionInfo: *mut libc::c_void) -> nsresult {
        ((*self.vtable).WriteMinidumpForException)(self, aExceptionInfo)
    }


    /// ```text
    /// /**
    ///    * Append note containing an Obj-C exception's info.
    ///    *
    ///    * @param aException  NSException object to append note for
    ///    */
    /// ```
    ///

    /// `[noscript] void appendObjCExceptionInfoToAppNotes (in voidPtr aException);`
    #[inline]
    pub unsafe fn AppendObjCExceptionInfoToAppNotes(&self, aException: *mut libc::c_void) -> nsresult {
        ((*self.vtable).AppendObjCExceptionInfoToAppNotes)(self, aException)
    }


    /// ```text
    /// /**
    ///    * User preference for submitting crash reports.
    ///    */
    /// ```
    ///

    /// `attribute boolean submitReports;`
    #[inline]
    pub unsafe fn GetSubmitReports(&self, aSubmitReports: *mut bool) -> nsresult {
        ((*self.vtable).GetSubmitReports)(self, aSubmitReports)
    }


    /// ```text
    /// /**
    ///    * User preference for submitting crash reports.
    ///    */
    /// ```
    ///

    /// `attribute boolean submitReports;`
    #[inline]
    pub unsafe fn SetSubmitReports(&self, aSubmitReports: bool) -> nsresult {
        ((*self.vtable).SetSubmitReports)(self, aSubmitReports)
    }


    /// ```text
    /// /**
    ///    * Cause the crash reporter to re-evaluate where crash events should go.
    ///    *
    ///    * This should be called during application startup and whenever profiles
    ///    * change.
    ///    */
    /// ```
    ///

    /// `void UpdateCrashEventsDir ();`
    #[inline]
    pub unsafe fn UpdateCrashEventsDir(&self, ) -> nsresult {
        ((*self.vtable).UpdateCrashEventsDir)(self, )
    }


    /// ```text
    /// /**
    ///    * Save an anonymized memory report file for inclusion in a future crash
    ///    * report in this session.
    ///    *
    ///    * @throws NS_ERROR_NOT_INITIALIZED if crash reporting is disabled.
    ///    */
    /// ```
    ///

    /// `void saveMemoryReport ();`
    #[inline]
    pub unsafe fn SaveMemoryReport(&self, ) -> nsresult {
        ((*self.vtable).SaveMemoryReport)(self, )
    }


    /// ```text
    /// /**
    ///    * Set the telemetry session ID which is recorded in crash metadata. This is
    ///    * saved in the crash manager and telemetry but is not submitted as a
    ///    * crash-stats annotation.
    ///    */
    /// ```
    ///

    /// `void setTelemetrySessionId (in AUTF8String id);`
    #[inline]
    pub unsafe fn SetTelemetrySessionId(&self, id: &::nsstring::nsACString) -> nsresult {
        ((*self.vtable).SetTelemetrySessionId)(self, id)
    }


}