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
//
// DO NOT EDIT.  THIS FILE IS GENERATED FROM ../../../dist/idl/mozILocaleService.idl
//


/// `interface mozILocaleService : nsISupports`
///


// 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 mozILocaleService {
    vtable: *const mozILocaleServiceVTable,

    /// 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 mozILocaleService.
unsafe impl XpCom for mozILocaleService {
    const IID: nsIID = nsID(0xc27f8983, 0xb48b, 0x4d1a,
        [0x92, 0xd7, 0xfe, 0xb8, 0x10, 0x6f, 0x21, 0x2d]);
}

// 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 mozILocaleService {
    #[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 mozILocaleService.
// 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 mozILocaleServiceCoerce {
    /// Cheaply cast a value of this type from a `mozILocaleService`.
    fn coerce_from(v: &mozILocaleService) -> &Self;
}

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

impl mozILocaleService {
    /// Cast this `mozILocaleService` to one of its base interfaces.
    #[inline]
    pub fn coerce<T: mozILocaleServiceCoerce>(&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 mozILocaleService {
    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> mozILocaleServiceCoerce for T {
    #[inline]
    fn coerce_from(v: &mozILocaleService) -> &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 mozILocaleService
// 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 mozILocaleServiceVTable {
    /// We need to include the members from the base interface's vtable at the start
    /// of the VTable definition.
    pub __base: nsISupportsVTable,

    /* readonly attribute ACString defaultLocale; */
    pub GetDefaultLocale: unsafe extern "system" fn (this: *const mozILocaleService, aDefaultLocale: &mut ::nsstring::nsACString) -> nsresult,

    /* readonly attribute ACString lastFallbackLocale; */
    pub GetLastFallbackLocale: unsafe extern "system" fn (this: *const mozILocaleService, aLastFallbackLocale: &mut ::nsstring::nsACString) -> nsresult,

    /* void getAppLocalesAsLangTags ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales); */
    pub GetAppLocalesAsLangTags: unsafe extern "system" fn (this: *const mozILocaleService, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult,

    /* void getAppLocalesAsBCP47 ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales); */
    pub GetAppLocalesAsBCP47: unsafe extern "system" fn (this: *const mozILocaleService, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult,

    /* void getRegionalPrefsLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aOutArray); */
    pub GetRegionalPrefsLocales: unsafe extern "system" fn (this: *const mozILocaleService, aCount: *mut libc::uint32_t, aOutArray: *mut *mut *const libc::c_char) -> nsresult,

    /* void negotiateLanguages ([array, size_is (aRequestedCount)] in string aRequested, [array, size_is (aAvailableCount)] in string aAvailable, [optional] in string aDefaultLocale, [optional] in long langNegStrategy, [optional] in unsigned long aRequestedCount, [optional] in unsigned long aAvailableCount, [optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales); */
    pub NegotiateLanguages: unsafe extern "system" fn (this: *const mozILocaleService, aRequested: *mut *const libc::c_char, aAvailable: *mut *const libc::c_char, aDefaultLocale: *const libc::c_char, langNegStrategy: libc::int32_t, aRequestedCount: libc::uint32_t, aAvailableCount: libc::uint32_t, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult,

    /* ACString getAppLocaleAsLangTag (); */
    pub GetAppLocaleAsLangTag: unsafe extern "system" fn (this: *const mozILocaleService, _retval: &mut ::nsstring::nsACString) -> nsresult,

    /* ACString getAppLocaleAsBCP47 (); */
    pub GetAppLocaleAsBCP47: unsafe extern "system" fn (this: *const mozILocaleService, _retval: &mut ::nsstring::nsACString) -> nsresult,

    /* void getRequestedLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales); */
    pub GetRequestedLocales: unsafe extern "system" fn (this: *const mozILocaleService, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult,

    /* ACString getRequestedLocale (); */
    pub GetRequestedLocale: unsafe extern "system" fn (this: *const mozILocaleService, _retval: &mut ::nsstring::nsACString) -> nsresult,

    /* void setRequestedLocales ([array, size_is (aRequestedCount)] in string aRequested, [optional] in unsigned long aRequestedCount); */
    pub SetRequestedLocales: unsafe extern "system" fn (this: *const mozILocaleService, aRequested: *mut *const libc::c_char, aRequestedCount: libc::uint32_t) -> nsresult,

    /* void getAvailableLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales); */
    pub GetAvailableLocales: unsafe extern "system" fn (this: *const mozILocaleService, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult,

    /* readonly attribute boolean isAppLocaleRTL; */
    pub GetIsAppLocaleRTL: unsafe extern "system" fn (this: *const mozILocaleService, aIsAppLocaleRTL: *mut bool) -> 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 mozILocaleService {
    /// ```text
    /// /**
    ///    * List of language negotiation strategies to use.
    ///    * For an example list of requested and available locales:
    ///    *
    ///    *   Requested: ['es-MX', 'fr-FR']
    ///    *   Available: ['fr', 'fr-CA', 'es', 'es-MX', 'it']
    ///    *   DefaultLocale: ['en-US']
    ///    *
    ///    * each of those strategies will build a different result:
    ///    *
    ///    *
    ///    * filtering (default) -
    ///    *   Matches as many of the available locales as possible.
    ///    *
    ///    *   Result:
    ///    *     Supported: ['es-MX', 'es', 'fr', 'fr-CA', 'en-US']
    ///    *
    ///    * matching -
    ///    *   Matches the best match from the available locales for every requested
    ///    *   locale.
    ///    *
    ///    *   Result:
    ///    *     Supported: ['es-MX', 'fr', 'en-US']
    ///    *
    ///    * lookup -
    ///    *   Matches a single best locale. This strategy always returns a list
    ///    *   of the length 1 and requires a defaultLocale to be set.
    ///    *
    ///    *   Result:
    ///    *     Supported: ['es-MX']
    ///    */
    /// ```
    ///

    pub const langNegStrategyFiltering: i64 = 0;


    pub const langNegStrategyMatching: i64 = 1;


    pub const langNegStrategyLookup: i64 = 2;

    /// ```text
    /// /**
    ///    * Default locale of the browser. The locale we are guaranteed to have
    ///    * resources for that should be used as a last resort fallack in cases
    ///    * where requested locales do not match available locales.
    ///    */
    /// ```
    ///

    /// `readonly attribute ACString defaultLocale;`
    #[inline]
    pub unsafe fn GetDefaultLocale(&self, aDefaultLocale: &mut ::nsstring::nsACString) -> nsresult {
        ((*self.vtable).GetDefaultLocale)(self, aDefaultLocale)
    }


    /// ```text
    /// /**
    ///    * Last fallback is the final fallback locale we're going to attempt if all
    ///    * else fails in any language negotiation or locale resource retrieval situations.
    ///    *
    ///    * At the moment it returns `en-US`.
    ///    */
    /// ```
    ///

    /// `readonly attribute ACString lastFallbackLocale;`
    #[inline]
    pub unsafe fn GetLastFallbackLocale(&self, aLastFallbackLocale: &mut ::nsstring::nsACString) -> nsresult {
        ((*self.vtable).GetLastFallbackLocale)(self, aLastFallbackLocale)
    }


    /// ```text
    /// /**
    ///    * Returns a list of locales that the application should be localized to.
    ///    *
    ///    * The result is a ordered list of valid locale IDs and it should be
    ///    * used for all APIs that accept list of locales, like ECMA402 and L10n APIs.
    ///    *
    ///    * This API always returns at least one locale.
    ///    *
    ///    * When retrieving the locales for language negotiation and matching
    ///    * to language resources, use the language tag form.
    ///    * When retrieving the locales for Intl API or ICU locale settings,
    ///    * use the BCP47 form.
    ///    *
    ///    * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
    ///    *
    ///    * (See LocaleService.h for a more C++-friendly version of this.)
    ///    */
    /// ```
    ///

    /// `void getAppLocalesAsLangTags ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales);`
    #[inline]
    pub unsafe fn GetAppLocalesAsLangTags(&self, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).GetAppLocalesAsLangTags)(self, aCount, aLocales)
    }



    /// `void getAppLocalesAsBCP47 ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales);`
    #[inline]
    pub unsafe fn GetAppLocalesAsBCP47(&self, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).GetAppLocalesAsBCP47)(self, aCount, aLocales)
    }


    /// ```text
    /// /**
    ///    * Returns a list of locales to use for any regional specific operations
    ///    * like date formatting, calendars, unit formatting etc.
    ///    *
    ///    * The result is a ordered list of valid locale IDs and it should be
    ///    * used for all APIs that accept list of locales, like ECMA402 and L10n APIs.
    ///    *
    ///    * This API always returns at least one locale.
    ///    *
    ///    * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
    ///    *
    ///    * (See LocaleService.h for a more C++-friendly version of this.)
    ///    */
    /// ```
    ///

    /// `void getRegionalPrefsLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aOutArray);`
    #[inline]
    pub unsafe fn GetRegionalPrefsLocales(&self, aCount: *mut libc::uint32_t, aOutArray: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).GetRegionalPrefsLocales)(self, aCount, aOutArray)
    }


    /// ```text
    /// /**
    ///    * Negotiates the best locales out of a ordered list of requested locales and
    ///    * a list of available locales.
    ///    *
    ///    * Internally it uses the following naming scheme:
    ///    *
    ///    *  Requested - locales requested by the user
    ///    *  Available - locales for which the data is available
    ///    *  Supported - locales negotiated by the algorithm
    ///    *
    ///    * Additionally, if defaultLocale is provided, it adds it to the end of the
    ///    * result list as a "last resort" locale.
    ///    *
    ///    * Strategy is one of the three strategies described at the top of this file.
    ///    *
    ///    * The result list is ordered according to the order of the requested locales.
    ///    *
    ///    * (See LocaleService.h for a more C++-friendly version of this.)
    ///    */
    /// ```
    ///

    /// `void negotiateLanguages ([array, size_is (aRequestedCount)] in string aRequested, [array, size_is (aAvailableCount)] in string aAvailable, [optional] in string aDefaultLocale, [optional] in long langNegStrategy, [optional] in unsigned long aRequestedCount, [optional] in unsigned long aAvailableCount, [optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales);`
    #[inline]
    pub unsafe fn NegotiateLanguages(&self, aRequested: *mut *const libc::c_char, aAvailable: *mut *const libc::c_char, aDefaultLocale: *const libc::c_char, langNegStrategy: libc::int32_t, aRequestedCount: libc::uint32_t, aAvailableCount: libc::uint32_t, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).NegotiateLanguages)(self, aRequested, aAvailable, aDefaultLocale, langNegStrategy, aRequestedCount, aAvailableCount, aCount, aLocales)
    }


    /// ```text
    /// /**
    ///    * Returns the best locale that the application should be localized to.
    ///    *
    ///    * The result is a valid locale ID and it should be
    ///    * used for all APIs that do not handle language negotiation.
    ///    *
    ///    * When retrieving the locales for language negotiation and matching
    ///    * to language resources, use the language tag form.
    ///    * When retrieving the locales for Intl API or ICU locale settings,
    ///    * use the BCP47 form.
    ///    *
    ///    * Where possible, getAppLocales*() should be preferred over this API and
    ///    * all callsites should handle some form of "best effort" language
    ///    * negotiation to respect user preferences in case the use case does
    ///    * not have data for the first locale in the list.
    ///    *
    ///    * Example: "zh-Hans-HK"
    ///    */
    /// ```
    ///

    /// `ACString getAppLocaleAsLangTag ();`
    #[inline]
    pub unsafe fn GetAppLocaleAsLangTag(&self, _retval: &mut ::nsstring::nsACString) -> nsresult {
        ((*self.vtable).GetAppLocaleAsLangTag)(self, _retval)
    }



    /// `ACString getAppLocaleAsBCP47 ();`
    #[inline]
    pub unsafe fn GetAppLocaleAsBCP47(&self, _retval: &mut ::nsstring::nsACString) -> nsresult {
        ((*self.vtable).GetAppLocaleAsBCP47)(self, _retval)
    }


    /// ```text
    /// /**
    ///    * Returns a list of locales that the user requested the app to be
    ///    * localized to.
    ///    *
    ///    * The result is an ordered list of locale IDs which should be
    ///    * used as a requestedLocales input list for language negotiation.
    ///    *
    ///    * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
    ///    */
    /// ```
    ///

    /// `void getRequestedLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales);`
    #[inline]
    pub unsafe fn GetRequestedLocales(&self, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).GetRequestedLocales)(self, aCount, aLocales)
    }


    /// ```text
    /// /**
    ///    * Returns the top-requested locale from the user, or an empty string if none is set.
    ///    */
    /// ```
    ///

    /// `ACString getRequestedLocale ();`
    #[inline]
    pub unsafe fn GetRequestedLocale(&self, _retval: &mut ::nsstring::nsACString) -> nsresult {
        ((*self.vtable).GetRequestedLocale)(self, _retval)
    }


    /// ```text
    /// /**
    ///    * Sets a list of locales that the user requested the app to be
    ///    * localized to.
    ///    *
    ///    * The argument is an ordered list of locale IDs which should be
    ///    * used as a requestedLocales input list for language negotiation.
    ///    *
    ///    * The current implementation is limited to handle at most one
    ///    * locale passed to the API. In the future we'll transition to support
    ///    * whole fallback chain.
    ///    *
    ///    * If an empty list is passed, the list of requested locales will
    ///    * be picked from the operating system.
    ///    *
    ///    * Example: ["de"]
    ///    */
    /// ```
    ///

    /// `void setRequestedLocales ([array, size_is (aRequestedCount)] in string aRequested, [optional] in unsigned long aRequestedCount);`
    #[inline]
    pub unsafe fn SetRequestedLocales(&self, aRequested: *mut *const libc::c_char, aRequestedCount: libc::uint32_t) -> nsresult {
        ((*self.vtable).SetRequestedLocales)(self, aRequested, aRequestedCount)
    }


    /// ```text
    /// /**
    ///    * Returns a list of locales that the app can be localized to.
    ///    *
    ///    * The result is an unordered list of locale IDs which should be
    ///    * used as a availableLocales input list for language negotiation.
    ///    *
    ///    * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
    ///    */
    /// ```
    ///

    /// `void getAvailableLocales ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aLocales);`
    #[inline]
    pub unsafe fn GetAvailableLocales(&self, aCount: *mut libc::uint32_t, aLocales: *mut *mut *const libc::c_char) -> nsresult {
        ((*self.vtable).GetAvailableLocales)(self, aCount, aLocales)
    }


    /// ```text
    /// /**
    ///    * Returns whether the current app locale is RTL.
    ///    */
    /// ```
    ///

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


}