@@ -16,6 +16,7 @@ from typing import List, Set, Dict, Optional
16
16
SCRIPT_DIR = os .path .dirname (os .path .abspath (__file__ ))
17
17
18
18
from apiref import ApiRef
19
+ import apiload
19
20
20
21
def getApiRefTopLevelType (type_obj ):
21
22
parents = type_obj ["Parents" ]
@@ -56,29 +57,13 @@ def isAnonType(type_name):
56
57
return type_name .endswith ("_e__Struct" ) or type_name .endswith ("_e__Union" )
57
58
58
59
def main ():
59
- win32json_branch = "10.0.19041.202-preview"
60
- win32json_sha = "7164f4ce9fe17b7c5da3473eed26886753ce1173"
61
-
62
- win32json = os .path .join (SCRIPT_DIR , "win32json" )
63
- if not os .path .exists (win32json ):
64
- print ("Error: missing '{}'" .format (win32json ))
65
- print ("Clone it with:" )
66
- print (" git clone https://github.com/marlersoft/win32json {} -b {} && git -C {} checkout {} -b for_win32_transform" .format (win32json , win32json_branch , win32json , win32json_sha ))
67
-
68
- api_dir = os .path .join (win32json , "api" )
69
-
70
- def getApiName (basename : str ) -> str :
71
- if not basename .endswith (".json" ):
72
- sys .exit ("found a non-json file '{}' in directory '{}'" .format (basename , api_dir ))
73
- return basename [:- 5 ]
74
- apis = [getApiName (basename ) for basename in os .listdir (api_dir )]
75
- apis .sort ()
60
+ apis = apiload .loadSortedList ()
76
61
77
62
api_direct_type_refs_table : Dict [str ,ApiTypeNameToApiRefMap ] = {}
78
63
print ("loading types..." )
79
64
for api_name in apis :
80
65
#print(api_name)
81
- filename = os .path .join (api_dir , api_name + ".json" )
66
+ filename = os .path .join (apiload . WIN32JSON_API_DIR , api_name + ".json" )
82
67
with open (filename , "r" , encoding = 'utf-8-sig' ) as file :
83
68
api = json .load (file )
84
69
constants = api ["Constants" ]
@@ -165,7 +150,7 @@ def main():
165
150
166
151
print ("types verified" )
167
152
168
- out_direct_deps_filename = "out-direct-deps .txt"
153
+ out_direct_deps_filename = "out_direct_deps .txt"
169
154
print ("generating {}..." .format (out_direct_deps_filename ))
170
155
with open (os .path .join (SCRIPT_DIR , out_direct_deps_filename ), "w" ) as file :
171
156
for api in apis :
@@ -176,7 +161,7 @@ def main():
176
161
file .write (" {}\n " .format (ref ))
177
162
178
163
179
- out_recursive_deps_filename = "out-recursive-deps .txt"
164
+ out_recursive_deps_filename = "out_recursive_deps .txt"
180
165
print ("calculating recursive type references (will store in {})..." .format (out_recursive_deps_filename ))
181
166
api_recursive_type_refs_table : Dict [str ,dict [str ,Set [ApiRef ]]] = {}
182
167
with open (os .path .join (SCRIPT_DIR , out_recursive_deps_filename ), "w" ) as file :
@@ -207,7 +192,7 @@ def main():
207
192
else :
208
193
type_set [t ] = cycle
209
194
210
- with open (os .path .join (SCRIPT_DIR , "out-cycles .txt" ), "w" ) as file :
195
+ with open (os .path .join (SCRIPT_DIR , "out_cycles .txt" ), "w" ) as file :
211
196
for api in apis :
212
197
#print("API: {}".format(api))
213
198
table = api_recursive_type_refs_table [api ]
@@ -247,20 +232,20 @@ def main():
247
232
248
233
api_types_list = list (api_cycle_type_set )
249
234
api_types_list .sort ()
250
- with open (os .path .join (SCRIPT_DIR , "out-cycle-types .txt" ), "w" ) as file :
235
+ with open (os .path .join (SCRIPT_DIR , "out_cycle_types .txt" ), "w" ) as file :
251
236
for cycle_type in api_types_list :
252
237
file .write ("{}\n " .format (cycle_type ))
253
238
for t in api_cycle_type_set [cycle_type ]:
254
239
file .write (" {}\n " .format (t ))
255
- with open (os .path .join (SCRIPT_DIR , "out-cycle-types .py" ), "w" ) as file :
240
+ with open (os .path .join (SCRIPT_DIR , "out_cycle_types .py" ), "w" ) as file :
256
241
file .write ("from apiref import ApiRef\n " )
257
242
file .write ("CYCLE_TYPES = {\n " )
258
243
for cycle_type in api_types_list :
259
244
file .write (" ApiRef(\" {}\" , \" {}\" ),\n " .format (cycle_type .api , cycle_type .name ))
260
245
file .write ("}\n " )
261
246
262
247
# NOTE: this is not all the cycles, just some of the for now
263
- with open (os .path .join (SCRIPT_DIR , "out-cycle-types .dot" ), "w" ) as file :
248
+ with open (os .path .join (SCRIPT_DIR , "out_cycle_types .dot" ), "w" ) as file :
264
249
file .write ("digraph type_cycles {\n " )
265
250
links = collections .defaultdict (set )
266
251
def addLink (links , a , b ):
@@ -274,7 +259,7 @@ def main():
274
259
for i in range (1 , len (cycle )):
275
260
addLink (links , cycle [i - 1 ], cycle [i ])
276
261
file .write ("}\n " )
277
- #with open(os.path.join(SCRIPT_DIR, "out-self-cycle-types .txt"), "w") as file:
262
+ #with open(os.path.join(SCRIPT_DIR, "out_self_cycle_types .txt"), "w") as file:
278
263
# types_list = list(self_cycle_type_set)
279
264
# types_list.sort()
280
265
# for cycle_type in types_list:
0 commit comments