1 #include <set> 2 #include <clang/AST/Decl.h> 3 #include "generator.h" 4 5 using namespace std; 6 using namespace clang; 7 8 class python_generator : public generator { 9 private: 10 set<string> done; 11 12 public: 13 python_generator(set<RecordDecl *> &exported_types, 14 set<FunctionDecl *> exported_functions, 15 set<FunctionDecl *> functions) : 16 generator(exported_types, exported_functions, functions) {} 17 18 virtual void generate(); 19 20 private: 21 void print(const isl_class &clazz); 22 void print_method_header(bool is_static, const string &name, int n_arg); 23 void print_class_header(const isl_class &clazz, const string &name, 24 const vector<string> &super); 25 void print_type_check(const string &type, int pos, bool upcast, 26 const string &super, const string &name, int n); 27 void print_callback(QualType type, int arg); 28 void print_arg_in_call(FunctionDecl *fd, int arg, int skip); 29 void print_argtypes(FunctionDecl *fd); 30 void print_method_return(FunctionDecl *method); 31 void print_restype(FunctionDecl *fd); 32 void print(map<string, isl_class> &classes, set<string> &done); 33 void print_constructor(const isl_class &clazz, FunctionDecl *method); 34 void print_representation(const isl_class &clazz, 35 const string &python_name); 36 void print_method_type(FunctionDecl *fd); 37 void print_method_types(const isl_class &clazz); 38 void print_method(const isl_class &clazz, FunctionDecl *method, 39 vector<string> super); 40 void print_method_overload(const isl_class &clazz, 41 FunctionDecl *method); 42 void print_method(const isl_class &clazz, const string &fullname, 43 const set<FunctionDecl *> &methods, vector<string> super); 44 45 }; 46