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