GNU Octave 7.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-2022 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
33namespace octave
34{
36 {
37 if (f.is_string ())
38 {
39 std::string name = f.string_value ();
40
41 m_rep = std::shared_ptr<base_hook_function> (new named_hook_function (name, d));
42 }
43 else if (f.is_function_handle ())
44 {
45 m_rep = std::shared_ptr<base_hook_function> (new fcn_handle_hook_function (f, d));
46 }
47 else
48 error ("invalid hook function");
49 }
50
52 {
53 octave_value_list args = initial_args;
54
55 if (m_data.is_defined ())
56 args.append (m_data);
57
58 feval (m_name, args, 0);
59 }
60
62 {
63 octave_value_list args = initial_args;
64
65 if (m_data.is_defined ())
66 args.append (m_data);
67
68 feval (m_fcn_handle, args, 0);
69 }
70}
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:61
std::shared_ptr< base_hook_function > m_rep
Definition: hook-fcn.h:90
void eval(const octave_value_list &initial_args)
Definition: hook-fcn.cc:51
octave_value_list & append(const octave_value &val)
Definition: ovl.cc:98
bool is_defined(void) const
Definition: ov.h:637
void error(const char *fmt,...)
Definition: error.cc:980
QString name
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
OCTINTERP_API octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
static double f(double k, double l_nu, double c_pm)
Definition: randpoisson.cc:118