Skip to content

Commit 601f23d

Browse files
committed
Rename ArrayOut -> OutNonNull
1 parent 6d04311 commit 601f23d

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

Generator/Types/MethodDef.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public string[] MakeInputParameters(Generator generator, ITypeRequestSource sour
2525

2626
public string MakeOutType(Generator generator, ITypeRequestSource source, bool isFactoryMethod)
2727
{
28-
string outType = String.Join(", ", OutTypes.Select(o => TypeHelpers.GetTypeName(generator, source, o.Item1, (o.Item2 || isFactoryMethod) ? TypeUsage.OutNonnull : TypeUsage.Out)));
28+
string outType = String.Join(", ", OutTypes.Select(o => TypeHelpers.GetTypeName(generator, source, o.Item1, (o.Item2 || isFactoryMethod) ? TypeUsage.OutNonNull : TypeUsage.Out)));
2929
if (OutTypes.Count() != 1)
3030
{
3131
outType = "(" + outType + ")"; // also works for count == 0 (empty tuple)

Generator/Types/TypeHelpers.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static string GetTypeName(Generator gen, ITypeRequestSource source, TypeR
4646
case TypeUsage.Raw: return $"{ t.Name }::Abi";
4747
case TypeUsage.In: return $"&{ t.Name }::In";
4848
case TypeUsage.Out: return $"{ t.Name }::Out";
49-
case TypeUsage.OutNonnull: return $"{ t.Name }::ArrayOut";
49+
case TypeUsage.OutNonNull: return $"{ t.Name }::OutNonNull";
5050
case TypeUsage.GenericArg: return t.Name;
5151
default: throw new NotSupportedException();
5252
}
@@ -83,7 +83,6 @@ private static string GetElementTypeName(Generator gen, ITypeRequestSource sourc
8383
case TypeUsage.Raw: return "HSTRING";
8484
case TypeUsage.In: return "&HStringArg";
8585
case TypeUsage.Out: return "HString";
86-
case TypeUsage.OutNonnull: return "HString";
8786
case TypeUsage.GenericArg: return "HString";
8887
default: throw new NotSupportedException();
8988
}
@@ -176,7 +175,7 @@ private static string GetElementTypeName(Generator gen, ITypeRequestSource sourc
176175
{
177176
name = $"Option<ComPtr<{ name }>>";
178177
}
179-
else if (usage == TypeUsage.OutNonnull)
178+
else if (usage == TypeUsage.OutNonNull)
180179
{
181180
name = $"ComPtr<{ name }>";
182181
}
@@ -196,7 +195,7 @@ public static string GetInputTypeName(Generator gen, ITypeRequestSource source,
196195
case InputKind.MutSlice:
197196
Assert(t.IsValueType);
198197
return $"&mut [{ GetTypeName(gen, source, t, TypeUsage.In) }]";
199-
case InputKind.VecBuffer: return $"&mut Vec<{ GetTypeName(gen, source, t, TypeUsage.OutNonnull) }>";
198+
case InputKind.VecBuffer: return $"&mut Vec<{ GetTypeName(gen, source, t, TypeUsage.OutNonNull) }>";
200199
default: throw new InvalidOperationException();
201200
}
202201
}
@@ -422,7 +421,7 @@ public enum TypeUsage
422421
{
423422
In,
424423
Out,
425-
OutNonnull,
424+
OutNonNull,
426425
Raw,
427426
Alias,
428427
GenericArg,

src/comptr.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,16 @@ impl<T> ComArray<T> where T: ::RtType {
173173
}
174174

175175
impl<T> Deref for ComArray<T> where T: ::RtType {
176-
type Target = [T::ArrayOut];
176+
type Target = [T::OutNonNull];
177177
#[inline]
178-
fn deref(&self) -> &[T::ArrayOut] {
179-
unsafe { ::std::slice::from_raw_parts(self.first as *mut T::ArrayOut, self.size as usize) }
178+
fn deref(&self) -> &[T::OutNonNull] {
179+
unsafe { ::std::slice::from_raw_parts(self.first as *mut T::OutNonNull, self.size as usize) }
180180
}
181181
}
182182
impl<T> DerefMut for ComArray<T> where T: ::RtType {
183183
#[inline]
184-
fn deref_mut(&mut self) -> &mut [T::ArrayOut] {
185-
unsafe { ::std::slice::from_raw_parts_mut(self.first as *mut T::ArrayOut, self.size as usize) }
184+
fn deref_mut(&mut self) -> &mut [T::OutNonNull] {
185+
unsafe { ::std::slice::from_raw_parts_mut(self.first as *mut T::OutNonNull, self.size as usize) }
186186
}
187187
}
188188

src/rt/gen/windows/foundation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3189,7 +3189,7 @@ impl<T: RtType> IIterator<T> {
31893189
let hr = ((*self.lpVtbl).MoveNext)(self as *const _ as *mut _, &mut out);
31903190
if hr == S_OK { Ok(out) } else { err(hr) }
31913191
}}
3192-
#[inline] pub fn get_many(&self, items: &mut Vec<T::ArrayOut>) -> Result<()> { unsafe {
3192+
#[inline] pub fn get_many(&self, items: &mut Vec<T::OutNonNull>) -> Result<()> { unsafe {
31933193
debug_assert!(items.capacity() > 0, "capacity of `items` must not be 0 (use Vec::with_capacity)"); items.clear();
31943194
let mut out = zeroed();
31953195
let hr = ((*self.lpVtbl).GetMany)(self as *const _ as *mut _, items.capacity() as u32, items.as_mut_ptr() as *mut T::Abi, &mut out);
@@ -3419,7 +3419,7 @@ impl<T: RtType> IVector<T> {
34193419
let hr = ((*self.lpVtbl).Clear)(self as *const _ as *mut _);
34203420
if hr == S_OK { Ok(()) } else { err(hr) }
34213421
}}
3422-
#[inline] pub fn get_many(&self, startIndex: u32, items: &mut Vec<T::ArrayOut>) -> Result<()> { unsafe {
3422+
#[inline] pub fn get_many(&self, startIndex: u32, items: &mut Vec<T::OutNonNull>) -> Result<()> { unsafe {
34233423
debug_assert!(items.capacity() > 0, "capacity of `items` must not be 0 (use Vec::with_capacity)"); items.clear();
34243424
let mut out = zeroed();
34253425
let hr = ((*self.lpVtbl).GetMany)(self as *const _ as *mut _, startIndex, items.capacity() as u32, items.as_mut_ptr() as *mut T::Abi, &mut out);
@@ -3480,7 +3480,7 @@ impl<T: RtType> IVectorView<T> {
34803480
let hr = ((*self.lpVtbl).IndexOf)(self as *const _ as *mut _, T::unwrap(value), &mut index, &mut out);
34813481
if hr == S_OK { Ok((index, out)) } else { err(hr) }
34823482
}}
3483-
#[inline] pub fn get_many(&self, startIndex: u32, items: &mut Vec<T::ArrayOut>) -> Result<()> { unsafe {
3483+
#[inline] pub fn get_many(&self, startIndex: u32, items: &mut Vec<T::OutNonNull>) -> Result<()> { unsafe {
34843484
debug_assert!(items.capacity() > 0, "capacity of `items` must not be 0 (use Vec::with_capacity)"); items.clear();
34853485
let mut out = zeroed();
34863486
let hr = ((*self.lpVtbl).GetMany)(self as *const _ as *mut _, startIndex, items.capacity() as u32, items.as_mut_ptr() as *mut T::Abi, &mut out);

src/rt/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub trait RtType {
5151
type In;
5252
type Abi;
5353
type Out;
54-
type ArrayOut;
54+
type OutNonNull;
5555

5656
unsafe fn unwrap(input: &Self::In) -> Self::Abi;
5757
unsafe fn uninitialized() -> Self::Abi;
@@ -62,7 +62,7 @@ impl<'a> RtType for HString {
6262
type In = HStringArg;
6363
type Abi = HSTRING;
6464
type Out = HString;
65-
type ArrayOut = Self::Out;
65+
type OutNonNull = Self::Out;
6666

6767
#[doc(hidden)] #[inline]
6868
unsafe fn unwrap(v: &HStringArg) -> Self::Abi {
@@ -83,7 +83,7 @@ impl<T> RtType for T where T: RtValueType
8383
type In = T;
8484
type Abi = T;
8585
type Out = T;
86-
type ArrayOut = Self::Out;
86+
type OutNonNull = Self::Out;
8787

8888
#[doc(hidden)] #[inline]
8989
unsafe fn unwrap(v: &Self::In) -> Self::Abi {
@@ -235,8 +235,8 @@ macro_rules! RT_INTERFACE {
235235
impl ::RtType for $interface {
236236
type In = $interface;
237237
type Abi = *mut $interface;
238-
type Out = Option<Self::ArrayOut>;
239-
type ArrayOut = ComPtr<$interface>;
238+
type Out = Option<Self::OutNonNull>;
239+
type OutNonNull = ComPtr<$interface>;
240240

241241
#[doc(hidden)] #[inline] unsafe fn unwrap(v: &Self::In) -> Self::Abi { v as *const _ as *mut _ }
242242
#[doc(hidden)] #[inline] unsafe fn uninitialized() -> Self::Abi { ::std::ptr::null_mut() }
@@ -284,8 +284,8 @@ macro_rules! RT_INTERFACE {
284284
impl ::RtType for $interface {
285285
type In = $interface;
286286
type Abi = *mut $interface;
287-
type Out = Option<Self::ArrayOut>;
288-
type ArrayOut = ComPtr<$interface>;
287+
type Out = Option<Self::OutNonNull>;
288+
type OutNonNull = ComPtr<$interface>;
289289

290290
#[doc(hidden)] #[inline] unsafe fn unwrap(v: &Self::In) -> Self::Abi { v as *const _ as *mut _ }
291291
#[doc(hidden)] #[inline] unsafe fn uninitialized() -> Self::Abi { ::std::ptr::null_mut() }
@@ -330,8 +330,8 @@ macro_rules! RT_INTERFACE {
330330
impl<$t1> ::RtType for $interface<$t1> where $t1: RtType{
331331
type In = $interface<$t1>;
332332
type Abi = *mut $interface<$t1>;
333-
type Out = Option<Self::ArrayOut>;
334-
type ArrayOut = ComPtr<$interface<$t1>>;
333+
type Out = Option<Self::OutNonNull>;
334+
type OutNonNull = ComPtr<$interface<$t1>>;
335335

336336
#[doc(hidden)] #[inline] unsafe fn unwrap(v: &Self::In) -> Self::Abi { v as *const _ as *mut _ }
337337
#[doc(hidden)] #[inline] unsafe fn uninitialized() -> Self::Abi { ::std::ptr::null_mut() }
@@ -375,8 +375,8 @@ macro_rules! RT_INTERFACE {
375375
impl<$t1, $t2> ::RtType for $interface<$t1, $t2> where $t1: RtType, $t2: RtType {
376376
type In = $interface<$t1, $t2>;
377377
type Abi = *mut $interface<$t1, $t2>;
378-
type Out = Option<Self::ArrayOut>;
379-
type ArrayOut = ComPtr<$interface<$t1, $t2>>;
378+
type Out = Option<Self::OutNonNull>;
379+
type OutNonNull = ComPtr<$interface<$t1, $t2>>;
380380

381381
#[doc(hidden)] #[inline] unsafe fn unwrap(v: &Self::In) -> Self::Abi { v as *const _ as *mut _ }
382382
#[doc(hidden)] #[inline] unsafe fn uninitialized() -> Self::Abi { ::std::ptr::null_mut() }
@@ -556,8 +556,8 @@ macro_rules! RT_CLASS {
556556
impl ::RtType for $cls {
557557
type In = $cls;
558558
type Abi = *mut $cls;
559-
type Out = Option<Self::ArrayOut>;
560-
type ArrayOut = ComPtr<$cls>;
559+
type Out = Option<Self::OutNonNull>;
560+
type OutNonNull = ComPtr<$cls>;
561561

562562
#[doc(hidden)] #[inline] unsafe fn unwrap(v: &Self::In) -> Self::Abi { v as *const _ as *mut _ }
563563
#[doc(hidden)] #[inline] unsafe fn uninitialized() -> Self::Abi { ::std::ptr::null_mut() }

0 commit comments

Comments
 (0)