%module template_typedef_cplx // // Change this to #if 1 to test the 'test' // #if 0 %{ #include typedef std::complex cmplx; %} %inline %{ typedef cmplx Complex; %} #else %inline %{ #include typedef std::complex Complex; %} #endif %inline %{ namespace vfncs { struct UnaryFunctionBase { }; template struct UnaryFunction; template struct ArithUnaryFunction; template struct UnaryFunction : UnaryFunctionBase { }; template struct ArithUnaryFunction : UnaryFunction { }; template struct unary_func_traits { typedef ArithUnaryFunction base; }; template inline typename unary_func_traits< ArgType, ArgType >::base make_Identity() { return typename unary_func_traits< ArgType, ArgType >::base(); } template struct arith_traits { }; template<> struct arith_traits< double, double > { typedef double argument_type; typedef double result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, Complex > { typedef Complex argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< Complex, double > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template<> struct arith_traits< double, Complex > { typedef double argument_type; typedef Complex result_type; static const char* const arg_type; static const char* const res_type; }; template inline ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type > make_Multiplies(const ArithUnaryFunction& f, const ArithUnaryFunction& g) { return ArithUnaryFunction::argument_type, typename arith_traits< RF, RG >::result_type>(); } #ifndef SWIG // Initialize these static class members const char* const arith_traits< double, double >::arg_type = "double"; const char* const arith_traits< double, double >::res_type = "double"; const char* const arith_traits< Complex, Complex >::arg_type = "complex"; const char* const arith_traits< Complex, Complex >::res_type = "complex"; const char* const arith_traits< Complex, double>::arg_type = "double"; const char* const arith_traits< Complex, double >::res_type = "complex"; const char* const arith_traits< double, Complex >::arg_type = "double"; const char* const arith_traits< double, Complex >::res_type = "complex"; #endif } %} namespace vfncs { %template(UnaryFunction_double_double) UnaryFunction; %template(ArithUnaryFunction_double_double) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_double) make_Identity; %template(UnaryFunction_complex_complex) UnaryFunction; %template(ArithUnaryFunction_complex_complex) ArithUnaryFunction; %template() unary_func_traits; %template() arith_traits; %template(make_Identity_complex) make_Identity; /* [beazley] Added this part */ %template() unary_func_traits; %template(UnaryFunction_double_complex) UnaryFunction; %template(ArithUnaryFunction_double_complex) ArithUnaryFunction; /* */ %template() arith_traits; %template() arith_traits; %template(make_Multiplies_double_double_complex_complex) make_Multiplies; %template(make_Multiplies_double_double_double_double) make_Multiplies; %template(make_Multiplies_complex_complex_complex_complex) make_Multiplies; %template(make_Multiplies_complex_complex_double_double) make_Multiplies; }