Skip to content

Commit d116782

Browse files
committed
rename go to find-cycles
1 parent 8229989 commit d116782

File tree

4 files changed

+177
-25
lines changed

4 files changed

+177
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/win32json
22
/out-*
33
.mypy_cache/
4+
__pycache__/

apiref.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class ApiRef:
2+
def __init__(self, api: str, name: str):
3+
self.api = api
4+
self.name = name
5+
self.combined = format("{}:{}".format(api, name))
6+
def __eq__(self, other):
7+
return self.combined.__eq__(other.combined)
8+
def __ge__(self, other):
9+
return self.combined.__ge__(other.combined)
10+
def __lt__(self, other):
11+
return self.combined.__lt__(other.combined)
12+
def __hash__(self):
13+
return self.combined.__hash__()
14+
def __str__(self):
15+
return self.combined
16+
def __repr__(self):
17+
return self.combined

go renamed to find-cycles

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import json
1313
import collections
1414
from typing import List, Set, Dict, Optional
1515

16+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
17+
18+
from apiref import ApiRef
19+
1620
def getApiRefTopLevelType(type_obj):
1721
parents = type_obj["Parents"]
1822
if parents:
@@ -26,23 +30,6 @@ class DefaultDict(dict):
2630
self[key] = self.factory(key)
2731
return self[key]
2832

29-
class ApiRef:
30-
def __init__(self, api: str, name: str):
31-
self.api = api
32-
self.name = name
33-
self.combined = format("{}:{}".format(api, name))
34-
def __eq__(self, other):
35-
return self.combined.__eq__(other.combined)
36-
def __ge__(self, other):
37-
return self.combined.__ge__(other.combined)
38-
def __lt__(self, other):
39-
return self.combined.__lt__(other.combined)
40-
def __hash__(self):
41-
return self.combined.__hash__()
42-
def __str__(self):
43-
return self.combined
44-
def __repr__(self):
45-
return self.combined
4633
class ApiTypeNameToApiRefMap:
4734
def __init__(self):
4835
self.top_level: Dict[str,Set[ApiRef]] = {}
@@ -72,8 +59,7 @@ def main():
7259
win32json_branch = "10.0.19041.202-preview"
7360
win32json_sha = "7164f4ce9fe17b7c5da3473eed26886753ce1173"
7461

75-
script_dir = os.path.dirname(os.path.abspath(__file__))
76-
win32json = os.path.join(script_dir, "win32json")
62+
win32json = os.path.join(SCRIPT_DIR, "win32json")
7763
if not os.path.exists(win32json):
7864
print("Error: missing '{}'".format(win32json))
7965
print("Clone it with:")
@@ -181,7 +167,7 @@ def main():
181167

182168
out_direct_deps_filename = "out-direct-deps.txt"
183169
print("generating {}...".format(out_direct_deps_filename))
184-
with open(os.path.join(script_dir, out_direct_deps_filename), "w") as file:
170+
with open(os.path.join(SCRIPT_DIR, out_direct_deps_filename), "w") as file:
185171
for api in apis:
186172
table = api_direct_type_refs_table[api]
187173
for type_name,refs in table.top_level.items():
@@ -193,7 +179,7 @@ def main():
193179
out_recursive_deps_filename = "out-recursive-deps.txt"
194180
print("calculating recursive type references (will store in {})...".format(out_recursive_deps_filename))
195181
api_recursive_type_refs_table: Dict[str,dict[str,Set[ApiRef]]] = {}
196-
with open(os.path.join(script_dir, out_recursive_deps_filename), "w") as file:
182+
with open(os.path.join(SCRIPT_DIR, out_recursive_deps_filename), "w") as file:
197183
for api in apis:
198184
#print("calculating recursive deps on {}...".format(api))
199185
direct_type_refs_table = api_direct_type_refs_table[api]
@@ -221,7 +207,7 @@ def main():
221207
else:
222208
type_set[t] = cycle
223209

224-
with open(os.path.join(script_dir, "out-cycles.txt"), "w") as file:
210+
with open(os.path.join(SCRIPT_DIR, "out-cycles.txt"), "w") as file:
225211
for api in apis:
226212
#print("API: {}".format(api))
227213
table = api_recursive_type_refs_table[api]
@@ -261,14 +247,20 @@ def main():
261247

