3295
|
1 #! /bin/sh |
7019
|
2 # |
|
3 # Copyright (C) 1999, 2000, 2002, 2003, 2005, 2006, 2007 John W. Eaton |
|
4 # |
|
5 # This file is part of Octave. |
|
6 # |
|
7 # Octave is free software; you can redistribute it and/or modify it |
|
8 # under the terms of the GNU General Public License as published by the |
|
9 # Free Software Foundation; either version 3 of the License, or (at |
|
10 # your option) any later version. |
|
11 # |
|
12 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 # for more details. |
|
16 # |
|
17 # You should have received a copy of the GNU General Public License |
|
18 # along with Octave; see the file COPYING. If not, see |
|
19 # <http://www.gnu.org/licenses/>. |
3295
|
20 |
4299
|
21 SED=${SED:-'sed'} |
|
22 |
3295
|
23 if test $# -ne 1; then |
|
24 echo "usage: mkgendoc f1" 1>&2 |
|
25 exit 1 |
|
26 fi |
|
27 |
|
28 DOC_FILES=`cat $1` |
|
29 |
|
30 if test -z "$DOC_FILES"; then |
|
31 echo "mkgendoc: DOC_FILES is empty!" 1>&2 |
|
32 exit 1 |
|
33 fi |
|
34 |
|
35 cat << \EOF |
3364
|
36 // DO NOT EDIT! Generated automatically by mkgendoc |
3295
|
37 |
4279
|
38 #if defined (__DECCXX) |
|
39 #define __USE_STD_IOSTREAM |
|
40 #endif |
|
41 |
3543
|
42 #include <iostream> |
3295
|
43 #include <string> |
|
44 |
3364
|
45 #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
|
46 print_doc_string (#name, doc); |
|
47 |
5796
|
48 #define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \ |
|
49 is_text_fcn, doc) \ |
|
50 print_doc_string (name, doc); |
|
51 |
3295
|
52 #define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ |
|
53 print_doc_string (#name, doc); |
|
54 |
4234
|
55 #define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, \ |
|
56 is_text_fcn, doc) \ |
|
57 print_doc_string (#name, doc); |
|
58 |
3746
|
59 #define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, \ |
|
60 is_text_fcn, doc) \ |
|
61 print_doc_string (name, doc); |
|
62 |
3295
|
63 #define XDEFALIAS_INTERNAL(alias, name) |
|
64 |
|
65 #define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \ |
|
66 print_doc_string (#name, doc); |
|
67 |
3321
|
68 #define XDEFCONST_INTERNAL(name, defn, doc) \ |
3295
|
69 print_doc_string (#name, doc); |
|
70 |
|
71 #define XDEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ |
|
72 d_c_map, c_c_map, lo, hi, \ |
4100
|
73 ch_map_flag, can_ret_cmplx_for_real, doc) \ |
3295
|
74 print_doc_string (#name, doc); |
|
75 |
|
76 static void |
3555
|
77 print_doc_string (const std::string& name, const std::string& doc) |
3295
|
78 { |
3553
|
79 std::cout << ""; |
3321
|
80 |
|
81 size_t len = name.length (); |
|
82 |
|
83 if (name[0] == '"' && name[len-1] == '"') |
3553
|
84 std::cout << name.substr (1, len-2); |
3321
|
85 else |
3553
|
86 std::cout << name; |
3321
|
87 |
3553
|
88 std::cout << "\n" << doc << "\n"; |
3295
|
89 } |
|
90 |
|
91 EOF |
|
92 |
|
93 for file in $DOC_FILES; do |
4299
|
94 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'` |
3295
|
95 echo "static void" |
|
96 echo "print_${fcn}_doc_strings (void)" |
|
97 echo "{" |
|
98 cat $file |
|
99 echo "}" |
|
100 echo "" |
|
101 done |
|
102 |
|
103 cat << \EOF |
|
104 |
|
105 int |
|
106 main (void) |
|
107 { |
5333
|
108 std::cout |
|
109 << "### DO NOT EDIT!\n" |
|
110 << "###\n" |
|
111 << "### This file is generated automatically from the Octave sources.\n" |
|
112 << "### Edit those files instead and run make to update this file.\n" |
|
113 << std::endl; |
|
114 |
3295
|
115 EOF |
|
116 |
|
117 for file in $DOC_FILES; do |
4299
|
118 fcn=`echo $file | $SED 's,^\./,,; s/\.df//; s/-/_/g'` |
3295
|
119 echo " print_${fcn}_doc_strings ();" |
|
120 done |
|
121 |
|
122 cat << \EOF |
|
123 |
|
124 return 0; |
|
125 } |
|
126 EOF |
|
127 |
|
128 exit 0 |