# HG changeset patch # User jwe # Date 949559299 0 # Node ID 403039c85792a3cc328ee5135932defba8e7cb0c # Parent 7031786b3f27af8239013f920e25ae2c904dbc52 [project @ 2000-02-03 06:23:11 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ +2000-02-03 John W. Eaton + + * mappers.cc (xconj, ximag, xreal): New functions. Use them in + DEFUN_MAPPER calls. + + * defun-int.h (DEFUN_MAPPER_INTERNAL): Cast function pointer args + to octave_mapper constructor. + 2000-02-02 John W. Eaton + * procstream.cc (procstreambase::procstreambase, + procstreambase::open, procstreambase::close): + Call std::ios::setstate, not set. + * lex.l (plot_axes_token): Declare plot_axes as const char *. Declare tmp const char **. diff --git a/src/defun-int.h b/src/defun-int.h --- a/src/defun-int.h +++ b/src/defun-int.h @@ -172,13 +172,21 @@ // How mapper functions are actually installed. +// XXX FIXME XXX -- Really want to avoid the following casts, since +// (as always with casts) it may mask some real errors... + #define DEFUN_MAPPER_INTERNAL(name, ch_map, d_b_map, c_b_map, d_d_map, \ d_c_map, c_c_map, lo, hi, \ can_ret_cmplx_for_real, doc) \ install_builtin_mapper \ - (new octave_mapper (ch_map, d_b_map, c_b_map, d_d_map, d_c_map, \ - c_c_map, lo, hi, \ - can_ret_cmplx_for_real, #name)) + (new octave_mapper \ + (X_CAST (octave_mapper::ch_mapper, ch_map), \ + X_CAST (octave_mapper::d_b_mapper, d_b_map), \ + X_CAST (octave_mapper::c_b_mapper, c_b_map), \ + X_CAST (octave_mapper::d_d_mapper, d_d_map), \ + X_CAST (octave_mapper::d_c_mapper, d_c_map), \ + X_CAST (octave_mapper::c_c_mapper, c_c_map), \ + lo, hi, can_ret_cmplx_for_real, #name)) #endif /* ! MAKE_BUILTINS */ diff --git a/src/mappers.cc b/src/mappers.cc --- a/src/mappers.cc +++ b/src/mappers.cc @@ -128,6 +128,30 @@ return toupper (c); } +static Complex +xconj (const Complex& x) +{ + return conj (x); +} + +static double +xconj (double x) +{ + return x; +} + +static Complex +ximag (const Complex& x) +{ + return Complex (0.0, x.imag ()); +} + +static Complex +xreal (const Complex& x) +{ + return Complex (x.real (), 0.0); +} + void install_mapper_functions (void) { @@ -230,7 +254,7 @@ complex, return @code{ceil (real (@var{x})) + ceil (imag (@var{x})) * I}.\n\ @end deftypefn"); - DEFUN_MAPPER (conj, 0, 0, 0, conj, 0, conj, 0.0, 0.0, 0, + DEFUN_MAPPER (conj, 0, 0, 0, xconj, 0, xconj, 0.0, 0.0, 0, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} conj (@var{z})\n\ Return the complex conjugate of @var{z}, defined as\n\ @@ -357,7 +381,7 @@ \n\ @seealso{gammai and lgamma}"); - DEFUN_MAPPER (imag, 0, 0, 0, imag, imag, 0, 0.0, 0.0, 0, + DEFUN_MAPPER (imag, 0, 0, 0, imag, ximag, 0, 0.0, 0.0, 0, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} imag (@var{z})\n\ Return the imaginary part of @var{z} as a real number.\n\ @@ -491,7 +515,7 @@ @end deftypefn\n\ @seealso{log, log2, logspace, and exp}"); - DEFUN_MAPPER (real, 0, 0, 0, real, real, 0, 0.0, 0.0, 0, + DEFUN_MAPPER (real, 0, 0, 0, real, xreal, 0, 0.0, 0.0, 0, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} real (@var{z})\n\ Return the real part of @var{z}.\n\