Home | History | Annotate | Download | only in typemaps
      1 /* -----------------------------------------------------------------------------
      2  * swigtypemaps.swg
      3  *
      4  * Unified Typemap Library frontend
      5  * ----------------------------------------------------------------------------- */
      6 
      7 /*
      8   This file provides the frontend to the Unified Typemap Library.
      9 
     10   When using this library in a SWIG target language, you need to
     11   define a minimum set of fragments, specialize a couple of macros,
     12   and then include this file.
     13 
     14   Typically you will create a 'mytypemaps.swg' file in each target
     15   languge, where you will have the following sections:
     16 
     17     === mytypemaps.swg ===
     18 
     19     //  Fragment section
     20     %include <typemaps/fragments.swg>
     21     <include target language fragments>
     22 
     23     // Unified typemap section
     24     <specialized the typemap library macros>
     25     %include <typemaps/swigtypemaps.swg>
     26 
     27     // Local typemap section
     28     <add/replace extra target language typemaps>
     29 
     30     === mytypemaps.swg ===
     31 
     32   While we add more docs, please take a look at the following cases
     33   to see how you specialized the unified typemap library for a new
     34   target language:
     35 
     36       Lib/python/pytypemaps.swg
     37       Lib/tcl/tcltypemaps.swg
     38       Lib/ruby/rubytypemaps.swg
     39       Lib/perl5/perltypemaps.swg
     40 
     41 */
     42 
     43 #define SWIGUTL SWIGUTL
     44 
     45 /* -----------------------------------------------------------------------------
     46  *   Language specialization section.
     47  *
     48  *   Tune these macros for each language as needed.
     49  * ----------------------------------------------------------------------------- */
     50 
     51 /*
     52   The SWIG target language object must be provided.
     53   For example in python you define:
     54 
     55     #define SWIG_Object PyObject *
     56 */
     57 
     58 #if !defined(SWIG_Object)
     59 #error "SWIG_Object must be defined as the SWIG target language object"
     60 #endif
     61 
     62 /*==== flags for new/convert methods ====*/
     63 
     64 
     65 #ifndef %convertptr_flags
     66 %define %convertptr_flags  0 %enddef
     67 #endif
     68 
     69 #ifndef %newpointer_flags
     70 %define %newpointer_flags  0 %enddef
     71 #endif
     72 
     73 #ifndef %newinstance_flags
     74 %define %newinstance_flags 0 %enddef
     75 #endif
     76 
     77 /*==== set output ====*/
     78 
     79 #ifndef %set_output
     80 /* simple set output operation */
     81 #define %set_output(obj)                  $result = obj
     82 #endif
     83 
     84 /*==== set variable output  ====*/
     85 
     86 #ifndef %set_varoutput
     87 /* simple set varoutput operation */
     88 #define %set_varoutput(obj)               $result = obj
     89 #endif
     90 
     91 /*==== append output ====*/
     92 
     93 #ifndef %append_output
     94 #if defined(SWIG_AppendOutput)
     95 /* simple append operation */
     96 #define %append_output(obj)               $result = SWIG_AppendOutput($result,obj)
     97 #else
     98 #error "Language must define SWIG_AppendOutput or %append_output"
     99 #endif
    100 #endif
    101 
    102 /*==== set constant ====*/
    103 
    104 #ifndef %set_constant
    105 #if defined(SWIG_SetConstant)
    106 /* simple set constant operation */
    107 #define %set_constant(name,value)         SWIG_SetConstant(name,value)
    108 #else
    109 #error "Language must define SWIG_SetConstant or %set_constant"
    110 #endif
    111 #endif
    112 
    113 /*==== raise an exception ====*/
    114 
    115 #ifndef %raise
    116 #if defined(SWIG_Raise)
    117 /* simple raise operation */
    118 #define %raise(obj, type, desc)           SWIG_Raise(obj, type, desc); SWIG_fail
    119 #else
    120 #error "Language must define SWIG_Raise or %raise"
    121 #endif
    122 #endif
    123 
    124 /*==== director output exception ====*/
    125 
    126 #if defined(SWIG_DIRECTOR_TYPEMAPS)
    127 #ifndef SWIG_DirOutFail
    128 #define SWIG_DirOutFail(code, msg)        Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
    129 #endif
    130 #endif
    131 
    132 
    133 /* -----------------------------------------------------------------------------
    134  *  Language independent definitions
    135  * ----------------------------------------------------------------------------- */
    136 
    137 #define %error_block(Block...)                 %block(Block)
    138 #define %default_code(code)                    SWIG_ArgError(code)
    139 #define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
    140 #define %argument_nullref(type, name, argn)    SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
    141 #define %variable_fail(code, type, name)       SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
    142 #define %variable_nullref(type, name)          SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))
    143 
    144 #if defined(SWIG_DIRECTOR_TYPEMAPS)
    145 #define %dirout_fail(code, type)          SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
    146 #define %dirout_nullref(type)             SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
    147 #endif
    148 
    149 /* -----------------------------------------------------------------------------
    150  *  All the typemaps
    151  * ----------------------------------------------------------------------------- */
    152 
    153 
    154 %include <typemaps/fragments.swg>
    155 %include <typemaps/exception.swg>
    156 %include <typemaps/swigtype.swg>
    157 %include <typemaps/void.swg>
    158 %include <typemaps/swigobject.swg>
    159 %include <typemaps/valtypes.swg>
    160 %include <typemaps/ptrtypes.swg>
    161 %include <typemaps/inoutlist.swg>
    162 %include <typemaps/primtypes.swg>
    163 %include <typemaps/string.swg>
    164 %include <typemaps/misctypes.swg>
    165 %include <typemaps/enumint.swg>
    166 
    167 
    168