Mercurial > octave
changeset 26970:340d44f2f942
backout changeset 98f1a964ff33
This changeset broke lookups for functions in packages. It may make
sense to cache packages differently or as load_path initialization
finds +package directories, but this changeset was the wrong thing to
do. My apologies.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Mar 2019 18:28:24 +0000 |
parents | abfae20a2bf7 |
children | f75882347af3 |
files | libinterp/corefcn/fcn-info.h libinterp/corefcn/load-path.cc libinterp/corefcn/load-path.h libinterp/corefcn/symtab.cc libinterp/corefcn/symtab.h libinterp/octave-value/cdef-manager.cc libinterp/octave-value/cdef-manager.h |
diffstat | 7 files changed, 27 insertions(+), 115 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/fcn-info.h Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/corefcn/fcn-info.h Mon Mar 25 18:28:24 2019 +0000 @@ -74,6 +74,8 @@ ~fcn_info_rep (void) = default; + octave_value install_local_function (const std::string& file_name); + octave_value load_private_function (const std::string& dir_name); octave_value load_class_constructor (void); @@ -98,11 +100,6 @@ return function_on_path.is_defined (); } - bool is_package_defined (void) const - { - return package.is_defined (); - } - octave_value find_function (const symbol_scope& search_scope, const octave_value_list& args) { @@ -120,11 +117,6 @@ local_functions[file_name] = f; } - void install_package (const octave_value& pack) - { - package = pack; - } - void install_user_function (const octave_value& f) { function_on_path = f; @@ -292,11 +284,6 @@ return m_rep->is_user_function_defined (); } - bool is_package_defined (void) const - { - return m_rep->is_package_defined (); - } - octave_value find_function (const symbol_scope& search_scope, const octave_value_list& args = octave_value_list ()) @@ -315,11 +302,6 @@ m_rep->install_local_function (f, file_name); } - void install_package (const octave_value& pack) - { - m_rep->install_package (pack); - } - void install_user_function (const octave_value& f) { m_rep->install_user_function (f);
--- a/libinterp/corefcn/load-path.cc Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/corefcn/load-path.cc Mon Mar 25 18:28:24 2019 +0000 @@ -1225,7 +1225,7 @@ } void - load_path::dir_info::initialize (const std::string& parent_package) + load_path::dir_info::initialize (void) { is_relative = ! sys::env::absolute_pathname (dir_name); @@ -1241,7 +1241,7 @@ dir_mtime = fs.mtime (); dir_time_last_checked = sys::time (); - get_file_list (dir_name, parent_package); + get_file_list (dir_name); try { @@ -1269,8 +1269,7 @@ } void - load_path::dir_info::get_file_list (const std::string& d, - const std::string& parent_package) + load_path::dir_info::get_file_list (const std::string& d) { sys::dir_entry dir (d); @@ -1303,14 +1302,7 @@ else if (fname[0] == '@') get_method_file_map (full_name, fname.substr (1)); else if (fname[0] == '+') - { - std::string pkg_name = fname.substr (1); - - if (! parent_package.empty ()) - pkg_name = parent_package + "." + pkg_name; - - get_package_dir (full_name, pkg_name); - } + get_package_dir (full_name, fname.substr (1)); } else { @@ -1368,12 +1360,7 @@ load_path::dir_info::get_package_dir (const std::string& d, const std::string& package_name) { - symbol_table& symtab - = __get_symbol_table__ ("load_path::dir_info::get_package_dir"); - - symtab.install_package (package_name); - - package_dir_map[package_name] = dir_info (d, package_name); + package_dir_map[package_name] = dir_info (d); } void
--- a/libinterp/corefcn/load-path.h Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/corefcn/load-path.h Mon Mar 25 18:28:24 2019 +0000 @@ -262,12 +262,12 @@ // constructor for any other purpose. dir_info (void) = default; - dir_info (const std::string& d, const std::string& parent_package = "") + dir_info (const std::string& d) : dir_name (d), abs_dir_name (), is_relative (false), dir_mtime (), dir_time_last_checked (), all_files (), fcn_files (), private_file_map (), method_file_map (), package_dir_map () { - initialize (parent_package); + initialize (); } dir_info (const dir_info&) = default; @@ -293,10 +293,9 @@ private: - void initialize (const std::string& parent_package = ""); + void initialize (void); - void get_file_list (const std::string& d, - const std::string& parent_package); + void get_file_list (const std::string& d); void get_private_file_map (const std::string& d);
--- a/libinterp/corefcn/symtab.cc Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/corefcn/symtab.cc Mon Mar 25 18:28:24 2019 +0000 @@ -36,9 +36,6 @@ #include "bp-table.h" #include "call-stack.h" -#include "cdef-manager.h" -#include "cdef-package.h" -#include "cdef-utils.h" #include "defun.h" #include "dirfns.h" #include "fcn-info.h" @@ -499,46 +496,6 @@ error ("install_built_in_dispatch: '%s' is undefined", name.c_str ()); } - // Install a +package directory object in the function table. - void symbol_table::install_package (const std::string& name) - { - auto p = m_fcn_table.find (name); - - bool found_in_fcn_table = (p != m_fcn_table.end ()); - - if (found_in_fcn_table) - { - fcn_info& finfo = p->second; - - if (finfo.is_package_defined ()) - return; - } - - cdef_manager& cdm = m_interpreter.get_cdef_manager (); - - octave_function *tmp = cdm.make_package_symbol (name); - - if (! tmp) - return; - - octave_value pack = tmp; - - if (found_in_fcn_table) - { - fcn_info& finfo = p->second; - - finfo.install_package (pack); - } - else - { - fcn_info finfo (name); - - finfo.install_package (pack); - - m_fcn_table[name] = finfo; - } - } - std::list<std::string> symbol_table::user_function_names (void) { std::list<std::string> retval;
--- a/libinterp/corefcn/symtab.h Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/corefcn/symtab.h Mon Mar 25 18:28:24 2019 +0000 @@ -157,8 +157,6 @@ void install_built_in_dispatch (const std::string& name, const std::string& klass); - void install_package (const std::string& name); - std::list<std::string> user_function_names (void); std::list<std::string> built_in_function_names (void);
--- a/libinterp/octave-value/cdef-manager.cc Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/octave-value/cdef-manager.cc Mon Mar 25 18:28:24 2019 +0000 @@ -719,7 +719,18 @@ load_path& lp = m_interpreter.get_load_path (); if (load_if_not_found && lp.find_package (name)) - retval = make_package (name); + { + size_t pos = name.rfind ('.'); + + if (pos == std::string::npos) + retval = make_package (name, ""); + else + { + std::string parent_name = name.substr (0, pos); + + retval = make_package (name, parent_name); + } + } else if (error_if_not_found) error ("unknown package `%s'", name.c_str ()); } @@ -740,19 +751,6 @@ return retval; } - octave_function * - cdef_manager::make_package_symbol (const std::string& pack_name) - { - octave_function *retval = nullptr; - - cdef_package pack = make_package (pack_name); - - if (pack.ok ()) - retval = new octave_classdef_meta (pack); - - return retval; - } - cdef_class cdef_manager::make_class (const std::string& name, const std::list<octave::cdef_class>& super_list) @@ -922,16 +920,9 @@ } cdef_package - cdef_manager::make_package (const std::string& package_name) + cdef_manager::make_package (const std::string& nm, const std::string& parent) { - cdef_package pack (package_name); - - std::string parent; - - size_t pos = package_name.rfind ('.'); - - if (pos != std::string::npos) - parent = package_name.substr (0, pos); + cdef_package pack (nm); pack.set_class (meta_package ()); @@ -940,7 +931,7 @@ else pack.put ("ContainingPackage", to_ov (find_package (parent))); - if (! package_name.empty ()) + if (! nm.empty ()) register_package (pack); return pack;
--- a/libinterp/octave-value/cdef-manager.h Mon Mar 25 12:13:06 2019 -0700 +++ b/libinterp/octave-value/cdef-manager.h Mon Mar 25 18:28:24 2019 +0000 @@ -62,8 +62,6 @@ octave_function * find_package_symbol (const std::string& pack_name); - octave_function * make_package_symbol (const std::string& pack_name); - void register_class (const cdef_class& cls) { m_all_classes[cls.get_name ()] = cls; @@ -130,7 +128,7 @@ bool is_static = false); cdef_package - make_package (const std::string& package_name); + make_package (const std::string& nm, const std::string& parent = ""); private: