зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1617369 - Reformat recent rust changes with rustfmt r=emilio
Done with: ./mach lint -l rustfmt --fix with rustfmt 1.4.12-stable (a828ffe 2020-03-11) # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D72527
This commit is contained in:
Родитель
4de4edd78c
Коммит
7f26dcf1b6
|
@ -34,11 +34,10 @@ use rayon;
|
|||
use swgl_bindings::SwCompositor;
|
||||
use tracy_rs::register_thread_with_profiler;
|
||||
use webrender::{
|
||||
api::units::*, api::*, set_profiler_hooks, AsyncPropertySampler, AsyncScreenshotHandle,
|
||||
Compositor, CompositorCapabilities, CompositorConfig, DebugFlags, Device, FastHashMap,
|
||||
NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PipelineInfo, ProfilerHooks, RecordedFrameHandle, Renderer,
|
||||
RendererOptions, RendererStats, SceneBuilderHooks, ShaderPrecacheFlags, Shaders, ThreadListener, UploadMethod,
|
||||
VertexUsageHint, WrShaders,
|
||||
api::units::*, api::*, set_profiler_hooks, AsyncPropertySampler, AsyncScreenshotHandle, Compositor,
|
||||
CompositorCapabilities, CompositorConfig, DebugFlags, Device, FastHashMap, NativeSurfaceId, NativeSurfaceInfo,
|
||||
NativeTileId, PipelineInfo, ProfilerHooks, RecordedFrameHandle, Renderer, RendererOptions, RendererStats,
|
||||
SceneBuilderHooks, ShaderPrecacheFlags, Shaders, ThreadListener, UploadMethod, VertexUsageHint, WrShaders,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
|
@ -1995,7 +1994,7 @@ pub extern "C" fn wr_resource_updates_add_raw_font(
|
|||
}
|
||||
|
||||
fn generate_capture_path(path: *const c_char) -> Option<PathBuf> {
|
||||
use std::fs::{File, create_dir_all};
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::io::Write;
|
||||
|
||||
let cstr = unsafe { CStr::from_ptr(path) };
|
||||
|
@ -2043,7 +2042,7 @@ fn generate_capture_path(path: *const c_char) -> Option<PathBuf> {
|
|||
}
|
||||
Err(e) => {
|
||||
warn!("Unable to create path '{:?}' for capture: {:?}", path, e);
|
||||
return None
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2482,10 +2481,7 @@ pub extern "C" fn wr_dp_define_image_mask_clip_with_parent_clip_chain(
|
|||
let clip_id = state
|
||||
.frame_builder
|
||||
.dl_builder
|
||||
.define_clip_image_mask(
|
||||
&parent.to_webrender(state.pipeline_id),
|
||||
mask,
|
||||
);
|
||||
.define_clip_image_mask(&parent.to_webrender(state.pipeline_id), mask);
|
||||
WrClipId::from_webrender(clip_id)
|
||||
}
|
||||
|
||||
|
|
|
@ -656,13 +656,7 @@ fn rasterize_blob(job: Job) -> (BlobImageRequest, BlobImageResult) {
|
|||
}
|
||||
|
||||
impl BlobImageHandler for Moz2dBlobImageHandler {
|
||||
fn add(
|
||||
&mut self,
|
||||
key: BlobImageKey,
|
||||
data: Arc<BlobImageData>,
|
||||
visible_rect: &DeviceIntRect,
|
||||
tile_size: TileSize,
|
||||
) {
|
||||
fn add(&mut self, key: BlobImageKey, data: Arc<BlobImageData>, visible_rect: &DeviceIntRect, tile_size: TileSize) {
|
||||
{
|
||||
let index = BlobReader::new(&data);
|
||||
assert!(index.reader.has_more());
|
||||
|
|
|
@ -84,7 +84,7 @@ impl From<GCThing> for SmooshGCThing {
|
|||
match item {
|
||||
GCThing::Function(_index) => {
|
||||
panic!("Not yet implemented");
|
||||
},
|
||||
}
|
||||
GCThing::Scope(index) => Self {
|
||||
kind: SmooshGCThingKind::ScopeIndex,
|
||||
index: index.into(),
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
extern crate jsrust_shared;
|
||||
extern crate wat;
|
||||
extern crate wasmparser;
|
||||
extern crate wat;
|
||||
|
||||
mod wasm;
|
||||
|
|
|
@ -33,7 +33,7 @@ use cranelift_wasm::{
|
|||
SignatureIndex, TableIndex, TargetEnvironment, WasmError, WasmResult,
|
||||
};
|
||||
|
||||
use crate::bindings::{self, SymbolicAddress, GlobalDesc};
|
||||
use crate::bindings::{self, GlobalDesc, SymbolicAddress};
|
||||
use crate::compile::{symbolic_function_name, wasm_function_name};
|
||||
use crate::isa::POINTER_SIZE;
|
||||
|
||||
|
|
|
@ -14,13 +14,10 @@ use audioipc::codec::LengthDelimitedCodec;
|
|||
use audioipc::frame::{framed, Framed};
|
||||
use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
|
||||
use audioipc::{core, rpc};
|
||||
use audioipc::{
|
||||
messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage,
|
||||
ServerMessage,
|
||||
};
|
||||
use audioipc::{messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage, ServerMessage};
|
||||
use cubeb_backend::{
|
||||
ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error, Ops, Result,
|
||||
Stream, StreamParams, StreamParamsRef,
|
||||
ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error, Ops, Result, Stream, StreamParams,
|
||||
StreamParamsRef,
|
||||
};
|
||||
use futures::Future;
|
||||
use futures_cpupool::{CpuFuture, CpuPool};
|
||||
|
@ -38,10 +35,8 @@ struct CubebClient;
|
|||
impl rpc::Client for CubebClient {
|
||||
type Request = ServerMessage;
|
||||
type Response = ClientMessage;
|
||||
type Transport = FramedWithPlatformHandles<
|
||||
audioipc::AsyncMessageStream,
|
||||
LengthDelimitedCodec<Self::Request, Self::Response>,
|
||||
>;
|
||||
type Transport =
|
||||
FramedWithPlatformHandles<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Request, Self::Response>>;
|
||||
}
|
||||
|
||||
pub const CLIENT_OPS: Ops = capi_new!(ClientContext, ClientStream);
|
||||
|
@ -141,16 +136,12 @@ impl rpc::Server for DeviceCollectionServer {
|
|||
type Request = DeviceCollectionReq;
|
||||
type Response = DeviceCollectionResp;
|
||||
type Future = CpuFuture<Self::Response, ()>;
|
||||
type Transport =
|
||||
Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
|
||||
type Transport = Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
|
||||
|
||||
fn process(&mut self, req: Self::Request) -> Self::Future {
|
||||
match req {
|
||||
DeviceCollectionReq::DeviceChange(device_type) => {
|
||||
trace!(
|
||||
"ctx_thread: DeviceChange Callback: device_type={}",
|
||||
device_type
|
||||
);
|
||||
trace!("ctx_thread: DeviceChange Callback: device_type={}", device_type);
|
||||
|
||||
let devtype = cubeb_backend::DeviceType::from_bits_truncate(device_type);
|
||||
|
||||
|
@ -166,14 +157,10 @@ impl rpc::Server for DeviceCollectionServer {
|
|||
self.cpu_pool.spawn_fn(move || {
|
||||
run_in_callback(|| {
|
||||
if devtype.contains(cubeb_backend::DeviceType::INPUT) {
|
||||
unsafe {
|
||||
input_cb.unwrap()(ptr::null_mut(), input_user_ptr as *mut c_void)
|
||||
}
|
||||
unsafe { input_cb.unwrap()(ptr::null_mut(), input_user_ptr as *mut c_void) }
|
||||
}
|
||||
if devtype.contains(cubeb_backend::DeviceType::OUTPUT) {
|
||||
unsafe {
|
||||
output_cb.unwrap()(ptr::null_mut(), output_user_ptr as *mut c_void)
|
||||
}
|
||||
unsafe { output_cb.unwrap()(ptr::null_mut(), output_user_ptr as *mut c_void) }
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -206,8 +193,7 @@ impl ContextOps for ClientContext {
|
|||
let thread_create_callback = params.thread_create_callback;
|
||||
let thread_destroy_callback = params.thread_destroy_callback;
|
||||
|
||||
let server_stream =
|
||||
unsafe { audioipc::MessageStream::from_raw_fd(params.server_connection) };
|
||||
let server_stream = unsafe { audioipc::MessageStream::from_raw_fd(params.server_connection) };
|
||||
|
||||
let core = core::spawn_thread(
|
||||
"AudioIPC Client RPC",
|
||||
|
@ -231,8 +217,8 @@ impl ContextOps for ClientContext {
|
|||
// will return errors the caller expects to handle.
|
||||
let _ = send_recv!(rpc, ClientConnect(std::process::id()) => ClientConnected);
|
||||
|
||||
let backend_id = send_recv!(rpc, ContextGetBackendId => ContextBackendId())
|
||||
.unwrap_or_else(|_| "(remote error)".to_string());
|
||||
let backend_id =
|
||||
send_recv!(rpc, ContextGetBackendId => ContextBackendId()).unwrap_or_else(|_| "(remote error)".to_string());
|
||||
let backend_id = CString::new(backend_id).expect("backend_id query failed");
|
||||
|
||||
let cpu_pool = futures_cpupool::Builder::new()
|
||||
|
@ -277,11 +263,7 @@ impl ContextOps for ClientContext {
|
|||
send_recv!(self.rpc(), ContextGetPreferredSampleRate => ContextPreferredSampleRate())
|
||||
}
|
||||
|
||||
fn enumerate_devices(
|
||||
&mut self,
|
||||
devtype: DeviceType,
|
||||
collection: &DeviceCollectionRef,
|
||||
) -> Result<()> {
|
||||
fn enumerate_devices(&mut self, devtype: DeviceType, collection: &DeviceCollectionRef) -> Result<()> {
|
||||
assert_not_in_callback();
|
||||
let v: Vec<ffi::cubeb_device_info> = match send_recv!(self.rpc(),
|
||||
ContextGetDeviceEnumeration(devtype.bits()) =>
|
||||
|
@ -304,11 +286,7 @@ impl ContextOps for ClientContext {
|
|||
assert_not_in_callback();
|
||||
unsafe {
|
||||
let coll = &mut *collection.as_ptr();
|
||||
let mut devices = Vec::from_raw_parts(
|
||||
coll.device as *mut ffi::cubeb_device_info,
|
||||
coll.count,
|
||||
coll.count,
|
||||
);
|
||||
let mut devices = Vec::from_raw_parts(coll.device as *mut ffi::cubeb_device_info, coll.count, coll.count);
|
||||
for dev in &mut devices {
|
||||
if !dev.device_id.is_null() {
|
||||
let _ = CString::from_raw(dev.device_id as *mut _);
|
||||
|
@ -383,8 +361,7 @@ impl ContextOps for ClientContext {
|
|||
ContextSetupDeviceCollectionCallback =>
|
||||
ContextSetupDeviceCollectionCallback())?;
|
||||
|
||||
let stream =
|
||||
unsafe { audioipc::MessageStream::from_raw_fd(fds.platform_handles[0].into_raw()) };
|
||||
let stream = unsafe { audioipc::MessageStream::from_raw_fd(fds.platform_handles[0].into_raw()) };
|
||||
|
||||
// TODO: The lowest comms layer expects exactly 3 PlatformHandles, but we only
|
||||
// need one here. Drop the dummy handles the other side sent us to discard.
|
||||
|
|
|
@ -62,8 +62,7 @@ impl rpc::Server for CallbackServer {
|
|||
type Request = CallbackReq;
|
||||
type Response = CallbackResp;
|
||||
type Future = CpuFuture<Self::Response, ()>;
|
||||
type Transport =
|
||||
Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
|
||||
type Transport = Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
|
||||
|
||||
fn process(&mut self, req: Self::Request) -> Self::Future {
|
||||
match req {
|
||||
|
@ -94,10 +93,7 @@ impl rpc::Server for CallbackServer {
|
|||
self.cpu_pool.spawn_fn(move || {
|
||||
// TODO: This is proof-of-concept. Make it better.
|
||||
let input_ptr: *const u8 = match input_shm {
|
||||
Some(shm) => shm
|
||||
.get_slice(nframes as usize * input_frame_size)
|
||||
.unwrap()
|
||||
.as_ptr(),
|
||||
Some(shm) => shm.get_slice(nframes as usize * input_frame_size).unwrap().as_ptr(),
|
||||
None => ptr::null(),
|
||||
};
|
||||
let output_ptr: *mut u8 = match output_shm {
|
||||
|
@ -173,13 +169,9 @@ impl<'ctx> ClientStream<'ctx> {
|
|||
let rpc = ctx.rpc();
|
||||
let data = send_recv!(rpc, StreamInit(init_params) => StreamCreated())?;
|
||||
|
||||
debug!(
|
||||
"token = {}, handles = {:?}",
|
||||
data.token, data.platform_handles
|
||||
);
|
||||
debug!("token = {}, handles = {:?}", data.token, data.platform_handles);
|
||||
|
||||
let stream =
|
||||
unsafe { audioipc::MessageStream::from_raw_fd(data.platform_handles[0].into_raw()) };
|
||||
let stream = unsafe { audioipc::MessageStream::from_raw_fd(data.platform_handles[0].into_raw()) };
|
||||
|
||||
let input_file = unsafe { data.platform_handles[1].into_file() };
|
||||
let input_shm = if has_input {
|
||||
|
|
|
@ -410,7 +410,10 @@ impl Device {
|
|||
}
|
||||
|
||||
pub fn forward_port(&self, local: u16, remote: u16) -> Result<u16> {
|
||||
let command = format!("host-serial:{}:forward:tcp:{};tcp:{}", self.serial, local, remote);
|
||||
let command = format!(
|
||||
"host-serial:{}:forward:tcp:{};tcp:{}",
|
||||
self.serial, local, remote
|
||||
);
|
||||
let response = self.host.execute_command(&command, true, false)?;
|
||||
|
||||
if local == 0 {
|
||||
|
@ -422,8 +425,7 @@ impl Device {
|
|||
|
||||
pub fn kill_forward_port(&self, local: u16) -> Result<()> {
|
||||
let command = format!("killforward:tcp:{}", local);
|
||||
self.execute_host_command(&command, true, false)
|
||||
.and(Ok(()))
|
||||
self.execute_host_command(&command, true, false).and(Ok(()))
|
||||
}
|
||||
|
||||
pub fn kill_forward_all_ports(&self) -> Result<()> {
|
||||
|
|
|
@ -178,10 +178,14 @@ where
|
|||
|
||||
let builder = thread::Builder::new().name("webdriver server".to_string());
|
||||
let handle = builder.spawn(move || {
|
||||
let mut rt = tokio::runtime::Builder::new().basic_scheduler().enable_io().build().unwrap();
|
||||
let mut listener = rt.handle().enter(|| {
|
||||
TcpListener::from_std(listener).unwrap()
|
||||
});
|
||||
let mut rt = tokio::runtime::Builder::new()
|
||||
.basic_scheduler()
|
||||
.enable_io()
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut listener = rt
|
||||
.handle()
|
||||
.enter(|| TcpListener::from_std(listener).unwrap());
|
||||
let wroutes = build_warp_routes(&extension_routes, msg_send.clone());
|
||||
let fut = warp::serve(wroutes).run_incoming(listener.incoming());
|
||||
rt.block_on(fut);
|
||||
|
@ -340,4 +344,3 @@ fn build_route<U: 'static + WebDriverExtensionRoute + Send + Sync>(
|
|||
))
|
||||
.boxed()
|
||||
}
|
||||
|
||||
|
|
|
@ -242,11 +242,7 @@ impl BitsRequest {
|
|||
pub fn on_progress(&self, transferred_bytes: i64, total_bytes: i64) {
|
||||
if let Some(progress_event_sink) = self.observer.query_interface::<nsIProgressEventSink>() {
|
||||
unsafe {
|
||||
progress_event_sink.OnProgress(
|
||||
self.coerce(),
|
||||
transferred_bytes,
|
||||
total_bytes,
|
||||
);
|
||||
progress_event_sink.OnProgress(self.coerce(), transferred_bytes, total_bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ macro_rules! task_done {
|
|||
Some(Ok(value)) => unsafe { callback.Resolve(self.convert(value)?.coerce()) },
|
||||
Some(Err(err)) => unsafe { callback.Reject(&*nsCString::from(err.to_string())) },
|
||||
None => unsafe { callback.Reject(&*nsCString::from("unexpected")) },
|
||||
}.to_result()
|
||||
}
|
||||
.to_result()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,7 +75,8 @@ macro_rules! task_done {
|
|||
Some(Ok(())) => unsafe { callback.Resolve() },
|
||||
Some(Err(err)) => unsafe { callback.Reject(&*nsCString::from(err.to_string())) },
|
||||
None => unsafe { callback.Reject(&*nsCString::from("unexpected")) },
|
||||
}.to_result()
|
||||
}
|
||||
.to_result()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -244,7 +244,10 @@ impl<'s> Store<'s> {
|
|||
let raw_validity: i64 = step.get_by_name("validity")?;
|
||||
item.validity = Validity::from_column(raw_validity)?;
|
||||
|
||||
let content = if item.validity == Validity::Replace || item.guid == dogear::ROOT_GUID || !item.needs_merge {
|
||||
let content = if item.validity == Validity::Replace
|
||||
|| item.guid == dogear::ROOT_GUID
|
||||
|| !item.needs_merge
|
||||
{
|
||||
None
|
||||
} else {
|
||||
match kind {
|
||||
|
|
|
@ -62,13 +62,11 @@ macro_rules! bool_putter {
|
|||
pub fn $method(&mut self, v: bool) -> Result<(), HResult> {
|
||||
let v = v.into_variant_bool();
|
||||
unsafe {
|
||||
com_call!(
|
||||
self.0,
|
||||
$interface :: $method(v))?;
|
||||
com_call!(self.0, $interface::$method(v))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// put a value that is already available as a `BString`
|
||||
|
@ -77,13 +75,11 @@ macro_rules! bstring_putter {
|
|||
#[allow(non_snake_case)]
|
||||
pub fn $method(&mut self, v: &BString) -> Result<(), HResult> {
|
||||
unsafe {
|
||||
com_call!(
|
||||
self.0,
|
||||
$interface :: $method(v.as_raw_ptr()))?;
|
||||
com_call!(self.0, $interface::$method(v.as_raw_ptr()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// put a `chrono::DateTime` value
|
||||
|
@ -93,13 +89,11 @@ macro_rules! datetime_putter {
|
|||
pub fn $method(&mut self, v: chrono::DateTime<chrono::Utc>) -> Result<(), HResult> {
|
||||
let v = try_to_bstring!(v.to_rfc3339_opts(chrono::SecondsFormat::Secs, true))?;
|
||||
unsafe {
|
||||
com_call!(
|
||||
self.0,
|
||||
$interface :: $method(v.as_raw_ptr()))?;
|
||||
com_call!(self.0, $interface::$method(v.as_raw_ptr()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// put a value of type `$ty`, which implements `AsRef<OsStr>`
|
||||
|
@ -109,13 +103,11 @@ macro_rules! to_os_str_putter {
|
|||
pub fn $method(&mut self, v: $ty) -> Result<(), HResult> {
|
||||
let v = try_to_bstring!(v)?;
|
||||
unsafe {
|
||||
com_call!(
|
||||
self.0,
|
||||
$interface :: $method(v.as_raw_ptr()))?;
|
||||
com_call!(self.0, $interface::$method(v.as_raw_ptr()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// put a value of type `$ty`, which implements `ToString`
|
||||
|
@ -125,13 +117,11 @@ macro_rules! to_string_putter {
|
|||
pub fn $method(&mut self, v: $ty) -> Result<(), HResult> {
|
||||
let v = try_to_bstring!(v.to_string())?;
|
||||
unsafe {
|
||||
com_call!(
|
||||
self.0,
|
||||
$interface :: $method(v.as_raw_ptr()))?;
|
||||
com_call!(self.0, $interface::$method(v.as_raw_ptr()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub struct TaskService(ComRef<ITaskService>);
|
||||
|
|
|
@ -113,17 +113,16 @@ macro_rules! shrinking_conversion {
|
|||
(name = $name:ident,
|
||||
convert = $convert:ident,
|
||||
other_ty = $other_ty:ty,
|
||||
math = $math:ident) => (
|
||||
math = $math:ident) => {
|
||||
fn $name(&mut self, other: $other_ty, old_len: usize) -> Result<BulkWriteOk, ()> {
|
||||
let needed = $math(other.len()).ok_or(())?;
|
||||
let mut handle = unsafe {
|
||||
self.bulk_write(old_len.checked_add(needed).ok_or(())?, old_len, false)?
|
||||
};
|
||||
let mut handle =
|
||||
unsafe { self.bulk_write(old_len.checked_add(needed).ok_or(())?, old_len, false)? };
|
||||
let written = $convert(other, &mut handle.as_mut_slice()[old_len..]);
|
||||
let new_len = old_len + written;
|
||||
Ok(handle.finish(new_len, new_len > CACHE_LINE))
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/// A conversion where the number of code units in the output is always equal
|
||||
|
@ -138,16 +137,19 @@ macro_rules! shrinking_conversion {
|
|||
macro_rules! constant_conversion {
|
||||
(name = $name:ident,
|
||||
convert = $convert:ident,
|
||||
other_ty = $other_ty:ty) => (
|
||||
fn $name(&mut self, other: $other_ty, old_len: usize, allow_shrinking: bool) -> Result<BulkWriteOk, ()> {
|
||||
other_ty = $other_ty:ty) => {
|
||||
fn $name(
|
||||
&mut self,
|
||||
other: $other_ty,
|
||||
old_len: usize,
|
||||
allow_shrinking: bool,
|
||||
) -> Result<BulkWriteOk, ()> {
|
||||
let new_len = old_len.checked_add(other.len()).ok_or(())?;
|
||||
let mut handle = unsafe {
|
||||
self.bulk_write(new_len, old_len, allow_shrinking)?
|
||||
};
|
||||
let mut handle = unsafe { self.bulk_write(new_len, old_len, allow_shrinking)? };
|
||||
$convert(other, &mut handle.as_mut_slice()[old_len..]);
|
||||
Ok(handle.finish(new_len, false))
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/// An intermediate check for avoiding a copy and having an `nsStringBuffer`
|
||||
|
@ -161,8 +163,12 @@ macro_rules! constant_conversion {
|
|||
macro_rules! ascii_copy_avoidance {
|
||||
(name = $name:ident,
|
||||
implementation = $implementation:ident,
|
||||
string_like = $string_like:ident) => (
|
||||
fn $name<T: $string_like + ?Sized>(&mut self, other: &T, old_len: usize) -> Result<BulkWriteOk, ()> {
|
||||
string_like = $string_like:ident) => {
|
||||
fn $name<T: $string_like + ?Sized>(
|
||||
&mut self,
|
||||
other: &T,
|
||||
old_len: usize,
|
||||
) -> Result<BulkWriteOk, ()> {
|
||||
let adapter = other.adapt();
|
||||
let other_slice = adapter.as_ref();
|
||||
let num_ascii = if adapter.is_abstract() && old_len == 0 {
|
||||
|
@ -173,7 +179,7 @@ macro_rules! ascii_copy_avoidance {
|
|||
// lifetime mess by keeping nsStringLike and
|
||||
// Latin1StringLike free of lifetime interdependencies.
|
||||
if unsafe { Gecko_FallibleAssignCString(self, other.adapt().as_ptr()) } {
|
||||
return Ok(BulkWriteOk{});
|
||||
return Ok(BulkWriteOk {});
|
||||
} else {
|
||||
return Err(());
|
||||
}
|
||||
|
@ -184,7 +190,7 @@ macro_rules! ascii_copy_avoidance {
|
|||
};
|
||||
self.$implementation(other_slice, old_len, num_ascii)
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
impl nsAString {
|
||||
|
|
Загрузка…
Ссылка в новой задаче