Mercurial > octave-nkf
comparison libinterp/octave-value/ov-fcn-handle.cc @ 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 | 302157614308 |
children | c702371ff6df |
comparison
equal
deleted
inserted
replaced
16645:450c03932d6c | 16676:7368654f302f |
---|---|
264 size_t xpos = str.find_last_of (file_ops::dir_sep_chars ()); | 264 size_t xpos = str.find_last_of (file_ops::dir_sep_chars ()); |
265 | 265 |
266 std::string dir_name = str.substr (0, xpos); | 266 std::string dir_name = str.substr (0, xpos); |
267 | 267 |
268 octave_function *xfcn | 268 octave_function *xfcn |
269 = load_fcn_from_file (str, dir_name, "", nm); | 269 = load_fcn_from_file (str, dir_name, "", "", nm); |
270 | 270 |
271 if (xfcn) | 271 if (xfcn) |
272 { | 272 { |
273 octave_value tmp (xfcn); | 273 octave_value tmp (xfcn); |
274 | 274 |
294 | 294 |
295 size_t xpos = str.find_last_of (file_ops::dir_sep_chars ()); | 295 size_t xpos = str.find_last_of (file_ops::dir_sep_chars ()); |
296 | 296 |
297 std::string dir_name = str.substr (0, xpos); | 297 std::string dir_name = str.substr (0, xpos); |
298 | 298 |
299 octave_function *xfcn = load_fcn_from_file (str, dir_name, "", nm); | 299 octave_function *xfcn = load_fcn_from_file (str, dir_name, "", "", nm); |
300 | 300 |
301 if (xfcn) | 301 if (xfcn) |
302 { | 302 { |
303 octave_value tmp (xfcn); | 303 octave_value tmp (xfcn); |
304 | 304 |
317 { | 317 { |
318 size_t xpos = fpath.find_last_of (file_ops::dir_sep_chars ()); | 318 size_t xpos = fpath.find_last_of (file_ops::dir_sep_chars ()); |
319 | 319 |
320 std::string dir_name = fpath.substr (0, xpos); | 320 std::string dir_name = fpath.substr (0, xpos); |
321 | 321 |
322 octave_function *xfcn = load_fcn_from_file (fpath, dir_name, "", nm); | 322 octave_function *xfcn = load_fcn_from_file (fpath, dir_name, "", "", nm); |
323 | 323 |
324 if (xfcn) | 324 if (xfcn) |
325 { | 325 { |
326 octave_value tmp (xfcn); | 326 octave_value tmp (xfcn); |
327 | 327 |