Mercurial > octave
diff libinterp/parse-tree/oct-parse.in.yy @ 16676:7368654f302f classdef
Initial support for (classdef) packages.
* libinterp/interpfcn/load-path.h (class load_path::loader): New class.
(load_path::default_loader, load_path::loader_map): New members.
(load_path::load_path): Initialize them.
(load_path::fcn_map, load_path::private_fcn_map,
load_path::method_map): Move to class load_path::loader.
(load_path::add_to_fcn_map, load_path::add_to_private_fcn_map,
load_path::add_to_method_map, load_path::move_fcn_map,
load_path::move_method_map, load_path::remove_fcn_map,
load_path::remove_private_fcn_map, load_path::remove_method_map):
Move to class load_path::loader.
(load_path::move): Change signature.
(load_path::do_move, load_path::remove, load_path::add,
load_path::get_loader): New methods.
(load_path::find_package, load_path::do_find_package): Likewise.
(load_path::dir_info::package_dir_map): New member.
(load_path::dir_info::dir_info, load_path::dir_info::operator=):
Initialize/assign it.
(load_path::dir_info::get_package_dir): New method.
(load_path::do_find_fcn, load_path::do_find_private_fcn): Remove
methods.
(load_path::find_fcn, load_path::find_private_fcn,
load_path::find_fcn_file, load_path::find_oct_file,
load_path::find_mex_file): Rewrite using class load_path::loader.
New argument for package name.
*libinterp/interpfcn/load-path.cc (load_path::dir_info::initialize):
Clear package_map_dir.
(load_path::dir_info::get_package_dir): New method.
(load_path::dir_info::get_files_list): Use it.
(load_path::add_to_fcn_map, load_path::add_to_private_fcn_map,
load_path::add_to_method_map, load_path::move_fcn_map,
load_path::move_method_map, load_path::remove_fcn_map,
load_path::remove_private_fcn_map, load_path::remove_method_map):
Move to class load_path::loader.
(load_path::move): Move implementation to do_move, rewrite using
class load_path::loader. Signature change.
(load_path::do_move, load_path::add, load_path::remove): New methods.
(load_path::do_clear): Rewrite using class load_path::loader.
(load_path::do_add): Use "do_move" and "add" methods.
(load_path::do_remove): Rewrite using "remove" method.
(load_path::do_update): Rewitre using class load_path::loader and
"add" method.
(load_path::do_find_method, load_path::do_methods,
load_path::do_overloads, load_path::do_fcn_names, load_path::do_display):
Move Implementation to class load_path::loader, without "do_" prefix.
Rewrite original to redirect to appropriate loaders.
(F__dump_load_path__): New debug function.
* libinterp/interpfcn/symtab.h (symbol_table::package_name): New member.
(symbol_table::symbol_table): Initialize it.
(symbol_table::find): New scope argument.
(symbol_table::alloc_package_scope): New method.
(symbol_table::fcn_info::find, symbol_table::fcn_info::find_function,
symbol_table::fcn_info::find_user_function,
symbol_table::fcn_info::fcn_info_rep::xfind,
symbol_table::fcn_info::fcn_info_rep::load_class_constructor,
symbol_table::fcn_info::fcn_info_rep::find,
symbol_table::fcn_info::fcn_info_rep::find_user_function): New
argument for package name.
(symbol_table::fcn_info::fcn_info_rep::package): New member.
(symbol_table::fcn_info::fcn_info_rep::find_package,
symbol_table::fcn_info::fcn_info_rep::clear_package): New methods.
(symbol_table::fcn_info::fcn_info_rep::clear): Clear package.
* libinterp/interpfcn/symtab.cc
(symbol_table::fcn_info::fcn_info_rep::load_class_constructor,
symbol_table::fcn_info::fcn_info_rep::find,
symbol_table::fcn_info::fcn_info_rep::xfind,
symbol_table::fcn_info::fcn_info_rep::find_user_function):
New argument for package name.
(symbol_table::fcn_info::fcn_info_rep::find_package): New method.
(symbol_table::find): New scope argument.
(symbol_table::do_find): Use package_name member.
* libinterp/octave-value/ov-classdef.h
(cdef_package::cdef_package_rep::scope): New member.
(cdef_package::cdef_package_rep::~cdef_package_rep): New destructor.
(cdef_package::cdef_package_rep::meta_subsref,
cdef_package::cdef_package_rep::meta_release,
cdef_package::cdef_package_rep::meta_is_postfix_index_handled,
cdef_package::cdef_package_rep::find,
cdef_package::cdef_package_rep::wrap): New methods.
(cdef_package::find): New method.
(cdef_manager::find_package, cdef_manager::do_find_package): New
argument "load_if_not_found".
(cdef_manager::find_package_symbol,
cdef_manager::do_find_package_symbol): New methods.
* libinterp/octave-value/ov-classdef.cc
(cdef_manager::do_find_package_symbol): New method.
(cdef_manager::do_find_package): New argument. Create package object if
it is not loaded yet and the package exists in load_path.
(cdef_manager::do_find_class): Handle class names with package.
(cdef_package::cdef_package_rep::meta_subsref,
cdef_package::cdef_package_rep::meta_release,
cdef_package::cdef_package_rep::find): New methods.
(cdef_class::make_meta_class): Handle package-scoped classes.
(make_package): Assign correct name to the package object.
* libinterp/parse-tree/pt-classdef.h (tree_classdef::pack_name): New
member.
(tree_classdef::tree_classdef): New argument. Initialize it.
(tree_classdef::package_name): New accessor.
* libinterp/parse-tree/parse.h (octave_base_parser::curr_package_name):
New member.
(octave_base_parser::octave_base_parser): Initialize it.
(load_fcn_from_file): New argument for package name.
* libinterp/parse-tree/oct-parse.in.yy (load_fcn_from_file): New
argument for package name. Change callers.
(parse_fcn_from_file): New argument for package name. Change callers.
(octave_base_parser::make_classdef): Use curr_package_name to create
the tree_classdef object.
* libinterp/octave-value/ov-fcn-handle.cc (octave_fcn_handle::set_fcn):
Adapt to new load_fcn_from_file signature.
* libinterp/interp-core/ls-mat5.cc (read_mat5_binary_element): Adapt
to new load_fcn_from_file signature.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Fri, 17 May 2013 23:17:25 -0400 |
parents | 856cb7cba231 |
children | e1c6ad54259f |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy Sun May 12 21:47:57 2013 -0400 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri May 17 23:17:25 2013 -0400 @@ -1588,6 +1588,7 @@ curr_fcn_depth = 0; primary_fcn_scope = -1; curr_class_name = ""; + curr_package_name = ""; function_scopes.clear (); primary_fcn_ptr = 0; subfunction_names.clear (); @@ -2972,7 +2973,8 @@ int l = tok_val->line (); int c = tok_val->column (); - retval = new tree_classdef (a, id, sc, body, lc, tc, l, c); + retval = new tree_classdef (a, id, sc, body, lc, tc, curr_package_name, + l, c); } return retval; @@ -3529,6 +3531,7 @@ static octave_function * parse_fcn_file (const std::string& full_file, const std::string& file, const std::string& dispatch_type, + const std::string& package_name, bool require_file, bool force_script, bool autoload, bool relative_lookup, const std::string& warn_for) { @@ -3562,6 +3565,7 @@ octave_parser parser (ffile); parser.curr_class_name = dispatch_type; + parser.curr_package_name = package_name; parser.autoloading = autoload; parser.fcn_file_from_relative_lookup = relative_lookup; @@ -3644,7 +3648,8 @@ symbol_found = true; octave_function *fcn - = parse_fcn_file (full_file, file, "", true, false, false, false, ""); + = parse_fcn_file (full_file, file, "", "", true, false, false, false, + ""); if (fcn) { @@ -3708,6 +3713,7 @@ octave_function * 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) { octave_function *retval = 0; @@ -3755,7 +3761,8 @@ // to get the help-string to use. octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), - nm, dispatch_type, false, + nm, dispatch_type, + package_name, false, autoload, autoload, relative_lookup, ""); @@ -3767,8 +3774,8 @@ } else if (len > 2) { - retval = parse_fcn_file (file, nm, dispatch_type, true, autoload, - autoload, relative_lookup, ""); + retval = parse_fcn_file (file, nm, dispatch_type, package_name, true, + autoload, autoload, relative_lookup, ""); } if (retval) @@ -3966,7 +3973,7 @@ if (! error_state) { octave_function *fcn = parse_fcn_file (file_full_name, file_name, - "", require_file, true, + "", "", require_file, true, false, false, warn_for); if (! error_state)