525
|
1 // defun-int.h -*- C++ -*- |
|
2 /* |
|
3 |
1884
|
4 Copyright (C) 1996 John W. Eaton |
525
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
525
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_defun_int_h) |
|
25 #define octave_defun_int_h 1 |
|
26 |
550
|
27 // MAKE_BUILTINS is defined to extract function names and related |
|
28 // information and create the *.def files that are eventually used to |
|
29 // create the buitlins.cc file. |
|
30 |
525
|
31 #ifdef MAKE_BUILTINS |
|
32 |
550
|
33 // Generate code to install name in the symbol table. The script |
|
34 // mkdefs will create a .def file for every .cc file that uses DEFUN, |
|
35 // DEFUN_TEXT, or DEFUN_DLD. |
|
36 |
1488
|
37 #define DEFUN_INTERNAL(name, fname, sname, unused_arg_flags, \ |
525
|
38 is_text_fcn, doc) \ |
|
39 BEGIN_INSTALL_BUILTIN \ |
1488
|
40 extern DECLARE_FUN_ ## unused_arg_flags (fname); \ |
|
41 DEFINE_FUN_STRUCT (name, fname, sname, is_text_fcn, doc); \ |
1755
|
42 install_builtin_function (sname); \ |
525
|
43 END_INSTALL_BUILTIN |
|
44 |
550
|
45 // Generate code for making another name for an existing function. |
|
46 |
|
47 #define DEFALIAS_INTERNAL(alias, name) \ |
|
48 BEGIN_INSTALL_BUILTIN \ |
|
49 alias_builtin (#alias, #name); \ |
|
50 END_INSTALL_BUILTIN |
525
|
51 |
|
52 #else /* ! MAKE_BUILTINS */ |
|
53 |
550
|
54 // Generate the first line of the function definition. This ensures |
|
55 // that the internal functions all have the same signature. |
|
56 |
1488
|
57 #define DEFUN_INTERNAL(name, fname, sname, unused_arg_flags, \ |
525
|
58 is_text_fcn, doc) \ |
1488
|
59 DECLARE_FUN_ ## unused_arg_flags (fname) |
525
|
60 |
550
|
61 // No definition is required for an alias. |
|
62 |
|
63 #define DEFALIAS_INTERNAL(name, alias) |
525
|
64 |
|
65 #endif /* ! MAKE_BUILTINS */ |
|
66 |
703
|
67 // Define the structure that will be used to insert this function into |
|
68 // the symbol table. |
|
69 |
1488
|
70 #define DEFINE_FUN_STRUCT(name, fname, sname, is_text_fcn, doc) \ |
1755
|
71 static builtin_function sname (name, is_text_fcn, fname, doc) |
703
|
72 |
|
73 #define DEFINE_FUN_STRUCT_FUN(sname, fsname) \ |
1755
|
74 builtin_function& \ |
703
|
75 fsname (void) \ |
|
76 { \ |
1755
|
77 return sname; \ |
703
|
78 } |
|
79 |
550
|
80 // Declare an internal function named fname. This is the interface |
|
81 // used by all internal functions in Octave that are also callable |
1488
|
82 // from the Octave language. The funny suffixes are used to help us |
|
83 // avoid warnings from g++ about unused arguments. |
|
84 |
|
85 #define DECLARE_FUN_00(fname) \ |
|
86 Octave_object fname (const Octave_object&, int) |
550
|
87 |
1488
|
88 #define DECLARE_FUN_01(fname) \ |
|
89 Octave_object fname (const Octave_object&, int nargout) |
|
90 |
|
91 #define DECLARE_FUN_10(fname) \ |
|
92 Octave_object fname (const Octave_object& args, int) |
|
93 |
|
94 #define DECLARE_FUN_11(fname) \ |
|
95 Octave_object fname (const Octave_object& args, int nargout) |
|
96 |
|
97 #define DECLARE_FUN_(fname) DECLARE_FUN_11 (fname) |
525
|
98 |
|
99 #endif |
|
100 |
|
101 /* |
|
102 ;;; Local Variables: *** |
|
103 ;;; mode: C++ *** |
|
104 ;;; page-delimiter: "^/\\*" *** |
|
105 ;;; End: *** |
|
106 */ |