Home | History | Annotate | Download | only in tcl
      1 /* ------------------------------------------------------------
      2  *  Typemap specializations for Tcl
      3  * ------------------------------------------------------------ */
      4 
      5 /* ------------------------------------------------------------
      6  *  Fragment section
      7  * ------------------------------------------------------------ */
      8 
      9 /*
     10   In Tcl we need to pass the interp value, so we define the decl/call
     11   macros as needed.
     12 */
     13 
     14 #define SWIG_AS_DECL_ARGS SWIG_TCL_DECL_ARGS_2
     15 #define SWIG_AS_CALL_ARGS SWIG_TCL_CALL_ARGS_2
     16 
     17 
     18 /* Include fundamental fragment definitions */
     19 %include <typemaps/fragments.swg>
     20 
     21 /* Look for user fragments file. */
     22 %include <tclfragments.swg>
     23 
     24 /* Tcl fragments for primitive types */
     25 %include <tclprimtypes.swg>
     26 
     27 /* Tcl fragments for char* strings */
     28 %include <tclstrings.swg>
     29 
     30 
     31 /* ------------------------------------------------------------
     32  *  Unified typemap section
     33  * ------------------------------------------------------------ */
     34 
     35 /* No director support in Tcl */
     36 #ifdef SWIG_DIRECTOR_TYPEMAPS
     37 #undef SWIG_DIRECTOR_TYPEMAPS
     38 #endif
     39 
     40 
     41 /* Tcl types */
     42 #define SWIG_Object                      Tcl_Obj *
     43 
     44 /* Overload of the output/constant/exception handling */
     45 
     46 /* output */
     47 #define %set_output(obj)                 Tcl_SetObjResult(interp,obj)
     48 
     49 /* append output */
     50 #define %append_output(obj)              Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj)
     51 
     52 /* set constant */
     53 #define SWIG_SetConstant(name, obj)      SWIG_Tcl_SetConstantObj(interp, name, obj)
     54 
     55 /* raise */
     56 #define SWIG_Raise(obj,type,desc)        SWIG_Tcl_SetErrorObj(interp,type,obj)
     57 
     58 
     59 /* Include the unified typemap library */
     60 %include <typemaps/swigtypemaps.swg>
     61 
     62 
     63 /* ------------------------------------------------------------
     64  *  Tcl extra typemaps / typemap overrides
     65  * ------------------------------------------------------------ */
     66 
     67 #if 1
     68 // Old 1.3.25 typemaps needed to avoid premature object deletion
     69 %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
     70   Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1), $1_descriptor,0));
     71 }
     72 
     73 %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
     74   swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,%as_voidptrptr(&$1));
     75   Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,0));
     76 }
     77 
     78 #endif
     79 
     80 %typemap(throws,noblock=1) SWIGTYPE CLASS {
     81   SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1));
     82   SWIG_fail;
     83 }
     84 
     85 %typemap(out)    SWIGTYPE    =  SWIGTYPE INSTANCE;
     86 %typemap(out)    SWIGTYPE *  =  SWIGTYPE *INSTANCE;
     87 %typemap(out)    SWIGTYPE *const  =  SWIGTYPE *;
     88 %typemap(out)    SWIGTYPE &  =  SWIGTYPE &INSTANCE;
     89 %typemap(out)    SWIGTYPE [] =  SWIGTYPE INSTANCE[];
     90 %typemap(varout) SWIGTYPE    =  SWIGTYPE INSTANCE;
     91