@ -24,53 +24,63 @@ let rec translate_one_declaration tenv cg cfg namespace dec =
let source_range = info . Clang_ast_t . di_source_range in
let source_range = info . Clang_ast_t . di_source_range in
let should_translate_enum = CLocation . should_translate_enum source_range in
let should_translate_enum = CLocation . should_translate_enum source_range in
match dec with
match dec with
| FunctionDecl ( di , name , qt , fdecl_info ) ->
| FunctionDecl ( di , name_info , qt , fdecl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
CMethod_declImpl . function_decl tenv cfg cg namespace false di name qt fdecl_info [] None CContext . ContextNoCls
CMethod_declImpl . function_decl tenv cfg cg namespace false di name qt fdecl_info [] None CContext . ContextNoCls
| TypedefDecl ( decl_info , name , opt_type , typedef_decl_info ) ->
| TypedefDecl ( decl_info , name_info , opt_type , typedef_decl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
CTypes_decl . do_typedef_declaration tenv namespace
CTypes_decl . do_typedef_declaration tenv namespace
decl_info name opt_type typedef_decl_info
decl_info name opt_type typedef_decl_info
(* Currently C/C++ record decl treated in the same way *)
(* Currently C/C++ record decl treated in the same way *)
| CXXRecordDecl ( decl_info , record_name , opt_type , decl_list , decl_context_info , record_decl_info )
| CXXRecordDecl ( decl_info , name_info , opt_type , decl_list , decl_context_info , record_decl_info )
| RecordDecl ( decl_info , record_name , opt_type , decl_list , decl_context_info , record_decl_info ) ->
| RecordDecl ( decl_info , name_info , opt_type , decl_list , decl_context_info , record_decl_info ) ->
let record_name = name_info . Clang_ast_t . ni_name in
CTypes_decl . do_record_declaration tenv namespace
CTypes_decl . do_record_declaration tenv namespace
decl_info record_name opt_type decl_list decl_context_info record_decl_info
decl_info record_name opt_type decl_list decl_context_info record_decl_info
| VarDecl ( decl_info , name , t , _ ) ->
| VarDecl ( decl_info , name_info , t , _ ) ->
let name = name_info . Clang_ast_t . ni_name in
CVar_decl . global_var_decl tenv namespace decl_info name t
CVar_decl . global_var_decl tenv namespace decl_info name t
| ObjCInterfaceDecl ( decl_info , name , decl_list , decl_context_info , obj_c_interface_decl_info ) ->
| ObjCInterfaceDecl ( decl_info , name_info , decl_list , decl_context_info , obj_c_interface_decl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
let curr_class =
let curr_class =
ObjcInterface_decl . interface_declaration tenv name decl_list obj_c_interface_decl_info in
ObjcInterface_decl . interface_declaration tenv name decl_list obj_c_interface_decl_info in
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
| ObjCProtocolDecl ( decl_info , name , decl_list , decl_context_info , obj_c_protocol_decl_info ) ->
| ObjCProtocolDecl ( decl_info , name_info , decl_list , decl_context_info , obj_c_protocol_decl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
let curr_class = ObjcProtocol_decl . protocol_decl tenv name decl_list in
let curr_class = ObjcProtocol_decl . protocol_decl tenv name decl_list in
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
| ObjCCategoryDecl ( decl_info , name , decl_list , decl_context_info , category_decl_info ) ->
| ObjCCategoryDecl ( decl_info , name_info , decl_list , decl_context_info , category_decl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
let curr_class =
let curr_class =
ObjcCategory_decl . category_decl tenv name category_decl_info decl_list in
ObjcCategory_decl . category_decl tenv name category_decl_info decl_list in
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
| ObjCCategoryImplDecl ( decl_info , name , decl_list , decl_context_info , category_impl_info ) ->
| ObjCCategoryImplDecl ( decl_info , name_info , decl_list , decl_context_info , category_impl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
let curr_class =
let curr_class =
ObjcCategory_decl . category_impl_decl tenv name decl_info category_impl_info decl_list in
ObjcCategory_decl . category_impl_decl tenv name decl_info category_impl_info decl_list in
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
| ObjCImplementationDecl ( decl_info , class_name , decl_list , decl_context_info , idi ) ->
| ObjCImplementationDecl ( decl_info , name_info , decl_list , decl_context_info , idi ) ->
let name = name_info . Clang_ast_t . ni_name in
let curr_class =
let curr_class =
ObjcInterface_decl . interface_impl_declaration tenv class_ name decl_list idi in
ObjcInterface_decl . interface_impl_declaration tenv name decl_list idi in
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
CMethod_declImpl . process_methods tenv cg cfg curr_class namespace decl_list
| EnumDecl ( decl_info , name , opt_type , decl_list , decl_context_info , enum_decl_info )
| EnumDecl ( decl_info , name _info , opt_type , decl_list , decl_context_info , enum_decl_info )
when should_translate_enum ->
when should_translate_enum ->
let name = name_info . Clang_ast_t . ni_name in
CEnum_decl . enum_decl name tenv cfg cg namespace decl_list opt_type
CEnum_decl . enum_decl name tenv cfg cg namespace decl_list opt_type
| LinkageSpecDecl ( decl_info , decl_list , decl_context_info ) ->
| LinkageSpecDecl ( decl_info , decl_list , decl_context_info ) ->
Printing . log_out " ADDING: LinkageSpecDecl decl list \n " ;
Printing . log_out " ADDING: LinkageSpecDecl decl list \n " ;
list_iter ( translate_one_declaration tenv cg cfg namespace ) decl_list
list_iter ( translate_one_declaration tenv cg cfg namespace ) decl_list
| NamespaceDecl ( decl_info , name , decl_list , decl_context_info , _ ) ->
| NamespaceDecl ( decl_info , name _info , decl_list , decl_context_info , _ ) ->
let name = ns_suffix ^ name in
let name = ns_suffix ^ name _info. Clang_ast_t . ni_name in
list_iter ( translate_one_declaration tenv cg cfg ( Some name ) ) decl_list
list_iter ( translate_one_declaration tenv cg cfg ( Some name ) ) decl_list
| EmptyDecl _ ->
| EmptyDecl _ ->
Printing . log_out " Passing from EmptyDecl. Treated as skip \n " ;
Printing . log_out " Passing from EmptyDecl. Treated as skip \n " ;
@ -82,7 +92,8 @@ let preprocess_one_declaration tenv cg cfg dec =
let info = Clang_ast_proj . get_decl_tuple dec in
let info = Clang_ast_proj . get_decl_tuple dec in
CLocation . update_curr_file info ;
CLocation . update_curr_file info ;
match dec with
match dec with
| FunctionDecl ( di , name , qt , fdecl_info ) ->
| FunctionDecl ( di , name_info , qt , fdecl_info ) ->
let name = name_info . Clang_ast_t . ni_name in
ignore ( CMethod_declImpl . create_function_signature di fdecl_info name qt false None )
ignore ( CMethod_declImpl . create_function_signature di fdecl_info name qt false None )
| _ -> ()
| _ -> ()