BIE |
/home/weinberg/src/BIE/include/MethodTable.h00001 // This is really -*- C++ -*- 00002 00003 #ifndef METHOD_TABLE_H 00004 #define METHOD_TABLE_H 00005 00006 class CliArgList; 00007 class AData; 00008 #include "BIEException.h" 00009 #include "GlobalTable.h" 00010 #include <string> 00011 #include <vector> 00012 #include <map> 00013 00019 class MethodTable 00020 { 00021 private: 00022 00023 class _class_info; 00028 class _method_info 00029 { 00030 public: 00032 char *method_name; 00035 char *arg_signature; 00037 bool staticmethod; 00039 bool cli_invokable; 00041 CliArgList *alist; 00043 AData *ret; 00045 string desc; 00047 _class_info * classinfo; 00048 }; 00049 00054 class _class_info 00055 { 00056 public: 00058 char *class_name; 00060 int num_methods; 00062 bool cli_class; 00064 _method_info *methods; 00066 char *super_class; 00068 string desc; 00069 }; 00070 00072 static _class_info *classes; 00073 00075 static int num_classes; 00076 00079 static _class_info * getClassInfo(const char * classname, bool cliquery); 00080 00084 static _method_info * choose_best_method 00085 (vector<_method_info*> & possibles, string method_name, 00086 CliArgList *args, bool cliquery); 00087 00088 enum {EXACT_MATCH = 0, CONVERSION_MATCH = 1, NOT_COMPATIBLE = 2}; 00089 00092 static int get_compatibility_level(const AData * formal, 00093 const AData * actual, bool cliquery); 00094 00097 static CliArgList * coerce_arguments 00098 (CliArgList * formal_params, CliArgList * actual_params); 00099 00101 static vector<_method_info *> get_callable_methods 00102 (const char *class_name, const char *method_name, bool cliquery); 00103 00118 class _inheritance_tree 00119 { 00120 class _itnode 00121 { 00122 public: 00124 _itnode() : parent(0), level(0) {} 00125 00127 _itnode(string& n, _itnode *p, bool cli) : 00128 name(n), parent(p), cli_cls(cli) 00129 { 00130 level = p->level + 1; 00131 } 00132 00134 string name; 00135 00137 _itnode *parent; 00138 00140 bool cli_cls; 00141 00143 unsigned level; 00144 00146 map<string, _itnode*> next; 00147 00149 map<string, _itnode*> all; 00150 00151 } root; 00152 00154 void add_to_all(_itnode *new_node, _itnode *parent); 00155 00156 public: 00158 _inheritance_tree(_class_info *classes, int num_classes); 00159 00161 ~_inheritance_tree(); 00162 00164 vector<string> get_derived(string root, bool cli); 00165 00167 void print_graph(_itnode* p=0); 00168 00169 }; 00170 00171 static _inheritance_tree *the_tree; 00172 00173 public: 00174 00176 static void setType(AData *a , char typecode); 00177 00180 static AData * coerce_argument(const AData *formal_arg, const AData *actual_param); 00181 00183 class NoSuchClassException : public BIE::BIEException 00184 { 00185 public: 00187 NoSuchClassException(string classname, string sourcefilename, int sourcelinenumber); 00188 }; 00189 00191 class NoConstructorException : public BIE::BIEException 00192 { 00193 public: 00195 NoConstructorException(string classname, string sourcefilename, int sourcelinenumber); 00196 }; 00197 00199 class NoSuchMethodException : public BIE::BIEException { 00201 public: NoSuchMethodException(string classname, string methodname, string sourcefilename, int sourcelinenumber); 00202 }; 00203 00205 class ReturnTypeException : public BIE::BIEException 00206 { 00207 public: 00209 ReturnTypeException(string methodargstring, string sourcefilename, int sourcelinenumber); 00210 }; 00211 00213 class ArgumentMismatchException : public BIE::BIEException 00214 { 00215 public: 00217 ArgumentMismatchException(string methodname, string sourcefilename, int sourcelinenumber); 00218 }; 00219 00221 class AmbiguousCallException : public BIE::BIEException 00222 { 00223 public: 00225 AmbiguousCallException(string methodname, string sourcefilename, int sourcelinenumber); 00226 }; 00227 00229 static void initialize(string& method_string); 00230 00244 static void invoke_constructor 00245 (const char *class_name, CliArgList *args, AData *return_value, bool cliinvocation); 00246 00265 static void invoke_method(const char *class_name, const char *method_name, 00266 CliArgList *args, AData *return_value, 00267 void *object, bool cliinvocation, 00268 bool staticmethod = false); 00269 00274 static void invoke_static(const char *class_name, const char *method_name, 00275 CliArgList *args, AData *return_value, 00276 bool cliinvocation); 00277 00281 static bool is_compatible_type(const AData *a1, const AData *a2, 00282 bool cliquery); 00283 00286 static bool is_compatible_return(const AData *a1, const AData *a2, 00287 bool cliquery); 00288 00290 static bool is_compatible_class 00291 (const char *class_to_match, const char *actual_class_name, bool cliquery); 00292 00296 static string get_class_desc(const char *class_name, bool cliquery); 00297 00301 static string get_method_desc 00302 (const char *class_name, const char *method_name, bool cliquery); 00303 00306 static string get_method_arg_string(_method_info & m); 00307 00310 static const char* get_super_classname(const char *classname, bool cliquery); 00311 00313 static void print_classes(); 00314 00317 static void print_methods(const char *class_name); 00318 00320 static bool isValidClassName(const char * class_name, bool cliquery); 00321 00323 static vector<string> get_derived(string root, bool cli_only=false); 00324 00326 static void print_graph(); 00327 00328 }; 00329 00330 #endif Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU. Documentation generated at Fri Mar 26 00:35:10 2010 by
|