
Le découpage en petits modules avait abimé la pauvre swilena. Le matching ne se faisait plus entre ntg::int_u8 (un typedef, nommé p__int_u8) et ntg::int_u<8, ntg::strict> (nommé int_u__T_8_...). Solution : n'utiliser que la version template. Index: tools/swilena/ChangeLog from Nicolas Burrus <burrus_n@lrde.epita.fr> * meta/swilena_ntg_int_u.i: Fix type matching problems between templates and typedefs. * meta/swilena_ntg_int_s.i: Likewise. * meta/swilena_ntg_cplx.i: Likewise. * meta/swilena_ntg.i: Likewise. Tweak for ruby. * meta/swilena_exception.i: Include <exception> in the c++ code. * expand.sh: Adjust consequently. +2003-09-21 Nicolas Burrus <burrus_n@lrde.epita.fr> + * meta/swilena_ntg.i: Adjust for ruby. * meta/swilena_describe.i: Tweak for ruby. Index: tools/swilena/meta/swilena_ntg_int_u.i --- tools/swilena/meta/swilena_ntg_int_u.i Tue, 06 May 2003 06:56:14 +0200 raph (oln/s/30_swilena_nt 1.1 640) +++ tools/swilena/meta/swilena_ntg_int_u.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/30_swilena_nt 1.2 640) @@ -7,13 +7,35 @@ #include <ntg/all.hh> %} -%template(int_u8) ntg::int_u<8, ntg::strict>; -%template(int_u8u) ntg::int_u<8, ntg::unsafe>; -%template(int_u8s) ntg::int_u<8, ntg::saturate>; -%template(int_u16) ntg::int_u<16, ntg::strict>; -%template(int_u16u) ntg::int_u<16, ntg::unsafe>; -%template(int_u16s) ntg::int_u<16, ntg::saturate>; -%template(int_u32) ntg::int_u<32, ntg::strict>; -%template(int_u32u) ntg::int_u<32, ntg::unsafe>; -%template(int_u32s) ntg::int_u<32, ntg::saturate>; +%define declare_int_u(Name, nbits, behavior) +%template(Name) ntg::int_u<nbits, behavior>; + +/* + This macro should be used in all modules + Using ntg::int_u8 directly leads to type matching problems: + + - it is a typedef never used in module swilena_ntg_int_u + => no type correspondence is created between ntg::int_u8 + and ntg::int_u<8, ntg::strict>. + + - if another module use ntg::int_u8, operations on it won't be + possible since this module won't recognize the type ntg::int_u8. + + - ntg::int_u<8, ntg::strict> or ntg_int_u8 should be used + everywhere. ntg_int_u8 is just a convenient macro. +*/ + +#define ntg_ ## Name ntg::int_u<nbits, behavior> + +%enddef + +declare_int_u(int_u8, 8, ntg::strict); +declare_int_u(int_u8u, 8, ntg::unsafe); +declare_int_u(int_u8s, 8, ntg::saturate); +declare_int_u(int_u16, 16, ntg::strict); +declare_int_u(int_u16u, 16, ntg::unsafe); +declare_int_u(int_u16s, 16, ntg::saturate); +declare_int_u(int_u32, 32, ntg::strict); +declare_int_u(int_u32u, 32, ntg::unsafe); +declare_int_u(int_u32s, 32, ntg::saturate); Index: tools/swilena/meta/swilena_ntg_int_s.i --- tools/swilena/meta/swilena_ntg_int_s.i Tue, 06 May 2003 06:56:14 +0200 raph (oln/s/31_swilena_nt 1.1 640) +++ tools/swilena/meta/swilena_ntg_int_s.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/31_swilena_nt 1.2 640) @@ -7,14 +7,21 @@ #include <ntg/all.hh> %} -%template(int_s8) ntg::int_s<8, ntg::strict>; -%template(int_s8u) ntg::int_s<8, ntg::unsafe>; -%template(int_s8s) ntg::int_s<8, ntg::saturate>; -%template(int_s16) ntg::int_s<16, ntg::strict>; -%template(int_s16u) ntg::int_s<16, ntg::unsafe>; -%template(int_s16s) ntg::int_s<16, ntg::saturate>; -%template(int_s32) ntg::int_s<32, ntg::strict>; -%template(int_s32u) ntg::int_s<32, ntg::unsafe>; -%template(int_s32s) ntg::int_s<32, ntg::saturate>; +%define declare_int_s(Name, nbits, behavior) +%template(Name) ntg::int_s<nbits, behavior>; +// See comments in swilena_ntg_int_u.i +#define ntg_ ## Name ntg::int_s<nbits, behavior> + +%enddef + +declare_int_s(int_s8, 8, ntg::strict); +declare_int_s(int_s8u, 8, ntg::unsafe); +declare_int_s(int_s8s, 8, ntg::saturate); +declare_int_s(int_s16, 16, ntg::strict); +declare_int_s(int_s16u, 16, ntg::unsafe); +declare_int_s(int_s16s, 16, ntg::saturate); +declare_int_s(int_s32, 32, ntg::strict); +declare_int_s(int_s32u, 32, ntg::unsafe); +declare_int_s(int_s32s, 32, ntg::saturate); Index: tools/swilena/meta/swilena_ntg_cplx.i --- tools/swilena/meta/swilena_ntg_cplx.i Tue, 13 May 2003 22:29:01 +0200 burrus_n (oln/s/32_swilena_nt 1.2 640) +++ tools/swilena/meta/swilena_ntg_cplx.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/32_swilena_nt 1.3 640) @@ -7,7 +7,17 @@ #include <ntg/all.hh> %} -%template(cplx_rf) ntg::cplx<ntg::rect, ntg::float_s>; -%template(cplx_rd) ntg::cplx<ntg::rect, ntg::float_d>; -%template(cplx_pf) ntg::cplx<ntg::polar, ntg::float_s>; -%template(cplx_pd) ntg::cplx<ntg::polar, ntg::float_d>; +%define declare_cplx(Name, repr, T) + +%template(Name) ntg::cplx<repr, T>; + +// See comments in swilena_ntg_int_u.i +#define ntg_ ## Name ntg::cplx<repr, T> + +%enddef + + +declare_cplx(cplx_rf, ntg::rect, ntg_float_s); +declare_cplx(cplx_rd, ntg::rect, ntg_float_d); +declare_cplx(cplx_pf, ntg::polar, ntg_float_s); +declare_cplx(cplx_pd, ntg::polar, ntg_float_d); Index: tools/swilena/meta/swilena_ntg.i --- tools/swilena/meta/swilena_ntg.i Tue, 13 May 2003 22:29:01 +0200 burrus_n (oln/s/33_swilena_nt 1.2 640) +++ tools/swilena/meta/swilena_ntg.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/33_swilena_nt 1.3 640) @@ -17,7 +17,7 @@ void value(ValueType x) { *self = Ns::Name<nbits, behaviour>(x); } -#if defined(SWIGPYTHON) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) Ns::Name<nbits, behaviour> operator+ (const Ns::Name<nbits, behaviour>& other) const { return (*self) + other; } Ns::Name<nbits, behaviour> operator- (const Ns::Name<nbits, behaviour>& other) const { return (*self) - other; } Ns::Name<nbits, behaviour> operator* (const Ns::Name<nbits, behaviour>& other) const { return (*self) * other; } @@ -26,6 +26,18 @@ Ns::Name<nbits, behaviour> operator- (ValueType other) const { return (*self) - other; } Ns::Name<nbits, behaviour> operator* (ValueType other) const { return (*self) * other; } Ns::Name<nbits, behaviour> operator/ (ValueType other) const { return (*self) / other; } +#else + Ns::Name<nbits, behaviour> add (const Ns::Name<nbits, behaviour>& other) const { return (*self) + other; } + Ns::Name<nbits, behaviour> sub (const Ns::Name<nbits, behaviour>& other) const { return (*self) - other; } + Ns::Name<nbits, behaviour> mul (const Ns::Name<nbits, behaviour>& other) const { return (*self) * other; } + Ns::Name<nbits, behaviour> div (const Ns::Name<nbits, behaviour>& other) const { return (*self) / other; } + Ns::Name<nbits, behaviour> add (ValueType other) const { return (*self) + other; } + Ns::Name<nbits, behaviour> sub (ValueType other) const { return (*self) - other; } + Ns::Name<nbits, behaviour> mul (ValueType other) const { return (*self) * other; } + Ns::Name<nbits, behaviour> div (ValueType other) const { return (*self) / other; } +#endif + +#if defined(SWIGPYTHON) Ns::Name<nbits, behaviour>& operator+= (const Ns::Name<nbits, behaviour>& other) { return (*self) += other; } Ns::Name<nbits, behaviour>& operator-= (const Ns::Name<nbits, behaviour>& other) { return (*self) -= other; } Ns::Name<nbits, behaviour>& operator*= (const Ns::Name<nbits, behaviour>& other) { return (*self) *= other; } @@ -34,48 +46,49 @@ Ns::Name<nbits, behaviour>& operator-= (ValueType other) { return (*self) -= other; } Ns::Name<nbits, behaviour>& operator*= (ValueType other) { return (*self) *= other; } Ns::Name<nbits, behaviour>& operator/= (ValueType other) { return (*self) /= other; } +#elseif !defined(SWIGRUBY) // These operators are generated by default in Ruby + Ns::Name<nbits, behaviour>& iadd (const Ns::Name<nbits, behaviour>& other) { return (*self) += other; } + Ns::Name<nbits, behaviour>& isub (const Ns::Name<nbits, behaviour>& other) { return (*self) -= other; } + Ns::Name<nbits, behaviour>& imul (const Ns::Name<nbits, behaviour>& other) { return (*self) *= other; } + Ns::Name<nbits, behaviour>& idiv (const Ns::Name<nbits, behaviour>& other) { return (*self) /= other; } + Ns::Name<nbits, behaviour>& iadd (ValueType other) { return (*self) += other; } + Ns::Name<nbits, behaviour>& isub (ValueType other) { return (*self) -= other; } + Ns::Name<nbits, behaviour>& imul (ValueType other) { return (*self) *= other; } + Ns::Name<nbits, behaviour>& idiv (ValueType other) { return (*self) /= other; } +#endif + +#if defined(SWIGPYTHON) || defined(SWIGRUBY) bool operator< (const Ns::Name<nbits, behaviour>& other) const { return (*self) < other; } bool operator> (const Ns::Name<nbits, behaviour>& other) const { return (*self) > other; } bool operator<= (const Ns::Name<nbits, behaviour>& other) const { return (*self) <= other; } bool operator>= (const Ns::Name<nbits, behaviour>& other) const { return (*self) >= other; } bool operator== (const Ns::Name<nbits, behaviour>& other) const { return (*self) == other; } - bool operator!= (const Ns::Name<nbits, behaviour>& other) const { return (*self) != other; } bool operator< (ValueType other) const { return (*self) < other; } bool operator> (ValueType other) const { return (*self) > other; } bool operator<= (ValueType other) const { return (*self) <= other; } bool operator>= (ValueType other) const { return (*self) >= other; } bool operator== (ValueType other) const { return (*self) == other; } - bool operator!= (ValueType other) const { return (*self) != other; } #else - Ns::Name<nbits, behaviour> add (const Ns::Name<nbits, behaviour>& other) const { return (*self) + other; } - Ns::Name<nbits, behaviour> sub (const Ns::Name<nbits, behaviour>& other) const { return (*self) - other; } - Ns::Name<nbits, behaviour> mul (const Ns::Name<nbits, behaviour>& other) const { return (*self) * other; } - Ns::Name<nbits, behaviour> div (const Ns::Name<nbits, behaviour>& other) const { return (*self) / other; } - Ns::Name<nbits, behaviour> add (ValueType other) const { return (*self) + other; } - Ns::Name<nbits, behaviour> sub (ValueType other) const { return (*self) - other; } - Ns::Name<nbits, behaviour> mul (ValueType other) const { return (*self) * other; } - Ns::Name<nbits, behaviour> div (ValueType other) const { return (*self) / other; } - Ns::Name<nbits, behaviour>& iadd (const Ns::Name<nbits, behaviour>& other) const { return (*self) += other; } - Ns::Name<nbits, behaviour>& isub (const Ns::Name<nbits, behaviour>& other) const { return (*self) -= other; } - Ns::Name<nbits, behaviour>& imul (const Ns::Name<nbits, behaviour>& other) const { return (*self) *= other; } - Ns::Name<nbits, behaviour>& idiv (const Ns::Name<nbits, behaviour>& other) const { return (*self) /= other; } - Ns::Name<nbits, behaviour>& iadd (ValueType other) const { return (*self) += other; } - Ns::Name<nbits, behaviour>& isub (ValueType other) const { return (*self) -= other; } - Ns::Name<nbits, behaviour>& imul (ValueType other) const { return (*self) *= other; } - Ns::Name<nbits, behaviour>& idiv (ValueType other) const { return (*self) /= other; } bool lt (const Ns::Name<nbits, behaviour>& other) const { return (*self) < other; } bool gt (const Ns::Name<nbits, behaviour>& other) const { return (*self) > other; } bool le (const Ns::Name<nbits, behaviour>& other) const { return (*self) <= other; } bool ge (const Ns::Name<nbits, behaviour>& other) const { return (*self) >= other; } bool eq (const Ns::Name<nbits, behaviour>& other) const { return (*self) == other; } - bool ne (const Ns::Name<nbits, behaviour>& other) const { return (*self) != other; } bool lt (ValueType other) const { return (*self) < other; } bool gt (ValueType other) const { return (*self) > other; } bool le (ValueType other) const { return (*self) <= other; } bool ge (ValueType other) const { return (*self) >= other; } bool eq (ValueType other) const { return (*self) == other; } +#endif + +#if defined(SWIGPYTHON) + bool operator!= (const Ns::Name<nbits, behaviour>& other) const { return (*self) != other; } + bool operator!= (ValueType other) const { return (*self) != other; } +#elseif !defined(SWIGRUBY) + bool ne (const Ns::Name<nbits, behaviour>& other) const { return (*self) != other; } bool ne (ValueType other) const { return (*self) != other; } #endif + } EXTEND_DESCRIBE2(Ns::Name<nbits, behaviour>); @@ -192,3 +205,8 @@ %enddef decl_ntg() + +// Compatibility macro, see swilena_ntg_int_u.i +#define ntg_bin ntg::bin +#define ntg_float_s ntg::float_s +#define ntg_float_d ntg::float_d Index: tools/swilena/meta/swilena_image.i --- tools/swilena/meta/swilena_image.i Mon, 15 Sep 2003 17:23:46 +0200 burrus_n (oln/s/36_swilena_im 1.3 640) +++ tools/swilena/meta/swilena_image.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/36_swilena_im 1.4 640) @@ -28,7 +28,6 @@ { return (*self)[p]; } T& set(const point ## Dim ## d& p, Val v) { (*self)[p] = v; return *self; } - Val& ref(const point ## Dim ## d& p) { return (*self)[p]; } } Index: tools/swilena/meta/swilena_exception.i --- tools/swilena/meta/swilena_exception.i Tue, 06 May 2003 06:56:14 +0200 raph (oln/s/37_swilena_ex 1.1 640) +++ tools/swilena/meta/swilena_exception.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n (oln/s/37_swilena_ex 1.2 640) @@ -2,6 +2,10 @@ %include exception.i +%{ +#include <exception> +%} + // Olena uses classes that derive from std::exception. Declare it. namespace std { class exception { public: const char *what() const; }; }