Mercurial > hg > octave-lyh
comparison src/corefcn/__dispatch__.cc @ 15039:e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
* __contourc__.cc, __dispatch__.cc, __lin_interpn__.cc, __pchip_deriv__.cc,
__qp__.cc, balance.cc, besselj.cc, betainc.cc, bsxfun.cc, cellfun.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, det.cc, dlmread.cc, dot.cc,
eig.cc, fft.cc, fft2.cc, fftn.cc, filter.cc, find.cc, gammainc.cc, gcd.cc,
getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, hess.cc, hex2num.cc, inv.cc,
kron.cc, lookup.cc, lsode.cc, lu.cc, luinc.cc, matrix_type.cc, max.cc,
md5sum.cc, mgorth.cc, nproc.cc, pinv.cc, quad.cc, quadcc.cc, qz.cc,
rand.cc, rcond.cc, regexp.cc, schur.cc, spparms.cc, sqrtm.cc, str2double.cc,
strfind.cc, sub2ind.cc, svd.cc, syl.cc, time.cc, tril.cc, typecast.cc:
Move functions from DLD-FUNCTIONS/ to corefcn/ directory. Include "defun.h",
not "defun-dld.h". Change docstring to refer to these as "Built-in Functions".
* build-aux/mk-opts.pl: Generate options code with '#include "defun.h"'. Change
option docstrings to refer to these as "Built-in Functions".
* corefcn/module.mk: List of functions to build in corefcn/ dir.
* DLD-FUNCTIONS/config-module.awk: Update to new build system.
* DLD-FUNCTIONS/module-files: Remove functions which are now in corefcn/ directory.
* src/Makefile.am: Update to build "convenience library" in corefcn/. Octave
program now links against all other libraries + corefcn libary.
* src/find-defun-files.sh: Strip $srcdir from filename.
* src/link-deps.mk: Add REGEX and FFTW link dependencies for liboctinterp.
* type.m, which.m: Change failing tests to use 'amd', still a dynamic function,
rather than 'dot', which isn't.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 27 Jul 2012 15:35:00 -0700 |
parents | src/DLD-FUNCTIONS/__dispatch__.cc@60e5cf354d80 |
children |
comparison
equal
deleted
inserted
replaced
15038:ab18578c2ade | 15039:e753177cde93 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 2001-2012 John W. Eaton and Paul Kienzle | |
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 your | |
10 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/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <list> | |
28 #include <map> | |
29 #include <string> | |
30 | |
31 #include "Cell.h" | |
32 #include "oct-map.h" | |
33 #include "defun.h" | |
34 #include "ov.h" | |
35 #include "ov-fcn.h" | |
36 #include "ov-typeinfo.h" | |
37 #include "pager.h" | |
38 #include "parse.h" | |
39 #include "symtab.h" | |
40 #include "variables.h" | |
41 | |
42 DEFUN (__dispatch__, args, nargout, | |
43 "Undocumented internal function") | |
44 { | |
45 octave_value retval; | |
46 | |
47 int nargin = args.length (); | |
48 | |
49 std::string f, r, t; | |
50 | |
51 if (nargin > 0 && nargin < 4) | |
52 { | |
53 if (nargin > 0) | |
54 { | |
55 f = args(0).string_value (); | |
56 | |
57 if (error_state) | |
58 { | |
59 error ("__dispatch__: first argument must be a function name"); | |
60 return retval; | |
61 } | |
62 } | |
63 | |
64 if (nargin > 1) | |
65 { | |
66 r = args(1).string_value (); | |
67 | |
68 if (error_state) | |
69 { | |
70 error ("__dispatch__: second argument must be a function name"); | |
71 return retval; | |
72 } | |
73 } | |
74 | |
75 if (nargin > 2) | |
76 { | |
77 t = args(2).string_value (); | |
78 | |
79 if (error_state) | |
80 { | |
81 error ("__dispatch__: third argument must be a type name"); | |
82 return retval; | |
83 } | |
84 } | |
85 | |
86 if (nargin == 1) | |
87 { | |
88 if (nargout > 0) | |
89 { | |
90 symbol_table::fcn_info::dispatch_map_type dm | |
91 = symbol_table::get_dispatch (f); | |
92 | |
93 size_t len = dm.size (); | |
94 | |
95 Cell type_field (len, 1); | |
96 Cell name_field (len, 1); | |
97 | |
98 symbol_table::fcn_info::dispatch_map_type::const_iterator p | |
99 = dm.begin (); | |
100 | |
101 for (size_t i = 0; i < len; i++) | |
102 { | |
103 type_field(i) = p->first; | |
104 name_field(i) = p->second; | |
105 | |
106 p++; | |
107 } | |
108 | |
109 octave_scalar_map m; | |
110 | |
111 m.assign ("type", type_field); | |
112 m.assign ("name", name_field); | |
113 | |
114 retval = m; | |
115 } | |
116 else | |
117 symbol_table::print_dispatch (octave_stdout, f); | |
118 } | |
119 else if (nargin == 2) | |
120 { | |
121 t = r; | |
122 symbol_table::clear_dispatch (f, t); | |
123 } | |
124 else | |
125 symbol_table::add_dispatch (f, t, r); | |
126 } | |
127 else | |
128 print_usage (); | |
129 | |
130 return retval; | |
131 } | |
132 | |
133 /* | |
134 ## No test needed for internal helper function. | |
135 %!assert (1) | |
136 */ |