1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * Unified Typemap Library frontend
8 * ----------------------------------------------------------------------------- */
11 This file provides the frontend to the Unified Typemap Library.
13 When using this library in a SWIG target language, you need to
14 define a minimum set of fragments, specialize a couple of macros,
15 and then include this file.
17 Typically you will create a 'mytypemaps.swg' file in each target
18 languge, where you will have the following sections:
20 === mytypemaps.swg ===
23 %include <typemaps/fragments.swg>
24 <include target language fragments>
26 // Unified typemap section
27 <specialized the typemap library macros>
28 %include <typemaps/swigtypemaps.swg>
30 // Local typemap section
31 <add/replace extra target language typemaps>
33 === mytypemaps.swg ===
35 While we add more docs, please take a look at the following cases
36 to see how you specialized the unified typemap library for a new
39 Lib/python/pytypemaps.swg
40 Lib/tcl/tcltypemaps.swg
41 Lib/ruby/rubytypemaps.swg
42 Lib/perl5/perltypemaps.swg
46 #define SWIGUTL SWIGUTL
48 /* -----------------------------------------------------------------------------
49 * Language specialization section.
51 * Tune these macros for each language as needed.
52 * ----------------------------------------------------------------------------- */
55 The SWIG target language object must be provided.
56 For example in python you define:
58 #define SWIG_Object PyObject *
61 #if !defined(SWIG_Object)
62 #error "SWIG_Object must be defined as the SWIG target language object"
65 /*==== flags for new/convert methods ====*/
68 #ifndef %convertptr_flags
69 %define %convertptr_flags 0 %enddef
72 #ifndef %newpointer_flags
73 %define %newpointer_flags 0 %enddef
76 #ifndef %newinstance_flags
77 %define %newinstance_flags 0 %enddef
80 /*==== set output ====*/
83 /* simple set output operation */
84 #define %set_output(obj) $result = obj
87 /*==== set variable output ====*/
89 #ifndef %set_varoutput
90 /* simple set varoutput operation */
91 #define %set_varoutput(obj) $result = obj
94 /*==== append output ====*/
96 #ifndef %append_output
97 #if defined(SWIG_AppendOutput)
98 /* simple append operation */
99 #define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
101 #error "Language must define SWIG_AppendOutput or %append_output"
105 /*==== set constant ====*/
107 #ifndef %set_constant
108 #if defined(SWIG_SetConstant)
109 /* simple set constant operation */
110 #define %set_constant(name,value) SWIG_SetConstant(name,value)
112 #error "Language must define SWIG_SetConstant or %set_constant"
116 /*==== raise an exception ====*/
119 #if defined(SWIG_Raise)
120 /* simple raise operation */
121 #define %raise(obj, type, desc) SWIG_Raise(obj, type, desc); SWIG_fail
123 #error "Language must define SWIG_Raise or %raise"
127 /*==== director output exception ====*/
129 #if defined(SWIG_DIRECTOR_TYPEMAPS)
130 #ifndef SWIG_DirOutFail
131 #define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
136 /* -----------------------------------------------------------------------------
137 * Language independent definitions
138 * ----------------------------------------------------------------------------- */
140 #define %error_block(Block...) %block(Block)
141 #define %default_code(code) SWIG_ArgError(code)
142 #define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
143 #define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
144 #define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
145 #define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))
147 #if defined(SWIG_DIRECTOR_TYPEMAPS)
148 #define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
149 #define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
152 /* -----------------------------------------------------------------------------
154 * ----------------------------------------------------------------------------- */
157 %include <typemaps/fragments.swg>
158 %include <typemaps/exception.swg>
159 %include <typemaps/swigtype.swg>
160 %include <typemaps/void.swg>
161 %include <typemaps/swigobject.swg>
162 %include <typemaps/valtypes.swg>
163 %include <typemaps/ptrtypes.swg>
164 %include <typemaps/inoutlist.swg>
165 %include <typemaps/primtypes.swg>
166 %include <typemaps/string.swg>
167 %include <typemaps/misctypes.swg>
168 %include <typemaps/enumint.swg>