Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include <list>
00028 #include <map>
00029 #include <string>
00030
00031 #include "Cell.h"
00032 #include "oct-map.h"
00033 #include "defun-dld.h"
00034 #include "ov.h"
00035 #include "ov-fcn.h"
00036 #include "ov-typeinfo.h"
00037 #include "pager.h"
00038 #include "parse.h"
00039 #include "symtab.h"
00040 #include "variables.h"
00041
00042 DEFUN_DLD (__dispatch__, args, nargout,
00043 "Undocumented internal function")
00044 {
00045 octave_value retval;
00046
00047 int nargin = args.length ();
00048
00049 std::string f, r, t;
00050
00051 if (nargin > 0 && nargin < 4)
00052 {
00053 if (nargin > 0)
00054 {
00055 f = args(0).string_value ();
00056
00057 if (error_state)
00058 {
00059 error ("__dispatch__: first argument must be a function name");
00060 return retval;
00061 }
00062 }
00063
00064 if (nargin > 1)
00065 {
00066 r = args(1).string_value ();
00067
00068 if (error_state)
00069 {
00070 error ("__dispatch__: second argument must be a function name");
00071 return retval;
00072 }
00073 }
00074
00075 if (nargin > 2)
00076 {
00077 t = args(2).string_value ();
00078
00079 if (error_state)
00080 {
00081 error ("__dispatch__: third argument must be a type name");
00082 return retval;
00083 }
00084 }
00085
00086 if (nargin == 1)
00087 {
00088 if (nargout > 0)
00089 {
00090 symbol_table::fcn_info::dispatch_map_type dm
00091 = symbol_table::get_dispatch (f);
00092
00093 size_t len = dm.size ();
00094
00095 Cell type_field (len, 1);
00096 Cell name_field (len, 1);
00097
00098 symbol_table::fcn_info::dispatch_map_type::const_iterator p
00099 = dm.begin ();
00100
00101 for (size_t i = 0; i < len; i++)
00102 {
00103 type_field(i) = p->first;
00104 name_field(i) = p->second;
00105
00106 p++;
00107 }
00108
00109 octave_scalar_map m;
00110
00111 m.assign ("type", type_field);
00112 m.assign ("name", name_field);
00113
00114 retval = m;
00115 }
00116 else
00117 symbol_table::print_dispatch (octave_stdout, f);
00118 }
00119 else if (nargin == 2)
00120 {
00121 t = r;
00122 symbol_table::clear_dispatch (f, t);
00123 }
00124 else
00125 symbol_table::add_dispatch (f, t, r);
00126 }
00127 else
00128 print_usage ();
00129
00130 return retval;
00131 }
00132
00133
00134
00135
00136
00137
00138