Mercurial > octave
annotate libinterp/corefcn/hook-fcn.cc @ 22003:2d3972b802ff
use consistent style for including config.h in source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 30 Jun 2016 11:41:49 -0400 |
parents | 40de9f8f23a6 |
children | bac0d6f07a3e |
rev | line source |
---|---|
16385
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
16892
diff
changeset
|
3 Copyright (C) 2013-2015 John W. Eaton |
16385
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 option) any later version. |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 for more details. |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 # include "config.h" |
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
25 #endif |
16385
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include "hook-fcn.h" |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 hook_function::hook_function (const octave_value& f, const octave_value& d) |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 { |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 if (f.is_string ()) |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 { |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 std::string name = f.string_value (); |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 rep = new named_hook_function (name, d); |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 } |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 else if (f.is_function_handle ()) |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 { |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 rep = new fcn_handle_hook_function (f, d); |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 } |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 else |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 error ("invalid hook function"); |
a1690c3e93eb
move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 } |