Backed out changeset f18666cc5793 (bug 1530028) for build bustages on a CLOSED TREE.

This commit is contained in:
Gurzau Raul 2019-02-25 16:55:00 +02:00
parent f4b66e3031
commit fbe889dd73
13 changed files with 31 additions and 17 deletions

View File

@ -8,7 +8,7 @@ extern crate nsstring;
extern crate xpcom;
use libc::{c_double, int64_t, uint16_t};
use nserror::{nsresult, NS_OK};
use nserror::{nsresult, NsresultExt, NS_OK};
use nsstring::{nsACString, nsAString, nsCString, nsString};
use xpcom::{getter_addrefs, interfaces::nsIVariant, RefPtr};

View File

@ -4,7 +4,7 @@
use libc::uint16_t;
use nserror::{
nsresult, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
nsresult, NsresultExt, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
NS_ERROR_NULL_POINTER, NS_ERROR_UNEXPECTED,
};
use nsstring::nsCString;

View File

@ -4,6 +4,7 @@
use error::KeyValueError;
use libc::int32_t;
use nserror::NsresultExt;
use nsstring::nsString;
use rkv::OwnedValue;
use storage_variant::{

View File

@ -7,7 +7,7 @@ extern crate xpcom;
use crossbeam_utils::atomic::AtomicCell;
use error::KeyValueError;
use moz_task::Task;
use nserror::{nsresult, NS_ERROR_FAILURE};
use nserror::{nsresult, NsresultExt, NS_ERROR_FAILURE};
use nsstring::nsCString;
use owned_value::owned_to_variant;
use rkv::{Manager, OwnedValue, Rkv, SingleStore, StoreError, StoreOptions, Value};

View File

@ -242,7 +242,7 @@ infallible_impl_tmpl = """\
pub unsafe fn %(name)s(&self) -> %(realtype)s {
let mut result = <%(realtype)s as ::std::default::Default>::default();
let _rv = ((*self.vtable).%(name)s)(self, &mut result);
debug_assert!(_rv.suceeded());
debug_assert!(::nserror::NsresultExt::succeeded(_rv));
result
}
"""

View File

@ -13,7 +13,7 @@ use std::os::raw::c_char;
use std::ptr;
use std::ffi::{CStr, CString};
use xpcom::interfaces;
use nserror::{nsresult, NS_OK};
use nserror::{NsresultExt, nsresult, NS_OK};
#[no_mangle]
pub unsafe extern fn Rust_ObserveFromRust() -> *const interfaces::nsIObserverService {

View File

@ -12,7 +12,7 @@ extern crate nsstring;
#[macro_use]
extern crate xpcom;
use nserror::{nsresult, NS_OK};
use nserror::{nsresult, NsresultExt, NS_OK};
use nsstring::{nsACString, nsCString};
use std::{
ptr,

View File

@ -7,19 +7,30 @@ use nsstring::{nsCString, nsACString};
/// as the C++ equivalent.
#[repr(transparent)]
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy, Debug)]
pub struct nsresult(pub u32);
impl nsresult {
pub fn failed(self) -> bool {
/// An extension trait that adds methods to `nsresult` types.
pub trait NsresultExt {
fn failed(self) -> bool;
fn succeeded(self) -> bool;
fn to_result(self) -> Result<(), nsresult>;
/// Get a printable name for the nsresult error code. This function returns
/// a nsCString<'static>, which implements `Display`.
fn error_name(self) -> nsCString;
}
impl NsresultExt for nsresult {
fn failed(self) -> bool {
(self.0 >> 31) != 0
}
pub fn succeeded(self) -> bool {
fn succeeded(self) -> bool {
!self.failed()
}
pub fn to_result(self) -> Result<(), nsresult> {
fn to_result(self) -> Result<(), nsresult> {
if self.failed() {
Err(self)
} else {
@ -27,9 +38,7 @@ impl nsresult {
}
}
/// Get a printable name for the nsresult error code. This function returns
/// a nsCString<'static>, which implements `Display`.
pub fn error_name(self) -> nsCString {
fn error_name(self) -> nsCString {
let mut cstr = nsCString::new();
unsafe {
Gecko_GetErrorName(self, &mut *cstr);

View File

@ -8,6 +8,7 @@ use {
GetterAddrefs
};
use interfaces::nsISupports;
use nserror::NsresultExt;
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)]

View File

@ -13,6 +13,6 @@ pub extern crate libc;
pub use nsstring::{nsACString, nsAString, nsCString, nsString};
pub use nserror::{nsresult, NS_ERROR_NO_INTERFACE, NS_OK};
pub use nserror::{nsresult, NsresultExt, NS_ERROR_NO_INTERFACE, NS_OK};
pub use std::ops::Deref;

View File

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use std::cell::Cell;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use nserror::{nsresult, NS_OK};
use nserror::{NsresultExt, nsresult, NS_OK};
use libc;

View File

@ -4,6 +4,7 @@
use std::ffi::CStr;
use std::ptr;
use nserror::NsresultExt;
use {
RefPtr,
GetterAddrefs,

View File

@ -619,7 +619,9 @@ fn xpcom(init: DeriveInput) -> Result<Tokens, Box<Error>> {
{
let mut ga = ::xpcom::GetterAddrefs::<T>::new();
unsafe {
if self.QueryInterface(&T::IID, ga.void_ptr()).succeeded() {
if ::xpcom::reexports::NsresultExt::succeeded(
self.QueryInterface(&T::IID, ga.void_ptr()),
) {
ga.refptr()
} else {
None