1 #ifndef ISL_INTERFACE_GENERATOR_H
2 #define ISL_INTERFACE_GENERATOR_H
8 #include <clang/AST/Decl.h>
11 using namespace clang
;
13 /* isl_class collects all constructors and methods for an isl "class".
14 * "name" is the name of the class.
15 * "type" is the declaration that introduces the type.
16 * "methods" contains the set of methods, grouped by method name.
17 * "fn_to_str" is a reference to the *_to_str method of this class, if any.
18 * "fn_copy" is a reference to the *_copy method of this class, if any.
19 * "fn_free" is a reference to the *_free method of this class, if any.
24 set
<FunctionDecl
*> constructors
;
25 map
<string
, set
<FunctionDecl
*> > methods
;
26 FunctionDecl
*fn_to_str
;
27 FunctionDecl
*fn_copy
;
28 FunctionDecl
*fn_free
;
31 /* Base class for interface generators.
35 map
<string
,isl_class
> classes
;
36 map
<string
, FunctionDecl
*> functions_by_name
;
39 generator(set
<RecordDecl
*> &exported_types
,
40 set
<FunctionDecl
*> exported_functions
,
41 set
<FunctionDecl
*> functions
);
43 virtual void generate() = 0;
44 virtual ~generator() {};
47 void print_class_header(const isl_class
&clazz
, const string
&name
,
48 const vector
<string
> &super
);
49 string
drop_type_suffix(string name
, FunctionDecl
*method
);
50 void die(const char *msg
) __attribute__((noreturn
));
51 void die(string msg
) __attribute__((noreturn
));
52 vector
<string
> find_superclasses(RecordDecl
*decl
);
53 bool is_overload(Decl
*decl
);
54 bool is_constructor(Decl
*decl
);
55 bool takes(Decl
*decl
);
56 bool keeps(Decl
*decl
);
57 bool gives(Decl
*decl
);
58 isl_class
*method2class(FunctionDecl
*fd
);
59 bool is_isl_ctx(QualType type
);
60 bool first_arg_is_isl_ctx(FunctionDecl
*fd
);
61 bool is_isl_type(QualType type
);
62 bool is_isl_bool(QualType type
);
63 bool is_isl_stat(QualType type
);
64 bool is_long(QualType type
);
65 bool is_callback(QualType type
);
66 bool is_string(QualType type
);
67 bool is_static(const isl_class
&clazz
, FunctionDecl
*method
);
68 string
extract_type(QualType type
);
69 FunctionDecl
*find_by_name(const string
&name
, bool required
);
72 #endif /* ISL_INTERFACE_GENERATOR_H */