comparison libinterp/octave-value/ov-fcn-handle.cc @ 31771:21f9b34eb893

maint: Eliminate "(void)" in C++ function prototypes/declarations. * mk-opts.pl, external.txi, embedded.cc, make_int.cc, standalone.cc, standalonebuiltin.cc, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.h, qdialog.cpp, qfontdialog.cpp, qprintdialog_win.cpp, liboctgui-build-info.h, liboctgui-build-info.in.cc, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, gui-preferences.cc, gui-preferences.h, gui-settings.cc, gui-settings.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, release-notes.cc, release-notes.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcuts-tree-widget.cc, shortcuts-tree-widget.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h, build-env.h, Cell.cc, Cell.h, __contourc__.cc, __magick_read__.cc, auto-shlib.cc, auto-shlib.h, base-text-renderer.h, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, debug.cc, defaults.cc, defaults.h, defun.cc, display.cc, display.h, dynamic-ld.cc, dynamic-ld.h, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, ft-text-renderer.cc, ft-text-renderer.h, genprops.awk, gh-manager.cc, gh-manager.h, gl-render.cc, gl-render.h, gl2ps-print.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, jsondecode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, ls-hdf5.cc, ls-hdf5.h, mxarray.h, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, pager.cc, pager.h, pr-flt-fmt.cc, pr-flt-fmt.h, pr-output.cc, pr-output.h, procstream.cc, procstream.h, settings.cc, settings.h, sighandlers.cc, sighandlers.h, stack-frame.cc, stack-frame.h, svd.cc, syminfo.cc, syminfo.h, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, toplev.cc, url-handle-manager.cc, url-handle-manager.h, variables.cc, xpow.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, audiodevinfo.cc, gzip.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-legacy-range.cc, ov-legacy-range.h, ov-magic-int.cc, ov-magic-int.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.h, pt.cc, pt.h, token.cc, token.h, usage.h, Array-base.cc, Array.h, CColVector.cc, CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc, DiagArray2.h, MArray.cc, MArray.h, MDiagArray2.h, MSparse.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-b.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.h, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc, idx-vector.h, intNDArray.cc, intNDArray.h, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.cc, DASPK.h, DASRT.cc, DASRT.h, DASSL.cc, DASSL.h, DET.h, EIG.h, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, chol.cc, chol.h, eigs-base.cc, fEIG.h, gepbalance.h, gsvd.cc, gsvd.h, hess.h, lu.cc, lu.h, oct-fftw.cc, oct-fftw.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randmtzig.cc, randmtzig.h, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.h, base-list.h, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, data-conv.cc, file-info.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, oct-inttypes.cc, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, singleton-cleanup.cc, singleton-cleanup.h, str-vec.cc, str-vec.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, version.cc, version.in.h, cxx-signal-helpers.cc, acinclude.m4, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h, octave-build-info.in.cc, octave-config.in.cc, octave-svgconvert.cc, shared-fcns.h: maint: Eliminate "(void)" in C++ function prototypes/declarations.
author Rik <rik@octave.org>
date Tue, 24 Jan 2023 17:19:44 -0800
parents 52a5bec0fc74
children fbadf4ce94c7
comparison
equal deleted inserted replaced
31770:1d1eff97670e 31771:21f9b34eb893
88 88
89 class invalid_fcn_handle : public base_fcn_handle 89 class invalid_fcn_handle : public base_fcn_handle
90 { 90 {
91 public: 91 public:
92 92
93 invalid_fcn_handle (void) : base_fcn_handle ("<invalid>") { } 93 invalid_fcn_handle () : base_fcn_handle ("<invalid>") { }
94 94
95 invalid_fcn_handle (const invalid_fcn_handle&) = default; 95 invalid_fcn_handle (const invalid_fcn_handle&) = default;
96 96
97 ~invalid_fcn_handle (void) = default; 97 ~invalid_fcn_handle () = default;
98 98
99 invalid_fcn_handle * clone (void) const 99 invalid_fcn_handle * clone () const
100 { 100 {
101 return new invalid_fcn_handle (*this); 101 return new invalid_fcn_handle (*this);
102 } 102 }
103 103
104 std::string type (void) const { return "<invalid>"; } 104 std::string type () const { return "<invalid>"; }
105 105
106 octave_value_list call (int nargout, const octave_value_list& args); 106 octave_value_list call (int nargout, const octave_value_list& args);
107 }; 107 };
108 108
109 // Create a handle to an unnamed internal function. There will be no 109 // Create a handle to an unnamed internal function. There will be no
118 : base_fcn_handle ("<internal>"), m_fcn (fcn) 118 : base_fcn_handle ("<internal>"), m_fcn (fcn)
119 { } 119 { }
120 120
121 internal_fcn_handle (const internal_fcn_handle&) = default; 121 internal_fcn_handle (const internal_fcn_handle&) = default;
122 122
123 ~internal_fcn_handle (void) = default; 123 ~internal_fcn_handle () = default;
124 124
125 internal_fcn_handle * clone (void) const 125 internal_fcn_handle * clone () const
126 { 126 {
127 return new internal_fcn_handle (*this); 127 return new internal_fcn_handle (*this);
128 } 128 }
129 129
130 std::string type (void) const { return "<internal>"; } 130 std::string type () const { return "<internal>"; }
131 131
132 bool is_internal (void) const { return true; } 132 bool is_internal () const { return true; }
133 133
134 octave_value_list call (int nargout, const octave_value_list& args); 134 octave_value_list call (int nargout, const octave_value_list& args);
135 135
136 // FIXME: These must go away. They don't do the right thing for 136 // FIXME: These must go away. They don't do the right thing for
137 // scoping or overloads. 137 // scoping or overloads.
143 octave_user_function * user_function_value (bool = false) 143 octave_user_function * user_function_value (bool = false)
144 { 144 {
145 return m_fcn.user_function_value (); 145 return m_fcn.user_function_value ();
146 } 146 }
147 147
148 octave_value fcn_val (void) { return m_fcn; } 148 octave_value fcn_val () { return m_fcn; }
149 149
150 // Should be const. 150 // Should be const.
151 octave_scalar_map info (void); 151 octave_scalar_map info ();
152 152
153 friend bool is_equal_to (const internal_fcn_handle& fh1, 153 friend bool is_equal_to (const internal_fcn_handle& fh1,
154 const internal_fcn_handle& fh2); 154 const internal_fcn_handle& fh2);
155 155
156 private: 156 private:
183 } 183 }
184 } 184 }
185 185
186 simple_fcn_handle (const simple_fcn_handle&) = default; 186 simple_fcn_handle (const simple_fcn_handle&) = default;
187 187
188 ~simple_fcn_handle (void) = default; 188 ~simple_fcn_handle () = default;
189 189
190 simple_fcn_handle * clone (void) const 190 simple_fcn_handle * clone () const
191 { 191 {
192 return new simple_fcn_handle (*this); 192 return new simple_fcn_handle (*this);
193 } 193 }
194 194
195 std::string type (void) const { return "simple"; } 195 std::string type () const { return "simple"; }
196 196
197 bool is_simple (void) const { return true; } 197 bool is_simple () const { return true; }
198 198
199 octave_value_list call (int nargout, const octave_value_list& args); 199 octave_value_list call (int nargout, const octave_value_list& args);
200 200
201 // FIXME: These must go away. They don't do the right thing for 201 // FIXME: These must go away. They don't do the right thing for
202 // scoping or overloads. 202 // scoping or overloads.
203 octave_function * function_value (bool); 203 octave_function * function_value (bool);
204 204
205 octave_user_function * user_function_value (bool); 205 octave_user_function * user_function_value (bool);
206 206
207 octave_value fcn_val (void); 207 octave_value fcn_val ();
208 208
209 // Should be const. 209 // Should be const.
210 octave_scalar_map info (void); 210 octave_scalar_map info ();
211 211
212 bool save_ascii (std::ostream& os); 212 bool save_ascii (std::ostream& os);
213 213
214 bool load_ascii (std::istream& is); 214 bool load_ascii (std::istream& is);
215 215
250 scoped_fcn_handle (const octave_value& fcn, const std::string& name, 250 scoped_fcn_handle (const octave_value& fcn, const std::string& name,
251 const std::list<std::string>& parentage); 251 const std::list<std::string>& parentage);
252 252
253 scoped_fcn_handle (const scoped_fcn_handle&) = default; 253 scoped_fcn_handle (const scoped_fcn_handle&) = default;
254 254
255 ~scoped_fcn_handle (void) = default; 255 ~scoped_fcn_handle () = default;
256 256
257 scoped_fcn_handle * clone (void) const 257 scoped_fcn_handle * clone () const
258 { 258 {
259 return new scoped_fcn_handle (*this); 259 return new scoped_fcn_handle (*this);
260 } 260 }
261 261
262 std::string type (void) const { return "scopedfunction"; } 262 std::string type () const { return "scopedfunction"; }
263 263
264 bool is_scoped (void) const { return true; } 264 bool is_scoped () const { return true; }
265 265
266 octave_value_list call (int nargout, const octave_value_list& args); 266 octave_value_list call (int nargout, const octave_value_list& args);
267 267
268 // FIXME: These must go away. They don't do the right thing for 268 // FIXME: These must go away. They don't do the right thing for
269 // scoping or overloads. 269 // scoping or overloads.
275 octave_user_function * user_function_value (bool = false) 275 octave_user_function * user_function_value (bool = false)
276 { 276 {
277 return m_fcn.user_function_value (); 277 return m_fcn.user_function_value ();
278 } 278 }
279 279
280 octave_value fcn_val (void) { return m_fcn; } 280 octave_value fcn_val () { return m_fcn; }
281 281
282 // Should be const. 282 // Should be const.
283 octave_scalar_map info (void); 283 octave_scalar_map info ();
284 284
285 bool save_ascii (std::ostream& os); 285 bool save_ascii (std::ostream& os);
286 286
287 bool load_ascii (std::istream& is); 287 bool load_ascii (std::istream& is);
288 288
302 friend bool is_equal_to (const scoped_fcn_handle& fh1, 302 friend bool is_equal_to (const scoped_fcn_handle& fh1,
303 const scoped_fcn_handle& fh2); 303 const scoped_fcn_handle& fh2);
304 304
305 protected: 305 protected:
306 306
307 void find_function (void); 307 void find_function ();
308 308
309 // The function we are handling. 309 // The function we are handling.
310 octave_value m_fcn; 310 octave_value m_fcn;
311 311
312 // List of parent function names. The first element is the name of 312 // List of parent function names. The first element is the name of
329 329
330 base_nested_fcn_handle (const octave_value& fcn, const std::string& name) 330 base_nested_fcn_handle (const octave_value& fcn, const std::string& name)
331 : base_fcn_handle (name), m_fcn (fcn) 331 : base_fcn_handle (name), m_fcn (fcn)
332 { } 332 { }
333 333
334 std::string type (void) const { return "nested"; } 334 std::string type () const { return "nested"; }
335 335
336 using base_fcn_handle::is_nested; 336 using base_fcn_handle::is_nested;
337 337
338 bool is_nested (void) const { return true; } 338 bool is_nested () const { return true; }
339 339
340 // FIXME: These must go away. They don't do the right thing for 340 // FIXME: These must go away. They don't do the right thing for
341 // scoping or overloads. 341 // scoping or overloads.
342 octave_function * function_value (bool = false) 342 octave_function * function_value (bool = false)
343 { 343 {
347 octave_user_function * user_function_value (bool = false) 347 octave_user_function * user_function_value (bool = false)
348 { 348 {
349 return m_fcn.user_function_value (); 349 return m_fcn.user_function_value ();
350 } 350 }
351 351
352 octave_value fcn_val (void) { return m_fcn; } 352 octave_value fcn_val () { return m_fcn; }
353 353
354 virtual octave_value workspace (void) const = 0; 354 virtual octave_value workspace () const = 0;
355 355
356 // Should be const. 356 // Should be const.
357 octave_scalar_map info (void); 357 octave_scalar_map info ();
358 358
359 bool save_ascii (std::ostream& os); 359 bool save_ascii (std::ostream& os);
360 360
361 bool load_ascii (std::istream& is); 361 bool load_ascii (std::istream& is);
362 362
400 m_stack_context->mark_closure_context (); 400 m_stack_context->mark_closure_context ();
401 } 401 }
402 402
403 nested_fcn_handle (const nested_fcn_handle&) = default; 403 nested_fcn_handle (const nested_fcn_handle&) = default;
404 404
405 ~nested_fcn_handle (void) = default; 405 ~nested_fcn_handle () = default;
406 406
407 using base_nested_fcn_handle::is_nested; 407 using base_nested_fcn_handle::is_nested;
408 408
409 bool is_nested (const std::shared_ptr<stack_frame>& frame) const 409 bool is_nested (const std::shared_ptr<stack_frame>& frame) const
410 { 410 {
411 return frame == m_stack_context; 411 return frame == m_stack_context;
412 } 412 }
413 413
414 nested_fcn_handle * clone (void) const 414 nested_fcn_handle * clone () const
415 { 415 {
416 return new nested_fcn_handle (*this); 416 return new nested_fcn_handle (*this);
417 } 417 }
418 418
419 octave_value make_weak_nested_handle (void) const; 419 octave_value make_weak_nested_handle () const;
420 420
421 octave_value_list call (int nargout, const octave_value_list& args); 421 octave_value_list call (int nargout, const octave_value_list& args);
422 422
423 octave_value workspace (void) const; 423 octave_value workspace () const;
424 424
425 friend bool is_equal_to (const nested_fcn_handle& fh1, 425 friend bool is_equal_to (const nested_fcn_handle& fh1,
426 const nested_fcn_handle& fh2); 426 const nested_fcn_handle& fh2);
427 427
428 std::shared_ptr<stack_frame> stack_context (void) const 428 std::shared_ptr<stack_frame> stack_context () const
429 { 429 {
430 return m_stack_context; 430 return m_stack_context;
431 } 431 }
432 432
433 protected: 433 protected:
444 : base_nested_fcn_handle (nfh), m_stack_context (nfh.stack_context ()) 444 : base_nested_fcn_handle (nfh), m_stack_context (nfh.stack_context ())
445 { } 445 { }
446 446
447 weak_nested_fcn_handle (const weak_nested_fcn_handle&) = default; 447 weak_nested_fcn_handle (const weak_nested_fcn_handle&) = default;
448 448
449 ~weak_nested_fcn_handle (void) = default; 449 ~weak_nested_fcn_handle () = default;
450 450
451 weak_nested_fcn_handle * clone (void) const 451 weak_nested_fcn_handle * clone () const
452 { 452 {
453 return new weak_nested_fcn_handle (*this); 453 return new weak_nested_fcn_handle (*this);
454 } 454 }
455 455
456 bool is_weak_nested (void) const { return true; } 456 bool is_weak_nested () const { return true; }
457 457
458 octave_value_list call (int nargout, const octave_value_list& args); 458 octave_value_list call (int nargout, const octave_value_list& args);
459 459
460 octave_value workspace (void) const; 460 octave_value workspace () const;
461 461
462 friend bool is_equal_to (const weak_nested_fcn_handle& fh1, 462 friend bool is_equal_to (const weak_nested_fcn_handle& fh1,
463 const weak_nested_fcn_handle& fh2); 463 const weak_nested_fcn_handle& fh2);
464 464
465 protected: 465 protected:
495 const std::string& class_nm, 495 const std::string& class_nm,
496 const std::string& meth_nm); 496 const std::string& meth_nm);
497 497
498 class_simple_fcn_handle (const class_simple_fcn_handle&) = default; 498 class_simple_fcn_handle (const class_simple_fcn_handle&) = default;
499 499
500 ~class_simple_fcn_handle (void) = default; 500 ~class_simple_fcn_handle () = default;
501 501
502 class_simple_fcn_handle * clone (void) const 502 class_simple_fcn_handle * clone () const
503 { 503 {
504 return new class_simple_fcn_handle (*this); 504 return new class_simple_fcn_handle (*this);
505 } 505 }
506 506
507 std::string type (void) const { return "classsimple"; } 507 std::string type () const { return "classsimple"; }
508 508
509 bool is_class_simple (void) const { return true; } 509 bool is_class_simple () const { return true; }
510 510
511 octave_value_list call (int nargout, const octave_value_list& args); 511 octave_value_list call (int nargout, const octave_value_list& args);
512 512
513 // FIXME: These must go away. They don't do the right thing for 513 // FIXME: These must go away. They don't do the right thing for
514 // scoping or overloads. 514 // scoping or overloads.
538 octave_user_function * user_function_value (bool = false) 538 octave_user_function * user_function_value (bool = false)
539 { 539 {
540 return m_fcn.user_function_value (); 540 return m_fcn.user_function_value ();
541 } 541 }
542 542
543 octave_value fcn_val (void) { return m_fcn; } 543 octave_value fcn_val () { return m_fcn; }
544 544
545 // Should be const. 545 // Should be const.
546 octave_scalar_map info (void); 546 octave_scalar_map info ();
547 547
548 std::string dispatch_class (void) const { return m_dispatch_class; } 548 std::string dispatch_class () const { return m_dispatch_class; }
549 549
550 bool save_ascii (std::ostream& os); 550 bool save_ascii (std::ostream& os);
551 551
552 bool load_ascii (std::istream& is); 552 bool load_ascii (std::istream& is);
553 553
625 : base_fcn_handle (anonymous), m_fcn (fcn), m_local_vars (local_vars) 625 : base_fcn_handle (anonymous), m_fcn (fcn), m_local_vars (local_vars)
626 { } 626 { }
627 627
628 base_anonymous_fcn_handle (const base_anonymous_fcn_handle&) = default; 628 base_anonymous_fcn_handle (const base_anonymous_fcn_handle&) = default;
629 629
630 ~base_anonymous_fcn_handle (void) = default; 630 ~base_anonymous_fcn_handle () = default;
631 631
632 std::string type (void) const { return "anonymous"; } 632 std::string type () const { return "anonymous"; }
633 633
634 bool is_anonymous (void) const { return true; } 634 bool is_anonymous () const { return true; }
635 635
636 // FIXME: These must go away. They don't do the right thing for 636 // FIXME: These must go away. They don't do the right thing for
637 // scoping or overloads. 637 // scoping or overloads.
638 octave_function * function_value (bool = false) 638 octave_function * function_value (bool = false)
639 { 639 {
643 octave_user_function * user_function_value (bool = false) 643 octave_user_function * user_function_value (bool = false)
644 { 644 {
645 return m_fcn.user_function_value (); 645 return m_fcn.user_function_value ();
646 } 646 }
647 647
648 octave_value fcn_val (void) { return m_fcn; } 648 octave_value fcn_val () { return m_fcn; }
649 649
650 virtual octave_value workspace (void) const = 0; 650 virtual octave_value workspace () const = 0;
651 651
652 // Should be const. 652 // Should be const.
653 octave_scalar_map info (void); 653 octave_scalar_map info ();
654 654
655 bool save_ascii (std::ostream& os); 655 bool save_ascii (std::ostream& os);
656 656
657 bool load_ascii (std::istream& is); 657 bool load_ascii (std::istream& is);
658 658
668 668
669 void print_raw (std::ostream&, bool pr_as_read_syntax, 669 void print_raw (std::ostream&, bool pr_as_read_syntax,
670 int current_print_indent_level) const; 670 int current_print_indent_level) const;
671 671
672 // Anonymous function handles are printed without a newline. 672 // Anonymous function handles are printed without a newline.
673 bool print_as_scalar (void) const { return false; } 673 bool print_as_scalar () const { return false; }
674 674
675 bool parse (const std::string& fcn_text); 675 bool parse (const std::string& fcn_text);
676 676
677 protected: 677 protected:
678 678
702 const stack_frame::local_vars_map& local_vars, 702 const stack_frame::local_vars_map& local_vars,
703 const std::shared_ptr<stack_frame>& stack_context = std::shared_ptr<stack_frame> ()); 703 const std::shared_ptr<stack_frame>& stack_context = std::shared_ptr<stack_frame> ());
704 704
705 anonymous_fcn_handle (const anonymous_fcn_handle&) = default; 705 anonymous_fcn_handle (const anonymous_fcn_handle&) = default;
706 706
707 ~anonymous_fcn_handle (void) = default; 707 ~anonymous_fcn_handle () = default;
708 708
709 anonymous_fcn_handle * clone (void) const 709 anonymous_fcn_handle * clone () const
710 { 710 {
711 return new anonymous_fcn_handle (*this); 711 return new anonymous_fcn_handle (*this);
712 } 712 }
713 713
714 octave_value make_weak_anonymous_handle (void) const; 714 octave_value make_weak_anonymous_handle () const;
715 715
716 octave_value_list call (int nargout, const octave_value_list& args); 716 octave_value_list call (int nargout, const octave_value_list& args);
717 717
718 octave_value workspace (void) const; 718 octave_value workspace () const;
719 719
720 friend bool is_equal_to (const anonymous_fcn_handle& fh1, 720 friend bool is_equal_to (const anonymous_fcn_handle& fh1,
721 const anonymous_fcn_handle& fh2); 721 const anonymous_fcn_handle& fh2);
722 722
723 std::shared_ptr<stack_frame> stack_context (void) const 723 std::shared_ptr<stack_frame> stack_context () const
724 { 724 {
725 return m_stack_context; 725 return m_stack_context;
726 } 726 }
727 727
728 protected: 728 protected:
741 : base_anonymous_fcn_handle (afh), m_stack_context (afh.stack_context ()) 741 : base_anonymous_fcn_handle (afh), m_stack_context (afh.stack_context ())
742 { } 742 { }
743 743
744 weak_anonymous_fcn_handle (const weak_anonymous_fcn_handle&) = default; 744 weak_anonymous_fcn_handle (const weak_anonymous_fcn_handle&) = default;
745 745
746 ~weak_anonymous_fcn_handle (void) = default; 746 ~weak_anonymous_fcn_handle () = default;
747 747
748 weak_anonymous_fcn_handle * clone (void) const 748 weak_anonymous_fcn_handle * clone () const
749 { 749 {
750 return new weak_anonymous_fcn_handle (*this); 750 return new weak_anonymous_fcn_handle (*this);
751 } 751 }
752 752
753 bool is_weak_anonymous (void) const { return true; } 753 bool is_weak_anonymous () const { return true; }
754 754
755 octave_value_list call (int nargout, const octave_value_list& args); 755 octave_value_list call (int nargout, const octave_value_list& args);
756 756
757 octave_value workspace (void) const; 757 octave_value workspace () const;
758 758
759 friend bool is_equal_to (const weak_anonymous_fcn_handle& fh1, 759 friend bool is_equal_to (const weak_anonymous_fcn_handle& fh1,
760 const weak_anonymous_fcn_handle& fh2); 760 const weak_anonymous_fcn_handle& fh2);
761 761
762 protected: 762 protected:
772 { 772 {
773 error ("invalid function handle, unable to find function for @%s", 773 error ("invalid function handle, unable to find function for @%s",
774 name.c_str ()); 774 name.c_str ());
775 } 775 }
776 776
777 octave_value base_fcn_handle::make_weak_nested_handle (void) const 777 octave_value base_fcn_handle::make_weak_nested_handle () const
778 { 778 {
779 std::string type_str = type (); 779 std::string type_str = type ();
780 error ("invalid conversion from %s handle to weak nestead handle", 780 error ("invalid conversion from %s handle to weak nestead handle",
781 type_str.c_str ()); 781 type_str.c_str ());
782 } 782 }
783 783
784 octave_value base_fcn_handle::make_weak_anonymous_handle (void) const 784 octave_value base_fcn_handle::make_weak_anonymous_handle () const
785 { 785 {
786 std::string type_str = type (); 786 std::string type_str = type ();
787 error ("invalid conversion from %s handle to weak anonymous handle", 787 error ("invalid conversion from %s handle to weak anonymous handle",
788 type_str.c_str ()); 788 type_str.c_str ());
789 } 789 }
919 interpreter& interp = __get_interpreter__ (); 919 interpreter& interp = __get_interpreter__ ();
920 920
921 return interp.feval (m_fcn, args, nargout); 921 return interp.feval (m_fcn, args, nargout);
922 } 922 }
923 923
924 octave_scalar_map internal_fcn_handle::info (void) 924 octave_scalar_map internal_fcn_handle::info ()
925 { 925 {
926 octave_scalar_map m; 926 octave_scalar_map m;
927 927
928 m.setfield ("function", fcn_name ()); 928 m.setfield ("function", fcn_name ());
929 m.setfield ("type", type ()); 929 m.setfield ("type", type ());
1164 m_fcn = symtab.find_user_function (m_name); 1164 m_fcn = symtab.find_user_function (m_name);
1165 1165
1166 return m_fcn.is_defined () ? m_fcn.user_function_value () : nullptr; 1166 return m_fcn.is_defined () ? m_fcn.user_function_value () : nullptr;
1167 } 1167 }
1168 1168
1169 octave_value simple_fcn_handle::fcn_val (void) 1169 octave_value simple_fcn_handle::fcn_val ()
1170 { 1170 {
1171 if (m_fcn.is_defined ()) 1171 if (m_fcn.is_defined ())
1172 return m_fcn; 1172 return m_fcn;
1173 1173
1174 symbol_table& symtab = __get_symbol_table__ (); 1174 symbol_table& symtab = __get_symbol_table__ ();
1180 m_fcn = symtab.find_user_function (m_name); 1180 m_fcn = symtab.find_user_function (m_name);
1181 1181
1182 return m_fcn; 1182 return m_fcn;
1183 } 1183 }
1184 1184
1185 octave_scalar_map simple_fcn_handle::info (void) 1185 octave_scalar_map simple_fcn_handle::info ()
1186 { 1186 {
1187 octave_scalar_map m; 1187 octave_scalar_map m;
1188 1188
1189 m.setfield ("function", fcn_name ()); 1189 m.setfield ("function", fcn_name ());
1190 m.setfield ("type", type ()); 1190 m.setfield ("type", type ());
1474 err_invalid_fcn_handle (m_name); 1474 err_invalid_fcn_handle (m_name);
1475 1475
1476 return interp.feval (m_fcn, args, nargout); 1476 return interp.feval (m_fcn, args, nargout);
1477 } 1477 }
1478 1478
1479 octave_scalar_map scoped_fcn_handle::info (void) 1479 octave_scalar_map scoped_fcn_handle::info ()
1480 { 1480 {
1481 octave_scalar_map m; 1481 octave_scalar_map m;
1482 1482
1483 m.setfield ("function", fcn_name ()); 1483 m.setfield ("function", fcn_name ());
1484 m.setfield ("type", type ()); 1484 m.setfield ("type", type ());
1629 return fh1.m_fcn.is_copy_of (fh2.m_fcn); 1629 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
1630 else 1630 else
1631 return false; 1631 return false;
1632 } 1632 }
1633 1633
1634 void scoped_fcn_handle::find_function (void) 1634 void scoped_fcn_handle::find_function ()
1635 { 1635 {
1636 // Since a scoped function is not visible by itself, try to load the 1636 // Since a scoped function is not visible by itself, try to load the
1637 // file named in m_file then find and define the scoped function. 1637 // file named in m_file then find and define the scoped function.
1638 // It is not an error if this fails. We can report later that the 1638 // It is not an error if this fails. We can report later that the
1639 // handle is invalid. 1639 // handle is invalid.
1686 } 1686 }
1687 } 1687 }
1688 } 1688 }
1689 } 1689 }
1690 1690
1691 octave_scalar_map base_nested_fcn_handle::info (void) 1691 octave_scalar_map base_nested_fcn_handle::info ()
1692 { 1692 {
1693 octave_scalar_map m; 1693 octave_scalar_map m;
1694 1694
1695 m.setfield ("function", fcn_name ()); 1695 m.setfield ("function", fcn_name ());
1696 m.setfield ("type", type ()); 1696 m.setfield ("type", type ());
1805 { 1805 {
1806 octave_print_internal (os, '@' + m_name, pr_as_read_syntax, 1806 octave_print_internal (os, '@' + m_name, pr_as_read_syntax,
1807 current_print_indent_level); 1807 current_print_indent_level);
1808 } 1808 }
1809 1809
1810 octave_value nested_fcn_handle::make_weak_nested_handle (void) const 1810 octave_value nested_fcn_handle::make_weak_nested_handle () const
1811 { 1811 {
1812 return octave_value (new octave_fcn_handle 1812 return octave_value (new octave_fcn_handle
1813 (new weak_nested_fcn_handle (*this))); 1813 (new weak_nested_fcn_handle (*this)));
1814 } 1814 }
1815 1815
1825 unwind_action act ([&tw] () { tw.pop_stack_frame (); }); 1825 unwind_action act ([&tw] () { tw.pop_stack_frame (); });
1826 1826
1827 return oct_usr_fcn->execute (tw, nargout, args); 1827 return oct_usr_fcn->execute (tw, nargout, args);
1828 } 1828 }
1829 1829
1830 octave_value nested_fcn_handle::workspace (void) const 1830 octave_value nested_fcn_handle::workspace () const
1831 { 1831 {
1832 return m_stack_context->workspace (); 1832 return m_stack_context->workspace ();
1833 } 1833 }
1834 1834
1835 bool is_equal_to (const nested_fcn_handle& fh1, const nested_fcn_handle& fh2) 1835 bool is_equal_to (const nested_fcn_handle& fh1, const nested_fcn_handle& fh2)
1855 unwind_action act ([&tw] () { tw.pop_stack_frame (); }); 1855 unwind_action act ([&tw] () { tw.pop_stack_frame (); });
1856 1856
1857 return oct_usr_fcn->execute (tw, nargout, args); 1857 return oct_usr_fcn->execute (tw, nargout, args);
1858 } 1858 }
1859 1859
1860 octave_value weak_nested_fcn_handle::workspace (void) const 1860 octave_value weak_nested_fcn_handle::workspace () const
1861 { 1861 {
1862 std::shared_ptr<stack_frame> frames = m_stack_context.lock (); 1862 std::shared_ptr<stack_frame> frames = m_stack_context.lock ();
1863 1863
1864 return frames ? frames->workspace () : octave_value (); 1864 return frames ? frames->workspace () : octave_value ();
1865 } 1865 }
1923 return interp.feval (m_fcn, args, nargout); 1923 return interp.feval (m_fcn, args, nargout);
1924 1924
1925 return interp.feval (fcn_name (), args, nargout); 1925 return interp.feval (fcn_name (), args, nargout);
1926 } 1926 }
1927 1927
1928 octave_scalar_map class_simple_fcn_handle::info (void) 1928 octave_scalar_map class_simple_fcn_handle::info ()
1929 { 1929 {
1930 octave_scalar_map m; 1930 octave_scalar_map m;
1931 1931
1932 m.setfield ("function", fcn_name ()); 1932 m.setfield ("function", fcn_name ());
1933 m.setfield ("type", type ()); 1933 m.setfield ("type", type ());
2052 return false; 2052 return false;
2053 } 2053 }
2054 2054
2055 const std::string base_anonymous_fcn_handle::anonymous ("@<anonymous>"); 2055 const std::string base_anonymous_fcn_handle::anonymous ("@<anonymous>");
2056 2056
2057 octave_scalar_map base_anonymous_fcn_handle::info (void) 2057 octave_scalar_map base_anonymous_fcn_handle::info ()
2058 { 2058 {
2059 octave_scalar_map m; 2059 octave_scalar_map m;
2060 2060
2061 std::ostringstream buf; 2061 std::ostringstream buf;
2062 print_raw (buf, true, 0); 2062 print_raw (buf, true, 0);
2692 { 2692 {
2693 if (m_stack_context) 2693 if (m_stack_context)
2694 m_stack_context->mark_closure_context (); 2694 m_stack_context->mark_closure_context ();
2695 } 2695 }
2696 2696
2697 octave_value anonymous_fcn_handle::make_weak_anonymous_handle (void) const 2697 octave_value anonymous_fcn_handle::make_weak_anonymous_handle () const
2698 { 2698 {
2699 return octave_value (new octave_fcn_handle 2699 return octave_value (new octave_fcn_handle
2700 (new weak_anonymous_fcn_handle (*this))); 2700 (new weak_anonymous_fcn_handle (*this)));
2701 } 2701 }
2702 2702
2712 unwind_action act ([&tw] () { tw.pop_stack_frame (); }); 2712 unwind_action act ([&tw] () { tw.pop_stack_frame (); });
2713 2713
2714 return oct_usr_fcn->execute (tw, nargout, args); 2714 return oct_usr_fcn->execute (tw, nargout, args);
2715 } 2715 }
2716 2716
2717 octave_value anonymous_fcn_handle::workspace (void) const 2717 octave_value anonymous_fcn_handle::workspace () const
2718 { 2718 {
2719 octave_scalar_map local_vars_map; 2719 octave_scalar_map local_vars_map;
2720 2720
2721 for (const auto& nm_val : m_local_vars) 2721 for (const auto& nm_val : m_local_vars)
2722 local_vars_map.assign (nm_val.first, nm_val.second); 2722 local_vars_map.assign (nm_val.first, nm_val.second);
2766 unwind_action act ([&tw] () { tw.pop_stack_frame (); }); 2766 unwind_action act ([&tw] () { tw.pop_stack_frame (); });
2767 2767
2768 return oct_usr_fcn->execute (tw, nargout, args); 2768 return oct_usr_fcn->execute (tw, nargout, args);
2769 } 2769 }
2770 2770
2771 octave_value weak_anonymous_fcn_handle::workspace (void) const 2771 octave_value weak_anonymous_fcn_handle::workspace () const
2772 { 2772 {
2773 octave_scalar_map local_vars_map; 2773 octave_scalar_map local_vars_map;
2774 2774
2775 for (const auto& nm_val : m_local_vars) 2775 for (const auto& nm_val : m_local_vars)
2776 local_vars_map.assign (nm_val.first, nm_val.second); 2776 local_vars_map.assign (nm_val.first, nm_val.second);
2811 return false; 2811 return false;
2812 } 2812 }
2813 2813
2814 OCTAVE_END_NAMESPACE(octave) 2814 OCTAVE_END_NAMESPACE(octave)
2815 2815
2816 octave_fcn_handle::octave_fcn_handle (void) 2816 octave_fcn_handle::octave_fcn_handle ()
2817 : octave_base_value (), m_rep (new octave::invalid_fcn_handle ()) 2817 : octave_base_value (), m_rep (new octave::invalid_fcn_handle ())
2818 { } 2818 { }
2819 2819
2820 octave_fcn_handle::octave_fcn_handle (const octave_value& fcn) 2820 octave_fcn_handle::octave_fcn_handle (const octave_value& fcn)
2821 : octave_base_value (), m_rep (new octave::internal_fcn_handle (fcn)) 2821 : octave_base_value (), m_rep (new octave::internal_fcn_handle (fcn))
2881 { 2881 {
2882 m_rep.reset (fh.m_rep->clone ()); 2882 m_rep.reset (fh.m_rep->clone ());
2883 } 2883 }
2884 2884
2885 dim_vector 2885 dim_vector
2886 octave_fcn_handle::dims (void) const 2886 octave_fcn_handle::dims () const
2887 { 2887 {
2888 static dim_vector dv (1, 1); 2888 static dim_vector dv (1, 1);
2889 return dv; 2889 return dv;
2890 } 2890 }
2891 2891