Skip to content

Commit

Permalink
Fix comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaanstra committed Mar 13, 2024
1 parent 2901891 commit ba34694
Showing 1 changed file with 57 additions and 83 deletions.
140 changes: 57 additions & 83 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1980,14 +1980,12 @@ private static IObjectReference %
get
{
var factory = __%;
if (factory != null && factory.IsInCurrentContext)
if (factory is not null && factory.IsInCurrentContext)
{
return factory;
}
else
{
return __% = ActivationFactory.Get("%.%");
}
return __% = ActivationFactory.Get("%.%");
}
}
)",
Expand All @@ -2012,14 +2010,12 @@ private static ObjectReference<%> %
get
{
var factory = __%;
if (factory != null && factory.IsInCurrentContext)
if (factory is not null && factory.IsInCurrentContext)
{
return factory;
}
else
{
return __% = ActivationFactory.Get<%>("%.%", %.IID);
}
return __% = ActivationFactory.Get<%>("%.%", %.IID);
}
}
)",
Expand All @@ -2044,14 +2040,12 @@ private static IObjectReference %
get
{
var factory = __%;
if (factory != null && factory.IsInCurrentContext)
if (factory is not null && factory.IsInCurrentContext)
{
return factory;
}
else
{
return __% = ActivationFactory.Get("%.%", %.IID);
}
return __% = ActivationFactory.Get("%.%", %.IID);
}
}
)",
Expand Down Expand Up @@ -3838,16 +3832,14 @@ private static global::System.Runtime.CompilerServices.ConditionalWeakTable<obje
get
{
var table = _%_;
if (table != null)
if (table is not null)
{
return table;
}
else
{
%
global::System.Threading.Interlocked.CompareExchange(ref _%_, new(), null);
return _%_;
}
%
global::System.Threading.Interlocked.CompareExchange(ref _%_, new(), null);
return _%_;
}
}
)",
Expand Down Expand Up @@ -5215,7 +5207,7 @@ internal unsafe volatile static delegate*<IObjectReference, %%%> _%;
else if (projected_signature_has_generic && !is_generic_method_instantiation_class)
{
w.write(R"(
if (!RuntimeFeature.IsDynamicCodeCompiled || _% != null)
if (!RuntimeFeature.IsDynamicCodeCompiled || _% is not null)
{
% _%(_genericObj%%);
}
Expand Down Expand Up @@ -5290,7 +5282,7 @@ else
else if (projected_signature_has_generic && !is_generic_method_instantiation_class)
{
w.write(R"(
if (!RuntimeFeature.IsDynamicCodeCompiled || _% != null)
if (!RuntimeFeature.IsDynamicCodeCompiled || _% is not null)
{
return _%(_genericObj);
}
Expand Down Expand Up @@ -5340,7 +5332,7 @@ else
if (projected_signature_has_generic && !is_generic_method_instantiation_class)
{
w.write(R"(
if (!RuntimeFeature.IsDynamicCodeCompiled || _% != null)
if (!RuntimeFeature.IsDynamicCodeCompiled || _% is not null)
{
_%(_genericObj, value);
}
Expand Down Expand Up @@ -6557,15 +6549,13 @@ private static global::System.Runtime.CompilerServices.ConditionalWeakTable<%, g
get
{
var tokenTables = _%_tokenTables;
if (tokenTables != null)
if (tokenTables is not null)
{
return tokenTables;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _%_tokenTables, new(), null);
return _%_tokenTables;
}
global::System.Threading.Interlocked.CompareExchange(ref _%_tokenTables, new(), null);
return _%_tokenTables;
}
}
)",
Expand Down Expand Up @@ -6625,7 +6615,7 @@ private static unsafe int Do_Abi_%%
try
{
var __this = global::WinRT.ComWrappersSupport.FindObject<%>(thisPtr);
if(__this != null && _%_TokenTables.TryGetValue(__this, out var __table) && __table.RemoveEventHandler(%, out var __handler))
if(__this is not null && _%_TokenTables.TryGetValue(__this, out var __table) && __table.RemoveEventHandler(%, out var __handler))
{
__this.% -= __handler;
}
Expand Down Expand Up @@ -6659,15 +6649,13 @@ private static global::System.Runtime.CompilerServices.ConditionalWeakTable<%, g
get
{
var tokenTables = _%_tokenTables;
if (tokenTables != null)
if (tokenTables is not null)
{
return tokenTables;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _%_tokenTables, new(), null);
return _%_tokenTables;
}
global::System.Threading.Interlocked.CompareExchange(ref _%_tokenTables, new(), null);
return _%_tokenTables;
}
})",
type_name,
Expand Down Expand Up @@ -6698,7 +6686,7 @@ return token;
public static void Do_Abi_%(IntPtr thisPtr, global::WinRT.EventRegistrationToken token)
{
var __this = global::WinRT.ComWrappersSupport.FindObject<%>(thisPtr);
if(__this != null && _%_TokenTables.TryGetValue(__this, out var __table) && __table.RemoveEventHandler(token, out var __handler))
if(__this is not null && _%_TokenTables.TryGetValue(__this, out var __table) && __table.RemoveEventHandler(token, out var __handler))
{
__this.% -= __handler;
}
Expand Down Expand Up @@ -7262,7 +7250,7 @@ IInspectableVftbl = global::WinRT.IInspectable.Vftbl.AbiToProjectionVftable,
{
%
internal static ObjectReference<Vftbl> FromAbi(IntPtr thisPtr)%
public static implicit operator %(IObjectReference obj) => (obj != null) ? new %(obj) : null;
public static implicit operator %(IObjectReference obj) => (obj is not null) ? new %(obj) : null;
protected readonly ObjectReference<Vftbl> _obj;
public IObjectReference ObjRef { get => _obj; }
public IntPtr ThisPtr => _obj.ThisPtr;
Expand Down Expand Up @@ -7385,15 +7373,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IO
get
{
var cache = _queryInterfaceCache;
if (cache != null)
if (cache is not null)
{
return cache;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
}
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> _additionalTypeData;
Expand All @@ -7402,15 +7388,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, ob
get
{
var typeData = _additionalTypeData;
if (typeData != null)
if (typeData is not null)
{
return typeData;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
}
%
Expand Down Expand Up @@ -7445,15 +7429,13 @@ private IObjectReference %
get
{
var objRef = __%;
if (objRef != null)
if (objRef is not null)
{
return objRef;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref __%, ((IWinRTObject)this).NativeObject.As<IUnknownVftbl>(%.IID), null);
return __%;
}
global::System.Threading.Interlocked.CompareExchange(ref __%, ((IWinRTObject)this).NativeObject.As<IUnknownVftbl>(%.IID), null);
return __%;
}
}
)",
Expand Down Expand Up @@ -8630,15 +8612,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IO
get
{
var cache = _queryInterfaceCache;
if (cache != null)
if (cache is not null)
{
return cache;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
}
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> _additionalTypeData;
Expand All @@ -8647,15 +8627,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, ob
get
{
var typeData = _additionalTypeData;
if (typeData != null)
if (typeData is not null)
{
return typeData;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
}
)");
Expand Down Expand Up @@ -8924,15 +8902,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IO
get
{
var cache = _queryInterfaceCache;
if (cache != null)
if (cache is not null)
{
return cache;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new(), null);
return _queryInterfaceCache;
}
}
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> _additionalTypeData;
Expand All @@ -8941,15 +8917,13 @@ global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, ob
get
{
var typeData = _additionalTypeData;
if (typeData != null)
if (typeData is not null)
{
return typeData;
}
else
{
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new(), null);
return _additionalTypeData;
}
}
#endif
Expand Down Expand Up @@ -9164,7 +9138,7 @@ Abi_Invoke_Type = Expression.GetDelegateType(new Type[] { typeof(void*), %typeof
if (!settings.netstandard_compat && have_generic_params)
{
w.write(R"(
if (%._Invoke != null || !RuntimeFeature.IsDynamicCodeCompiled)
if (%._Invoke is not null || !RuntimeFeature.IsDynamicCodeCompiled)
{
%._Invoke(_nativeDelegate, %);
}
Expand Down

0 comments on commit ba34694

Please sign in to comment.