26 #if defined (HAVE_CONFIG_H)
61 if (file_name.empty ())
74 std::string class_name;
78 if (pos != std::string::npos)
80 std::string tmp = dir_name.substr (pos+1);
83 class_name = tmp.substr (1);
102 std::string file_name = lp.
find_method (name, name, dir_name, package_name);
104 if (! file_name.empty ())
117 class_constructors[name] = retval;
118 class_methods[name] = retval;
138 retval = maybe_cdef_ctor;
140 class_constructors[name] = retval;
141 class_methods[name] = retval;
143 function_on_path = old_function_on_path;
156 if (full_name () == dispatch_type)
157 retval = load_class_constructor ();
166 std::string dir_name;
170 std::string file_name = lp.
find_method (dispatch_type, name,
173 if (! file_name.empty ())
187 class_methods[dispatch_type] = retval;
198 const std::list<std::string>& plist
201 auto it = plist.begin ();
203 while (it != plist.end ())
209 class_methods[dispatch_type] = retval;
222 if (built_in_function.is_defined ())
228 retval = built_in_function;
230 class_methods[dispatch_type] = retval;
263 sup_table[i][j] = (use_j ? jtyp : ityp);
274 std::string dispatch_type;
281 builtin_type = args(0).builtin_type ();
284 for (i = 1; i <
n; i++)
288 builtin_type = sup_table[builtin_type][bti];
300 dispatch_type = args(i).class_name ();
304 for (
int j = i+1; j <
n; j++)
316 dispatch_type = cname;
326 return dispatch_type;
369 retval = xfind (search_scope, args);
380 std::size_t pos = name.rfind (
'.');
385 if (pos != std::string::npos)
387 fname = name.substr (pos + 1);
388 pname = name.substr (0, pos);
409 const std::string& dir_name_arg,
411 const std::string& dispatch_type =
"",
412 const std::string& package_name =
"")
416 std::string dir_name = dir_name_arg;
418 if (dir_name.empty ())
422 dir_name = file_name.substr (0, pos);
431 = pos != std::string::npos && dir_name.substr (pos+1) ==
"private";
434 dir_name = dir_name.substr (0, pos);
436 std::string class_name;
440 if (pos != std::string::npos)
442 std::string tmp = dir_name.substr (pos+1);
445 class_name = tmp.substr (1);
471 const std::string& dispatch_type =
"",
472 bool check_relative =
true)
490 bool relative = check_relative && fcn->
is_relative ();
495 bool clear_breakpoints =
false;
496 std::string nm = fcn->
name ();
500 bool is_same_file =
false;
503 std::string dir_name;
507 int nm_len = nm.length ();
511 && (nm.substr (nm_len-4) ==
".oct"
512 || nm.substr (nm_len-4) ==
".mex"))
514 && nm.substr (nm_len-2) ==
".m")))
522 if (! dispatch_type.empty ())
536 const std::list<std::string>& plist
539 std::list<std::string>::const_iterator it
542 while (it != plist.end ())
571 file = lp.
find_fcn (nm, dir_name, pack);
591 clear_breakpoints =
true;
593 else if (is_same_file)
598 OCTAVE_TIME_T tp = ottp.unix_time ();
606 sys::file_stat fs (ff);
610 if (fs.is_newer (tp))
617 clear_breakpoints =
true;
624 clear_breakpoints =
true;
634 dispatch_type, pack);
636 clear_breakpoints =
true;
641 if (clear_breakpoints)
676 if (! fcn_file.empty ())
678 auto r = local_functions.find (fcn_file);
680 if (
r != local_functions.end ())
702 if (! dir_name.empty ())
704 auto q = private_functions.find (dir_name);
706 if (q == private_functions.end ())
770 auto q = class_constructors.find (name);
772 if (q == class_constructors.end ())
799 if (cmdline_function.is_defined ())
800 return cmdline_function;
818 fcn = find_package ();
825 return built_in_function;
865 retval = x_builtin_find (search_scope);
875 if (built_in_function.is_defined ())
876 return built_in_function;
894 if (cmdline_function.is_defined ())
895 return cmdline_function;
903 std::string dir_name = search_scope.
dir_name ();
905 if (! dir_name.empty ())
907 auto q = private_functions.find (dir_name);
909 if (q == private_functions.end ())
939 if (! fcn_file.empty ())
941 auto r = local_functions.find (fcn_file);
943 if (
r != local_functions.end ())
971 auto q = class_methods.find (dispatch_type);
973 if (q == class_methods.end ())
1006 if (autoload_function.is_defined ())
1009 if (! autoload_function.is_defined ())
1015 if (! file_name.empty ())
1019 std::string dir_name = file_name.substr (0, pos);
1029 return autoload_function;
1037 if (function_on_path.is_defined ())
1040 if (function_on_path.is_undefined ())
1042 std::string dir_name;
1047 std::string file_name = lp.
find_fcn (name, dir_name, package_name);
1049 if (! file_name.empty ())
1055 function_on_path = ov_fcn;
1059 return function_on_path;
1069 if (package.is_undefined ())
1073 package = cdm.find_package_symbol (full_name ());
1082 if (built_in_function.is_defined ())
1089 warning (
"install_built_in_dispatch: '%s' already defined for class '%s'",
1090 name.c_str (), klass.c_str ());
1096 error (
"install_built_in_dispatch: '%s' is not a built-in function",
1103 std::map<std::string, octave_value>
m
1104 = {{
"name", full_name () },
1105 {
"package", package.dump () },
1110 {
"cmdline_function", cmdline_function.
dump () },
1111 {
"autoload_function", autoload_function.
dump () },
1112 {
"function_on_path", function_on_path.
dump () },
1113 {
"built_in_function", built_in_function.
dump () }
1122 if (fcn_map.empty ())
1125 std::map<std::string, octave_value> info_map;
1127 for (
const auto& nm_fcn : fcn_map)
1129 std::string nm = nm_fcn.first;
1131 info_map[nm] = fcn.
dump ();
1137 DEFUN (ignore_function_time_stamp, args, nargout,
1159 int nargin = args.length ();
1166 if (nargout > 0 || nargin == 0)
1186 std::string sval = args(
1187 0).
xstring_value (
"ignore_function_time_stamp: first argument must be a string");
1191 else if (sval ==
"system")
1193 else if (sval ==
"none")
1196 error (R
"(ignore_function_time_stamp: argument must be one of "all", "system", or "none")");
bp_lines remove_all_breakpoints_from_function(const std::string &fname, bool silent=false)
OCTINTERP_API octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
octave_value find_private_function(const std::string &dir_name)
octave_value builtin_find(const symbol_scope &search_scope)
octave_value xfind(const symbol_scope &search_scope, const octave_value_list &args)
octave_value find_method(const std::string &dispatch_type)
octave_value load_private_function(const std::string &dir_name)
octave_value dump(void) const
octave_value load_class_constructor(void)
octave_value find_autoload(void)
octave_value find_user_function(void)
std::map< std::string, octave_value > private_functions
void install_built_in_dispatch(const std::string &klass)
octave_value find_package(void)
octave_value x_builtin_find(const symbol_scope &search_scope)
octave_value find_scoped_function(const symbol_scope &search_scope)
octave_value find(const symbol_scope &search_scope, const octave_value_list &args)
octave_value load_class_method(const std::string &dispatch_type)
octave_value find_method(const std::string &dispatch_type) const
octave_value find_scoped_function(const symbol_scope &search_scope) const
octave_value find_autoload(void)
octave_value find_private_function(const std::string &dir_name) const
octave_value find_user_function(void)
std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name="")
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
virtual bool is_anonymous_function(void) const
virtual octave_function * function_value(bool silent=false)
virtual bool handles_dispatch_class(const std::string &) const
virtual std::string fcn_file_name(void) const
virtual octave::sys::time time_parsed(void) const
bool is_relative(void) const
std::string package_name(void) const
bool is_class_method(const std::string &cname="") const
virtual void push_dispatch_class(const std::string &)
virtual bool is_subfunction(void) const
virtual bool is_classdef_constructor(const std::string &="") const
std::string canonical_name(void) const
virtual octave::sys::time time_checked(void) const
virtual void mark_fcn_file_up_to_date(const octave::sys::time &)
virtual void mark_as_private_function(const std::string &cname="")
std::string name(void) const
virtual bool is_system_fcn_file(void) const
octave_idx_type length(void) const
OCTINTERP_API octave_function * function_value(bool silent=false) const
OCTINTERP_API std::string xstring_value(const char *fmt,...) const
builtin_type_t builtin_type(void) const
octave_value dump(void) const
bool is_defined(void) const
std::string class_name(void) const
bool is_undefined(void) const
std::string fcn_file_name(void) const
octave_value find_subfunction(const std::string &name) const
std::string dir_name(void) const
bool is_superiorto(const std::string &a, const std::string &b)
std::list< std::string > parent_classes(const std::string &dispatch_type)
std::string lookup_autoload(const std::string &nm) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void error(const char *fmt,...)
std::string get_dispatch_type(const octave_value_list &args, builtin_type_t &builtin_type)
static bool out_of_date_check(octave_value &function, const std::string &dispatch_type="", bool check_relative=true)
static builtin_type_t(* build_sup_table(void))[btyp_num_types]
octave_value dump_function_map(const std::map< std::string, octave_value > &fcn_map)
static bool load_out_of_date_fcn(const std::string &file_name, const std::string &dir_name_arg, octave_value &function, const std::string &dispatch_type="", const std::string &package_name="")
static void split_name_with_package(const std::string &name, std::string &fname, std::string &pname)
static int Vignore_function_time_stamp
std::string canonicalize_file_name(const std::string &name)
bp_table & __get_bp_table__(void)
load_path & __get_load_path__(void)
cdef_manager & __get_cdef_manager__(void)
symbol_table & __get_symbol_table__(void)
symbol_scope __get_current_scope__(void)
tree_evaluator & __get_evaluator__(void)
sys::time Vlast_chdir_time
octave_value load_fcn_from_file(const std::string &file_name, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, const std::string &fcn_name, bool autoload)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
std::string btyp_class_name[btyp_num_types+1]
bool btyp_isinteger(builtin_type_t btyp)
bool btyp_isarray(builtin_type_t btyp)
static bool absolute_pathname(const std::string &s)
static std::string dir_sep_chars
bool same_file(const std::string &f, const std::string &g)