GNU Octave  6.2.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-2021 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 "parse.h"
32 
34 {
35  if (f.is_string ())
36  {
37  std::string name = f.string_value ();
38 
39  rep = new named_hook_function (name, d);
40  }
41  else if (f.is_function_handle ())
42  {
44  }
45  else
46  error ("invalid hook function");
47 }
48 
49 void named_hook_function::eval (const octave_value_list& initial_args)
50 {
51  octave_value_list args = initial_args;
52 
53  if (data.is_defined ())
54  args.append (data);
55 
56  octave::feval (name, args, 0);
57 }
58 
60 {
61  octave_value_list args = initial_args;
62 
63  if (data.is_defined ())
64  args.append (data);
65 
66  octave::feval (fcn_handle, args, 0);
67 }
68 
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:59
octave_value fcn_handle
Definition: hook-fcn.h:171
hook_function(void)
Definition: hook-fcn.h:67
base_hook_function * rep
Definition: hook-fcn.h:114
std::string name
Definition: hook-fcn.h:134
octave_value data
Definition: hook-fcn.h:136
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:49
octave_value_list & append(const octave_value &val)
Definition: ovl.cc:98
bool is_defined(void) const
Definition: ov.h:551
void error(const char *fmt,...)
Definition: error.cc:968
QString name
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE const F77_DBLE * f
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
Definition: oct-parse.cc:9580