1%include <std/std_except.i> 2%include <rubystdcommon.swg> 3%include <rubystdautodoc.swg> 4 5 6/* 7 Generate the traits for a 'primitive' type, such as 'double', 8 for which the SWIG_AsVal and SWIG_From methods are already defined. 9*/ 10 11%define %traits_ptypen(Type...) 12 %fragment(SWIG_Traits_frag(Type),"header", 13 fragment=SWIG_AsVal_frag(Type), 14 fragment=SWIG_From_frag(Type), 15 fragment="StdTraits") { 16namespace swig { 17 template <> struct traits<Type > { 18 typedef value_category category; 19 static const char* type_name() { return #Type; } 20 }; 21 template <> struct traits_asval<Type > { 22 typedef Type value_type; 23 static int asval(VALUE obj, value_type *val) { 24 return SWIG_AsVal(Type)(obj, val); 25 } 26 }; 27 template <> struct traits_from<Type > { 28 typedef Type value_type; 29 static VALUE from(const value_type& val) { 30 return SWIG_From(Type)(val); 31 } 32 }; 33} 34} 35%enddef 36 37 38%include <std/std_common.i> 39 40// 41// Generates the traits for all the known primitive 42// C++ types (int, double, ...) 43// 44%apply_cpptypes(%traits_ptypen); 45