Upstream version 1.3.40
[profile/ivi/swig.git] / Lib / typemaps / swigtypemaps.swg
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.
4  *
5  * swigtypemaps.swg
6  *
7  * Unified Typemap Library frontend
8  * ----------------------------------------------------------------------------- */
9
10 /*
11   This file provides the frontend to the Unified Typemap Library.
12
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.
16
17   Typically you will create a 'mytypemaps.swg' file in each target
18   languge, where you will have the following sections:
19
20     === mytypemaps.swg ===
21
22     //  Fragment section 
23     %include <typemaps/fragments.swg>
24     <include target language fragments>
25
26     // Unified typemap section 
27     <specialized the typemap library macros>
28     %include <typemaps/swigtypemaps.swg>
29
30     // Local typemap section 
31     <add/replace extra target language typemaps>
32
33     === mytypemaps.swg ===
34
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
37   target language:
38
39       Lib/python/pytypemaps.swg
40       Lib/tcl/tcltypemaps.swg
41       Lib/ruby/rubytypemaps.swg
42       Lib/perl5/perltypemaps.swg
43     
44 */
45
46 #define SWIGUTL SWIGUTL
47
48 /* -----------------------------------------------------------------------------
49  *   Language specialization section. 
50  *
51  *   Tune these macros for each language as needed.
52  * ----------------------------------------------------------------------------- */
53
54 /*
55   The SWIG target language object must be provided.
56   For example in python you define:
57
58     #define SWIG_Object PyObject *
59 */
60
61 #if !defined(SWIG_Object) 
62 #error "SWIG_Object must be defined as the SWIG target language object"
63 #endif
64
65 /*==== flags for new/convert methods ====*/
66
67
68 #ifndef %convertptr_flags
69 %define %convertptr_flags  0 %enddef
70 #endif
71
72 #ifndef %newpointer_flags
73 %define %newpointer_flags  0 %enddef
74 #endif
75
76 #ifndef %newinstance_flags
77 %define %newinstance_flags 0 %enddef
78 #endif
79
80 /*==== set output ====*/
81
82 #ifndef %set_output
83 /* simple set output operation */
84 #define %set_output(obj)                  $result = obj
85 #endif
86
87 /*==== set variable output  ====*/
88
89 #ifndef %set_varoutput
90 /* simple set varoutput operation */
91 #define %set_varoutput(obj)               $result = obj
92 #endif
93
94 /*==== append output ====*/
95
96 #ifndef %append_output
97 #if defined(SWIG_AppendOutput)
98 /* simple append operation */
99 #define %append_output(obj)               $result = SWIG_AppendOutput($result,obj) 
100 #else
101 #error "Language must define SWIG_AppendOutput or %append_output"
102 #endif
103 #endif
104
105 /*==== set constant ====*/
106
107 #ifndef %set_constant
108 #if defined(SWIG_SetConstant)
109 /* simple set constant operation */
110 #define %set_constant(name,value)         SWIG_SetConstant(name,value)
111 #else
112 #error "Language must define SWIG_SetConstant or %set_constant"
113 #endif
114 #endif
115
116 /*==== raise an exception ====*/
117
118 #ifndef %raise
119 #if defined(SWIG_Raise)
120 /* simple raise operation */
121 #define %raise(obj, type, desc)           SWIG_Raise(obj, type, desc); SWIG_fail
122 #else
123 #error "Language must define SWIG_Raise or %raise"
124 #endif
125 #endif
126
127 /*==== director output exception ====*/
128
129 #if defined(SWIG_DIRECTOR_TYPEMAPS)
130 #ifndef SWIG_DirOutFail
131 #define SWIG_DirOutFail(code, msg)        Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
132 #endif
133 #endif
134
135
136 /* -----------------------------------------------------------------------------
137  *  Language independent definitions
138  * ----------------------------------------------------------------------------- */
139
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))
146
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))
150 #endif
151
152 /* -----------------------------------------------------------------------------
153  *  All the typemaps
154  * ----------------------------------------------------------------------------- */
155
156
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>
169
170