@ -135,16 +135,16 @@ let module T = {
| Tarray t static_length /* * array type with statically fixed length */
| Tarray t static_length /* * array type with statically fixed length */
[ @@ deriving compare ]
[ @@ deriving compare ]
and name =
and name =
| CStruct Mangled . t
| CStruct QualifiedCppName . t
| CUnion Mangled . t
| CUnion QualifiedCppName . t
| CppClass Mangled . t template_spec_info
| CppClass QualifiedCppName . t template_spec_info
| JavaClass Mangled . t
| JavaClass Mangled . t
| ObjcClass Mangled . t
| ObjcClass QualifiedCppName . t
| ObjcProtocol Mangled . t
| ObjcProtocol QualifiedCppName . t
[ @@ deriving compare ]
[ @@ deriving compare ]
and template_spec_info =
and template_spec_info =
| NoTemplate
| NoTemplate
| Template ( string , list ( option t ) )
| Template ( QualifiedCppName . t , list ( option t ) )
[ @@ deriving compare ] ;
[ @@ deriving compare ] ;
let equal = [ % compare . equal : t ] ;
let equal = [ % compare . equal : t ] ;
let hash = Hashtbl . hash ;
let hash = Hashtbl . hash ;
@ -160,9 +160,17 @@ let module Name = {
| CStruct name
| CStruct name
| CUnion name
| CUnion name
| CppClass name _
| CppClass name _
| JavaClass name
| ObjcClass name
| ObjcClass name
| ObjcProtocol name = > Mangled . to_string name ;
| ObjcProtocol name = > QualifiedCppName . to_qual_string name
| JavaClass name = > Mangled . to_string name ;
let qual_name =
fun
| CStruct name
| CUnion name
| CppClass name _
| ObjcClass name
| ObjcProtocol name = > name
| JavaClass _ = > QualifiedCppName . empty ;
let to_string tname = > {
let to_string tname = > {
let prefix =
let prefix =
fun
fun
@ -192,8 +200,9 @@ let module Name = {
| _ = > false
| _ = > false
} ;
} ;
let module C = {
let module C = {
let from_string name_str = > CStruct ( Mangled . from_string name_str ) ;
let from_qual_name qual_name = > CStruct qual_name ;
let union_from_string name_str = > CUnion ( Mangled . from_string name_str ) ;
let from_string name_str = > QualifiedCppName . of_qual_string name_str | > from_qual_name ;
let union_from_qual_name qual_name = > CUnion qual_name ;
} ;
} ;
let module Java = {
let module Java = {
let from_string name_str = > JavaClass ( Mangled . from_string name_str ) ;
let from_string name_str = > JavaClass ( Mangled . from_string name_str ) ;
@ -212,17 +221,16 @@ let module Name = {
let java_lang_cloneable = from_string " java.lang.Cloneable " ;
let java_lang_cloneable = from_string " java.lang.Cloneable " ;
} ;
} ;
let module Cpp = {
let module Cpp = {
let from_string name_str = > CppClass ( Mangled . from_string name_str ) NoTemplate ;
let from_qual_name template_spec_info qual_name = > CppClass qual_name template_spec_info ;
let from_template_string template_spec_info name = >
CppClass ( Mangled . from_string name ) template_spec_info ;
let is_class =
let is_class =
fun
fun
| CppClass _ = > true
| CppClass _ = > true
| _ = > false ;
| _ = > false ;
} ;
} ;
let module Objc = {
let module Objc = {
let from_string name_str = > ObjcClass ( Mangled . from_string name_str ) ;
let from_qual_name qual_name = > ObjcClass qual_name ;
let protocol_from_string name_str = > ObjcProtocol ( Mangled . from_string name_str ) ;
let from_string name_str = > QualifiedCppName . of_qual_string name_str | > from_qual_name ;
let protocol_from_qual_name qual_name = > ObjcProtocol qual_name ;
let is_class =
let is_class =
fun
fun
| ObjcClass _ = > true
| ObjcClass _ = > true
@ -407,7 +415,7 @@ let module Procname = {
[ @@ deriving compare ] ;
[ @@ deriving compare ] ;
/* * Type of c procedure names. */
/* * Type of c procedure names. */
type c = { name : string , mangled : option string , template_args : template_spec_info }
type c = { name : QualifiedCppName . t , mangled : option string , template_args : template_spec_info }
[ @@ deriving compare ] ;
[ @@ deriving compare ] ;
type objc_cpp_method_kind =
type objc_cpp_method_kind =
| CPPMethod ( option string ) /* * with mangling */
| CPPMethod ( option string ) /* * with mangling */
@ -492,12 +500,13 @@ let module Procname = {
| None = > ( None , package_classname )
| None = > ( None , package_classname )
} ;
} ;
let split_typename typename = > split_classname ( Name . name typename ) ;
let split_typename typename = > split_classname ( Name . name typename ) ;
let c ( name : string ) ( mangled : string ) ( template_args : template_spec_info ) = > {
let c ( name : QualifiedCppName . t ) ( mangled : string ) ( template_args : template_spec_info ) = > {
name ,
name ,
mangled : Some mangled ,
mangled : Some mangled ,
template_args
template_args
} ;
} ;
let from_string_c_fun ( name : string ) = > C { name , mangled : None , template_args : NoTemplate } ;
let from_string_c_fun ( name : string ) = >
C { name : QualifiedCppName . of_qual_string name , mangled : None , template_args : NoTemplate } ;
let java class_name return_type method_name parameters kind = > {
let java class_name return_type method_name parameters kind = > {
class_name ,
class_name ,
return_type ,
return_type ,
@ -576,7 +585,7 @@ let module Procname = {
let get_method =
let get_method =
fun
fun
| ObjC_Cpp name = > name . method_name
| ObjC_Cpp name = > name . method_name
| C { name } = > name
| C { name } = > QualifiedCppName . to_qual_string name
| Block name = > name
| Block name = > name
| Java j = > j . method_name
| Java j = > j . method_name
| Linters_dummy_method = > " Linters_dummy_method " ;
| Linters_dummy_method = > " Linters_dummy_method " ;
@ -783,15 +792,19 @@ let module Procname = {
} ;
} ;
let get_global_name_of_initializer =
let get_global_name_of_initializer =
fun
fun
| C { name } when String . is_prefix prefix :: Config . clang_initializer_prefix name = > {
| C { name }
when
String . is_prefix
prefix :: Config . clang_initializer_prefix ( QualifiedCppName . to_qual_string name ) = > {
let name_str = QualifiedCppName . to_qual_string name ;
let prefix_len = String . length Config . clang_initializer_prefix ;
let prefix_len = String . length Config . clang_initializer_prefix ;
Some ( String . sub name pos :: prefix_len len :: ( String . length name - prefix_len ) )
Some ( String . sub name _str pos :: prefix_len len :: ( String . length name _str - prefix_len ) )
}
}
| _ = > None ;
| _ = > None ;
/* * to_string for C_function type */
/* * to_string for C_function type */
let to_readable_string ( c1 , c2 ) verbose = > {
let to_readable_string ( c1 , c2 ) verbose = > {
let plain = c1 ;
let plain = QualifiedCppName . to_qual_string c1 ;
if verbose {
if verbose {
switch c2 {
switch c2 {
| None = > plain
| None = > plain
@ -884,12 +897,10 @@ let module Procname = {
/* * Pretty print a set of proc names */
/* * Pretty print a set of proc names */
let pp_set fmt set = > Set . iter ( fun pname = > F . fprintf fmt " %a " pp pname ) set ;
let pp_set fmt set = > Set . iter ( fun pname = > F . fprintf fmt " %a " pp pname ) set ;
let objc_cpp_get_class_qualifiers objc_cpp = > QualifiedCppName . of_qual_string (
let objc_cpp_get_class_qualifiers objc_cpp = > Name . qual_name objc_cpp . class_name ;
Name . name objc_cpp . class_name
) ;
let get_qualifiers pname = >
let get_qualifiers pname = >
switch pname {
switch pname {
| C { name } = > QualifiedCppName . of_qual_string name
| C { name } = > name
| ObjC_Cpp objc_cpp = >
| ObjC_Cpp objc_cpp = >
objc_cpp_get_class_qualifiers objc_cpp | >
objc_cpp_get_class_qualifiers objc_cpp | >
QualifiedCppName . append_qualifier qual :: objc_cpp . method_name
QualifiedCppName . append_qualifier qual :: objc_cpp . method_name