3 // This module changes SWIG to place constant values into a Tcl array
 
   7 %subsection "Array Constants",pre
 
  11 This module changes SWIG so that constant values are placed into a Tcl
 
  12 array instead of global variables.   The array is given the same name as
 
  13 the SWIG module (specified with the %module directive).
 
  15 This module should generally be included at the top of an interface
 
  16 file before any declarations appear.   Furthermore, this module changes
 
  17 the default handling of basic datatypes including integers, floats,
 
  18 and character strings.
 
  20 When this module is used, constants are simply accessed through the
 
  21 module name.  For example :
 
  27 would be accessed as '$example(FOO)'
 
  29 Note : This module replaces the existing mechanism for creating constants.
 
  30 The method used by this module is based on a set of typemaps supplied
 
  35 %typemap(tcl,const) int SWIG_DEFAULT_TYPE, 
 
  36                     unsigned int SWIG_DEFAULT_TYPE,
 
  37                     long SWIG_DEFAULT_TYPE,
 
  38                     unsigned long SWIG_DEFAULT_TYPE,
 
  39                     short SWIG_DEFAULT_TYPE,
 
  40                     unsigned short SWIG_DEFAULT_TYPE,
 
  41                     unsigned char  SWIG_DEFAULT_TYPE,
 
  42                     signed char    SWIG_DEFAULT_TYPE
 
  44   static int ivalue = (int) $source;
 
  45   Tcl_LinkVar(interp,SWIG_name "($target)",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
 
  48 %typemap(tcl,const) float  SWIG_DEFAULT_TYPE, 
 
  49                     double SWIG_DEFAULT_TYPE
 
  51   static double dvalue = (double) $source;
 
  52   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
 
  55 %typemap(tcl,const) char  *SWIG_DEFAULT_TYPE
 
  57   static char *cvalue = $source;
 
  58   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
 
  61 %typemap(tcl,const) Pointer *SWIG_DEFAULT_TYPE
 
  64   pvalue = (char *) malloc(20+strlen("$mangle"));
 
  65   SWIG_MakePtr(pvalue, (void *) ($source), "$mangle");
 
  66   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &pvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
 
  69 // ----------------------------------------------------------------------------------
 
  70 // Tcl 8 Object versions
 
  71 // ----------------------------------------------------------------------------------
 
  73 %typemap(tcl8,const) int SWIG_DEFAULT_TYPE, 
 
  74                     unsigned int SWIG_DEFAULT_TYPE,
 
  75                     long SWIG_DEFAULT_TYPE,
 
  76                     unsigned long SWIG_DEFAULT_TYPE,
 
  77                     short SWIG_DEFAULT_TYPE,
 
  78                     unsigned short SWIG_DEFAULT_TYPE,
 
  79                     unsigned char  SWIG_DEFAULT_TYPE,
 
  80                     signed char    SWIG_DEFAULT_TYPE
 
  82   static int ivalue = (int) $source;
 
  83   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
 
  86 %typemap(tcl8,const) float  SWIG_DEFAULT_TYPE, 
 
  87                     double SWIG_DEFAULT_TYPE
 
  89   static double dvalue = (double) $source;
 
  90   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
 
  93 %typemap(tcl8,const) char  *SWIG_DEFAULT_TYPE
 
  95   static char *cvalue = $source;
 
  96   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
 
  99 %typemap(tcl8,const) Pointer *SWIG_DEFAULT_TYPE
 
 102   pvalue = (char *) malloc(20+strlen("$mangle"));
 
 103   SWIG_MakePtr(pvalue, (void *) ($source), "$mangle");
 
 104   Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &pvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);