annotate src/ov-type-conv.h @ 16088:b29b10fbb744 stable release-3-6-4

Version 3.6.4 released. * configure.ac (AC_INIT): Version is now 3.6.4. (OCTAVE_RELEASE_DATE): Now 2013-02-21.
author John W. Eaton <jwe@octave.org>
date Thu, 21 Feb 2013 15:17:54 -0500
parents 72c96de7a403
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
1 /*
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
3 Copyright (C) 2004-2012 John W. Eaton
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
4
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
6
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
10 option) any later version.
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
11
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
15 for more details.
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
16
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
19 <http://www.gnu.org/licenses/>.
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
20
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
21 */
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
22
9340
49fe8721bae1 fix include guards
Kai NODA <nodakai@gmail.com>
parents: 8920
diff changeset
23 #if !defined (octave_ov_type_conv_h)
49fe8721bae1 fix include guards
Kai NODA <nodakai@gmail.com>
parents: 8920
diff changeset
24 #define octave_ov_type_conv_h 1
49fe8721bae1 fix include guards
Kai NODA <nodakai@gmail.com>
parents: 8920
diff changeset
25
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
26 static
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
27 octave_value
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
28 octave_type_conv_body (const octave_value &arg, const std::string& name, int t_result)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
29 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
30 int t_arg = arg.type_id ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
31 octave_value retval;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
32
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
33 if (t_arg == t_result || arg.class_name () == name)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
34 {
10184
b39bd23019eb partially revert a668fbd32e34
Jaroslav Hajek <highegg@gmail.com>
parents: 10181
diff changeset
35 retval = arg;
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
36 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
37 else
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
38 {
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
39 octave_base_value::type_conv_fcn cf1
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
40 = octave_value_typeinfo::lookup_type_conv_op (t_arg, t_result);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
41
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
42 if (cf1)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
43 {
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
44 octave_base_value *tmp (cf1 (*(arg.internal_rep ())));
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
45
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
46 if (tmp)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
47 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
48 retval = octave_value (tmp);
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
49
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
50 retval.maybe_mutate ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
51 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
52 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
53 else
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
54 {
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
55 octave_base_value::type_conv_fcn cf2
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
56 = arg.numeric_conversion_function ();
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
57
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
58 if (cf2)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
59 {
8184
bb3bdcdaa063 oct-type-conv.h (octave_type_conv_body): avoid shadow warning from GCC
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
60 octave_base_value *tmp (cf2 (*(arg.internal_rep ())));
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
61
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
62 if (tmp)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
63 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
64 octave_value xarg (tmp);
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
65
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
66 retval = octave_type_conv_body (xarg, name, t_result);
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
67 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
68 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
69 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
70 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
71
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
72 return retval;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
73 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
74
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
75
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
76 #define OCTAVE_TYPE_CONV_BODY3(NAME, MATRIX_RESULT_T, SCALAR_RESULT_T) \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
77 \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
78 octave_value retval; \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
79 \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
80 int nargin = args.length (); \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
81 \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
82 if (nargin == 1) \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
83 { \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
84 const octave_value arg = args(0); \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
85 \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
86 int t_result = MATRIX_RESULT_T::static_type_id (); \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
87 \
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
88 retval = octave_type_conv_body (arg, #NAME, t_result); \
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
89 if (retval.is_undefined ()) \
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
90 { \
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
91 std::string arg_tname = arg.type_name (); \
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
92 \
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
93 std::string result_tname = arg.numel () == 1 \
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
94 ? SCALAR_RESULT_T::static_type_name () \
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
95 : MATRIX_RESULT_T::static_type_name (); \
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
96 \
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
97 gripe_invalid_conversion (arg_tname, result_tname); \
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
98 } \
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
99 } \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
100 else \
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5759
diff changeset
101 print_usage (); \
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
102 \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
103 return retval
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
104
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
105 #define OCTAVE_TYPE_CONV_BODY(NAME) \
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
106 OCTAVE_TYPE_CONV_BODY3 (NAME, octave_ ## NAME ## _matrix, \
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10184
diff changeset
107 octave_ ## NAME ## _scalar)
4901
35bfb4e0b96b [project @ 2004-06-14 18:33:02 by jwe]
jwe
parents:
diff changeset
108
9340
49fe8721bae1 fix include guards
Kai NODA <nodakai@gmail.com>
parents: 8920
diff changeset
109 #endif