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 %typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = (*$input).is_defined();"; 42 %typecheck(SWIG_TYPECHECK_SWIGOBJECT) octave_value_list "$1 = true;"; 43 44 %typemap(in) (octave_value_list varargs,...) { 45 for (int j=$argnum-1;j<args.length();++j) 46 $1.append(args(j)); 47 } 48 %typecheck(2000) (octave_value_list varargs,...) { 49 $1=1; 50 } 51 52 %typemap(in) (const octave_value_list& varargs,...) (octave_value_list tmp) { 53 for (int j=$argnum-1;j<args.length();++j) 54 tmp.append(args(j)); 55 $1=&tmp; 56 } 57 %typecheck(2000) (const octave_value_list& varargs,...) { 58 $1=1; 59 } 60 61 %typemap(out) octave_value_list { 62 _outp->append($1); 63 } 64 %typemap(out,noblock=1) octave_map, Octave_map { 65 $result=$1; 66 } 67 %typemap(out,noblock=1) NDArray { 68 $result=$1; 69 } 70 %typemap(out,noblock=1) Cell { 71 $result=$1; 72 } 73 74 /* 75 // Smart Pointers 76 %typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { 77 $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); 78 } 79 80 %typemap(ret) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { 81 octave_swig_type* lobj=Swig::swig_value_deref($result); 82 if (lobj) { 83 std::list<octave_value_list> idx; 84 idx.push_back(octave_value("__deref__")); 85 idx.push_back(octave_value_list()); 86 octave_value_list ovl(lobj->subsref(".(",idx)); 87 octave_swig_type* robj=ovl.length()>=1?Swig::swig_value_deref(ovl(0)):0; 88 if (robj && !error_state) 89 lobj->append(robj); 90 } 91 } 92 */ 93