mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Backed out changeset f18666cc5793 (bug 1530028) for build bustages on a CLOSED TREE.
This commit is contained in:
parent
f4b66e3031
commit
fbe889dd73
@ -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};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use error::KeyValueError;
|
||||
use libc::int32_t;
|
||||
use nserror::NsresultExt;
|
||||
use nsstring::nsString;
|
||||
use rkv::OwnedValue;
|
||||
use storage_variant::{
|
||||
|
@ -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};
|
||||
|
@ -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
|
||||
}
|
||||
"""
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -8,6 +8,7 @@ use {
|
||||
GetterAddrefs
|
||||
};
|
||||
use interfaces::nsISupports;
|
||||
use nserror::NsresultExt;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
use nserror::NsresultExt;
|
||||
use {
|
||||
RefPtr,
|
||||
GetterAddrefs,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user