|
|
@ -35,14 +35,14 @@ let fields_superclass tenv interface_decl_info =
|
|
|
|
| _ -> [])
|
|
|
|
| _ -> [])
|
|
|
|
| _ -> []
|
|
|
|
| _ -> []
|
|
|
|
|
|
|
|
|
|
|
|
let build_sil_field qual_type_to_sil_type tenv field_name qual_type prop_attributes =
|
|
|
|
let build_sil_field qual_type_to_sil_type tenv class_tname field_name qual_type prop_attributes =
|
|
|
|
let prop_atts = List.map ~f:Clang_ast_j.string_of_property_attribute prop_attributes in
|
|
|
|
let prop_atts = List.map ~f:Clang_ast_j.string_of_property_attribute prop_attributes in
|
|
|
|
let annotation_from_type t =
|
|
|
|
let annotation_from_type t =
|
|
|
|
match t.Typ.desc with
|
|
|
|
match t.Typ.desc with
|
|
|
|
| Typ.Tptr (_, Typ.Pk_objc_weak) -> [Config.weak]
|
|
|
|
| Typ.Tptr (_, Typ.Pk_objc_weak) -> [Config.weak]
|
|
|
|
| Typ.Tptr (_, Typ.Pk_objc_unsafe_unretained) -> [Config.unsafe_unret]
|
|
|
|
| Typ.Tptr (_, Typ.Pk_objc_unsafe_unretained) -> [Config.unsafe_unret]
|
|
|
|
| _ -> [] in
|
|
|
|
| _ -> [] in
|
|
|
|
let fname = CGeneral_utils.mk_class_field_name field_name in
|
|
|
|
let fname = CGeneral_utils.mk_class_field_name class_tname field_name.Clang_ast_t.ni_name in
|
|
|
|
let typ = qual_type_to_sil_type tenv qual_type in
|
|
|
|
let typ = qual_type_to_sil_type tenv qual_type in
|
|
|
|
let item_annotations = match prop_atts with
|
|
|
|
let item_annotations = match prop_atts with
|
|
|
|
| [] ->
|
|
|
|
| [] ->
|
|
|
@ -55,11 +55,11 @@ let build_sil_field qual_type_to_sil_type tenv field_name qual_type prop_attribu
|
|
|
|
fname, typ, item_annotations
|
|
|
|
fname, typ, item_annotations
|
|
|
|
|
|
|
|
|
|
|
|
(* Given a list of declarations in an interface returns a list of fields *)
|
|
|
|
(* Given a list of declarations in an interface returns a list of fields *)
|
|
|
|
let rec get_fields qual_type_to_sil_type tenv decl_list =
|
|
|
|
let rec get_fields qual_type_to_sil_type tenv class_tname decl_list =
|
|
|
|
let open Clang_ast_t in
|
|
|
|
let open Clang_ast_t in
|
|
|
|
let add_field name_info (qt : qual_type) attributes decl_list' =
|
|
|
|
let add_field name_info (qt : qual_type) attributes decl_list' =
|
|
|
|
let fields = get_fields qual_type_to_sil_type tenv decl_list' in
|
|
|
|
let fields = get_fields qual_type_to_sil_type tenv class_tname decl_list' in
|
|
|
|
let field_tuple = build_sil_field qual_type_to_sil_type tenv
|
|
|
|
let field_tuple = build_sil_field qual_type_to_sil_type tenv class_tname
|
|
|
|
name_info qt attributes in
|
|
|
|
name_info qt attributes in
|
|
|
|
CGeneral_utils.append_no_duplicates_fields [field_tuple] fields in
|
|
|
|
CGeneral_utils.append_no_duplicates_fields [field_tuple] fields in
|
|
|
|
match decl_list with
|
|
|
|
match decl_list with
|
|
|
@ -70,11 +70,11 @@ let rec get_fields qual_type_to_sil_type tenv decl_list =
|
|
|
|
| Some (ObjCIvarDecl (_, name_info, qual_type, _, _)) ->
|
|
|
|
| Some (ObjCIvarDecl (_, name_info, qual_type, _, _)) ->
|
|
|
|
let attributes = obj_c_property_decl_info.Clang_ast_t.opdi_property_attributes in
|
|
|
|
let attributes = obj_c_property_decl_info.Clang_ast_t.opdi_property_attributes in
|
|
|
|
add_field name_info qual_type attributes decl_list'
|
|
|
|
add_field name_info qual_type attributes decl_list'
|
|
|
|
| _ -> get_fields qual_type_to_sil_type tenv decl_list')
|
|
|
|
| _ -> get_fields qual_type_to_sil_type tenv class_tname decl_list')
|
|
|
|
| ObjCIvarDecl (_, name_info, qual_type, _, _) :: decl_list' ->
|
|
|
|
| ObjCIvarDecl (_, name_info, qual_type, _, _) :: decl_list' ->
|
|
|
|
add_field name_info qual_type [] decl_list'
|
|
|
|
add_field name_info qual_type [] decl_list'
|
|
|
|
| _ :: decl_list' ->
|
|
|
|
| _ :: decl_list' ->
|
|
|
|
get_fields qual_type_to_sil_type tenv decl_list'
|
|
|
|
get_fields qual_type_to_sil_type tenv class_tname decl_list'
|
|
|
|
|
|
|
|
|
|
|
|
(* Add potential extra fields defined only in the implementation of the class *)
|
|
|
|
(* Add potential extra fields defined only in the implementation of the class *)
|
|
|
|
(* to the info given in the interface. Update the tenv accordingly. *)
|
|
|
|
(* to the info given in the interface. Update the tenv accordingly. *)
|
|
|
@ -95,9 +95,8 @@ let modelled_fields_in_classes =
|
|
|
|
let modelled_field class_name_info =
|
|
|
|
let modelled_field class_name_info =
|
|
|
|
let modelled_field_in_class res (class_name, field_name, typ) =
|
|
|
|
let modelled_field_in_class res (class_name, field_name, typ) =
|
|
|
|
if String.equal class_name class_name_info.Clang_ast_t.ni_name then
|
|
|
|
if String.equal class_name class_name_info.Clang_ast_t.ni_name then
|
|
|
|
let class_name_qualified = class_name_info.Clang_ast_t.ni_qual_name in
|
|
|
|
let class_tname = Typ.Name.Objc.from_string class_name in
|
|
|
|
let field_name_qualified = CAst_utils.make_qual_name_decl class_name_qualified field_name in
|
|
|
|
let name = Typ.Fieldname.Clang.from_class_name class_tname field_name in
|
|
|
|
let name = CGeneral_utils.mk_class_field_name field_name_qualified in
|
|
|
|
|
|
|
|
(name, typ, Annot.Item.empty) :: res
|
|
|
|
(name, typ, Annot.Item.empty) :: res
|
|
|
|
else res in
|
|
|
|
else res in
|
|
|
|
List.fold ~f:modelled_field_in_class ~init:[] modelled_fields_in_classes
|
|
|
|
List.fold ~f:modelled_field_in_class ~init:[] modelled_fields_in_classes
|
|
|
|