262248
api_types_list = list(api_cycle_type_set)
263249
api_types_list.sort()
264-
with open(os.path.join(script_dir, "out-cycle-types.txt"), "w") as file:
250+
with open(os.path.join(SCRIPT_DIR, "out-cycle-types.txt"), "w") as file:
265251
for cycle_type in api_types_list:
266252
file.write("{}\n".format(cycle_type))
267253
for t in api_cycle_type_set[cycle_type]:
268254
file.write(" {}\n".format(t))
255+
with open(os.path.join(SCRIPT_DIR, "out-cycle-types.py"), "w") as file:
256+
file.write("from apiref import ApiRef\n")
257+
file.write("CYCLE_TYPES = {\n")
258+
for cycle_type in api_types_list:
259+
file.write(" ApiRef(\"{}\", \"{}\"),\n".format(cycle_type.api, cycle_type.name))
260+
file.write("}\n")
269261

270262
# NOTE: this is not all the cycles, just some of the for now
271-
with open(os.path.join(script_dir, "out-cycle-types.dot"), "w") as file:
263+
with open(os.path.join(SCRIPT_DIR, "out-cycle-types.dot"), "w") as file:
272264
file.write("digraph type_cycles {\n")
273265
links = collections.defaultdict(set)
274266
def addLink(links, a, b):
@@ -282,7 +274,7 @@ def main():
282274
for i in range(1, len(cycle)):
283275
addLink(links, cycle[i-1], cycle[i])
284276
file.write("}\n")
285-
#with open(os.path.join(script_dir, "out-self-cycle-types.txt"), "w") as file:
277+
#with open(os.path.join(SCRIPT_DIR, "out-self-cycle-types.txt"), "w") as file:
286278
# types_list = list(self_cycle_type_set)
287279
# types_list.sort()
288280
# for cycle_type in types_list:

