import source from 1.3.40
[external/swig.git] / Lib / octave / octtypemaps.swg
1
2 // Include fundamental fragemt definitions
3 %include <typemaps/fragments.swg>
4
5 // Look for user fragments file.
6 %include <octfragments.swg>
7
8 // Octave fragments for primitive types
9 %include <octprimtypes.swg>
10
11 // Octave fragments for char* strings
12 //%include <octstrings.swg>
13
14
15 #ifndef SWIG_DIRECTOR_TYPEMAPS
16 #define SWIG_DIRECTOR_TYPEMAPS
17 #endif
18
19 // Octave types
20 #define SWIG_Object                      octave_value
21 #define VOID_Object                      octave_value()
22
23 /*
24 // Octave allows implicit conversion
25 #define %implicitconv_flag              $implicitconv 
26 */
27
28 // append output
29 #define SWIG_AppendOutput(result, obj)  SWIG_Octave_AppendOutput(result, obj)
30
31 // set constant
32 #define SWIG_SetConstant(name, obj)     SWIG_Octave_SetConstant(module_ns,name,obj) 
33
34 // raise
35 #define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
36 #define SWIG_Raise(obj, type, desc)     SWIG_Octave_Raise(obj, type, desc)
37
38 // Include the unified typemap library
39 %include <typemaps/swigtypemaps.swg>
40
41
42 %typemap(constcode,noblock=1) int double {
43   SWIG_Octave_SetConstant(module_ns,"$symname",octave_value($value));
44 }
45
46 %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = (*$input).is_defined();";
47 %typecheck(SWIG_TYPECHECK_SWIGOBJECT) octave_value_list "$1 = true;";
48
49 %typemap(in) (octave_value_list varargs,...) {
50   for (int j=$argnum-1;j<args.length();++j)
51     $1.append(args(j));
52 }
53 %typecheck(2000) (octave_value_list varargs,...) {
54   $1=1;
55 }
56
57 %typemap(in) (const octave_value_list& varargs,...) (octave_value_list tmp) {
58   for (int j=$argnum-1;j<args.length();++j)
59     tmp.append(args(j));
60   $1=&tmp;
61 }
62 %typecheck(2000) (const octave_value_list& varargs,...) {
63   $1=1;
64 }
65
66 %typemap(out) octave_value_list {
67   _outp->append($1);
68 }
69 %typemap(out,noblock=1) Octave_map {
70   $result=$1;
71 }
72 %typemap(out,noblock=1) NDArray {
73   $result=$1;
74 }
75 %typemap(out,noblock=1) Cell {
76   $result=$1;
77 }
78
79 /*
80 // Smart Pointers
81 %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER  {
82   $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
83 }
84
85 %typemap(ret) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER {
86   octave_swig_type* lobj=Swig::swig_value_deref($result);
87   if (lobj) {
88     std::list<octave_value_list> idx;
89     idx.push_back(octave_value("__deref__"));
90     idx.push_back(octave_value_list());
91     octave_value_list ovl(lobj->subsref(".(",idx));
92     octave_swig_type* robj=ovl.length()>=1?Swig::swig_value_deref(ovl(0)):0;
93     if (robj && !error_state)
94       lobj->append(robj);
95   }
96 }
97 */