File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ SELECT * FROM globals WHERE is_volatile
5454 | bases_count | Integer | Number of bases for this class |
5555 | methods_count | Integer | Number of methods declarations |
5656 | fields_count | Integer | Number of fields declarations |
57+ | size_of | Integer | Class Size in bytes |
5758 | file | Text | File path |
5859 | line | Integer | Line at the file path |
5960 | column | Integer | Column at the file path |
Original file line number Diff line number Diff line change @@ -131,6 +131,11 @@ fn select_classes(
131131 continue ;
132132 }
133133
134+ if field_name == "size_of" {
135+ values. push ( Value :: Integer ( class. size_of ) ) ;
136+ continue ;
137+ }
138+
134139 if field_name == "file" {
135140 values. push ( Value :: Text ( class. location . file . to_string ( ) ) ) ;
136141 continue ;
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ lazy_static! {
3131 map. insert( "fields_count" , DataType :: Integer ) ;
3232 map. insert( "constants_count" , DataType :: Integer ) ;
3333
34+ map. insert( "size_of" , DataType :: Integer ) ;
35+
3436 // Source code location columns
3537 map. insert( "file" , DataType :: Text ) ;
3638 map. insert( "line" , DataType :: Integer ) ;
@@ -51,6 +53,7 @@ lazy_static! {
5153 "bases_count" ,
5254 "methods_count" ,
5355 "fields_count" ,
56+ "size_of" ,
5457 "line" ,
5558 "column" ,
5659 "offset" ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ pub struct ClassNode {
1212 pub name : String ,
1313 pub attributes : ClassAttributes ,
1414 pub is_struct : bool ,
15+ pub size_of : i64 ,
1516 pub location : location:: SourceLocation ,
1617}
1718
@@ -71,6 +72,9 @@ extern "C" fn visit_class_or_struct_declaration(
7172 let classes = & mut * ( data as * mut Vec < ClassNode > ) ;
7273 let is_struct = cursor_kind == CXCursor_StructDecl ;
7374
75+ let class_type = clang_getCursorType ( cursor) ;
76+ let size_of = clang_Type_getSizeOf ( class_type) / 8 ;
77+
7478 let mut attributes = ClassAttributes :: default ( ) ;
7579 let attributes_pointer = & mut attributes as * mut ClassAttributes as * mut c_void ;
7680 clang_visitChildren ( cursor, visit_class_attributes, attributes_pointer) ;
@@ -79,6 +83,7 @@ extern "C" fn visit_class_or_struct_declaration(
7983 name : class_name. to_string ( ) ,
8084 attributes,
8185 is_struct,
86+ size_of,
8287 location,
8388 } ) ;
8489
You can’t perform that action at this time.
0 commit comments