26#if defined (HAVE_CONFIG_H)
62 if (file_name.empty ())
75 std::string class_name;
79 if (pos != std::string::npos)
81 std::string tmp = dir_name.substr (pos+1);
84 class_name = tmp.substr (1);
106 if (! file_name.empty ())
119 class_constructors[
name] = retval;
120 class_methods[
name] = retval;
140 retval = maybe_cdef_ctor;
142 class_constructors[
name] = retval;
143 class_methods[
name] = retval;
145 function_on_path = old_function_on_path;
158 if (full_name () == dispatch_type)
159 retval = load_class_constructor ();
165 retval = cdm.find_method_symbol (
name, dispatch_type);
169 std::string dir_name;
176 if (! file_name.empty ())
190 class_methods[dispatch_type] = retval;
202 const std::list<std::string>& plist
205 auto it = plist.begin ();
207 while (it != plist.end ())
213 class_methods[dispatch_type] = retval;
226 if (built_in_function.is_defined ())
232 retval = built_in_function;
234 class_methods[dispatch_type] = retval;
267 sup_table[i][j] = (use_j ? jtyp : ityp);
278 std::string dispatch_type;
285 builtin_type = args(0).builtin_type ();
288 for (i = 1; i < n; i++)
292 builtin_type = sup_table[builtin_type][bti];
304 dispatch_type = args(i).class_name ();
308 for (
int j = i+1; j < n; j++)
320 dispatch_type = cname;
330 return dispatch_type;
357 symbol_scope search_scope
373 retval = xfind (search_scope, args);
384 std::size_t pos =
name.rfind (
'.');
389 if (pos != std::string::npos)
391 fname =
name.substr (pos + 1);
392 pname =
name.substr (0, pos);
413 const std::string& dir_name_arg,
415 const std::string& dispatch_type =
"",
416 const std::string& package_name =
"")
420 std::string dir_name = dir_name_arg;
422 if (dir_name.empty ())
426 dir_name = file_name.substr (0, pos);
435 = pos != std::string::npos && dir_name.substr (pos+1) ==
"private";
438 dir_name = dir_name.substr (0, pos);
440 std::string class_name;
444 if (pos != std::string::npos)
446 std::string tmp = dir_name.substr (pos+1);
449 class_name = tmp.substr (1);
475 const std::string& dispatch_type =
"",
476 bool check_relative =
true)
494 bool relative = check_relative && fcn->
is_relative ();
499 bool clear_breakpoints =
false;
500 std::string nm = fcn->
name ();
504 bool is_same_file =
false;
507 std::string dir_name;
511 int nm_len = nm.length ();
515 && (nm.substr (nm_len-4) ==
".oct"
516 || nm.substr (nm_len-4) ==
".mex"))
518 && nm.substr (nm_len-2) ==
".m")))
526 if (! dispatch_type.empty ())
542 const std::list<std::string>& plist
545 std::list<std::string>::const_iterator it
548 while (it != plist.end ())
579 file = lp.
find_fcn (nm, dir_name, pack);
599 clear_breakpoints =
true;
601 else if (is_same_file)
614 sys::file_stat fs (ff);
618 if (fs.is_newer (tp))
625 clear_breakpoints =
true;
632 clear_breakpoints =
true;
642 dispatch_type, pack);
644 clear_breakpoints =
true;
649 if (clear_breakpoints)
654 bptab.remove_all_breakpoints_from_function (canonical_nm,
679 std::string fcn_file = search_scope.fcn_file_name ();
685 if (! fcn_file.empty ())
687 auto r = local_functions.find (fcn_file);
689 if (r != local_functions.end ())
711 if (! dir_name.empty ())
713 auto q = private_functions.find (dir_name);
715 if (q == private_functions.end ())
779 auto q = class_constructors.find (
name);
781 if (q == class_constructors.end ())
808 if (cmdline_function.is_defined ())
809 return cmdline_function;
827 fcn = find_package ();
834 return built_in_function;
858 symbol_scope search_scope
874 retval = x_builtin_find (search_scope);
884 if (built_in_function.is_defined ())
885 return built_in_function;
903 if (cmdline_function.is_defined ())
904 return cmdline_function;
912 std::string dir_name = search_scope.dir_name ();
914 if (! dir_name.empty ())
916 auto q = private_functions.find (dir_name);
918 if (q == private_functions.end ())
946 std::string fcn_file = search_scope.fcn_file_name ();
948 if (! fcn_file.empty ())
950 auto r = local_functions.find (fcn_file);
952 if (r != local_functions.end ())
980 auto q = class_methods.find (dispatch_type);
982 if (q == class_methods.end ())
1015 if (autoload_function.is_defined ())
1018 if (! autoload_function.is_defined ())
1025 if (! file_name.empty ())
1029 std::string dir_name = file_name.substr (0, pos);
1039 return autoload_function;
1047 if (function_on_path.is_defined ())
1050 if (function_on_path.is_undefined ())
1052 std::string dir_name;
1058 std::string file_name = lp.
find_fcn (
name, dir_name, package_name);
1060 if (! file_name.empty ())
1066 function_on_path = ov_fcn;
1070 return function_on_path;
1080 if (package.is_undefined ())
1085 package = cdm.find_package_symbol (full_name ());
1094 if (built_in_function.is_defined ())
1101 warning (
"install_built_in_dispatch: '%s' already defined for class '%s'",
1102 name.c_str (), klass.c_str ());
1108 error (
"install_built_in_dispatch: '%s' is not a built-in function",
1115 std::map<std::string, octave_value> m
1116 = {{
"name", full_name () },
1117 {
"package", package.
dump () },
1122 {
"cmdline_function", cmdline_function.
dump () },
1123 {
"autoload_function", autoload_function.
dump () },
1124 {
"function_on_path", function_on_path.
dump () },
1125 {
"built_in_function", built_in_function.
dump () }};
1133 if (fcn_map.empty ())
1136 std::map<std::string, octave_value> info_map;
1138 for (
const auto& nm_fcn : fcn_map)
1140 std::string nm = nm_fcn.first;
1142 info_map[nm] = fcn.
dump ();
1148DEFUN (ignore_function_time_stamp, args, nargout,
1170 int nargin = args.length ();
1177 if (nargout > 0 || nargin == 0)
1197 std::string sval = args(0).
xstring_value (
"ignore_function_time_stamp: first argument must be a string");
1201 else if (sval ==
"system")
1203 else if (sval ==
"none")
1206 error (R
"(ignore_function_time_stamp: argument must be one of "all", "system", or "none")");
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 dump(void) const
octave_value load_private_function(const std::string &dir_name)
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="")
OCTAVE_TIME_T unix_time(void) const
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 std::string xstring_value(const char *fmt,...) const
OCTINTERP_API octave_function * function_value(bool silent=false) 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
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
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
sys::time Vlast_chdir_time
std::string canonicalize_file_name(const std::string &name)
cdef_manager & __get_cdef_manager__(const std::string &who)
tree_evaluator & __get_evaluator__(const std::string &who)
symbol_scope __get_current_scope__(const std::string &who)
bp_table & __get_bp_table__(const std::string &who)
load_path & __get_load_path__(const std::string &who)
symbol_table & __get_symbol_table__(const std::string &who)
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)