import source from 1.3.40
[external/swig.git] / Lib / octave / std_common.i
1 %include <std/std_except.i>
2 %include <octstdcommon.swg>
3
4
5 // Generate the traits for a 'primitive' type, such as 'double',
6 // for which the SWIG_AsVal and SWIG_From methods are already defined.
7
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") {
13 namespace swig {
14   template <> struct traits<Type > {
15     typedef value_category category;
16     static const char* type_name() { return  #Type; }
17   };  
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);
22     }
23   };
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);
28     }
29   };
30 }
31 }
32 %enddef
33
34 %include <std/std_common.i>
35
36 //
37 // Generates the traits for all the known primitive
38 // C++ types (int, double, ...)
39 //
40 %apply_cpptypes(%traits_ptypen);
41