MethodTable Class Reference

MethodTable: This class is our form of a reflective meta-object. More...

#include <MethodTable.h>

Collaboration diagram for MethodTable:

List of all members.

Static Public Member Functions

static void setType (AData *a, char typecode)
 Set the type for this datum.
static ADatacoerce_argument (const AData *formal_arg, const AData *actual_param)
 Returns a new AData object that has had value coerced to formal value if this was required.
static void initialize (string &method_string)
 Initializes the class and method info by parsing the method string.
static void invoke_constructor (const char *class_name, CliArgList *args, AData *return_value, bool cliinvocation)
 Dynamically creates a new object of the specified class by invoking the constructor with matching arguments.
static void invoke_method (const char *class_name, const char *method_name, CliArgList *args, AData *return_value, void *object, bool cliinvocation, bool staticmethod=false)
 Dynamically calls a method on the specified object.
static void invoke_static (const char *class_name, const char *method_name, CliArgList *args, AData *return_value, bool cliinvocation)
 Dynamically calls a static method (a method call without an object instance).
static bool is_compatible_type (const AData *a1, const AData *a2, bool cliquery)
 Returns true if the type of the second argument is compatible with or can be converted to the type of the first.
static bool is_compatible_return (const AData *a1, const AData *a2, bool cliquery)
 Returns true if the type of the second argument is compatible with or can be converted to the type of the first.
static bool is_compatible_class (const char *class_to_match, const char *actual_class_name, bool cliquery)
 Returns true if the first class is a superclass of the second class.
static string get_class_desc (const char *class_name, bool cliquery)
 This returns a description of the class if the class exists.
static string get_method_desc (const char *class_name, const char *method_name, bool cliquery)
 This returns a description of the method if the class and method exist.
static string get_method_arg_string (_method_info &m)
 Fills in a string with a description of the arguments to a methog or constructor.
static const char * get_super_classname (const char *classname, bool cliquery)
 Returns the name of the superclass of the specified class or returns NULL if there is no superclass.
static void print_classes ()
 Used by CLI, this prints a list of the classes available in CLI.
static void print_methods (const char *class_name)
 Used by CLI, this prints a list of the methods available in CLI for the specified class.
static bool isValidClassName (const char *class_name, bool cliquery)
 Returns true if a classname is valid.
static vector< string > get_derived (string root, bool cli_only=false)
 Used by CLI; get list of children of a particular parent.
static void print_graph ()
 Used by CLI; print entire inheritance tree.

Classes

class  _class_info
 A class that holds information about a class accessible through the reflection mechanism.
class  _inheritance_tree
 This class creats an inheritance tree from the class list to be used by the CLI for user help.
class  _method_info
 A class that holds information about a method accesible through the reflection mechanism.
class  AmbiguousCallException
 Parser does not know which method to call. More...
class  ArgumentMismatchException
 Argument does not match defined type. More...
class  NoConstructorException
 I don't have a constructor! More...
class  NoSuchClassException
 Class has not been defined. More...
class  NoSuchMethodException
 CLI does not know about the requested method. More...
class  ReturnTypeException
 Incorrect return type. More...


Detailed Description

MethodTable: This class is our form of a reflective meta-object.

It holds details of classes and methods, and can be used to dynamically invoke constructors and methods at run time.


Member Function Documentation

static AData* MethodTable::coerce_argument ( const AData formal_arg,
const AData actual_param 
) [static]

Returns a new AData object that has had value coerced to formal value if this was required.

static void MethodTable::invoke_constructor ( const char *  class_name,
CliArgList args,
AData return_value,
bool  cliinvocation 
) [static]

Dynamically creates a new object of the specified class by invoking the constructor with matching arguments.

This method matches argument lists using the same preferences as C++. Here are the steps taken:

  1. Search class's list of methods for methods named after the class. Methods in superclasses are not considered.
  2. Gathers list of constructors by looking at names
  3. Chooses best match using C++ rules, e.g. prefer Con(int) to Con(double) when argument is an int or bool.

static void MethodTable::invoke_method ( const char *  class_name,
const char *  method_name,
CliArgList args,
AData return_value,
void *  object,
bool  cliinvocation,
bool  staticmethod = false 
) [static]

Dynamically calls a method on the specified object.

This method matches argument lists using the same preferences as C++. Here are the steps taken:

  1. Search class's list of methods for methods with the same name.
  2. If there are no methods with the same name consider superclass.
  3. Chooses best match using C++ rules, e.g. prefer a(int) to a(double) when argument is an int or bool.
  4. Does not compare argument lists of methods in different class scopes - if a method is overloaded and there are others in superclass that are still to be available, they should be declared with C++'s 'using' keyword, and a stylized comment.
For more details of these preferences, see Bjarne Stroustrup's, "The C++ Programming Language", third edition, section 7.4 on overloaded Function Names, and 15.2.2 on 'using' declarations.

static void MethodTable::invoke_static ( const char *  class_name,
const char *  method_name,
CliArgList args,
AData return_value,
bool  cliinvocation 
) [static]

Dynamically calls a static method (a method call without an object instance).

Uses the same matching technique as invoke_method.

static bool MethodTable::is_compatible_return ( const AData a1,
const AData a2,
bool  cliquery 
) [static]

Returns true if the type of the second argument is compatible with or can be converted to the type of the first.

static string MethodTable::get_class_desc ( const char *  class_name,
bool  cliquery 
) [static]

This returns a description of the class if the class exists.

If calling from CLI, the class and method must be CLI accessible. Returns NULL if there is no such method or it is not accessible.

static string MethodTable::get_method_desc ( const char *  class_name,
const char *  method_name,
bool  cliquery 
) [static]

This returns a description of the method if the class and method exist.

If calling from CLI, the class and method must be CLI accessible. Returns NULL if there is no such method or it is not accessible.

static string MethodTable::get_method_arg_string ( _method_info &  m  )  [static]

Fills in a string with a description of the arguments to a methog or constructor.

static const char* MethodTable::get_super_classname ( const char *  classname,
bool  cliquery 
) [static]

Returns the name of the superclass of the specified class or returns NULL if there is no superclass.

static void MethodTable::print_methods ( const char *  class_name  )  [static]

Used by CLI, this prints a list of the methods available in CLI for the specified class.


The documentation for this class was generated from the following file:

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:12 2010 by doxygen