Mercurial > hg > octave-nkf
comparison src/oct-stream.cc @ 9202:4b2147b25e8d
clean up Array instantiation mess in oct-stream.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 15 May 2009 13:34:43 +0200 |
parents | 9543a90fac18 |
children | e793865ede63 |
comparison
equal
deleted
inserted
replaced
9201:472f0e22aa60 | 9202:4b2147b25e8d |
---|---|
28 #include <cassert> | 28 #include <cassert> |
29 #include <cctype> | 29 #include <cctype> |
30 #include <cstring> | 30 #include <cstring> |
31 | 31 |
32 #include <iomanip> | 32 #include <iomanip> |
33 #include <iostream> | |
33 #include <fstream> | 34 #include <fstream> |
34 #include <sstream> | 35 #include <sstream> |
35 #include <string> | 36 #include <string> |
36 | 37 |
37 #include <Array.h> | 38 #include <Array.h> |
38 #include <Array2.h> | |
39 #include <Array3.h> | |
40 | |
41 #include <Array.cc> | |
42 | 39 |
43 #include "byte-swap.h" | 40 #include "byte-swap.h" |
44 #include "lo-ieee.h" | 41 #include "lo-ieee.h" |
45 #include "lo-mappers.h" | 42 #include "lo-mappers.h" |
46 #include "lo-utils.h" | 43 #include "lo-utils.h" |
3268 INSTANTIATE_DO_READ (boolNDArray); | 3265 INSTANTIATE_DO_READ (boolNDArray); |
3269 | 3266 |
3270 typedef octave_value (*read_fptr) (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, | 3267 typedef octave_value (*read_fptr) (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, |
3271 oct_mach_info::float_format ffmt, octave_idx_type&); | 3268 oct_mach_info::float_format ffmt, octave_idx_type&); |
3272 | 3269 |
3273 NO_INSTANTIATE_ARRAY_SORT (read_fptr); | |
3274 INSTANTIATE_ARRAY (read_fptr,); | |
3275 template class Array2<read_fptr>; | |
3276 | |
3277 #define FILL_TABLE_ROW(R, VAL_T) \ | 3270 #define FILL_TABLE_ROW(R, VAL_T) \ |
3278 read_fptr_table(R,oct_data_conv::dt_int8) = do_read<VAL_T, octave_int8>; \ | 3271 read_fptr_table[R][oct_data_conv::dt_int8] = do_read<VAL_T, octave_int8>; \ |
3279 read_fptr_table(R,oct_data_conv::dt_uint8) = do_read<VAL_T, octave_uint8>; \ | 3272 read_fptr_table[R][oct_data_conv::dt_uint8] = do_read<VAL_T, octave_uint8>; \ |
3280 read_fptr_table(R,oct_data_conv::dt_int16) = do_read<VAL_T, octave_int16>; \ | 3273 read_fptr_table[R][oct_data_conv::dt_int16] = do_read<VAL_T, octave_int16>; \ |
3281 read_fptr_table(R,oct_data_conv::dt_uint16) = do_read<VAL_T, octave_uint16>; \ | 3274 read_fptr_table[R][oct_data_conv::dt_uint16] = do_read<VAL_T, octave_uint16>; \ |
3282 read_fptr_table(R,oct_data_conv::dt_int32) = do_read<VAL_T, octave_int32>; \ | 3275 read_fptr_table[R][oct_data_conv::dt_int32] = do_read<VAL_T, octave_int32>; \ |
3283 read_fptr_table(R,oct_data_conv::dt_uint32) = do_read<VAL_T, octave_uint32>; \ | 3276 read_fptr_table[R][oct_data_conv::dt_uint32] = do_read<VAL_T, octave_uint32>; \ |
3284 read_fptr_table(R,oct_data_conv::dt_int64) = do_read<VAL_T, octave_int64>; \ | 3277 read_fptr_table[R][oct_data_conv::dt_int64] = do_read<VAL_T, octave_int64>; \ |
3285 read_fptr_table(R,oct_data_conv::dt_uint64) = do_read<VAL_T, octave_uint64>; \ | 3278 read_fptr_table[R][oct_data_conv::dt_uint64] = do_read<VAL_T, octave_uint64>; \ |
3286 read_fptr_table(R,oct_data_conv::dt_single) = do_read<VAL_T, float>; \ | 3279 read_fptr_table[R][oct_data_conv::dt_single] = do_read<VAL_T, float>; \ |
3287 read_fptr_table(R,oct_data_conv::dt_double) = do_read<VAL_T, double>; \ | 3280 read_fptr_table[R][oct_data_conv::dt_double] = do_read<VAL_T, double>; \ |
3288 read_fptr_table(R,oct_data_conv::dt_char) = do_read<VAL_T, char>; \ | 3281 read_fptr_table[R][oct_data_conv::dt_char] = do_read<VAL_T, char>; \ |
3289 read_fptr_table(R,oct_data_conv::dt_schar) = do_read<VAL_T, signed char>; \ | 3282 read_fptr_table[R][oct_data_conv::dt_schar] = do_read<VAL_T, signed char>; \ |
3290 read_fptr_table(R,oct_data_conv::dt_uchar) = do_read<VAL_T, unsigned char>; \ | 3283 read_fptr_table[R][oct_data_conv::dt_uchar] = do_read<VAL_T, unsigned char>; \ |
3291 read_fptr_table(R,oct_data_conv::dt_logical) = do_read<VAL_T, unsigned char> | 3284 read_fptr_table[R][oct_data_conv::dt_logical] = do_read<VAL_T, unsigned char> |
3292 | 3285 |
3293 octave_value | 3286 octave_value |
3294 octave_stream::read (const Array<double>& size, octave_idx_type block_size, | 3287 octave_stream::read (const Array<double>& size, octave_idx_type block_size, |
3295 oct_data_conv::data_type input_type, | 3288 oct_data_conv::data_type input_type, |
3296 oct_data_conv::data_type output_type, | 3289 oct_data_conv::data_type output_type, |
3299 { | 3292 { |
3300 static bool initialized = false; | 3293 static bool initialized = false; |
3301 | 3294 |
3302 // Table function pointers for return types x read types. | 3295 // Table function pointers for return types x read types. |
3303 | 3296 |
3304 static Array2<read_fptr> read_fptr_table (oct_data_conv::dt_unknown, 14, 0); | 3297 static read_fptr read_fptr_table[oct_data_conv::dt_unknown][14]; |
3305 | 3298 |
3306 if (! initialized) | 3299 if (! initialized) |
3307 { | 3300 { |
3301 for (int i = 0; i < oct_data_conv::dt_unknown; i++) | |
3302 for (int j = 0; j < 14; j++) | |
3303 read_fptr_table[i][j] = 0; | |
3304 | |
3308 FILL_TABLE_ROW (oct_data_conv::dt_int8, int8NDArray); | 3305 FILL_TABLE_ROW (oct_data_conv::dt_int8, int8NDArray); |
3309 FILL_TABLE_ROW (oct_data_conv::dt_uint8, uint8NDArray); | 3306 FILL_TABLE_ROW (oct_data_conv::dt_uint8, uint8NDArray); |
3310 FILL_TABLE_ROW (oct_data_conv::dt_int16, int16NDArray); | 3307 FILL_TABLE_ROW (oct_data_conv::dt_int16, int16NDArray); |
3311 FILL_TABLE_ROW (oct_data_conv::dt_uint16, uint16NDArray); | 3308 FILL_TABLE_ROW (oct_data_conv::dt_uint16, uint16NDArray); |
3312 FILL_TABLE_ROW (oct_data_conv::dt_int32, int32NDArray); | 3309 FILL_TABLE_ROW (oct_data_conv::dt_int32, int32NDArray); |
3349 else | 3346 else |
3350 { | 3347 { |
3351 if (ffmt == oct_mach_info::flt_fmt_unknown) | 3348 if (ffmt == oct_mach_info::flt_fmt_unknown) |
3352 ffmt = float_format (); | 3349 ffmt = float_format (); |
3353 | 3350 |
3354 read_fptr fcn = read_fptr_table (output_type, input_type); | 3351 read_fptr fcn = read_fptr_table[output_type][input_type]; |
3355 | 3352 |
3356 bool do_float_fmt_conv = ((input_type == oct_data_conv::dt_double | 3353 bool do_float_fmt_conv = ((input_type == oct_data_conv::dt_double |
3357 || input_type == oct_data_conv::dt_single) | 3354 || input_type == oct_data_conv::dt_single) |
3358 && ffmt != float_format ()); | 3355 && ffmt != float_format ()); |
3359 | 3356 |