GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
hook-fcn.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2013-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "hook-fcn.h"
31 #include "interpreter-private.h"
32 #include "interpreter.h"
33 
35 
37 {
38  if (f.is_string ())
39  {
40  std::string name = f.string_value ();
41 
42  m_rep = std::shared_ptr<base_hook_function> (new named_hook_function (name, d));
43  }
44  else if (f.is_function_handle ())
45  {
46  m_rep = std::shared_ptr<base_hook_function> (new fcn_handle_hook_function (f, d));
47  }
48  else
49  error ("invalid hook function");
50 }
51 
52 void
54 {
55  octave_value_list args = initial_args;
56 
57  if (m_data.is_defined ())
58  args.append (m_data);
59 
60  interpreter& interp = __get_interpreter__ ();
61 
62  interp.feval (m_name, args, 0);
63 }
64 
65 void
67 {
68  octave_value_list args = initial_args;
69 
70  if (m_data.is_defined ())
71  args.append (m_data);
72 
73  interpreter& interp = __get_interpreter__ ();
74 
75  interp.feval (m_fcn_handle, args, 0);
76 }
77 
78 OCTAVE_END_NAMESPACE(octave)
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:66
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:53
octave_value_list & append(const octave_value &val)
Definition: ovl.cc:98
bool is_defined() const
Definition: ov.h:592
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
Definition: error.cc:988
interpreter & __get_interpreter__()
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE const F77_DBLE * f