annotate libinterp/interpfcn/hook-fcn.cc @ 16385:a1690c3e93eb

move hook_function constructor to .cc file * hook-fcn.cc: New file. Move hook_function::hook_function definition here from hook-fcn.h. * libinterp/interpfcn/module.mk (INTERPFCN_SRC): Include hook-fcn.cc in the list.
author John W. Eaton <jwe@octave.org>
date Thu, 28 Mar 2013 02:52:18 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2013 John W. Eaton
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
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #include <config.h>
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #include "hook-fcn.h"
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 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
28 {
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 if (f.is_string ())
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 std::string name = f.string_value ();
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 rep = new named_hook_function (name, d);
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 else if (f.is_function_handle ())
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 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
38 }
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 else
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 error ("invalid hook function");
a1690c3e93eb move hook_function constructor to .cc file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 }