Skip to content

Commit

Permalink
Simplify factory generated code. (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaanstra committed Sep 12, 2023
1 parent 5721184 commit 7a8c3b1
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ internal static % Instance => _instance;
else
{
w.write(R"(
internal sealed class _% : IWinRTObject
internal sealed class _%
{
private IObjectReference _obj;
public _%()
Expand All @@ -1872,23 +1872,6 @@ _obj = %(GuidGenerator.GetIID(typeof(%.%).GetHelperType()));
%
internal static % Instance => (%)_instance;
IObjectReference IWinRTObject.NativeObject => _obj;
bool IWinRTObject.HasUnwrappableNativeObject => false;
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> _queryInterfaceCache;
private global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> MakeQueryInterfaceCache()
{
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference>(), null);
return _queryInterfaceCache;
}
global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> IWinRTObject.QueryInterfaceCache => _queryInterfaceCache ?? MakeQueryInterfaceCache();
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> _additionalTypeData;
private global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> MakeAdditionalTypeData()
{
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object>(), null);
return _additionalTypeData;
}
global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> IWinRTObject.AdditionalTypeData => _additionalTypeData ?? MakeAdditionalTypeData();
}
)",
cache_type_name,
Expand Down Expand Up @@ -4050,7 +4033,7 @@ internal static _% Instance => _instance;
else
{
w.write(R"(
internal sealed class _% : IWinRTObject
internal sealed class _%
{
private IObjectReference _obj;
private IntPtr ThisPtr => _obj.ThisPtr;
Expand All @@ -4061,24 +4044,6 @@ _obj = ActivationFactory<%>.As(GuidGenerator.GetIID(typeof(%.%).GetHelperType())
private static _% _instance = new _%();
internal static _% Instance => _instance;
IObjectReference IWinRTObject.NativeObject => _obj;
bool IWinRTObject.HasUnwrappableNativeObject => false;
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> _queryInterfaceCache;
private global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> MakeQueryInterfaceCache()
{
global::System.Threading.Interlocked.CompareExchange(ref _queryInterfaceCache, new global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference>(), null);
return _queryInterfaceCache;
}
global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, IObjectReference> IWinRTObject.QueryInterfaceCache => _queryInterfaceCache ?? MakeQueryInterfaceCache();
private volatile global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> _additionalTypeData;
private global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> MakeAdditionalTypeData()
{
global::System.Threading.Interlocked.CompareExchange(ref _additionalTypeData, new global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object>(), null);
return _additionalTypeData;
}
global::System.Collections.Concurrent.ConcurrentDictionary<RuntimeTypeHandle, object> IWinRTObject.AdditionalTypeData => _additionalTypeData ?? MakeAdditionalTypeData();
%
}
)",
Expand Down

0 comments on commit 7a8c3b1

Please sign in to comment.