File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ import clang .cindex
2+ import json
3+
4+ clang .cindex .Config .set_library_path (
5+ "/Applications/Xcode.app/Contents/Developer/Toolchains/"
6+ "XcodeDefault.xctoolchain/usr/lib/"
7+ )
8+ index = clang .cindex .Index .create ()
9+
10+
11+ def extract (cursor ):
12+ data = {"Name" : cursor .spelling }
13+ if cursor .kind == clang .cindex .CursorKind .OBJC_INTERFACE_DECL :
14+ data ["Type" ] = "Interface"
15+ elif cursor .kind in [
16+ clang .cindex .CursorKind .OBJC_INSTANCE_METHOD_DECL ,
17+ clang .cindex .CursorKind .OBJC_CLASS_METHOD_DECL ,
18+ ]:
19+ data ["Type" ] = "Method"
20+ elif cursor .kind == clang .cindex .CursorKind .OBJC_PROPERTY_DECL :
21+ data ["Type" ] = "Property"
22+ else :
23+ return None
24+ children = [extract (c ) for c in cursor .get_children ()]
25+ children = [c for c in children if c is not None ]
26+ if children :
27+ data ["Children" ] = children
28+ return data
29+
30+
31+ def main ():
32+ tu = index .parse (
33+ "/Applications/Xcode.app/Contents/Developer/Platforms/"
34+ "iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/"
35+ "Library/Frameworks/UIKit.framework/Headers/UIKit.h"
36+ )
37+ metadata = extract (tu .cursor )
38+ with open ("metadata.json" , "w" ) as f :
39+ json .dump (metadata , f , indent = 2 )
40+
41+
42+ if __name__ == "__main__" :
43+ main ()
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ build==0.10.0
77certifi == 2023.5.7
88chardet == 5.1.0
99charset-normalizer == 3.1.0
10+ clang == 16.0.1.1
1011click == 8.1.3
1112contourpy == 1.0.7
1213cookiecutter == 2.1.1
You can’t perform that action at this time.
0 commit comments