зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1567739 - Stop using deprecated rust libc integer types in storage_variant and kvstore. r=lina
Differential Revision: https://phabricator.services.mozilla.com/D38940 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
baf04d4ceb
Коммит
103c1bec20
|
@ -9,7 +9,7 @@ extern crate xpcom;
|
||||||
|
|
||||||
mod bag;
|
mod bag;
|
||||||
|
|
||||||
use libc::{c_double, int64_t, uint16_t};
|
use libc::c_double;
|
||||||
use nserror::{nsresult, NS_OK};
|
use nserror::{nsresult, NS_OK};
|
||||||
use nsstring::{nsACString, nsAString, nsCString, nsString};
|
use nsstring::{nsACString, nsAString, nsCString, nsString};
|
||||||
use xpcom::{getter_addrefs, interfaces::nsIVariant, RefPtr};
|
use xpcom::{getter_addrefs, interfaces::nsIVariant, RefPtr};
|
||||||
|
@ -17,10 +17,10 @@ use xpcom::{getter_addrefs, interfaces::nsIVariant, RefPtr};
|
||||||
pub use crate::bag::HashPropertyBag;
|
pub use crate::bag::HashPropertyBag;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn NS_GetDataType(variant: *const nsIVariant) -> uint16_t;
|
fn NS_GetDataType(variant: *const nsIVariant) -> u16;
|
||||||
fn NS_NewStorageNullVariant(result: *mut *const nsIVariant);
|
fn NS_NewStorageNullVariant(result: *mut *const nsIVariant);
|
||||||
fn NS_NewStorageBooleanVariant(value: bool, result: *mut *const nsIVariant);
|
fn NS_NewStorageBooleanVariant(value: bool, result: *mut *const nsIVariant);
|
||||||
fn NS_NewStorageIntegerVariant(value: int64_t, result: *mut *const nsIVariant);
|
fn NS_NewStorageIntegerVariant(value: i64, result: *mut *const nsIVariant);
|
||||||
fn NS_NewStorageFloatVariant(value: c_double, result: *mut *const nsIVariant);
|
fn NS_NewStorageFloatVariant(value: c_double, result: *mut *const nsIVariant);
|
||||||
fn NS_NewStorageTextVariant(value: *const nsAString, result: *mut *const nsIVariant);
|
fn NS_NewStorageTextVariant(value: *const nsAString, result: *mut *const nsIVariant);
|
||||||
fn NS_NewStorageUTF8TextVariant(value: *const nsACString, result: *mut *const nsIVariant);
|
fn NS_NewStorageUTF8TextVariant(value: *const nsACString, result: *mut *const nsIVariant);
|
||||||
|
@ -52,19 +52,19 @@ pub enum DataType {
|
||||||
// and since that enum is unlikely to change frequently, this workaround
|
// and since that enum is unlikely to change frequently, this workaround
|
||||||
// seems sufficient.)
|
// seems sufficient.)
|
||||||
//
|
//
|
||||||
pub const DATA_TYPE_INT32: uint16_t = DataType::INT32 as u16;
|
pub const DATA_TYPE_INT32: u16 = DataType::INT32 as u16;
|
||||||
pub const DATA_TYPE_DOUBLE: uint16_t = DataType::DOUBLE as u16;
|
pub const DATA_TYPE_DOUBLE: u16 = DataType::DOUBLE as u16;
|
||||||
pub const DATA_TYPE_BOOL: uint16_t = DataType::BOOL as u16;
|
pub const DATA_TYPE_BOOL: u16 = DataType::BOOL as u16;
|
||||||
pub const DATA_TYPE_VOID: uint16_t = DataType::VOID as u16;
|
pub const DATA_TYPE_VOID: u16 = DataType::VOID as u16;
|
||||||
pub const DATA_TYPE_WSTRING: uint16_t = DataType::WSTRING as u16;
|
pub const DATA_TYPE_WSTRING: u16 = DataType::WSTRING as u16;
|
||||||
pub const DATA_TYPE_EMPTY: uint16_t = DataType::EMPTY as u16;
|
pub const DATA_TYPE_EMPTY: u16 = DataType::EMPTY as u16;
|
||||||
|
|
||||||
pub trait GetDataType {
|
pub trait GetDataType {
|
||||||
fn get_data_type(&self) -> uint16_t;
|
fn get_data_type(&self) -> u16;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetDataType for nsIVariant {
|
impl GetDataType for nsIVariant {
|
||||||
fn get_data_type(&self) -> uint16_t {
|
fn get_data_type(&self) -> u16 {
|
||||||
unsafe { NS_GetDataType(self) }
|
unsafe { NS_GetDataType(self) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use libc::uint16_t;
|
|
||||||
use nserror::{
|
use nserror::{
|
||||||
nsresult, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
|
nsresult, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
|
||||||
NS_ERROR_NULL_POINTER, NS_ERROR_UNEXPECTED,
|
NS_ERROR_NULL_POINTER, NS_ERROR_UNEXPECTED,
|
||||||
|
@ -53,7 +52,7 @@ pub enum KeyValueError {
|
||||||
UnexpectedValue,
|
UnexpectedValue,
|
||||||
|
|
||||||
#[fail(display = "unsupported variant type: {}", _0)]
|
#[fail(display = "unsupported variant type: {}", _0)]
|
||||||
UnsupportedVariant(uint16_t),
|
UnsupportedVariant(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<nsresult> for KeyValueError {
|
impl From<nsresult> for KeyValueError {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use error::KeyValueError;
|
use error::KeyValueError;
|
||||||
use libc::int32_t;
|
|
||||||
use nsstring::nsString;
|
use nsstring::nsString;
|
||||||
use rkv::OwnedValue;
|
use rkv::OwnedValue;
|
||||||
use storage_variant::{
|
use storage_variant::{
|
||||||
|
@ -35,7 +34,7 @@ pub fn variant_to_owned(variant: &nsIVariant) -> Result<Option<OwnedValue>, KeyV
|
||||||
|
|
||||||
match data_type {
|
match data_type {
|
||||||
DATA_TYPE_INT32 => {
|
DATA_TYPE_INT32 => {
|
||||||
let mut val: int32_t = 0;
|
let mut val: i32 = 0;
|
||||||
unsafe { variant.GetAsInt32(&mut val) }.to_result()?;
|
unsafe { variant.GetAsInt32(&mut val) }.to_result()?;
|
||||||
Ok(Some(OwnedValue::I64(val.into())))
|
Ok(Some(OwnedValue::I64(val.into())))
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче