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(SourceManager &SM, set<RecordDecl *> &exported_types, 14 set<FunctionDecl *> exported_functions, 15 set<FunctionDecl *> functions) : 16 generator(SM, 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_copy(QualType type); 28 void print_callback(ParmVarDecl *param, int arg); 29 void print_arg_in_call(FunctionDecl *fd, int arg, int skip); 30 void print_argtypes(FunctionDecl *fd); 31 void print_method_return(FunctionDecl *method); 32 void print_restype(FunctionDecl *fd); 33 void print(map<string, isl_class> &classes, set<string> &done); 34 void print_constructor(const isl_class &clazz, FunctionDecl *method); 35 void print_representation(const isl_class &clazz, 36 const string &python_name); 37 void print_method_type(FunctionDecl *fd); 38 void print_method_types(const isl_class &clazz); 39 void print_method(const isl_class &clazz, FunctionDecl *method, 40 vector<string> super); 41 void print_method_overload(const isl_class &clazz, 42 FunctionDecl *method); 43 void print_method(const isl_class &clazz, const string &fullname, 44 const set<FunctionDecl *> &methods, vector<string> super); 45 46 }; 47