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
33
hook_function::hook_function
(
const
octave_value
&
f
,
const
octave_value
&
d
)
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
{
43
rep
=
new
fcn_handle_hook_function
(
f
,
d
);
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
59
void
fcn_handle_hook_function::eval
(
const
octave_value_list
& initial_args)
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
fcn_handle_hook_function
Definition:
hook-fcn.h:141
fcn_handle_hook_function::data
octave_value data
Definition:
hook-fcn.h:173
fcn_handle_hook_function::eval
void eval(const octave_value_list &initial_args)
Definition:
hook-fcn.cc:59
fcn_handle_hook_function::fcn_handle
octave_value fcn_handle
Definition:
hook-fcn.h:171
hook_function::hook_function
hook_function(void)
Definition:
hook-fcn.h:67
hook_function::rep
base_hook_function * rep
Definition:
hook-fcn.h:114
named_hook_function
Definition:
hook-fcn.h:119
named_hook_function::name
std::string name
Definition:
hook-fcn.h:134
named_hook_function::data
octave_value data
Definition:
hook-fcn.h:136
named_hook_function::eval
void eval(const octave_value_list &initial_args)
Definition:
hook-fcn.cc:49
octave_value_list
Definition:
ovl.h:44
octave_value_list::append
octave_value_list & append(const octave_value &val)
Definition:
ovl.cc:98
octave_value
Definition:
ov.h:79
octave_value::is_defined
bool is_defined(void) const
Definition:
ov.h:551
error
void error(const char *fmt,...)
Definition:
error.cc:968
name
QString name
Definition:
gui-preferences-dw.h:51
hook-fcn.h
d
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
Definition:
lo-slatec-proto.h:39
f
F77_RET_T const F77_DBLE const F77_DBLE * f
Definition:
lo-slatec-proto.h:39
octave::feval
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
parse.h
libinterp
corefcn
hook-fcn.cc
Generated on Tue Apr 13 2021 15:27:45 for GNU Octave by
1.9.1