Mercurial > hg > octave-lojdl
changeset 7999:f7f2d867c523
style fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 30 Jul 2008 16:36:58 -0400 |
parents | a4acda9fc3e7 |
children | ea3cd9791703 |
files | liboctave/ChangeLog liboctave/oct-inttypes.h src/ChangeLog src/ov-intx.h src/ov.cc |
diffstat | 5 files changed, 65 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,9 +1,14 @@ +2008-07-30 John W. Eaton <jwe@octave.org> + + * oct-inttypes.h: Style fixes. + 2008-07-30 Jaroslav Hajek <highegg@gmail.com> * oct-inttypes.h (octave_int<T>::trunc_flag): New member static field. (octave_int<T>::get_trunc_flag, octave_int<T>::clear_trunc_flag): New member functions. - (octave_int<T>::octave_int (const octave_int<U>&)): set trunc_flag on truncation. + (octave_int<T>::octave_int (const octave_int<U>&)): set trunc_flag + on truncation. (SPECIALIZE_WIDENING_CONVERSION): New macro. (DECLARE_OCTAVE_INT_TYPENAME): New macro.
--- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -43,7 +43,7 @@ }; #define OCTAVE_INT_BINOP_TRAIT(T1, T2, T3) \ - template<> \ + template <> \ class octave_int_binop_traits <T1, T2> \ { \ public: \ @@ -506,37 +506,40 @@ #define SPECIALIZE_WIDENING_CONVERSION(T1, T2) \ template <> template <> \ - inline octave_int<T2>::octave_int (T1 i) : ival (i) {} \ + inline octave_int<T2>::octave_int (T1 i) \ + : ival (i) { } \ + \ template <> template <> \ - inline octave_int<T2>::octave_int (const octave_int<T1>& i) : ival (i.value ()) {} + inline octave_int<T2>::octave_int (const octave_int<T1>& i) \ + : ival (i.value ()) { } -SPECIALIZE_WIDENING_CONVERSION(int8_t, int16_t) -SPECIALIZE_WIDENING_CONVERSION(int8_t, int32_t) -SPECIALIZE_WIDENING_CONVERSION(int8_t, int64_t) -SPECIALIZE_WIDENING_CONVERSION(int16_t, int32_t) -SPECIALIZE_WIDENING_CONVERSION(int16_t, int64_t) -SPECIALIZE_WIDENING_CONVERSION(int32_t, int64_t) -SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint16_t) -SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint32_t) -SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint64_t) -SPECIALIZE_WIDENING_CONVERSION(uint16_t, uint32_t) -SPECIALIZE_WIDENING_CONVERSION(uint16_t, uint64_t) -SPECIALIZE_WIDENING_CONVERSION(uint32_t, uint64_t) +SPECIALIZE_WIDENING_CONVERSION (int8_t, int16_t) +SPECIALIZE_WIDENING_CONVERSION (int8_t, int32_t) +SPECIALIZE_WIDENING_CONVERSION (int8_t, int64_t) +SPECIALIZE_WIDENING_CONVERSION (int16_t, int32_t) +SPECIALIZE_WIDENING_CONVERSION (int16_t, int64_t) +SPECIALIZE_WIDENING_CONVERSION (int32_t, int64_t) +SPECIALIZE_WIDENING_CONVERSION (uint8_t, uint16_t) +SPECIALIZE_WIDENING_CONVERSION (uint8_t, uint32_t) +SPECIALIZE_WIDENING_CONVERSION (uint8_t, uint64_t) +SPECIALIZE_WIDENING_CONVERSION (uint16_t, uint32_t) +SPECIALIZE_WIDENING_CONVERSION (uint16_t, uint64_t) +SPECIALIZE_WIDENING_CONVERSION (uint32_t, uint64_t) // declare type names #define DECLARE_OCTAVE_INT_TYPENAME(TYPE, TYPENAME) \ - template<> \ + template <> \ inline const char * \ octave_int<TYPE>::type_name () { return TYPENAME; } -DECLARE_OCTAVE_INT_TYPENAME(int8_t, "int8") -DECLARE_OCTAVE_INT_TYPENAME(int16_t, "int16") -DECLARE_OCTAVE_INT_TYPENAME(int32_t, "int32") -DECLARE_OCTAVE_INT_TYPENAME(int64_t, "int64") -DECLARE_OCTAVE_INT_TYPENAME(uint8_t, "uint8") -DECLARE_OCTAVE_INT_TYPENAME(uint16_t, "uint16") -DECLARE_OCTAVE_INT_TYPENAME(uint32_t, "uint32") -DECLARE_OCTAVE_INT_TYPENAME(uint64_t, "uint64") +DECLARE_OCTAVE_INT_TYPENAME (int8_t, "int8") +DECLARE_OCTAVE_INT_TYPENAME (int16_t, "int16") +DECLARE_OCTAVE_INT_TYPENAME (int32_t, "int32") +DECLARE_OCTAVE_INT_TYPENAME (int64_t, "int64") +DECLARE_OCTAVE_INT_TYPENAME (uint8_t, "uint8") +DECLARE_OCTAVE_INT_TYPENAME (uint16_t, "uint16") +DECLARE_OCTAVE_INT_TYPENAME (uint32_t, "uint32") +DECLARE_OCTAVE_INT_TYPENAME (uint64_t, "uint64") typedef octave_int<int8_t> octave_int8; typedef octave_int<int16_t> octave_int16; @@ -559,9 +562,9 @@ return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); \ } -OCTAVE_INT_BIN_OP(+) -OCTAVE_INT_BIN_OP(-) -OCTAVE_INT_BIN_OP(*) +OCTAVE_INT_BIN_OP (+) +OCTAVE_INT_BIN_OP (-) +OCTAVE_INT_BIN_OP (*) template <class T1, class T2> octave_int<typename octave_int_binop_traits<T1, T2>::TR> @@ -584,10 +587,10 @@ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } -OCTAVE_INT_DOUBLE_BIN_OP(+) -OCTAVE_INT_DOUBLE_BIN_OP(-) -OCTAVE_INT_DOUBLE_BIN_OP(*) -OCTAVE_INT_DOUBLE_BIN_OP(/) +OCTAVE_INT_DOUBLE_BIN_OP (+) +OCTAVE_INT_DOUBLE_BIN_OP (-) +OCTAVE_INT_DOUBLE_BIN_OP (*) +OCTAVE_INT_DOUBLE_BIN_OP (/) #define OCTAVE_DOUBLE_INT_BIN_OP(OP) \ template <class T> \ @@ -600,10 +603,10 @@ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } -OCTAVE_DOUBLE_INT_BIN_OP(+) -OCTAVE_DOUBLE_INT_BIN_OP(-) -OCTAVE_DOUBLE_INT_BIN_OP(*) -OCTAVE_DOUBLE_INT_BIN_OP(/) +OCTAVE_DOUBLE_INT_BIN_OP (+) +OCTAVE_DOUBLE_INT_BIN_OP (-) +OCTAVE_DOUBLE_INT_BIN_OP (*) +OCTAVE_DOUBLE_INT_BIN_OP (/) #define OCTAVE_INT_DOUBLE_CMP_OP(OP) \ template <class T> \ @@ -648,10 +651,10 @@ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } -OCTAVE_INT_FLOAT_BIN_OP(+) -OCTAVE_INT_FLOAT_BIN_OP(-) -OCTAVE_INT_FLOAT_BIN_OP(*) -OCTAVE_INT_FLOAT_BIN_OP(/) +OCTAVE_INT_FLOAT_BIN_OP (+) +OCTAVE_INT_FLOAT_BIN_OP (-) +OCTAVE_INT_FLOAT_BIN_OP (*) +OCTAVE_INT_FLOAT_BIN_OP (/) #define OCTAVE_FLOAT_INT_BIN_OP(OP) \ template <class T> \ @@ -664,10 +667,10 @@ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } -OCTAVE_FLOAT_INT_BIN_OP(+) -OCTAVE_FLOAT_INT_BIN_OP(-) -OCTAVE_FLOAT_INT_BIN_OP(*) -OCTAVE_FLOAT_INT_BIN_OP(/) +OCTAVE_FLOAT_INT_BIN_OP (+) +OCTAVE_FLOAT_INT_BIN_OP (-) +OCTAVE_FLOAT_INT_BIN_OP (*) +OCTAVE_FLOAT_INT_BIN_OP (/) #define OCTAVE_INT_FLOAT_CMP_OP(OP) \ template <class T> \
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2008-07-30 John W. Eaton <jwe@octave.org> + * ov-intx.h, ov.cc: Style fixes. + * gripes.cc (gripe_truncated_conversion): Use the warning ID Octave:int-convert-overflow.
--- a/src/ov-intx.h +++ b/src/ov-intx.h @@ -69,19 +69,18 @@ private: - template <class _int_matrix> - _int_matrix convert_gripe () const + template <class IM> + IM convert_gripe () const { - typedef typename _int_matrix::element_type dest_el_type; + typedef typename IM::element_type dest_el_type; typedef OCTAVE_INT_NDARRAY_T::element_type src_el_type; dest_el_type::clear_trunc_flag (); - _int_matrix retval (matrix); + IM retval (matrix); if (dest_el_type::get_trunc_flag ()) { gripe_truncated_conversion (src_el_type::type_name (), dest_el_type::type_name ()); dest_el_type::clear_trunc_flag (); - } return retval; @@ -429,13 +428,13 @@ private: - template <class _int_scalar> - _int_scalar convert_gripe () const + template <class IS> + IS convert_gripe () const { - typedef _int_scalar dest_el_type; + typedef IS dest_el_type; typedef OCTAVE_INT_T src_el_type; dest_el_type::clear_trunc_flag (); - _int_scalar retval (scalar); + IS retval (scalar); if (dest_el_type::get_trunc_flag ()) { gripe_truncated_conversion (src_el_type::type_name (),
--- a/src/ov.cc +++ b/src/ov.cc @@ -1350,19 +1350,19 @@ static Array<int> convert_to_int_array (const Array<octave_int<T> >& A) { - Array<int> O (A.dims ()); + Array<int> retval (A.dims ()); octave_idx_type n = A.numel (); octave_int<int>::clear_trunc_flag (); for (octave_idx_type i = 0; i < n; i++) - O.xelem (i) = octave_int<int> (A.xelem (i)); + retval.xelem (i) = octave_int<int> (A.xelem (i)); if (octave_int<int>::get_trunc_flag ()) { gripe_truncated_conversion (octave_int<T>::type_name (), "int"); octave_int<int>::clear_trunc_flag (); } - return O; + return retval; } Array<int>