1 %include <std/std_except.i>
2 %include <octstdcommon.swg>
5 // Generate the traits for a 'primitive' type, such as 'double',
6 // for which the SWIG_AsVal and SWIG_From methods are already defined.
8 %define %traits_ptypen(Type...)
9 %fragment(SWIG_Traits_frag(Type),"header",
10 fragment=SWIG_AsVal_frag(Type),
11 fragment=SWIG_From_frag(Type),
12 fragment="StdTraits") {
14 template <> struct traits<Type > {
15 typedef value_category category;
16 static const char* type_name() { return #Type; }
18 template <> struct traits_asval<Type > {
19 typedef Type value_type;
20 static int asval(octave_value obj, value_type *val) {
21 return SWIG_AsVal(Type)(obj, val);
24 template <> struct traits_from<Type > {
25 typedef Type value_type;
26 static octave_value from(const value_type& val) {
27 return SWIG_From(Type)(val);
34 %include <std/std_common.i>
37 // Generates the traits for all the known primitive
38 // C++ types (int, double, ...)
40 %apply_cpptypes(%traits_ptypen);