1 %include <std/std_except.i>
2 %include <pystdcommon.swg>
6 Generate the traits for a 'primitive' type, such as 'double',
7 for which the SWIG_AsVal and SWIG_From methods are already defined.
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") {
16 template <> struct traits<Type > {
17 typedef value_category category;
18 static const char* type_name() { return #Type; }
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);
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);
37 %include <std/std_common.i>
40 // Generates the traits for all the known primitive
41 // C++ types (int, double, ...)
43 %apply_cpptypes(%traits_ptypen);