10
10
import os
11
11
import sys
12
12
import json
13
- import collections
13
+ from collections import defaultdict , OrderedDict
14
14
from typing import List , Set , Dict , Optional
15
15
16
16
SCRIPT_DIR = os .path .dirname (os .path .abspath (__file__ ))
@@ -65,7 +65,7 @@ def main():
65
65
#print(api_name)
66
66
filename = os .path .join (apiload .WIN32JSON_API_DIR , api_name + ".json" )
67
67
with open (filename , "r" , encoding = 'utf-8-sig' ) as file :
68
- api = json .load (file )
68
+ api = json .load (file , object_pairs_hook = OrderedDict )
69
69
constants = api ["Constants" ]
70
70
types = api ["Types" ]
71
71
functions = api ["Functions" ]
@@ -182,7 +182,7 @@ def main():
182
182
183
183
print ("searching for cycles..." )
184
184
full_type_set : Set [ApiRef ] = set ()
185
- api_cycle_type_set : Dict [ApiRef ,List [ApiRef ]] = {}
185
+ api_cycle_type_set : OrderedDict [ApiRef ,List [ApiRef ]] = {}
186
186
#self_cycle_type_set: Dict[ApiRef,List[ApiRef]] = {}
187
187
188
188
def addApiCycleType (type_set , t , cycle ):
@@ -231,7 +231,8 @@ def main():
231
231
#print("{} types have self-referential cycles".format(len(self_cycle_type_set)))
232
232
233
233
api_types_list = list (api_cycle_type_set )
234
- api_types_list .sort ()
234
+ # I don't think I need to sort anymore since moving to OrderedDict
235
+ #api_types_list.sort()
235
236
with open (os .path .join (SCRIPT_DIR , "out_cycle_types.txt" ), "w" ) as file :
236
237
for cycle_type in api_types_list :
237
238
file .write ("{}\n " .format (cycle_type ))
@@ -247,7 +248,7 @@ def main():
247
248
# NOTE: this is not all the cycles, just some of the for now
248
249
with open (os .path .join (SCRIPT_DIR , "out_cycle_types.dot" ), "w" ) as file :
249
250
file .write ("digraph type_cycles {\n " )
250
- links = collections . defaultdict (set )
251
+ links = defaultdict (set )
251
252
def addLink (links , a , b ):
252
253
link_set = links [a ]
253
254
if b not in link_set :
0 commit comments