Mercurial > octave
comparison libinterp/corefcn/help.cc @ 30260:bfbe6e528af5
which: report correct info for classdef constructors (bug #49434)
* help.cc (help_system::which): Handle octave_classdef_meta objects.
* which.m: Fix test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 30 Oct 2021 09:47:47 -0400 |
parents | 7d6709900da7 |
children | f18f5cae2b06 |
comparison
equal
deleted
inserted
replaced
30259:03ff3f1020cf | 30260:bfbe6e528af5 |
---|---|
54 #include "help.h" | 54 #include "help.h" |
55 #include "input.h" | 55 #include "input.h" |
56 #include "interpreter-private.h" | 56 #include "interpreter-private.h" |
57 #include "interpreter.h" | 57 #include "interpreter.h" |
58 #include "load-path.h" | 58 #include "load-path.h" |
59 #include "ov-classdef.h" | |
59 #include "ov-fcn-handle.h" | 60 #include "ov-fcn-handle.h" |
60 #include "ov-usr-fcn.h" | 61 #include "ov-usr-fcn.h" |
61 #include "ovl.h" | 62 #include "ovl.h" |
62 #include "pager.h" | 63 #include "pager.h" |
63 #include "parse.h" | 64 #include "parse.h" |
241 if (name.empty ()) | 242 if (name.empty ()) |
242 return file; | 243 return file; |
243 | 244 |
244 type = ""; | 245 type = ""; |
245 | 246 |
246 if (name.find_first_of ('.') == std::string::npos) | 247 symbol_table& symtab = m_interpreter.get_symbol_table (); |
248 | |
249 octave_value val = symtab.find_function (name); | |
250 | |
251 if (val.is_defined ()) | |
247 { | 252 { |
248 symbol_table& symtab = m_interpreter.get_symbol_table (); | 253 octave_function *fcn = val.function_value (); |
249 | 254 |
250 octave_value val = symtab.find_function (name); | 255 if (fcn) |
251 | 256 { |
252 if (val.is_defined ()) | 257 if (fcn->is_classdef_meta ()) |
253 { | |
254 octave_function *fcn = val.function_value (); | |
255 | |
256 if (fcn) | |
257 { | 258 { |
259 octave_classdef_meta *meta_obj | |
260 = dynamic_cast<octave_classdef_meta *> (fcn); | |
261 | |
262 file = meta_obj->file_name (); | |
263 | |
264 if (meta_obj->is_classdef_constructor ()) | |
265 type = "class constructor"; | |
266 else if (meta_obj->is_classdef_method ()) | |
267 type = "class method"; | |
268 else | |
269 type = "classdef meta object"; | |
270 } | |
271 else | |
272 { | |
273 | |
258 file = fcn->fcn_file_name (); | 274 file = fcn->fcn_file_name (); |
259 | 275 |
260 if (file.empty ()) | 276 if (! file.empty ()) |
277 type = val.is_user_script () ? "script" : "function"; | |
278 else | |
261 { | 279 { |
262 if (fcn->is_user_function ()) | 280 if (fcn->is_user_function ()) |
263 type = "command-line function"; | 281 type = "command-line function"; |
264 else | 282 else |
265 { | 283 { |
266 file = fcn->src_file_name (); | 284 file = fcn->src_file_name (); |
267 type = "built-in function"; | 285 type = "built-in function"; |
268 } | 286 } |
269 } | 287 } |
270 else | |
271 type = val.is_user_script () ? "script" : "function"; | |
272 } | 288 } |
273 } | 289 } |
274 else | 290 else |
275 { | 291 { |
276 // We might find a file that contains only a doc string. | 292 // We might find a file that contains only a doc string. |
278 load_path& lp = m_interpreter.get_load_path (); | 294 load_path& lp = m_interpreter.get_load_path (); |
279 | 295 |
280 file = lp.find_fcn_file (name); | 296 file = lp.find_fcn_file (name); |
281 } | 297 } |
282 } | 298 } |
283 else | 299 |
300 if (file.empty ()) | |
284 { | 301 { |
285 // File query. | 302 // File query. |
286 | 303 |
287 load_path& lp = m_interpreter.get_load_path (); | 304 load_path& lp = m_interpreter.get_load_path (); |
288 | 305 |