out

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
loading types...
2+
types loaded, checking that type refs exist...
3+
types verified
4+
calculating recursive type references...
5+
done calculating recursive type references
6+
searching for cycles...
7+
9 cycles: AI.MachineLearning.DirectML:IDMLDebugDevice
8+
15 cycles: AI.MachineLearning.WinML:IMLOperatorRegistry
9+
2 cycles: Data.HtmlHelp:IITResultSet
10+
3 cycles: Devices.AllJoyn:alljoyn_sessionportlistener
11+
128 cycles: Devices.BiometricFramework:WINBIO_FRAMEWORK_INTERFACE
12+
6 cycles: Devices.Bluetooth:BTH_INFO_RSP
13+
4 cycles: Devices.Display:MC_COLOR_TEMPERATURE
14+
6 cycles: Devices.Enumeration.Pnp:SW_DEVICE_CREATE_CALLBACK
15+
57 cycles: Devices.Fax:SendToMode
16+
7 cycles: Devices.FunctionDiscovery:IPNPXDeviceAssociation
17+
43 cycles: Devices.HumanInterfaceDevice:JOYREGHWVALUES
18+
8 cycles: Devices.ImageAcquisition:IWiaVideo
19+
27 cycles: Devices.PortableDevices:IConnectionRequestCallback
20+
5 cycles: Devices.Sensors:ISensorEvents
21+
101 cycles: Devices.Tapi:IMcastAddressAllocation
22+
117 cycles: Devices.WebServicesOnDevices:IWSDInboundAttachment
23+
1 cycles: Gaming:KnownGamingPrivileges
24+
27 cycles: Globalization:IActiveIME2
25+
158 cycles: Graphics.Direct2D:ID2D1EffectContext2
26+
74 cycles: Graphics.Direct3D10:PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN1
27+
101 cycles: Graphics.Direct3D11:D3DX11_FFT_CREATE_FLAG
28+
101 cycles: Graphics.Direct3D12:IHolographicQuadLayerUpdateParametersInterop
29+
22 cycles: Graphics.Direct3D9:IDirect3DSwapChain9Ex
30+
48 cycles: Graphics.DirectComposition:IDCompositionAffineTransform2DEffect
31+
16 cycles: Graphics.DirectDraw:DDCOLORCONTROL
32+
10 cycles: Graphics.DirectManipulation:IDirectManipulationDeferContactService
33+
293 cycles: Graphics.DirectShow:MPEG_HEADER_VERSION_BITS
34+
133 cycles: Graphics.DirectWrite:DWRITE_GLYPH_IMAGE_FORMATS
35+
62 cycles: Graphics.Dxgi:IDXGIDebug1
36+
2 cycles: Graphics.Gdi:MONITORENUMPROC
37+
13 cycles: Graphics.Hlsl:D3D_SHADER_DATA
38+
54 cycles: Graphics.Imaging:IWICComponentFactory
39+
50 cycles: Media.Audio.CoreAudio:HTASK
40+
20 cycles: Media.Audio.DirectMusic:IPropertyStore
41+
9 cycles: Media.Audio.XAudio2:IXAPOHrtfParameters
42+
65 cycles: Media.DeviceManager:MTP_COMMAND_DATA_OUT
43+
2 cycles: Media.LibrarySharingServices:IWindowsMediaLibrarySharingServices
44+
387 cycles: Media.MediaFoundation:D3D11_FEATURE_VIDEO
45+
52 cycles: Media.MediaPlayer:WMP_WMDM_METADATA_ROUND_TRIP_DEVICE2PC
46+
7 cycles: Media.Multimedia:LPTASKCALLBACK
47+
6 cycles: Media.PictureAcquisition:IPhotoAcquirePlugin
48+
85 cycles: Media.Speech:ISpeechPhoneConverter
49+
59 cycles: Media.WindowsMediaFormat:IWMSInternalAdminNetSource3
50+
21 cycles: NetworkManagement.Dhcp:DHCP_FAILOVER_STATISTICS
51+
8 cycles: NetworkManagement.Dns:DnsContextHandle
52+
18 cycles: NetworkManagement.IpHelper:NET_ADDRESS_FORMAT
53+
18 cycles: NetworkManagement.MobileBroadband:IMbnPin
54+
2 cycles: NetworkManagement.Ndis:NDIS_HARDWARE_CROSSTIMESTAMP
55+
4 cycles: NetworkManagement.NetManagement:USER_MODALS_ROLES
56+
3 cycles: NetworkManagement.NetShell:PNS_DLL_INIT_FN
57+
10 cycles: NetworkManagement.NetworkDiagnosticsFramework:INetDiagExtensibleHelper
58+
23 cycles: NetworkManagement.P2P:PEERDIST_CLIENT_BASIC_INFO
59+
25 cycles: NetworkManagement.Rras:RTM_ENTITY_EXPORT_METHODS
60+
2 cycles: NetworkManagement.WNet:DISCDLGSTRUCT_FLAGS
61+
1 cycles: NetworkManagement.WebDav:PFNDAVAUTHCALLBACK
62+
12 cycles: NetworkManagement.WiFi:IDot11AdHocInterfaceNotificationSink
63+
1 cycles: NetworkManagement.WindowsConnectionManager:ONDEMAND_NOTIFICATION_CALLBACK
64+
30 cycles: NetworkManagement.WindowsFilteringPlatform:FWPM_FILTER_FLAGS
65+
27 cycles: NetworkManagement.WindowsFirewall:INetFwProducts
66+
17 cycles: Networking.ActiveDirectory:GetDcContextHandle
67+
33 cycles: Networking.BackgroundIntelligentTransferService:BG_TOKEN
68+
50 cycles: Networking.Clustering:ISClusResDependents
69+
4 cycles: Networking.HttpServer:HTTP_INITIALIZE
70+
4 cycles: Networking.NetworkListManager:INetworkConnectionCostEvents
71+
8 cycles: Networking.RemoteDifferentialCompression:ISimilarity
72+
2 cycles: Networking.WinInet:INTERNET_STATE
73+
55 cycles: Networking.WinSock:LPWSCWRITENAMESPACEORDER
74+
114 cycles: Networking.WindowsWebServices:WEBAUTHN_ASSERTION
75+
34 cycles: Networking.XmlHttpExtendedRequest:IXMLHTTPRequest3
76+
456 cycles: Security:TRUSTED_DOMAIN_TRUST_ATTRIBUTES
77+
13 cycles: Security.ExtensibleAuthenticationProtocol:EAP_AUTHENTICATOR_METHOD_ROUTINES
78+
2 cycles: Storage.CloudFilters:CF_CONNECTION_KEY
79+
2 cycles: Storage.DataDeduplication:IDedupDataPortManager
80+
2 cycles: Storage.DistributedFileSystem:DFS_GET_PKT_ENTRY_STATE_ARG
81+
4 cycles: Storage.EnhancedStorage:IEnhancedStorageSiloAction
82+
64 cycles: Storage.FileServerResourceManager:DIFsrmClassificationEvents
83+
2 cycles: Storage.FileSystem:FILE_ID_DESCRIPTOR
84+
19 cycles: Storage.Imapi:DISC_RECORDER_STATE_FLAGS
85+
2 cycles: Storage.IscsiDisc:ISCSI_VERSION_INFO
86+
21 cycles: Storage.OfflineFiles:IOfflineFilesCache2
87+
42 cycles: Storage.Packaging.Appx:AppPolicyCreateFileAccess
88+
41 cycles: Storage.Packaging.Opc:IOpcFactory
89+
10 cycles: Storage.ProjectedFileSystem:PRJ_COMPLETE_COMMAND_EXTENDED_PARAMETERS
90+
16 cycles: Storage.StructuredStorage:PROPSPEC_KIND
91+
24 cycles: Storage.VirtualDiskService:VDS_NF_DISK
92+
16 cycles: Storage.Vss:IVssFileShareSnapshotProvider
93+
83 cycles: Storage.Xps:DEVICE_CAPABILITIES
94+
53 cycles: System.AddressBook:Gender
95+
2 cycles: System.Antimalware:HAMSISESSION
96+
8 cycles: System.ApplicationInstallationAndServicing:PROTECTED_FILE_DATA
97+
1 cycles: System.AssessmentTool:IQueryOEMWinSATCustomization
98+
176 cycles: System.Com:ACTRL_ACCESSW
99+
31 cycles: System.ComponentServices:IDontSupportEventSubscription
100+
18 cycles: System.DeploymentServices:WDS_TRANSPORTCLIENT_REQUEST_AUTH_LEVEL
101+
17 cycles: System.DesktopSharing:_IRDPSessionEvents
102+
225 cycles: System.Diagnostics.Debug:IMAGEHLP_DUPLICATE_SYMBOL
103+
7 cycles: System.Diagnostics.Etw:EVENT_TRACE_FLAG
104+
39 cycles: System.GroupPolicy:GPOBROWSEINFO
105+
5 cycles: System.Hypervisor:WHV_EMULATOR_CALLBACKS
106+
1 cycles: System.Kernel:SUITE_TYPE
107+
4 cycles: System.Mapi:LPMAPIRESOLVENAME
108+
31 cycles: System.Mmc:IResultData2
109+
29 cycles: System.OleAutomation:VARENUM
110+
3 cycles: System.ParentalControls:IWPCProviderSupport
111+
22 cycles: System.Performance:PERF_COUNTER_AGGREGATE_FUNC
112+
2 cycles: System.Power:POWER_SETTING_REGISTER_NOTIFICATION_FLAGS
113+
7 cycles: System.PropertiesSystem:DRAWPROGRESSFLAGS
114+
62 cycles: System.RemoteDesktop:IRemoteDesktopClient
115+
19 cycles: System.RemoteManagement:IWSManInternal
116+
13 cycles: System.Rpc:RPC_BINDING_HANDLE_OPTIONS_FLAGS
117+
58 cycles: System.Search:CHANNEL_AGENT_FLAGS
118+
2 cycles: System.ServerBackup:WSB_OB_REGISTRATION_INFO
119+
6 cycles: System.SettingsManagementInfrastructure:ISettingsContext
120+
83 cycles: System.SystemServices:POWER_REQUEST_CONTEXT_FLAGS
121+
35 cycles: System.TaskScheduler:IRepetitionPattern
122+
57 cycles: System.UpdateAgent:UpdateServiceOption
123+
30 cycles: System.WinRT:IWindowsDevicesAllJoynBusObjectFactoryInterop
124+
192 cycles: System.WindowsProgramming:EXTENDED_NAME_FORMAT
125+
59 cycles: System.WindowsSync:ISyncRegistrationChange
126+
58 cycles: System.Wmi:ISWbemRefreshableItem
127+
77 cycles: UI.Accessibility:SOUNDSENTRY_WINDOWS_EFFECT
128+
19 cycles: UI.Animation:UI_ANIMATION_KEYFRAME
129+
6 cycles: UI.ColorSystem:COLOR_MATCH_TO_TARGET_ACTION
130+
53 cycles: UI.Controls:PARAFORMAT_ALIGNMENT
131+
140 cycles: UI.DisplayDevices:DDHAL_DESTROYDDLOCALDATA
132+
1 cycles: UI.LegacyWindowsEnvironmentFeatures:_ColumnSortOrder
133+
2 cycles: UI.PointerInput:POINTER_FLAGS
134+
3 cycles: UI.Ribbon:IUIImageFromBitmap
135+
220 cycles: UI.Shell:ICreateObject
136+
50 cycles: UI.TabletPC:ITipAutoCompleteClient
137+
105 cycles: UI.TextServices:TF_CONTEXT_EDIT_CONTEXT_FLAGS
138+
14 cycles: UI.WindowsAndMessaging:GUITHREADINFO_FLAGS
139+
15 cycles: UI.Wpf:IMILBitmapEffectEvents
140+
4 cycles: UI.Xaml.Diagnostics:IVisualTreeService3
141+
182 cycles: Web.MsHtml:IBFCacheable
142+
done

0 commit comments

Comments
 (0)