/* ------------------------------------------------------------
 *  Typemap specializations for Tcl
 * ------------------------------------------------------------ */

/* ------------------------------------------------------------
 *  Fragment section
 * ------------------------------------------------------------ */

/*
  in Tcl we need to pass the interp value, so, we define the decl/call
  macros as needed.
*/

#define SWIG_AS_DECL_ARGS SWIG_TCL_DECL_ARGS_2
#define SWIG_AS_CALL_ARGS SWIG_TCL_CALL_ARGS_2


/* Include fundamental fragemt definitions */
%include <typemaps/fragments.swg>

/* Look for user fragments file. */
%include <tclfragments.swg>

/* Tcl fragments for primitve types */
%include <tclprimtypes.swg>

/* Tcl fragments for char* strings */
%include <tclstrings.swg>


/* ------------------------------------------------------------
 *  Unified typemap section
 * ------------------------------------------------------------ */

/* No director supported in Tcl */
#ifdef SWIG_DIRECTOR_TYPEMAPS
#undef SWIG_DIRECTOR_TYPEMAPS
#endif

#ifndef SWIG_INOUT_NODEF
#define SWIG_INOUT_NODEF
#endif

/* Tcl types */
#define SWIG_Object                      Tcl_Obj *

/* Simple overload of the output/constant/exception handling */
/* output */
#define %set_output(obj)                 Tcl_SetObjResult(interp,obj)
#define %append_output(obj)              Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj)
#define SWIG_SetConstant(name, obj)      SWIG_Tcl_SetConstantObj(interp, name, obj)
#define SWIG_Raise(obj,type,desc)        SWIG_Tcl_SetErrorObj(interp,type,obj)


/* Include the unified typemap library */
%include <typemaps/swigtypemaps.swg>


/* ------------------------------------------------------------
 *  Tcl extra typemaps
 * ------------------------------------------------------------ */

%typemap(out)    SWIGTYPE    =  SWIGTYPE INSTANCE;
%typemap(out)    SWIGTYPE *  =  SWIGTYPE *INSTANCE;
%typemap(out)    SWIGTYPE &  =  SWIGTYPE &INSTANCE;
%typemap(out)    SWIGTYPE [] =  SWIGTYPE INSTANCE[];
%typemap(varout) SWIGTYPE    =  SWIGTYPE INSTANCE;

%typemap(throws,noblock=1) SWIGTYPE CLASS {
  SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1));
  SWIG_fail;
}

